diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderer.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderer.java index 23cf5303aa..8b0eac2e04 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderer.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderer.java @@ -2,6 +2,7 @@ import net.caffeinemc.mods.sodium.api.util.ColorABGR; import net.caffeinemc.mods.sodium.api.util.ColorARGB; +import net.caffeinemc.mods.sodium.client.compatibility.workarounds.Workarounds; import net.caffeinemc.mods.sodium.client.model.color.ColorProvider; import net.caffeinemc.mods.sodium.client.model.color.ColorProviderRegistry; import net.caffeinemc.mods.sodium.client.model.light.LightMode; @@ -184,6 +185,7 @@ private void bufferQuad(MutableQuadViewImpl quad, float[] brightnesses, Material // attempt render pass downgrade if possible var pass = material.pass; + var downgradedPass = attemptPassDowngrade(atlasSprite, pass); if (downgradedPass != null) { pass = downgradedPass; @@ -225,7 +227,11 @@ private boolean validateQuadUVs(TextureAtlasSprite atlasSprite) { return true; } - private TerrainRenderPass attemptPassDowngrade(TextureAtlasSprite sprite, TerrainRenderPass pass) { + private @Nullable TerrainRenderPass attemptPassDowngrade(TextureAtlasSprite sprite, TerrainRenderPass pass) { + if (Workarounds.isWorkaroundEnabled(Workarounds.Reference.INTEL_DEPTH_BUFFER_COMPARISON_UNRELIABLE)) { + return null; + } + boolean attemptDowngrade = true; boolean hasNonOpaqueVertex = false; diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/render/compositing/RenderTargetMixin.java b/common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/render/compositing/RenderTargetMixin.java index 3f38c0e9ac..51ca705493 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/render/compositing/RenderTargetMixin.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/render/compositing/RenderTargetMixin.java @@ -27,7 +27,7 @@ public class RenderTargetMixin { */ @Inject(method = "blitToScreen(IIZ)V", at = @At("HEAD"), cancellable = true) public void blitToScreen(int width, int height, boolean disableBlend, CallbackInfo ci) { - if (Workarounds.isWorkaroundEnabled(Workarounds.Reference.INTEL_FRAMEBUFFER_BLIT_UNSUPPORTED)) { + if (Workarounds.isWorkaroundEnabled(Workarounds.Reference.INTEL_FRAMEBUFFER_BLIT_CRASH_WHEN_UNFOCUSED)) { return; } diff --git a/common/src/workarounds/java/net/caffeinemc/mods/sodium/client/compatibility/workarounds/Workarounds.java b/common/src/workarounds/java/net/caffeinemc/mods/sodium/client/compatibility/workarounds/Workarounds.java index ed4cf40ed1..a8223272b6 100644 --- a/common/src/workarounds/java/net/caffeinemc/mods/sodium/client/compatibility/workarounds/Workarounds.java +++ b/common/src/workarounds/java/net/caffeinemc/mods/sodium/client/compatibility/workarounds/Workarounds.java @@ -43,8 +43,9 @@ private static Set findNecessaryWorkarounds() { workarounds.add(Reference.NVIDIA_THREADED_OPTIMIZATIONS); } - if (checkIntelFramebufferBlitBug()) { - workarounds.add(Reference.INTEL_FRAMEBUFFER_BLIT_UNSUPPORTED); + if (isUsingIntelGen8OrOlder()) { + workarounds.add(Reference.INTEL_FRAMEBUFFER_BLIT_CRASH_WHEN_UNFOCUSED); + workarounds.add(Reference.INTEL_DEPTH_BUFFER_COMPARISON_UNRELIABLE); } if (operatingSystem == OsUtils.OperatingSystem.LINUX) { @@ -64,7 +65,7 @@ private static Set findNecessaryWorkarounds() { return Collections.unmodifiableSet(workarounds); } - private static boolean checkIntelFramebufferBlitBug() { + private static boolean isUsingIntelGen8OrOlder() { if (OsUtils.getOs() != OsUtils.OperatingSystem.WIN) { return false; } @@ -109,10 +110,18 @@ public enum Reference { NO_ERROR_CONTEXT_UNSUPPORTED, /** - * Intel's graphics driver for Gen 7.5 GPUs seems to be faulty and causes a crash when calling + * Intel's graphics driver for Gen8 and older seems to be faulty and causes a crash when calling * glFramebufferBlit after the window loses focus. * GitHub Issue */ - INTEL_FRAMEBUFFER_BLIT_UNSUPPORTED + INTEL_FRAMEBUFFER_BLIT_CRASH_WHEN_UNFOCUSED, + + /** + * Intel's graphics driver for Gen8 and older does not respect depth comparison rules per the OpenGL + * specification, causing block model overlays to Z-fight when the overlay is on a different render pass than + * the base model. + * GitHub Issue + */ + INTEL_DEPTH_BUFFER_COMPARISON_UNRELIABLE } }