1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
/*
Simple DirectMedia Layer
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
/* WIKI CATEGORY: OpenXR */
/**
* # CategoryOpenXR
*
* Functions for creating OpenXR handles for [GPU API](CategoryGPU) contexts.
*
* For the most part, OpenXR operates independent of SDL, but the graphics
* initialization depends on direct support from the GPU API.
*/
/* Set up for C function definitions, even when using C++ */
extern "C" SDL_WIKI_DOCUMENTATION_SECTION
/* OPENXR_H_ */
/* XR_DEFINE_HANDLE */
typedef enum XrStructureType XrStructureType;
typedef struct XrSessionCreateInfo;
typedef struct XrSwapchainCreateInfo;
typedef enum XrResult XrResult;
/* NO_SDL_OPENXR_TYPEDEFS */
/* !SDL_WIKI_DOCUMENTATION_SECTION */
/**
* Creates an OpenXR session.
*
* The OpenXR system ID is pulled from the passed GPU context.
*
* \param device a GPU context.
* \param createinfo the create info for the OpenXR session, sans the system
* ID.
* \param session a 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.
*
* \sa SDL_CreateGPUDeviceWithProperties
*/
extern SDL_DECLSPEC XrResult SDLCALL ;
/**
* 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().
*
* \param device a GPU context.
* \param session an OpenXR session created for the given device.
* \param num_formats a 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.
*
* \sa SDL_CreateGPUXRSwapchain
*/
extern SDL_DECLSPEC SDL_GPUTextureFormat * SDLCALL ;
/**
* 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.
*
* \param device a GPU context.
* \param session an OpenXR session created for the given device.
* \param createinfo the create info for the OpenXR swapchain, sans the
* format.
* \param format a supported format for the OpenXR swapchain.
* \param swapchain a pointer filled in with the created OpenXR swapchain.
* \param textures a 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.
*
* \sa SDL_CreateGPUDeviceWithProperties
* \sa SDL_CreateGPUXRSession
* \sa SDL_GetGPUXRSwapchainFormats
* \sa SDL_DestroyGPUXRSwapchain
*/
extern SDL_DECLSPEC XrResult SDLCALL ;
/**
* Destroys and OpenXR swapchain previously returned by
* SDL_CreateGPUXRSwapchain.
*
* \param device a GPU context.
* \param swapchain a swapchain previously returned by
* SDL_CreateGPUXRSwapchain.
* \param swapchainImages an 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.
*
* \sa SDL_CreateGPUDeviceWithProperties
* \sa SDL_CreateGPUXRSession
* \sa SDL_CreateGPUXRSwapchain
*/
extern SDL_DECLSPEC XrResult SDLCALL ;
/**
* 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.
*
* \sa SDL_HINT_OPENXR_LIBRARY
*/
extern SDL_DECLSPEC bool SDLCALL ;
/**
* 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.
*/
extern SDL_DECLSPEC void SDLCALL ;
/**
* 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.
*/
extern SDL_DECLSPEC PFN_xrGetInstanceProcAddr SDLCALL ;
/* Ends C function definitions when using C++ */
}
/* SDL_openxr_h_ */