diff --git a/filament/backend/src/opengl/OpenGLDriver.cpp b/filament/backend/src/opengl/OpenGLDriver.cpp index fcf4975267..cc360128d2 100644 --- a/filament/backend/src/opengl/OpenGLDriver.cpp +++ b/filament/backend/src/opengl/OpenGLDriver.cpp @@ -2232,6 +2232,13 @@ void OpenGLDriver::beginRenderPass(Handle rth, } CHECK_GL_ERROR(utils::slog.e) } + } else { + // on GL desktop we assume we don't have glInvalidateFramebuffer, but even if the GPU is + // not a tiler, it's important to clear the framebuffer before drawing, as it resets + // the fb to a known state (resets fb compression and possibly other things). + // So we use glClear instead of glInvalidateFramebuffer + gl.disable(GL_SCISSOR_TEST); + clearWithRasterPipe(discardFlags & ~clearFlags, { 0.0f }, 0.0f, 0); } if (rt->gl.fbo_read) { @@ -2262,8 +2269,7 @@ void OpenGLDriver::beginRenderPass(Handle rth, #ifndef NDEBUG // clear the discarded (but not the cleared ones) buffers in debug builds - mContext.bindFramebuffer(GL_FRAMEBUFFER, rt->gl.fbo); - mContext.disable(GL_SCISSOR_TEST); + gl.disable(GL_SCISSOR_TEST); clearWithRasterPipe(discardFlags & ~clearFlags, { 1, 0, 0, 1 }, 1.0, 0); #endif