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 c63e4a0c87..3f38c0e9ac 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 @@ -2,6 +2,7 @@ import com.mojang.blaze3d.pipeline.RenderTarget; +import net.caffeinemc.mods.sodium.client.compatibility.workarounds.Workarounds; import org.lwjgl.opengl.GL32C; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -26,6 +27,10 @@ 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)) { + return; + } + if (disableBlend) { ci.cancel(); 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 5768eb8102..798de1d46e 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 @@ -4,6 +4,8 @@ import net.caffeinemc.mods.sodium.client.compatibility.environment.probe.GraphicsAdapterInfo; import net.caffeinemc.mods.sodium.client.compatibility.environment.probe.GraphicsAdapterProbe; import net.caffeinemc.mods.sodium.client.compatibility.environment.probe.GraphicsAdapterVendor; +import net.caffeinemc.mods.sodium.client.platform.windows.api.d3dkmt.D3DKMT; +import org.jetbrains.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -41,6 +43,10 @@ private static Set findNecessaryWorkarounds() { workarounds.add(Reference.NVIDIA_THREADED_OPTIMIZATIONS); } + if (checkIntelFramebufferBlitBug()) { + workarounds.add(Reference.INTEL_FRAMEBUFFER_BLIT_UNSUPPORTED); + } + if (operatingSystem == OsUtils.OperatingSystem.LINUX) { var session = System.getenv("XDG_SESSION_TYPE"); @@ -58,6 +64,25 @@ private static Set findNecessaryWorkarounds() { return Collections.unmodifiableSet(workarounds); } + private static boolean checkIntelFramebufferBlitBug() { + if (OsUtils.getOs() != OsUtils.OperatingSystem.WIN) { + return false; + } + + for (var adapter : GraphicsAdapterProbe.getAdapters()) { + if (adapter instanceof D3DKMT.WDDMAdapterInfo wddmAdapterInfo) { + @Nullable var driverName = wddmAdapterInfo.getOpenGlIcdName(); + + // Intel OpenGL ICD for Generation 7.5 GPUs + if (driverName != null && driverName.matches("ig75icd(32|64)")) { + return true; + } + } + } + + return false; + } + private static boolean isUsingNvidiaGraphicsCard(OsUtils.OperatingSystem operatingSystem, Collection adapters) { return (operatingSystem == OsUtils.OperatingSystem.WIN || operatingSystem == OsUtils.OperatingSystem.LINUX) && @@ -82,5 +107,12 @@ public enum Reference { * GitHub Issue */ NO_ERROR_CONTEXT_UNSUPPORTED, + + /** + * Intel's graphics driver for Gen 7.5 GPUs seems to be faulty and causes a crash when calling + * glFramebufferBlit after the window loses focus. + * GitHub Issue + */ + INTEL_FRAMEBUFFER_BLIT_UNSUPPORTED } }