I’ve managed to minimize a incredibly weird bug in one of my programs.
Basically:
- Create OpenGL contexts A and B
- Activate context B and bind
GL_FRAMEBUFFER0 - Activate context A and create a texture
- Activate context B and bind
GL_FRAMEBUFFER0 glClearColorandglClearto red- Create a target FBO X, set 0 as read FBO, X as draw FBO
- Activate context A and do nothing
- Activate context B and do nothing
- Call
GLint out; glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, &out); - Blit framebuffers (from 0 to X)
- Assert that the result of the blit is red
The assertion will unexpectedly fail unless:
- The
glGetIntegervcall in step 9 is commented out; - OR the activation of context A in step 7 is commented out;
- OR
GL_FRAMEBUFFERis bound to 0 again between steps 8 and 9.
I have no idea why this is happening. I am on a RTX4090 with the latest driver, and I’ve also tried studio drivers and an older version from Oct 2024. Is this a driver bug, or am I doing something wrong?
Fully replicable example using SDL3: