SteamVR-for-Linux icon indicating copy to clipboard operation
SteamVR-for-Linux copied to clipboard

[BUG] OpenXR: xrCreateSwapchain changes current OpenGL context

Open ChristophHaag opened this issue 4 years ago • 4 comments

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.

ChristophHaag avatar Jan 26 '21 22:01 ChristophHaag

same for xrWaitSwapchainImage, possibly others.

ChristophHaag avatar Jan 26 '21 22:01 ChristophHaag

This also breaks hello_xr -G OpenGL

ChristophHaag avatar Jan 26 '21 22:01 ChristophHaag

https://developer.blender.org/T92723

ChristophHaag avatar Nov 21 '21 22:11 ChristophHaag

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.

ChristophHaag avatar Nov 29 '21 01:11 ChristophHaag

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.

amalon avatar May 14 '23 07:05 amalon

I haven't tried it but I take your word for it :)

ChristophHaag avatar May 14 '23 10:05 ChristophHaag