From d91c356a99cd131fbc1562641585e2eddb2bca0e Mon Sep 17 00:00:00 2001 From: Jason Mitchell Date: Mon, 30 Mar 2026 15:34:54 -0700 Subject: [PATCH] Shader fixes (#1619) --- dependencies.gradle | 2 +- .../iris/pipeline/PatchedShaderPrinter.java | 86 +++++++++---------- 2 files changed, 43 insertions(+), 45 deletions(-) diff --git a/dependencies.gradle b/dependencies.gradle index 9dbe28c80..51adfbcf2 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -83,7 +83,7 @@ dependencies { shadowImplementation("net.minecraftforge:eventbus:7.0-beta.15") shadowImplementation("org.anarres:jcpp:1.4.14") // Apache 2.0 - shadowImplementation("org.taumc:glsl-transformation-lib:0.2.0-26.g5ee7d96-GTNH") { + shadowImplementation("org.taumc:glsl-transformation-lib:0.2.0-32.g7dd88a4-GTNH") { exclude module: "antlr4" // we only want to shadow the runtime module } shadowImplementation("org.antlr:antlr4-runtime:4.13.2") diff --git a/src/main/java/net/coderbot/iris/pipeline/PatchedShaderPrinter.java b/src/main/java/net/coderbot/iris/pipeline/PatchedShaderPrinter.java index 44c8d0886..0af5d7f15 100644 --- a/src/main/java/net/coderbot/iris/pipeline/PatchedShaderPrinter.java +++ b/src/main/java/net/coderbot/iris/pipeline/PatchedShaderPrinter.java @@ -39,56 +39,54 @@ public class PatchedShaderPrinter { } public static void debugPatchedShaders(String name, String vertex, String geometry, String tessControl, String tessEval, String fragment, String compute) { - if (!Iris.getIrisConfig().areDebugOptionsEnabled()) { + if (!prettyPrintShaders && !Iris.getIrisConfig().areDebugOptionsEnabled()) { return; } - if (prettyPrintShaders) { - final Path debugOutDir = Minecraft.getMinecraft().mcDataDir.toPath().resolve("patched_shaders"); - if (!outputLocationCleared) { - try { - if (Files.exists(debugOutDir)) { - try (Stream stream = Files.list(debugOutDir)) { - stream.forEach(path -> { - try { - Files.delete(path); - } catch (IOException e) { - throw new RuntimeException(e); - } - }); - } - } - - Files.createDirectories(debugOutDir); - } catch (IOException e) { - Iris.logger.warn("Failed to initialize debug patched shader source location", e); - } - outputLocationCleared = true; - } - + final Path debugOutDir = Minecraft.getMinecraft().mcDataDir.toPath().resolve("patched_shaders"); + if (!outputLocationCleared) { try { - programCounter++; - String prefix = String.format("%03d_", programCounter); - if (vertex != null) { - Files.write(debugOutDir.resolve(prefix + name + ".vsh"), vertex.getBytes(StandardCharsets.UTF_8)); - } - if (geometry != null) { - Files.write(debugOutDir.resolve(prefix + name + ".gsh"), geometry.getBytes(StandardCharsets.UTF_8)); - } - if (tessControl != null) { - Files.write(debugOutDir.resolve(prefix + name + ".tcs"), tessControl.getBytes(StandardCharsets.UTF_8)); - } - if (tessEval != null) { - Files.write(debugOutDir.resolve(prefix + name + ".tes"), tessEval.getBytes(StandardCharsets.UTF_8)); - } - if (fragment != null) { - Files.write(debugOutDir.resolve(prefix + name + ".fsh"), fragment.getBytes(StandardCharsets.UTF_8)); - } - if (compute != null) { - Files.write(debugOutDir.resolve(prefix + name + ".csh"), compute.getBytes(StandardCharsets.UTF_8)); + if (Files.exists(debugOutDir)) { + try (Stream stream = Files.list(debugOutDir)) { + stream.forEach(path -> { + try { + Files.delete(path); + } catch (IOException e) { + throw new RuntimeException(e); + } + }); + } } + + Files.createDirectories(debugOutDir); } catch (IOException e) { - Iris.logger.warn("Failed to write debug patched shader source", e); + Iris.logger.warn("Failed to initialize debug patched shader source location", e); } + outputLocationCleared = true; + } + + try { + programCounter++; + String prefix = String.format("%03d_", programCounter); + if (vertex != null) { + Files.write(debugOutDir.resolve(prefix + name + ".vsh"), vertex.getBytes(StandardCharsets.UTF_8)); + } + if (geometry != null) { + Files.write(debugOutDir.resolve(prefix + name + ".gsh"), geometry.getBytes(StandardCharsets.UTF_8)); + } + if (tessControl != null) { + Files.write(debugOutDir.resolve(prefix + name + ".tcs"), tessControl.getBytes(StandardCharsets.UTF_8)); + } + if (tessEval != null) { + Files.write(debugOutDir.resolve(prefix + name + ".tes"), tessEval.getBytes(StandardCharsets.UTF_8)); + } + if (fragment != null) { + Files.write(debugOutDir.resolve(prefix + name + ".fsh"), fragment.getBytes(StandardCharsets.UTF_8)); + } + if (compute != null) { + Files.write(debugOutDir.resolve(prefix + name + ".csh"), compute.getBytes(StandardCharsets.UTF_8)); + } + } catch (IOException e) { + Iris.logger.warn("Failed to write debug patched shader source", e); } } }