[BUG] OpenXR: xrCreateSwapchain changes current OpenGL context
I believe this is a regression in 1.16.x.
This message would be printed with 1.16.x.
GLXContext glxContext = glXGetCurrentContext();
xrCreateSwapchain(session, &swapchain_create_info, &swapchain);
if (glXGetCurrentContext() != glxContext) {
printf("xrCreateSwapchain changed current gl context\n");
}
Applications now have to call
glXMakeCurrent(graphics_binding_gl.xDisplay, graphics_binding_gl.glxDrawable, graphics_binding_gl.glxContext);
after creating swapchains, which is quite unexpected behavior.
same for xrWaitSwapchainImage, possibly others.
This also breaks hello_xr -G OpenGL
https://developer.blender.org/T92723
Made a quick&dirty API layer https://github.com/ChristophHaag/gl_context_fix_layer
After every of the affected OpenXR API calls it calls glxMakeCurrent() with the Display*, GLXContext and GLXDrawable originally passed in the XrGraphicsBindingOpenGLXlibKHR. This might not be what applications actually want, but it gets at least hello_xr -G OpenGL working.
This issue appears to have been fixed in 1.25 (though I see nothing obviously related in the release notes): https://github.com/ValveSoftware/SteamVR-for-Linux/issues/546#issuecomment-1312264559
Anyway, it works for me without workarounds in 1.26.2. I guess this issue can be closed now.
I haven't tried it but I take your word for it :)