try not to crash on shader load failure

This commit is contained in:
mcrcortex
2025-09-14 20:14:06 +10:00
parent d78653a76f
commit f0efd36674
5 changed files with 49 additions and 4 deletions

View File

@@ -316,15 +316,14 @@ public class IrisShaderPatch {
} catch (Exception e) {
patchData = null;
Logger.error("Failed to parse patch data gson",e);
IrisUtil.disableIrisShaders();
throw new ShaderLoadError("Failed to parse patch data gson",e);
}
if (patchData == null) {
return null;
}
if (patchData.version != VERSION) {
Logger.error("Shader has voxy patch data, but patch version is incorrect. expected " + VERSION + " got "+patchData.version);
IrisUtil.disableIrisShaders();
return null;
throw new IllegalStateException("Shader version mismatch expected " + VERSION + " got "+patchData.version);
}
return new IrisShaderPatch(patchData, ipack);
}

View File

@@ -0,0 +1,11 @@
package me.cortex.voxy.client.iris;
public class ShaderLoadError extends RuntimeException {
public ShaderLoadError(String reason) {
super(reason);
}
public ShaderLoadError(String reason, Exception cause) {
super(reason, cause);
}
}

View File

@@ -0,0 +1,25 @@
package me.cortex.voxy.client.mixin.iris;
import me.cortex.voxy.client.iris.ShaderLoadError;
import me.cortex.voxy.common.Logger;
import net.irisshaders.iris.Iris;
import net.irisshaders.iris.shaderpack.ShaderPack;
import net.irisshaders.iris.shaderpack.materialmap.NamespacedId;
import net.irisshaders.iris.shaderpack.programs.ProgramSet;
import net.minecraft.util.Identifier;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(Iris.class)
public class MixinIris {
@Redirect(method = "createPipeline", at = @At(value = "INVOKE", target = "Lnet/irisshaders/iris/shaderpack/ShaderPack;getProgramSet(Lnet/irisshaders/iris/shaderpack/materialmap/NamespacedId;)Lnet/irisshaders/iris/shaderpack/programs/ProgramSet;"))
private static ProgramSet voxy$redirectProgramSet(ShaderPack shaderPack, NamespacedId dim) {
try {
return shaderPack.getProgramSet(dim);
} catch (ShaderLoadError e) {
Logger.error(e);
return null;
}
}
}

View File

@@ -4,6 +4,7 @@ import me.cortex.voxy.client.VoxyClientInstance;
import me.cortex.voxy.client.config.VoxyConfig;
import me.cortex.voxy.client.core.IGetVoxyRenderSystem;
import me.cortex.voxy.client.core.VoxyRenderSystem;
import me.cortex.voxy.client.core.util.IrisUtil;
import me.cortex.voxy.common.Logger;
import me.cortex.voxy.common.world.WorldEngine;
import me.cortex.voxy.commonImpl.VoxyCommon;
@@ -79,6 +80,14 @@ public abstract class MixinWorldRenderer implements IGetVoxyRenderSystem {
Logger.error("Null world selected");
return;
}
this.renderer = new VoxyRenderSystem(world, instance.getThreadPool());
try {
this.renderer = new VoxyRenderSystem(world, instance.getThreadPool());
} catch (RuntimeException e) {
if (IrisUtil.irisShaderPackEnabled()) {
IrisUtil.disableIrisShaders();
} else {
throw e;
}
}
}
}

View File

@@ -9,6 +9,7 @@
"iris.MixinPackRenderTargetDirectives",
"iris.CustomUniformsAccessor",
"iris.IrisRenderingPipelineAccessor",
"iris.MixinIris",
"iris.MixinIrisRenderingPipeline",
"iris.MixinIrisSamplers",
"iris.MixinMatrixUniforms",