From 8e5138da2757c1ac71d104180bd0984fbcfaffb7 Mon Sep 17 00:00:00 2001 From: David Quintana Date: Fri, 3 Jul 2020 14:40:21 +0200 Subject: [PATCH] Attempt to use a more compatible method to initialize stencil support. In case the separate attachments don't work for everyone, there's a new setting to choose the combined attachment. --- .../minecraft/client/shader/Framebuffer.java.patch | 12 ++++++++---- .../java/net/minecraftforge/common/ForgeConfig.java | 7 +++++++ .../debug/client/rendering/StencilEnableTest.java | 2 +- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/patches/minecraft/net/minecraft/client/shader/Framebuffer.java.patch b/patches/minecraft/net/minecraft/client/shader/Framebuffer.java.patch index 583eafcca..7359d0953 100644 --- a/patches/minecraft/net/minecraft/client/shader/Framebuffer.java.patch +++ b/patches/minecraft/net/minecraft/client/shader/Framebuffer.java.patch @@ -11,18 +11,22 @@ } this.func_147607_a(9728); -@@ -127,7 +130,10 @@ +@@ -127,7 +130,14 @@ GlStateManager.func_227727_h_(FramebufferConstants.field_227592_a_, this.field_147616_f); GlStateManager.func_227645_a_(FramebufferConstants.field_227592_a_, FramebufferConstants.field_227594_c_, 3553, this.field_147617_g, 0); if (this.field_147619_e) { + if(!stencilEnabled) GlStateManager.func_227645_a_(FramebufferConstants.field_227592_a_, FramebufferConstants.field_227595_d_, 3553, this.field_147624_h, 0); -+ else -+ GlStateManager.func_227645_a_(FramebufferConstants.field_227592_a_, org.lwjgl.opengl.GL30.GL_DEPTH_STENCIL_ATTACHMENT, 3553, this.field_147624_h, 0); ++ else if(net.minecraftforge.common.ForgeConfig.CLIENT.useCombinedDepthStencilAttachment.get()) { ++ GlStateManager.func_227645_a_(FramebufferConstants.field_227592_a_, org.lwjgl.opengl.GL30.GL_DEPTH_STENCIL_ATTACHMENT, 3553, this.field_147624_h, 0); ++ } else { ++ GlStateManager.func_227645_a_(FramebufferConstants.field_227592_a_, org.lwjgl.opengl.GL30.GL_DEPTH_ATTACHMENT, 3553, this.field_147624_h, 0); ++ GlStateManager.func_227645_a_(FramebufferConstants.field_227592_a_, org.lwjgl.opengl.GL30.GL_STENCIL_ATTACHMENT, 3553, this.field_147624_h, 0); ++ } } this.func_147611_b(); -@@ -280,4 +286,30 @@ +@@ -280,4 +290,30 @@ GlStateManager.func_227658_a_(i, p_216493_1_); this.func_147609_e(); } diff --git a/src/main/java/net/minecraftforge/common/ForgeConfig.java b/src/main/java/net/minecraftforge/common/ForgeConfig.java index da2425641..940e00a32 100644 --- a/src/main/java/net/minecraftforge/common/ForgeConfig.java +++ b/src/main/java/net/minecraftforge/common/ForgeConfig.java @@ -139,6 +139,8 @@ public class ForgeConfig public final BooleanValue showLoadWarnings; + public final BooleanValue useCombinedDepthStencilAttachment; + Client(ForgeConfigSpec.Builder builder) { builder.comment("Client only settings, mostly things related to rendering") .push("client"); @@ -184,6 +186,11 @@ public class ForgeConfig .translation("forge.configgui.showLoadWarnings") .define("showLoadWarnings", true); + useCombinedDepthStencilAttachment = builder + .comment("Set to true to use a combined DEPTH_STENCIL attachment instead of two separate ones.") + .translation("forge.configgui.useCombinedDepthStencilAttachment") + .define("useCombinedDepthStencilAttachment", false); + builder.pop(); } } diff --git a/src/test/java/net/minecraftforge/debug/client/rendering/StencilEnableTest.java b/src/test/java/net/minecraftforge/debug/client/rendering/StencilEnableTest.java index 2750e2229..103cfb8f4 100644 --- a/src/test/java/net/minecraftforge/debug/client/rendering/StencilEnableTest.java +++ b/src/test/java/net/minecraftforge/debug/client/rendering/StencilEnableTest.java @@ -28,7 +28,7 @@ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; @Mod("stencil_enable_test") public class StencilEnableTest { - public static boolean ENABLED = false; + public static boolean ENABLED = true; public StencilEnableTest() { FMLJavaModLoadingContext.get().getModEventBus().addListener(this::clientSetup);