Would you like to have OpenXR initialization helpers?

Hello! That’s my first time posting here! :grin:

So, I started playing with the OpenXR API last week… And well, it’s initialization procedure is fairly similar to the one of Vulkan. And Like for Vulkan, If the core of the API is cross platform, it needs to talk to the outside world, and that part require some platform specific things that basically required cross-platform developers to #ifdef a bunch of stuff.

One of the areas SDL is really useful is the fact that it allows one single API for doing everything on all supported platforms.

Without going into all the nitty gritty details, OpenXR require you to be aware of 2 main things

  1. The Graphics API used. This is fairly obvious, but determine the list of extensions you have to request when creating the instance. A function that return the apropriate list of string for an “SDL_OPENXR_GL(ES)/VK/D3D11/D3D12” would be helpful
  2. The Windowing system used (between Windows WIN32, X11 or Wayland, or “Hey, we’re running on Android right now”. This is easy to handle knowing that SDL created the window. Everything in syswm info is there. This require creating a pair of structures, with one pointing to the other and setting a bunch of flags and low level information to them that depend (for example window handles on Windows or Display pointer when XLIB is running on Linux/UNIX).

The actual way this is done is fairly similar to the way a Vulkan instance and Vulkan surface are created. For Vulkan, SDL has some really handy functions that retries you the extensions you need to load, and create that (platform specific) surface object.

I think there’s value to have SDL be able to do similar things for OpenXR… I am not talking about deeper integration like trying to pipe the OpenXR “action” system through SDL_Events (that’s sounds fun, useful, and horrible to do at the same time :joy:) but I would be happy to try to contribute utilities for bootstrapping OpenXR in a platform independent way to SDL2>

I would like to know if this would interest anybody here, if somebody already thought about that (and started to do it), and if I submit a patch for doing so to the SDL team, is it something that would be likely accepted and merged?

I have been using the SDL for… Well, years. And I feel the itch to give back to the project a little bit :wink:

That would be sweet man :slight_smile: Im super interested in VR using SDL/Vulkan combination

I’m starting to look into this a bit more seriously. I’m looking at how the Vulkan utils in SDL2 are actually put together as this is a bit similar.

Source code vendor-in pretty much all the headers required under /src/video/khronos/.

I am looking into automatically returning the right strings and datastructure depending on the detected platform, and I will probably not have to do any OpenXR call inside the SDL.