Fix crash on windows (#1766)

This commit is contained in:
Jason Mitchell authored and GitHub committed 2026-05-19 08:02:37 -07:00
1 parent fa91b70528
commit 9c1b6c75ff
8 files changed
+50 -8

No files matched your search

@@ -113,10 +113,13 @@ public class GlFramebuffer extends GlResource {
GLStateManager.glDeleteFramebuffers(getGlId());
}
public boolean isComplete() {
public int getStatus() {
bind();
return GLStateManager.glCheckFramebufferStatus(GL30.GL_FRAMEBUFFER);
}
return GLStateManager.glCheckFramebufferStatus(GL30.GL_FRAMEBUFFER) == GL30.GL_FRAMEBUFFER_COMPLETE;
public boolean isComplete() {
return getStatus() == GL30.GL_FRAMEBUFFER_COMPLETE;
}
public int getId() {
@@ -1560,6 +1560,11 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
@Override
public void beginLevelRendering() {
final Framebuffer mainFb = Minecraft.getMinecraft().getFramebuffer();
if (mainFb == null || mainFb.framebufferWidth < 16 || mainFb.framebufferHeight < 16) {
return;
}
isRenderingFullScreenPass = false;
isRenderingWorld = true;
isBeforeTranslucent = true;
@@ -18,6 +18,7 @@ import net.coderbot.iris.shaderpack.texture.TextureStage;
import net.coderbot.iris.uniforms.FrameUpdateNotifier;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.EntityRenderer;
import net.minecraft.client.shader.Framebuffer;
import java.util.List;
import java.util.OptionalInt;
@@ -33,8 +34,12 @@ public class FixedFunctionWorldRenderingPipeline implements WorldRenderingPipeli
@Override
public void beginLevelRendering() {
final Framebuffer mainFb = Minecraft.getMinecraft().getFramebuffer();
if (mainFb == null || mainFb.framebufferWidth < 16 || mainFb.framebufferHeight < 16) {
return;
}
// Use the default Minecraft framebuffer and ensure that no programs are in use
Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(true);
mainFb.bindFramebuffer(true);
GLStateManager.glUseProgram(0);
}
@@ -12,6 +12,7 @@ import net.coderbot.iris.shaderpack.PackDirectives;
import net.coderbot.iris.shaderpack.PackRenderTargetDirectives;
import org.joml.Vector2i;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL30;
import java.util.ArrayList;
import java.util.List;
@@ -320,8 +321,9 @@ public class RenderTargets {
framebuffer.drawBuffers(actualDrawBuffers);
framebuffer.readBuffer(0);
if (!framebuffer.isComplete()) {
throw new IllegalStateException("Unexpected error while creating framebuffer");
final int status = framebuffer.getStatus();
if (status != GL30.GL_FRAMEBUFFER_COMPLETE) {
throw new IllegalStateException(String.format( "Unexpected error while creating framebuffer: glCheckFramebufferStatus=0x%X, size=%dx%d, drawBuffers=%d", status, cachedWidth, cachedHeight, drawBuffers.length));
}
return framebuffer;
@@ -14,6 +14,7 @@ import net.coderbot.iris.pipeline.WorldRenderingPipeline;
import net.coderbot.iris.rendertarget.RenderTarget;
import net.coderbot.iris.shaderpack.PackShadowDirectives;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL30;
import java.util.ArrayList;
import java.util.List;
@@ -283,8 +284,9 @@ public class ShadowRenderTargets {
framebuffer.drawBuffers(actualDrawBuffers);
framebuffer.readBuffer(0);
if (!framebuffer.isComplete()) {
throw new IllegalStateException("Unexpected error while creating framebuffer");
final int status = framebuffer.getStatus();
if (status != GL30.GL_FRAMEBUFFER_COMPLETE) {
throw new IllegalStateException(String.format( "Unexpected error while creating shadow framebuffer: glCheckFramebufferStatus=0x%X, resolution=%d, drawBuffers=%d", status, resolution, drawBuffers.length));
}
return framebuffer;