Skip to content

Commit

Permalink
Disable framebuffer blits on Intel Gen 7.5 drivers
Browse files Browse the repository at this point in the history
Closes #2727
  • Loading branch information
jellysquid3 committed Aug 30, 2024
1 parent e7643f4 commit 1ac46d0
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -41,6 +43,10 @@ private static Set<Reference> 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");

Expand All @@ -58,6 +64,25 @@ private static Set<Reference> 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<? extends GraphicsAdapterInfo> adapters) {

return (operatingSystem == OsUtils.OperatingSystem.WIN || operatingSystem == OsUtils.OperatingSystem.LINUX) &&
Expand All @@ -82,5 +107,12 @@ public enum Reference {
* <a href="https://github.com/CaffeineMC/sodium-fabric/issues/1624">GitHub Issue</a>
*/
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.
* <a href="https://github.com/CaffeineMC/sodium-fabric/issues/2727">GitHub Issue</a>
*/
INTEL_FRAMEBUFFER_BLIT_UNSUPPORTED
}
}

0 comments on commit 1ac46d0

Please sign in to comment.