fix ssao frame buffer binding
This commit is contained in:
@@ -23,11 +23,13 @@ import org.lwjgl.opengl.GL32;
|
||||
|
||||
public class GLState
|
||||
{
|
||||
private static final int FBO_MAX = 4;
|
||||
|
||||
public int program;
|
||||
public int vao;
|
||||
public int vbo;
|
||||
public int ebo;
|
||||
public int fbo;
|
||||
public int[] fbo;
|
||||
public int texture2D;
|
||||
/** IE: GL_TEXTURE0, GL_TEXTURE1, etc. */
|
||||
public int activeTextureNumber;
|
||||
@@ -54,6 +56,8 @@ public class GLState
|
||||
|
||||
|
||||
public GLState() {
|
||||
this.fbo = new int[FBO_MAX];
|
||||
|
||||
this.saveState();
|
||||
}
|
||||
|
||||
@@ -63,7 +67,8 @@ public class GLState
|
||||
this.vao = GL32.glGetInteger(GL32.GL_VERTEX_ARRAY_BINDING);
|
||||
this.vbo = GL32.glGetInteger(GL32.GL_ARRAY_BUFFER_BINDING);
|
||||
this.ebo = GL32.glGetInteger(GL32.GL_ELEMENT_ARRAY_BUFFER_BINDING);
|
||||
this.fbo = GL32.glGetInteger(GL32.GL_FRAMEBUFFER_BINDING);
|
||||
|
||||
GL32.glGetIntegerv(GL32.GL_FRAMEBUFFER_BINDING, this.fbo);
|
||||
|
||||
this.texture2D = GL32.glGetInteger(GL32.GL_TEXTURE_BINDING_2D);
|
||||
this.activeTextureNumber = GL32.glGetInteger(GL32.GL_ACTIVE_TEXTURE);
|
||||
@@ -101,7 +106,7 @@ public class GLState
|
||||
public String toString()
|
||||
{
|
||||
return "GLState{" +
|
||||
"program=" + this.program + ", vao=" + this.vao + ", vbo=" + this.vbo + ", ebo=" + this.ebo + ", fbo=" + this.fbo +
|
||||
"program=" + this.program + ", vao=" + this.vao + ", vbo=" + this.vbo + ", ebo=" + this.ebo + ", fbo=" + this.fbo[0] +
|
||||
", text=" + GLEnums.getString(this.texture2D) + "@" + this.activeTextureNumber + ", text0=" + GLEnums.getString(this.texture0) +
|
||||
", blend=" + this.blend + ", blendMode=" + GLEnums.getString(this.blendSrcColor) + "," + GLEnums.getString(this.blendDstColor) +
|
||||
", depth=" + this.depth +
|
||||
@@ -113,9 +118,21 @@ public class GLState
|
||||
'}';
|
||||
}
|
||||
|
||||
public void RestoreFrameBuffer()
|
||||
{
|
||||
for (int i = 0; i < FBO_MAX; i++)
|
||||
{
|
||||
int buffer = this.fbo[i];
|
||||
if (i > 0 && buffer == 0) break;
|
||||
|
||||
GL32.glBindFramebuffer(GL32.GL_FRAMEBUFFER, GL32.glIsFramebuffer(buffer) ? buffer : 0);
|
||||
}
|
||||
}
|
||||
|
||||
public void restore()
|
||||
{
|
||||
GL32.glBindFramebuffer(GL32.GL_FRAMEBUFFER, GL32.glIsFramebuffer(this.fbo) ? this.fbo : 0);
|
||||
this.RestoreFrameBuffer();
|
||||
|
||||
if (this.blend)
|
||||
{
|
||||
GL32.glEnable(GL32.GL_BLEND);
|
||||
|
||||
@@ -176,8 +176,6 @@ public class LodRenderer
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!renderLock.tryLock())
|
||||
{
|
||||
// never lock the render thread, if the lock isn't available don't wait for it
|
||||
@@ -285,7 +283,7 @@ public class LodRenderer
|
||||
if (Config.Client.Advanced.Graphics.Ssao.enabled.get())
|
||||
{
|
||||
profiler.popPush("LOD SSAO");
|
||||
SSAORenderer.INSTANCE.render(partialTicks);
|
||||
SSAORenderer.INSTANCE.render(minecraftGlState, partialTicks);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+2
-2
@@ -99,7 +99,7 @@ public abstract class AbstractShaderRenderer
|
||||
int width = MC_RENDER.getTargetFrameBufferViewportWidth();
|
||||
int height = MC_RENDER.getTargetFrameBufferViewportHeight();
|
||||
|
||||
GL32.glBindFramebuffer(GL32.GL_FRAMEBUFFER, MC_RENDER.getTargetFrameBuffer());
|
||||
//GL32.glBindFramebuffer(GL32.GL_FRAMEBUFFER, MC_RENDER.getTargetFrameBuffer());
|
||||
GL32.glViewport(0, 0, width, height);
|
||||
GL32.glDisable(GL32.GL_DEPTH_TEST);
|
||||
GL32.glDisable(GL32.GL_SCISSOR_TEST);
|
||||
@@ -118,7 +118,7 @@ public abstract class AbstractShaderRenderer
|
||||
GL32.glDrawArrays(GL32.GL_TRIANGLES, 0, 6);
|
||||
|
||||
// explicitly unbinding the frame buffer is necessary to prevent GL_CLEAR calls from hitting the wrong buffer
|
||||
GL32.glBindFramebuffer(GL32.GL_FRAMEBUFFER, 0);
|
||||
//GL32.glBindFramebuffer(GL32.GL_FRAMEBUFFER, 0);
|
||||
|
||||
state.restore();
|
||||
}
|
||||
|
||||
+3
-2
@@ -179,7 +179,7 @@ public class SSAORenderer
|
||||
// render //
|
||||
//========//
|
||||
|
||||
public void render(float partialTicks)
|
||||
public void render(GLState primaryState, float partialTicks)
|
||||
{
|
||||
GLState state = new GLState();
|
||||
|
||||
@@ -239,7 +239,8 @@ public class SSAORenderer
|
||||
|
||||
this.applyShader.bind();
|
||||
|
||||
GL32.glBindFramebuffer(GL32.GL_FRAMEBUFFER, MC_RENDER.getTargetFrameBuffer());
|
||||
//GL32.glBindFramebuffer(GL32.GL_FRAMEBUFFER, MC_RENDER.getTargetFrameBuffer());
|
||||
primaryState.RestoreFrameBuffer();
|
||||
|
||||
GL32.glEnable(GL11.GL_BLEND);
|
||||
GL32.glBlendEquation(GL32.GL_FUNC_ADD);
|
||||
|
||||
Reference in New Issue
Block a user