The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

st/oxr: Support getting xrGetOpenGLGraphicsRequirementsKHR if only EGL enable is used

Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2534>

+58 -9
+58 -9
src/xrt/state_trackers/oxr/oxr_api_negotiate.c
··· 1 1 // Copyright 2018-2024, Collabora, Ltd. 2 + // Copyright 2025, NVIDIA CORPORATION. 2 3 // SPDX-License-Identifier: BSL-1.0 3 4 /*! 4 5 * @file ··· 101 102 return XR_SUCCESS; 102 103 } 103 104 105 + 106 + /*! 107 + * @brief Helper define for generating that GetInstanceProcAddr function. 108 + * 109 + * Return the function if the extra condition is true. 110 + */ 111 + #define RETURN_IF_TRUE(funcName, extraCondition) \ 112 + do { \ 113 + if (extraCondition) { \ 114 + PFN_##funcName ret = &oxr_##funcName; \ 115 + *out_function = (PFN_xrVoidFunction)(ret); \ 116 + return XR_SUCCESS; \ 117 + } \ 118 + } while (false) 119 + 120 + /*! 121 + * @brief Helper define for generating that GetInstanceProcAddr function. 122 + * 123 + * Return the function if the extension is enabled. 124 + */ 125 + #define RETURN_IF_EXT(funcName, short_ext_name) RETURN_IF_TRUE(funcName, inst->extensions.short_ext_name) 126 + 104 127 /*! 105 128 * @brief Helper define for generating that GetInstanceProcAddr function. 106 129 * ··· 124 147 #define ENTRY_IF(funcName, extraCondition, message) \ 125 148 do { \ 126 149 if (strcmp(name, #funcName) == 0) { \ 127 - if (extraCondition) { \ 128 - PFN_##funcName ret = &oxr_##funcName; \ 129 - *out_function = (PFN_xrVoidFunction)(ret); \ 130 - return XR_SUCCESS; \ 131 - } \ 150 + RETURN_IF_TRUE(funcName, extraCondition); \ 132 151 return XR_ERROR_FUNCTION_UNSUPPORTED; \ 133 152 } \ 134 153 } while (false) ··· 298 317 ENTRY_IF_EXT(xrSessionInsertDebugUtilsLabelEXT, EXT_debug_utils); 299 318 #endif // OXR_HAVE_EXT_debug_utils 300 319 320 + if (strcmp(name, "xrGetOpenGLGraphicsRequirementsKHR") == 0) { 321 + bool enabled_extension = false; 301 322 #ifdef OXR_HAVE_KHR_opengl_enable 302 - ENTRY_IF_EXT(xrGetOpenGLGraphicsRequirementsKHR, KHR_opengl_enable); 303 - #endif // OXR_HAVE_KHR_opengl_enable 323 + enabled_extension |= inst->extensions.KHR_opengl_enable; 324 + #endif 325 + #ifdef OXR_HAVE_MNDX_egl_enable 326 + enabled_extension |= inst->extensions.MNDX_egl_enable; 327 + #endif 328 + 329 + #ifdef XR_USE_GRAPHICS_API_OPENGL 330 + RETURN_IF_TRUE(xrGetOpenGLGraphicsRequirementsKHR, enabled_extension); 331 + #else 332 + if (enabled_extension) { 333 + oxr_warn(log, "Asked for xrGetOpenGLGraphicsRequirementsKHR but not compiled in."); 334 + } 335 + #endif 336 + return XR_ERROR_FUNCTION_UNSUPPORTED; 337 + } 304 338 339 + if (strcmp(name, "xrGetOpenGLESGraphicsRequirementsKHR") == 0) { 340 + bool enabled_extension = false; 305 341 #ifdef OXR_HAVE_KHR_opengl_es_enable 306 - ENTRY_IF_EXT(xrGetOpenGLESGraphicsRequirementsKHR, KHR_opengl_es_enable); 307 - #endif // OXR_HAVE_KHR_opengl_es_enable 342 + enabled_extension |= inst->extensions.KHR_opengl_es_enable; 343 + #endif 344 + #ifdef OXR_HAVE_MNDX_egl_enable 345 + enabled_extension |= inst->extensions.MNDX_egl_enable; 346 + #endif 347 + 348 + #ifdef XR_USE_GRAPHICS_API_OPENGL_ES 349 + RETURN_IF_TRUE(xrGetOpenGLESGraphicsRequirementsKHR, enabled_extension); 350 + #else 351 + if (enabled_extension) { 352 + oxr_warn(log, "Asked for xrGetOpenGLESGraphicsRequirementsKHR but not compiled in."); 353 + } 354 + #endif 355 + return XR_ERROR_FUNCTION_UNSUPPORTED; 356 + } 308 357 309 358 #ifdef OXR_HAVE_KHR_visibility_mask 310 359 ENTRY_IF_EXT(xrGetVisibilityMaskKHR, KHR_visibility_mask);