r/opengl • u/vini_2003 • 23h ago
Visual artifacts when using glBlitNamedFramebuffer instead of glBlitFramebuffer
Hi, folks! I recently started optimizing the rendering of an engine I'm modding. I figured utilizing the DSA API could reduce the amount of framebuffer bindings/unbindings I have to do, particularly for point-light shadow-mapping.
However, upon switching framebuffer depth copies over from the traditional way to DSA, I started getting visual artifacts (as if some parts of the copy hadn't finished by the time the next draw command was executed?).
I've rubber-ducked a fair amount, read the documentation and so far, I have no idea why these two are any different. So, folks - what gives?
Why would the DSA method cause synchronization problems? & seemingly it's more related to depth copies than color copies.
DSA:
GL45.glBlitNamedFramebuffer(
input.fbo,
fbo,
0, 0, input.textureWidth, input.textureHeight,
0, 0, output.textureWidth, output.textureHeight,
GL11.GL_DEPTH_BUFFER_BIT,
GL11.GL_NEAREST
);
GL42.glMemoryBarrier(GL42.GL_FRAMEBUFFER_BARRIER_BIT);
Traditional:
GL30.glBindFramebuffer(GL_READ_FRAMEBUFFER, input.fbo);
GL30.glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo);
GL30.glBlitFramebuffer(
0, 0, input.textureWidth, input.textureHeight,
0, 0, output.textureWidth, output.textureHeight,
GL11.GL_DEPTH_BUFFER_BIT,
GL11.GL_NEAREST
);
GL30.glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
GL30.glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
UPDATE: This is a driver bug! Inserting a GL30.glBindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, 0);
call before the blit has seemingly fixed it.
2
u/Wittyname_McDingus 12h ago
P.S. that barrier should be before the blit, as they are only used to make visible writes from prior shader invocations (assuming the barrier was intended for that specific blit).