Blender V5.0
GHOST_XrContext.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2020-2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
10
11#include <algorithm>
12#include <cassert>
13#include <sstream>
14#include <string>
15#include <string_view>
16
17#include "GHOST_Types.h"
18#include "GHOST_XrException.hh"
19#include "GHOST_XrSession.hh"
20#include "GHOST_Xr_intern.hh"
21
22#include "GHOST_XrContext.hh"
23
25 XrInstance instance = XR_NULL_HANDLE;
26 XrInstanceProperties instance_properties = {};
27
28 std::vector<XrExtensionProperties> extensions;
29 std::vector<XrApiLayerProperties> layers;
30
31 static PFN_xrCreateDebugUtilsMessengerEXT s_xrCreateDebugUtilsMessengerEXT_fn;
32 static PFN_xrDestroyDebugUtilsMessengerEXT s_xrDestroyDebugUtilsMessengerEXT_fn;
33
34 XrDebugUtilsMessengerEXT debug_messenger = XR_NULL_HANDLE;
35};
36
37PFN_xrCreateDebugUtilsMessengerEXT OpenXRInstanceData::s_xrCreateDebugUtilsMessengerEXT_fn =
38 nullptr;
39PFN_xrDestroyDebugUtilsMessengerEXT OpenXRInstanceData::s_xrDestroyDebugUtilsMessengerEXT_fn =
40 nullptr;
41
42GHOST_XrErrorHandlerFn GHOST_XrContext::s_error_handler = nullptr;
43void *GHOST_XrContext::s_error_handler_customdata = nullptr;
44
45/* -------------------------------------------------------------------- */
48
49GHOST_XrContext::GHOST_XrContext(const GHOST_XrContextCreateInfo *create_info)
50 : oxr_(std::make_unique<OpenXRInstanceData>()),
51 debug_(create_info->context_flag & GHOST_kXrContextDebug),
52 debug_time_(create_info->context_flag & GHOST_kXrContextDebugTime)
53{
54}
55
57{
58 /* Destroy session data first. Otherwise xrDestroyInstance will implicitly do it, before the
59 * session had a chance to do so explicitly. */
60 session_ = nullptr;
61
62 if (oxr_->debug_messenger != XR_NULL_HANDLE) {
63 assert(oxr_->s_xrDestroyDebugUtilsMessengerEXT_fn != nullptr);
64 oxr_->s_xrDestroyDebugUtilsMessengerEXT_fn(oxr_->debug_messenger);
65 }
66 if (oxr_->instance != XR_NULL_HANDLE) {
67 CHECK_XR_ASSERT(xrDestroyInstance(oxr_->instance));
68 oxr_->instance = XR_NULL_HANDLE;
69 }
70}
71
72void GHOST_XrContext::initialize(const GHOST_XrContextCreateInfo *create_info)
73{
74 initApiLayers();
75 initExtensions();
76 if (isDebugMode()) {
77 printSDKVersion();
78 printAvailableAPILayersAndExtensionsInfo();
79 }
80
81 /* Multiple graphics binding extensions can be enabled, but only one will actually be used
82 * (determined later on). */
83 const std::vector<GHOST_TXrGraphicsBinding> graphics_binding_types =
84 determineGraphicsBindingTypesToEnable(create_info);
85
86 assert(oxr_->instance == XR_NULL_HANDLE);
87 createOpenXRInstance(graphics_binding_types);
88 storeInstanceProperties();
89
90 /* Multiple bindings may be enabled. Now that we know the runtime in use, settle for one. */
91 gpu_binding_type_ = determineGraphicsBindingTypeToUse(graphics_binding_types, create_info);
92
93 printInstanceInfo();
94 if (isDebugMode()) {
95 initDebugMessenger();
96 }
97}
98
99void GHOST_XrContext::createOpenXRInstance(
100 const std::vector<GHOST_TXrGraphicsBinding> &graphics_binding_types)
101{
102 XrInstanceCreateInfo create_info = {XR_TYPE_INSTANCE_CREATE_INFO};
103
104 std::string("Blender").copy(create_info.applicationInfo.applicationName,
105 XR_MAX_APPLICATION_NAME_SIZE);
106 create_info.applicationInfo.apiVersion = XR_CURRENT_API_VERSION;
107
108 getAPILayersToEnable(enabled_layers_);
109 getExtensionsToEnable(graphics_binding_types, enabled_extensions_);
110 create_info.enabledApiLayerCount = enabled_layers_.size();
111 create_info.enabledApiLayerNames = enabled_layers_.data();
112 create_info.enabledExtensionCount = enabled_extensions_.size();
113 create_info.enabledExtensionNames = enabled_extensions_.data();
114 if (isDebugMode()) {
115 printExtensionsAndAPILayersToEnable();
116 }
117
118 CHECK_XR(xrCreateInstance(&create_info, &oxr_->instance),
119 "Failed to connect to an OpenXR runtime.");
120}
121
122void GHOST_XrContext::storeInstanceProperties()
123{
124 const std::map<std::string, GHOST_TXrOpenXRRuntimeID> runtime_map = {
125 {"Monado(XRT) by Collabora et al", OPENXR_RUNTIME_MONADO},
126 {"Oculus", OPENXR_RUNTIME_OCULUS},
127 {"SteamVR/OpenXR", OPENXR_RUNTIME_STEAMVR},
128 {"Windows Mixed Reality Runtime", OPENXR_RUNTIME_WMR},
129 {"Varjo OpenXR Runtime", OPENXR_RUNTIME_VARJO}};
130 decltype(runtime_map)::const_iterator runtime_map_iter;
131
132 oxr_->instance_properties.type = XR_TYPE_INSTANCE_PROPERTIES;
133 CHECK_XR(xrGetInstanceProperties(oxr_->instance, &oxr_->instance_properties),
134 "Failed to get OpenXR runtime information. Do you have an active runtime set up?");
135
136 runtime_map_iter = runtime_map.find(oxr_->instance_properties.runtimeName);
137 if (runtime_map_iter != runtime_map.end()) {
138 runtime_id_ = runtime_map_iter->second;
139 }
140}
141 /* Create, Initialize and Destruct */
143
144/* -------------------------------------------------------------------- */
147
148void GHOST_XrContext::printSDKVersion()
149{
150 const XrVersion sdk_version = XR_CURRENT_API_VERSION;
151
152 printf("OpenXR SDK Version: %u.%u.%u\n",
153 XR_VERSION_MAJOR(sdk_version),
154 XR_VERSION_MINOR(sdk_version),
155 XR_VERSION_PATCH(sdk_version));
156}
157
158void GHOST_XrContext::printInstanceInfo()
159{
160 assert(oxr_->instance != XR_NULL_HANDLE);
161
162 printf("Connected to OpenXR runtime: %s (Version %u.%u.%u)\n",
163 oxr_->instance_properties.runtimeName,
164 XR_VERSION_MAJOR(oxr_->instance_properties.runtimeVersion),
165 XR_VERSION_MINOR(oxr_->instance_properties.runtimeVersion),
166 XR_VERSION_PATCH(oxr_->instance_properties.runtimeVersion));
167}
168
169void GHOST_XrContext::printAvailableAPILayersAndExtensionsInfo()
170{
171 puts("Available OpenXR API-layers/extensions:");
172 for (const XrApiLayerProperties &layer_info : oxr_->layers) {
173 printf("Layer: %s\n", layer_info.layerName);
174 }
175 for (const XrExtensionProperties &ext_info : oxr_->extensions) {
176 printf("Extension: %s\n", ext_info.extensionName);
177 }
178}
179
180void GHOST_XrContext::printExtensionsAndAPILayersToEnable()
181{
182 for (const char *layer_name : enabled_layers_) {
183 printf("Enabling OpenXR API-Layer: %s\n", layer_name);
184 }
185 for (const char *ext_name : enabled_extensions_) {
186 printf("Enabling OpenXR Extension: %s\n", ext_name);
187 }
188}
189
190static XrBool32 debug_messenger_func(XrDebugUtilsMessageSeverityFlagsEXT /*messageSeverity*/,
191 XrDebugUtilsMessageTypeFlagsEXT /*messageTypes*/,
192 const XrDebugUtilsMessengerCallbackDataEXT *callbackData,
193 void * /*user_data*/)
194{
195 puts("OpenXR Debug Message:");
196 puts(callbackData->message);
197 return XR_FALSE; /* OpenXR spec suggests always returning false. */
198}
199
200void GHOST_XrContext::initDebugMessenger()
201{
202 XrDebugUtilsMessengerCreateInfoEXT create_info = {XR_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT};
203
204 /* Extension functions need to be obtained through xrGetInstanceProcAddr(). */
205 if (XR_FAILED(xrGetInstanceProcAddr(
206 oxr_->instance,
207 "xrCreateDebugUtilsMessengerEXT",
208 (PFN_xrVoidFunction *)&oxr_->s_xrCreateDebugUtilsMessengerEXT_fn)) ||
209 XR_FAILED(xrGetInstanceProcAddr(
210 oxr_->instance,
211 "xrDestroyDebugUtilsMessengerEXT",
212 (PFN_xrVoidFunction *)&oxr_->s_xrDestroyDebugUtilsMessengerEXT_fn)))
213 {
214 oxr_->s_xrCreateDebugUtilsMessengerEXT_fn = nullptr;
215 oxr_->s_xrDestroyDebugUtilsMessengerEXT_fn = nullptr;
216
217 fprintf(stderr,
218 "Could not use XR_EXT_debug_utils to enable debug prints. Not a fatal error, "
219 "continuing without the messenger.\n");
220 return;
221 }
222
223 create_info.messageSeverities = XR_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT |
224 XR_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT |
225 XR_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT |
226 XR_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT;
227 create_info.messageTypes = XR_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT |
228 XR_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT |
229 XR_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT;
230 create_info.userCallback = debug_messenger_func;
231
232 if (XR_FAILED(oxr_->s_xrCreateDebugUtilsMessengerEXT_fn(
233 oxr_->instance, &create_info, &oxr_->debug_messenger)))
234 {
235 fprintf(stderr,
236 "Failed to create OpenXR debug messenger. Not a fatal error, continuing without the "
237 "messenger.\n");
238 return;
239 }
240}
241 /* Debug Printing */
243
244/* -------------------------------------------------------------------- */
247
249{
250 GHOST_XrError error;
251
252 error.user_message = exception->msg_.data();
253 error.customdata = s_error_handler_customdata;
254
255 char error_string_buf[XR_MAX_RESULT_STRING_SIZE];
256 xrResultToString(getInstance(), static_cast<XrResult>(exception->result_), error_string_buf);
257
258 if (isDebugMode()) {
259 fprintf(stderr,
260 "Error: \t%s\n\tOpenXR error: %s (error value: %i)\n",
261 error.user_message,
262 error_string_buf,
263 exception->result_);
264 }
265
266 /* Potentially destroys GHOST_XrContext */
267 s_error_handler(&error);
268}
269
270void GHOST_XrContext::setErrorHandler(GHOST_XrErrorHandlerFn handler_fn, void *customdata)
271{
272 s_error_handler = handler_fn;
273 s_error_handler_customdata = customdata;
274}
275 /* Error handling */
277
278/* -------------------------------------------------------------------- */
281
285void GHOST_XrContext::initExtensionsEx(std::vector<XrExtensionProperties> &extensions,
286 const char *layer_name)
287{
288 uint32_t extension_count = 0;
289
290 /* Get count for array creation/init first. */
291 CHECK_XR(xrEnumerateInstanceExtensionProperties(layer_name, 0, &extension_count, nullptr),
292 "Failed to query OpenXR runtime information. Do you have an active runtime set up?");
293
294 if (extension_count == 0) {
295 /* Extensions are optional, can successfully exit. */
296 return;
297 }
298
299 for (uint32_t i = 0; i < extension_count; i++) {
300 XrExtensionProperties ext = {XR_TYPE_EXTENSION_PROPERTIES};
301 extensions.push_back(ext);
302 }
303
304 /* Actually get the extensions. */
305 CHECK_XR(xrEnumerateInstanceExtensionProperties(
306 layer_name, extension_count, &extension_count, extensions.data()),
307 "Failed to query OpenXR runtime information. Do you have an active runtime set up?");
308}
309
310void GHOST_XrContext::initExtensions()
311{
312 initExtensionsEx(oxr_->extensions, nullptr);
313}
314
315void GHOST_XrContext::initApiLayers()
316{
317 uint32_t layer_count = 0;
318
319 /* Get count for array creation/init first. */
320 CHECK_XR(xrEnumerateApiLayerProperties(0, &layer_count, nullptr),
321 "Failed to query OpenXR runtime information. Do you have an active runtime set up?");
322
323 if (layer_count == 0) {
324 /* Layers are optional, can safely exit. */
325 return;
326 }
327
328 oxr_->layers = std::vector<XrApiLayerProperties>(layer_count);
329 for (XrApiLayerProperties &layer : oxr_->layers) {
330 layer.type = XR_TYPE_API_LAYER_PROPERTIES;
331 }
332
333 /* Actually get the layers. */
334 CHECK_XR(xrEnumerateApiLayerProperties(layer_count, &layer_count, oxr_->layers.data()),
335 "Failed to query OpenXR runtime information. Do you have an active runtime set up?");
336 for (const XrApiLayerProperties &layer : oxr_->layers) {
337 /* Each layer may have own extensions. */
338 initExtensionsEx(oxr_->extensions, layer.layerName);
339 }
340}
341
342static bool openxr_layer_is_available(const std::vector<XrApiLayerProperties> &layers_info,
343 const std::string &layer_name)
344{
345 for (const XrApiLayerProperties &layer_info : layers_info) {
346 if (layer_info.layerName == layer_name) {
347 return true;
348 }
349 }
350
351 return false;
352}
353
355 const std::vector<XrExtensionProperties> &extensions_info,
356 const std::string_view &extension_name)
357{
358 for (const XrExtensionProperties &ext_info : extensions_info) {
359 if (ext_info.extensionName == extension_name) {
360 return true;
361 }
362 }
363
364 return false;
365}
366
370void GHOST_XrContext::getAPILayersToEnable(std::vector<const char *> &r_ext_names)
371{
372 static std::vector<std::string> try_layers;
373
374 try_layers.clear();
375
376 if (isDebugMode()) {
377 try_layers.push_back("XR_APILAYER_LUNARG_core_validation");
378 }
379
380 r_ext_names.reserve(try_layers.size());
381
382 for (const std::string &layer : try_layers) {
383 if (openxr_layer_is_available(oxr_->layers, layer)) {
384 r_ext_names.push_back(layer.data());
385 }
386 }
387}
388
389static const char *openxr_ext_name_from_wm_gpu_binding(GHOST_TXrGraphicsBinding binding)
390{
391 switch (binding) {
392 case GHOST_kXrGraphicsOpenGL:
393#ifdef WITH_OPENGL_BACKEND
394 return XR_KHR_OPENGL_ENABLE_EXTENSION_NAME;
395#else
396 return nullptr;
397#endif
398
399 case GHOST_kXrGraphicsVulkan:
400#ifdef WITH_VULKAN_BACKEND
401 return XR_KHR_VULKAN_ENABLE2_EXTENSION_NAME;
402#else
403 return nullptr;
404#endif
405
406#ifdef WIN32
407# ifdef WITH_OPENGL_BACKEND
408 case GHOST_kXrGraphicsOpenGLD3D11:
409# endif
410# ifdef WITH_VULKAN_BACKEND
411 case GHOST_kXrGraphicsVulkanD3D11:
412# endif
413 return XR_KHR_D3D11_ENABLE_EXTENSION_NAME;
414#endif
415 case GHOST_kXrGraphicsUnknown:
416 assert(!"Could not identify graphics binding to choose.");
417 return nullptr;
418 }
419
420 return nullptr;
421}
422
426void GHOST_XrContext::getExtensionsToEnable(
427 const std::vector<GHOST_TXrGraphicsBinding> &graphics_binding_types,
428 std::vector<const char *> &r_ext_names)
429{
430 std::vector<std::string_view> try_ext;
431
432 /* Try enabling debug extension. */
433 if (isDebugMode()) {
434 try_ext.push_back(XR_EXT_DEBUG_UTILS_EXTENSION_NAME);
435 }
436
437 /* Interaction profile extensions. */
438 try_ext.push_back(XR_EXT_HP_MIXED_REALITY_CONTROLLER_EXTENSION_NAME);
439 try_ext.push_back(XR_HTC_VIVE_COSMOS_CONTROLLER_INTERACTION_EXTENSION_NAME);
440#ifdef XR_HTC_VIVE_FOCUS3_CONTROLLER_INTERACTION_EXTENSION_NAME
441 try_ext.push_back(XR_HTC_VIVE_FOCUS3_CONTROLLER_INTERACTION_EXTENSION_NAME);
442#endif
443 try_ext.push_back(XR_HUAWEI_CONTROLLER_INTERACTION_EXTENSION_NAME);
444
445 /* Controller model extension. */
446 try_ext.push_back(XR_MSFT_CONTROLLER_MODEL_EXTENSION_NAME);
447
448 /* Varjo quad view extension. */
449 try_ext.push_back(XR_VARJO_QUAD_VIEWS_EXTENSION_NAME);
450
451 /* Varjo foveated extension. */
452 try_ext.push_back(XR_VARJO_FOVEATED_RENDERING_EXTENSION_NAME);
453
454 /* Meta/Facebook passthrough extension. */
455 try_ext.push_back(XR_FB_PASSTHROUGH_EXTENSION_NAME);
456
457 r_ext_names.reserve(try_ext.size() + graphics_binding_types.size());
458
459 /* Add graphics binding extensions (may be multiple ones, we'll settle for one to use later, once
460 * we have more info about the runtime). */
461 for (GHOST_TXrGraphicsBinding type : graphics_binding_types) {
462 const char *gpu_binding = openxr_ext_name_from_wm_gpu_binding(type);
463 assert(openxr_extension_is_available(oxr_->extensions, gpu_binding));
464 r_ext_names.push_back(gpu_binding);
465 }
466
467#if defined(WITH_GHOST_X11)
468 if (openxr_extension_is_available(oxr_->extensions, XR_MNDX_EGL_ENABLE_EXTENSION_NAME)) {
469 /* Use EGL if that backend is available. */
470 r_ext_names.push_back(XR_MNDX_EGL_ENABLE_EXTENSION_NAME);
471 }
472#endif
473
474 for (const std::string_view &ext : try_ext) {
475 if (openxr_extension_is_available(oxr_->extensions, ext)) {
476 r_ext_names.push_back(ext.data());
477 }
478 }
479}
480
485std::vector<GHOST_TXrGraphicsBinding> GHOST_XrContext::determineGraphicsBindingTypesToEnable(
486 const GHOST_XrContextCreateInfo *create_info)
487{
488 std::vector<GHOST_TXrGraphicsBinding> result;
489 assert(create_info->gpu_binding_candidates != nullptr);
490 assert(create_info->gpu_binding_candidates_count > 0);
491
492 for (uint32_t i = 0; i < create_info->gpu_binding_candidates_count; i++) {
493 assert(create_info->gpu_binding_candidates[i] != GHOST_kXrGraphicsUnknown);
494 const char *ext_name = openxr_ext_name_from_wm_gpu_binding(
495 create_info->gpu_binding_candidates[i]);
496 if (openxr_extension_is_available(oxr_->extensions, ext_name)) {
497 result.push_back(create_info->gpu_binding_candidates[i]);
498 }
499 }
500
501 if (result.empty()) {
502 throw GHOST_XrException("No supported graphics binding found.");
503 }
504
505 return result;
506}
507
508GHOST_TXrGraphicsBinding GHOST_XrContext::determineGraphicsBindingTypeToUse(
509 const std::vector<GHOST_TXrGraphicsBinding> &enabled_types,
510 const GHOST_XrContextCreateInfo *create_info)
511{
512 /* Return the first working type. */
513 for (GHOST_TXrGraphicsBinding type : enabled_types) {
514#ifdef WIN32
515 /* The SteamVR OpenGL backend currently fails for NVIDIA GPU's. Disable it and allow falling
516 * back to the DirectX one. */
517 if ((runtime_id_ == OPENXR_RUNTIME_STEAMVR) && (type == GHOST_kXrGraphicsOpenGL) &&
518 ((create_info->context_flag & GHOST_kXrContextGpuNVIDIA) != 0))
519 {
520 continue;
521 }
522#else
523 ((void)create_info);
524#endif
525
526 assert(type != GHOST_kXrGraphicsUnknown);
527 return type;
528 }
529
530 throw GHOST_XrException("Failed to determine a graphics binding to use.");
531}
532 /* OpenXR API-Layers and Extensions */
534
535/* -------------------------------------------------------------------- */
540
541void GHOST_XrContext::startSession(const GHOST_XrSessionBeginInfo *begin_info)
542{
543 custom_funcs_.session_create_fn = begin_info->create_fn;
544 custom_funcs_.session_exit_fn = begin_info->exit_fn;
545 custom_funcs_.session_exit_customdata = begin_info->exit_customdata;
546
547 if (session_ == nullptr) {
548 session_ = std::make_unique<GHOST_XrSession>(*this);
549 }
550 session_->start(begin_info);
551}
552
554{
555 if (session_) {
556 if (session_->isRunning()) {
557 session_->requestEnd();
558 }
559 else {
560 session_ = nullptr;
561 }
562 }
563}
564
566{
567 return session_ && session_->isRunning();
568}
569
570void GHOST_XrContext::drawSessionViews(void *draw_customdata)
571{
572 session_->draw(draw_customdata);
573}
574
578void GHOST_XrContext::handleSessionStateChange(const XrEventDataSessionStateChanged &lifecycle)
579{
580 if (session_ && session_->handleStateChangeEvent(lifecycle) == GHOST_XrSession::SESSION_DESTROY)
581 {
582 session_ = nullptr;
583 }
584}
585 /* Session Management */
587
588/* -------------------------------------------------------------------- */
593
595{
596 return session_.get();
597}
598
600{
601 return session_.get();
602}
603
604void GHOST_XrContext::setGraphicsContextBindFuncs(GHOST_XrGraphicsContextBindFn bind_fn,
605 GHOST_XrGraphicsContextUnbindFn unbind_fn)
606{
607 if (session_) {
608 session_->unbindGraphicsContext();
609 }
610 custom_funcs_.gpu_ctx_bind_fn = bind_fn;
611 custom_funcs_.gpu_ctx_unbind_fn = unbind_fn;
612}
613
614void GHOST_XrContext::setDrawViewFunc(GHOST_XrDrawViewFn draw_view_fn)
615{
616 custom_funcs_.draw_view_fn = draw_view_fn;
617}
618
620 GHOST_XrPassthroughEnabledFn passthrough_enabled_fn)
621{
622 custom_funcs_.passthrough_enabled_fn = passthrough_enabled_fn;
623}
624
626 GHOST_XrDisablePassthroughFn disable_passthrough_fn)
627{
628 custom_funcs_.disable_passthrough_fn = disable_passthrough_fn;
629}
630
632{
633 /* Must only be called after the session was started */
634 assert(session_);
635 return session_->needsUpsideDownDrawing();
636}
637 /* Public Accessors and Mutators */
639
640/* -------------------------------------------------------------------- */
643
645{
646 return runtime_id_;
647}
648
650{
651 return custom_funcs_;
652}
653
654GHOST_TXrGraphicsBinding GHOST_XrContext::getGraphicsBindingType() const
655{
656 return gpu_binding_type_;
657}
658
660{
661 return oxr_->instance;
662}
663
665{
666 return debug_;
667}
668
670{
671 return debug_time_;
672}
673
674bool GHOST_XrContext::isExtensionEnabled(const char *ext) const
675{
676 bool contains = std::find(enabled_extensions_.begin(), enabled_extensions_.end(), ext) !=
677 enabled_extensions_.end();
678 return contains;
679}
680 /* Ghost Internal Accessors and Mutators */
static const char * openxr_ext_name_from_wm_gpu_binding(GHOST_TXrGraphicsBinding binding)
static XrBool32 debug_messenger_func(XrDebugUtilsMessageSeverityFlagsEXT, XrDebugUtilsMessageTypeFlagsEXT, const XrDebugUtilsMessengerCallbackDataEXT *callbackData, void *)
static bool openxr_layer_is_available(const std::vector< XrApiLayerProperties > &layers_info, const std::string &layer_name)
static bool openxr_extension_is_available(const std::vector< XrExtensionProperties > &extensions_info, const std::string_view &extension_name)
GHOST_TXrOpenXRRuntimeID
@ OPENXR_RUNTIME_MONADO
@ OPENXR_RUNTIME_OCULUS
@ OPENXR_RUNTIME_STEAMVR
@ OPENXR_RUNTIME_WMR
@ OPENXR_RUNTIME_VARJO
#define CHECK_XR_ASSERT(call)
#define CHECK_XR(call, error_msg)
XrInstance getInstance() const
void setDisablePassthroughFunc(GHOST_XrDisablePassthroughFn disable_passthrough_fn) override
GHOST_TXrOpenXRRuntimeID getOpenXRRuntimeID() const
void setGraphicsContextBindFuncs(GHOST_XrGraphicsContextBindFn bind_fn, GHOST_XrGraphicsContextUnbindFn unbind_fn) override
GHOST_TXrGraphicsBinding getGraphicsBindingType() const
void drawSessionViews(void *draw_customdata) override
void handleSessionStateChange(const XrEventDataSessionStateChanged &lifecycle)
const GHOST_XrCustomFuncs & getCustomFuncs() const
void dispatchErrorMessage(const class GHOST_XrException *exception) const override
bool isDebugTimeMode() const
void setDrawViewFunc(GHOST_XrDrawViewFn draw_view_fn) override
bool needsUpsideDownDrawing() const override
bool isSessionRunning() const override
void startSession(const GHOST_XrSessionBeginInfo *begin_info) override
void endSession() override
bool isExtensionEnabled(const char *ext) const
GHOST_XrContext(const GHOST_XrContextCreateInfo *create_info)
bool isDebugMode() const
void initialize(const GHOST_XrContextCreateInfo *create_info)
static void setErrorHandler(GHOST_XrErrorHandlerFn handler_fn, void *customdata)
void setPassthroughEnabledFunc(GHOST_XrPassthroughEnabledFn passthrough_enabled_fn) override
GHOST_XrSession * getSession() override
#define assert(assertion)
#define printf(...)
static void error(const char *str)
XrDebugUtilsMessengerEXT debug_messenger
XrInstanceProperties instance_properties
std::vector< XrExtensionProperties > extensions
static PFN_xrDestroyDebugUtilsMessengerEXT s_xrDestroyDebugUtilsMessengerEXT_fn
std::vector< XrApiLayerProperties > layers
static PFN_xrCreateDebugUtilsMessengerEXT s_xrCreateDebugUtilsMessengerEXT_fn
i
Definition text_draw.cc:230