From 23394df432e7efc02093036308d2108c61803399 Mon Sep 17 00:00:00 2001 From: IMS212 Date: Sat, 12 Oct 2024 10:37:27 -0700 Subject: [PATCH] Potentially fix #2321 --- .../net/irisshaders/iris/gl/IrisRenderSystem.java | 14 ++++++++++++++ .../irisshaders/iris/mixin/MixinLevelRenderer.java | 4 +++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/net/irisshaders/iris/gl/IrisRenderSystem.java b/common/src/main/java/net/irisshaders/iris/gl/IrisRenderSystem.java index 1d692a94fc..0f9a959baf 100644 --- a/common/src/main/java/net/irisshaders/iris/gl/IrisRenderSystem.java +++ b/common/src/main/java/net/irisshaders/iris/gl/IrisRenderSystem.java @@ -6,6 +6,8 @@ import net.irisshaders.iris.Iris; import net.irisshaders.iris.gl.sampler.SamplerLimits; import net.irisshaders.iris.mixin.GlStateManagerAccessor; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.screens.Screen; import org.jetbrains.annotations.Nullable; import org.joml.Matrix4f; import org.joml.Vector3i; @@ -454,6 +456,18 @@ public static int createBuffers() { return dsaState.createBuffers(); } + private static boolean cullingState; + + public static void backupAndDisableCullingState(boolean b) { + cullingState = Minecraft.getInstance().smartCull; + Minecraft.getInstance().smartCull = Minecraft.getInstance().smartCull && !b; + } + + public static void restoreCullingState() { + Minecraft.getInstance().smartCull = cullingState; + cullingState = true; + } + public interface DSAAccess { void generateMipmaps(int texture, int target); diff --git a/common/src/main/java/net/irisshaders/iris/mixin/MixinLevelRenderer.java b/common/src/main/java/net/irisshaders/iris/mixin/MixinLevelRenderer.java index b1c49edc28..33fb2bdb83 100644 --- a/common/src/main/java/net/irisshaders/iris/mixin/MixinLevelRenderer.java +++ b/common/src/main/java/net/irisshaders/iris/mixin/MixinLevelRenderer.java @@ -103,7 +103,7 @@ public class MixinLevelRenderer { this.overrideFrustum = null; } - Minecraft.getInstance().smartCull = !pipeline.shouldDisableOcclusionCulling(); + IrisRenderSystem.backupAndDisableCullingState(pipeline.shouldDisableOcclusionCulling()); if (Iris.shouldActivateWireframe() && this.minecraft.isLocalServer()) { IrisRenderSystem.setPolygonMode(GL43C.GL_LINE); @@ -141,6 +141,8 @@ private Frustum changeFrustum(Frustum frustum) { Minecraft.getInstance().gui.getChat().addMessage(Component.literal("A new beta is out for Iris " + info.betaTag + ". Please redownload it.").withStyle(ChatFormatting.BOLD, ChatFormatting.RED))); } + IrisRenderSystem.restoreCullingState(); + if (Iris.shouldActivateWireframe() && this.minecraft.isLocalServer()) { IrisRenderSystem.setPolygonMode(GL43C.GL_FILL); }