SDL 3.0
SDL_openxr.h File Reference
Include dependency graph for SDL_openxr.h:

Go to the source code of this file.

Data Structures

struct  XrSessionCreateInfo
struct  XrSwapchainCreateInfo

Macros

#define XR_NULL_HANDLE   0
#define XR_DEFINE_HANDLE(object)
#define PFN_xrGetInstanceProcAddr   SDL_FunctionPointer

Enumerations

enum  XrStructureType {
  XR_TYPE_SESSION_CREATE_INFO = 8 ,
  XR_TYPE_SWAPCHAIN_CREATE_INFO = 9
}
enum  XrResult {
  XR_ERROR_FUNCTION_UNSUPPORTED = -7 ,
  XR_ERROR_HANDLE_INVALID = -12
}

Functions

XrResult SDL_CreateGPUXRSession (SDL_GPUDevice *device, const XrSessionCreateInfo *createinfo, XrSession *session)
SDL_GPUTextureFormatSDL_GetGPUXRSwapchainFormats (SDL_GPUDevice *device, XrSession session, int *num_formats)
XrResult SDL_CreateGPUXRSwapchain (SDL_GPUDevice *device, XrSession session, const XrSwapchainCreateInfo *createinfo, SDL_GPUTextureFormat format, XrSwapchain *swapchain, SDL_GPUTexture ***textures)
XrResult SDL_DestroyGPUXRSwapchain (SDL_GPUDevice *device, XrSwapchain swapchain, SDL_GPUTexture **swapchainImages)
bool SDL_OpenXR_LoadLibrary (void)
void SDL_OpenXR_UnloadLibrary (void)
PFN_xrGetInstanceProcAddr SDL_OpenXR_GetXrGetInstanceProcAddr (void)

Macro Definition Documentation

◆ PFN_xrGetInstanceProcAddr

#define PFN_xrGetInstanceProcAddr   SDL_FunctionPointer

Definition at line 79 of file SDL_openxr.h.

Referenced by SDL_OpenXR_GetXrGetInstanceProcAddr().

◆ XR_DEFINE_HANDLE

#define XR_DEFINE_HANDLE ( object)
Value:
typedef Uint64 object;
uint64_t Uint64
Definition SDL_stdinc.h:504

Definition at line 52 of file SDL_openxr.h.

◆ XR_NULL_HANDLE

#define XR_NULL_HANDLE   0

CategoryOpenXR

Functions for creating OpenXR handles for SDL_gpu contexts.

For the most part, OpenXR operates independent of SDL, but the graphics initialization depends on direct support from SDL_gpu.

Definition at line 49 of file SDL_openxr.h.

Enumeration Type Documentation

◆ XrResult

enum XrResult
Enumerator
XR_ERROR_FUNCTION_UNSUPPORTED 
XR_ERROR_HANDLE_INVALID 

Definition at line 74 of file SDL_openxr.h.

74 {
77} XrResult;
XrResult
Definition SDL_openxr.h:74
@ XR_ERROR_HANDLE_INVALID
Definition SDL_openxr.h:76
@ XR_ERROR_FUNCTION_UNSUPPORTED
Definition SDL_openxr.h:75

◆ XrStructureType

Enumerator
XR_TYPE_SESSION_CREATE_INFO 
XR_TYPE_SWAPCHAIN_CREATE_INFO 

Definition at line 55 of file SDL_openxr.h.

55 {
XrStructureType
Definition SDL_openxr.h:55
@ XR_TYPE_SESSION_CREATE_INFO
Definition SDL_openxr.h:56
@ XR_TYPE_SWAPCHAIN_CREATE_INFO
Definition SDL_openxr.h:57

Function Documentation

◆ SDL_CreateGPUXRSession()

XrResult SDL_CreateGPUXRSession ( SDL_GPUDevice * device,
const XrSessionCreateInfo * createinfo,
XrSession * session )
extern

Creates an OpenXR session.

The OpenXR system ID is pulled from the passed GPU context.

Parameters
devicea GPU context.
createinfothe create info for the OpenXR session, sans the system ID.
sessiona pointer filled in with an OpenXR session created for the given device.
Returns
the result of the call.
Since
This function is available since SDL 3.6.0.
See also
SDL_CreateGPUDeviceWithProperties

◆ SDL_CreateGPUXRSwapchain()

XrResult SDL_CreateGPUXRSwapchain ( SDL_GPUDevice * device,
XrSession session,
const XrSwapchainCreateInfo * createinfo,
SDL_GPUTextureFormat format,
XrSwapchain * swapchain,
SDL_GPUTexture *** textures )
extern

Creates an OpenXR swapchain.

The array returned via textures is sized according to xrEnumerateSwapchainImages, and thus should only be accessed via index values returned from xrAcquireSwapchainImage.

Applications are still allowed to call xrEnumerateSwapchainImages on the returned XrSwapchain if they need to get the exact size of the array.

Parameters
devicea GPU context.
sessionan OpenXR session created for the given device.
createinfothe create info for the OpenXR swapchain, sans the format.
formata supported format for the OpenXR swapchain.
swapchaina pointer filled in with the created OpenXR swapchain.
texturesa pointer filled in with the array of created swapchain images.
Returns
the result of the call.
Since
This function is available since SDL 3.6.0.
See also
SDL_CreateGPUDeviceWithProperties
SDL_CreateGPUXRSession
SDL_GetGPUXRSwapchainFormats
SDL_DestroyGPUXRSwapchain

◆ SDL_DestroyGPUXRSwapchain()

XrResult SDL_DestroyGPUXRSwapchain ( SDL_GPUDevice * device,
XrSwapchain swapchain,
SDL_GPUTexture ** swapchainImages )
extern

Destroys and OpenXR swapchain previously returned by SDL_CreateGPUXRSwapchain.

Parameters
devicea GPU context.
swapchaina swapchain previously returned by SDL_CreateGPUXRSwapchain.
swapchainImagesan array of swapchain images returned by the same call to SDL_CreateGPUXRSwapchain.
Returns
the result of the call.
Since
This function is available since SDL 3.6.0.
See also
SDL_CreateGPUDeviceWithProperties
SDL_CreateGPUXRSession
SDL_CreateGPUXRSwapchain

◆ SDL_GetGPUXRSwapchainFormats()

SDL_GPUTextureFormat * SDL_GetGPUXRSwapchainFormats ( SDL_GPUDevice * device,
XrSession session,
int * num_formats )
extern

Queries the GPU device for supported XR swapchain image formats.

The returned pointer should be allocated with SDL_malloc() and will be passed to SDL_free().

Parameters
devicea GPU context.
sessionan OpenXR session created for the given device.
num_formatsa pointer filled with the number of supported XR swapchain formats.
Returns
a 0 terminated array of supported formats or NULL on failure; call SDL_GetError() for more information. This should be freed with SDL_free() when it is no longer needed.
Since
This function is available since SDL 3.6.0.
See also
SDL_CreateGPUXRSwapchain

◆ SDL_OpenXR_GetXrGetInstanceProcAddr()

PFN_xrGetInstanceProcAddr SDL_OpenXR_GetXrGetInstanceProcAddr ( void )
extern

Get the address of the xrGetInstanceProcAddr function.

This should be called after either calling SDL_OpenXR_LoadLibrary() or creating an OpenXR SDL_GPUDevice.

The actual type of the returned function pointer is PFN_xrGetInstanceProcAddr, but that isn't always available. You should include the OpenXR headers before this header, or cast the return value of this function to the correct type.

Returns
the function pointer for xrGetInstanceProcAddr or NULL on failure; call SDL_GetError() for more information.
Since
This function is available since SDL 3.6.0.

References PFN_xrGetInstanceProcAddr.

◆ SDL_OpenXR_LoadLibrary()

bool SDL_OpenXR_LoadLibrary ( void )
extern

Dynamically load the OpenXR loader.

This can be called at any time.

SDL keeps a reference count of the OpenXR loader, calling this function multiple times will increment that count, rather than loading the library multiple times.

If not called, this will be implicitly called when creating a GPU device with OpenXR.

This function will use the platform default OpenXR loader name, unless the SDL_HINT_OPENXR_LIBRARY hint is set.

Returns
true on success or false on failure; call SDL_GetError() for more information.

\threadsafety This function is not thread safe.

Since
This function is available since SDL 3.6.0.
See also
SDL_HINT_OPENXR_LIBRARY

◆ SDL_OpenXR_UnloadLibrary()

void SDL_OpenXR_UnloadLibrary ( void )
extern

Unload the OpenXR loader previously loaded by SDL_OpenXR_LoadLibrary.

SDL keeps a reference count of the OpenXR loader, calling this function will decrement that count. Once the reference count reaches zero, the library is unloaded.

\threadsafety This function is not thread safe.

Since
This function is available since SDL 3.6.0.