protonscr

[BUG] OpenXR: xrCreateSwapchain changes current OpenGL context

steamvrclosed bug
ValveSoftware/SteamVR-for-Linux#421 · opened 2021-01-26 by ChristophHaag · updated 2023-05-14 · 6 comments · github
CChristophHaag 2021-01-26 github

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.

CChristophHaag 2021-01-26 github

same for xrWaitSwapchainImage, possibly others.

CChristophHaag 2021-01-26 github

This also breaks hello_xr -G OpenGL

CChristophHaag 2021-11-21 github
CChristophHaag 2021-11-29 github

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.

Aamalon 2023-05-14 github

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.

CChristophHaag 2023-05-14 github

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

Nothing extracted yet.