Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Faker: Don't clear new Pbuffer if drawing to FBO
Since the beginning, VirtualGL has cleared new "virtual window" Pbuffers (Pbuffers that it creates to emulate OpenGL windows) when the Pbuffers are made current for the first time. Unlike new X windows, the contents of new Pbuffers are undefined, and "back in the day", some OpenGL implementations did not clear new Pbuffers. Applications were particularly economical with their 3D rendering back then, and some of them relied on the fact that new X windows start out blank. Thus, VirtualGL had to clear new virtual window Pbuffers, particularly ones that it created in midstream (in response to a window resize that occurred between glXSwapBuffers() or glXMakeCurrent() calls.) Since the Pbuffer clearing code was introduced before VirtualGL was open sourced, information about the specific OpenGL implementations and 3D applications that necessitated it has been lost to history. Clearing new virtual window Pbuffers is likely never necessary in 2024, and it definitely isn't necessary unless the default framebuffer is bound to the GL_DRAW_FRAMEBUFFER target. (FBOs weren't a thing "back in the day.") VirtualGL handles midstream window resizes in the body of glViewport(), but because FBOs and their bindings are attached to a specific context rather than a specific drawable, the first glViewport() call that a 3D application makes after its window is resized might be made while an FBO is bound to the GL_DRAW_FRAMEBUFFER target. That is the case with Firefox, so VirtualGL's attempt to clear the new virtual window Pbuffer that it created in the body of glViewport() cleared part of an FBO instead, resulting in the disappearance of random characters or other elements of the Firefox window. Modern OpenGL implementations seem to clear new Pbuffers, at least in my limited testing, so we could probably get away with jettisoning the Pbuffer clearing code altogether. However, the minimally invasive fix is simply to forego clearing a new virtual window Pbuffer if an FBO is bound to the GL_DRAW_FRAMEBUFFER target. Note that this appears to have been the "update issue" that I observed in certain versions of Firefox and documented in #228 (comment) In fact, the issue was always reproducible with either back end. I didn't always observe it because it didn't always occur unless you resized the Firefox window repeatedly, and it was more likely to occur with the GLX back end than with the EGL back end.
- Loading branch information