OpenXR-SDK-Source icon indicating copy to clipboard operation
OpenXR-SDK-Source copied to clipboard

Linux XCB compat

Open rpavlik opened this issue 4 years ago • 7 comments

Hmm. When I pull this into the internal repo with CI, it fails during the xcb-backend build of the exported source. (Don't know why it doesn't fail with the normal source)

FAILED: /usr/bin/c++   -DOPENXR_HAVE_COMMON_CONFIG -DOS_LINUX_XCB_GLX -DXR_OS_LINUX -DXR_USE_GRAPHICS_API_OPENGL -DXR_USE_PLATFORM_XCB -DXR_USE_TIMESPEC -I../src/../include -I../src -Isrc/tests/hello_xr -I../src/common -I../include -Iinclude -I../external/include -fPIE   -Wall -std=gnu++14 -MMD -MT src/tests/hello_xr/CMakeFiles/hello_xr.dir/graphicsplugin_opengl.cpp.o -MF src/tests/hello_xr/CMakeFiles/hello_xr.dir/graphicsplugin_opengl.cpp.o.d -o src/tests/hello_xr/CMakeFiles/hello_xr.dir/graphicsplugin_opengl.cpp.o -c ../src/tests/hello_xr/graphicsplugin_opengl.cpp
In file included from ../src/tests/hello_xr/graphicsplugin_opengl.cpp:9:0:
../src/common/xr_linear.h:24:0: warning: ignoring #pragma clang diagnostic [-Wunknown-pragmas]
 #pragma clang diagnostic ignored "-Wunused-function"
 ^
../src/tests/hello_xr/graphicsplugin_opengl.cpp: In member function ‘virtual void {anonymous}::OpenGLGraphicsPlugin::InitializeDevice(XrInstance, XrSystemId)’:
../src/tests/hello_xr/graphicsplugin_opengl.cpp:124:55: error: ‘struct ksGpuContext’ has no member named ‘connection’
         m_graphicsBinding.connection = window.context.connection;
                                                       ^
../src/tests/hello_xr/graphicsplugin_opengl.cpp:125:57: error: ‘struct ksGpuContext’ has no member named ‘screenNumber’
         m_graphicsBinding.screenNumber = window.context.screenNumber;
                                                         ^
../src/tests/hello_xr/graphicsplugin_opengl.cpp:126:55: error: ‘struct ksGpuContext’ has no member named ‘fbconfigid’
         m_graphicsBinding.fbconfigid = window.context.fbconfigid;
                                                       ^
../src/tests/hello_xr/graphicsplugin_opengl.cpp:129:55: error: invalid conversion from ‘GLXContext {aka __GLXcontextRec*}’ to ‘xcb_glx_context_t {aka unsigned int}’ [-fpermissive]
         m_graphicsBinding.glxContext = window.context.glxContext;
                                                       ^

I'll dig into it further tomorrow.

Originally posted by @rpavlik in https://github.com/KhronosGroup/OpenXR-SDK-Source/pull/144#issuecomment-557314798

rpavlik avatar Nov 21 '19 23:11 rpavlik

I looked back at the definition for the 'ksGpuContext' struct in gfxwrapper_opengl.h and noticed the #elif defined(OS_LINUX_XLIB) || defined(OS_LINUX_XCB_GLX) directive that decides if the struct has the XLib fields. Was the || defined(OS_LINUX_XCB_GLX) supposed to go with the #elif defined(OS_LINUX_XCB) block of XCB fields instead? I thought I checked if the code compiled with XCB, but maybe I only checked OS_LINUX_XCB and not OS_LINUX_XCB_GLX.

SamanthaBowen avatar Nov 21 '19 23:11 SamanthaBowen

Hmm, looks like the build system says:

    # XCB + XCB GLX is limited to OpenGL 2.1
    # add_definitions( -DOS_LINUX_XCB )
    # XCB + Xlib GLX 1.3
    add_definitions( -DOS_LINUX_XCB_GLX )

so it doesn't have all those fields. It does have connection - via window.connection, and the visualid and glxDrawable are still OK, but the other 3 are absent.

rpavlik avatar Nov 22 '19 15:11 rpavlik

Almost looks like the XCB OpenGL graphics binding is only half of what it needs to be - as in, it's missing a XCB + GLX xlib version. What a mess.

rpavlik avatar Nov 22 '19 15:11 rpavlik

Oh, interesting. The XCB hello_xr never ran because of a missing "platform adapter". I'll probably just partially revert/comment out the change to fix this for now.

rpavlik avatar Nov 22 '19 19:11 rpavlik

and monado doesn't support the xcb binding. OK. So I have a partial fix available but for the release I'll just do the partial revert, so you can review the mess I made of the code :)

rpavlik avatar Nov 22 '19 19:11 rpavlik

OK, the less-than-perfect fix has been released. There may actually be a spec bug here.

rpavlik avatar Nov 22 '19 23:11 rpavlik

An issue (number 1278) has been filed to correspond to this issue in the internal Khronos GitLab.

If you have a Khronos account, you can access that issue at KHR:openxr/openxr#1278.

rpavlik-bot avatar Dec 05 '19 18:12 rpavlik-bot