The open source OpenXR runtime
0
fork

Configure Feed

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

st/oxr: Refactor verification of supported view configuration

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

+38 -31
+4 -12
src/xrt/state_trackers/oxr/oxr_api_session.c
··· 1 1 // Copyright 2019-2024, Collabora, Ltd. 2 + // Copyright 2025, NVIDIA CORPORATION. 2 3 // SPDX-License-Identifier: BSL-1.0 3 4 /*! 4 5 * @file ··· 99 100 // in a headless session there is no compositor and primaryViewConfigurationType must be ignored 100 101 if (sess->compositor != NULL) { 101 102 OXR_VERIFY_VIEW_CONFIG_TYPE(&log, sess->sys->inst, beginInfo->primaryViewConfigurationType); 103 + OXR_VERIFY_VIEW_CONFIG_TYPE_SUPPORTED(&log, sess->sys, beginInfo->primaryViewConfigurationType); 102 104 } 103 105 104 106 // Going to effectively double check this, but this gives us an early out. ··· 239 241 OXR_VERIFY_SPACE_NOT_NULL(&log, viewLocateInfo->space, spc); 240 242 OXR_VERIFY_ARG_TYPE_AND_NOT_NULL(&log, viewState, XR_TYPE_VIEW_STATE); 241 243 OXR_VERIFY_VIEW_CONFIG_TYPE(&log, sess->sys->inst, viewLocateInfo->viewConfigurationType); 244 + OXR_VERIFY_VIEW_CONFIG_TYPE_SUPPORTED(&log, sess->sys, viewLocateInfo->viewConfigurationType); 242 245 243 246 if (viewCapacityInput == 0) { 244 247 OXR_VERIFY_ARG_NOT_NULL(&log, viewCountOutput); ··· 255 258 viewLocateInfo->displayTime); 256 259 } 257 260 258 - if (viewLocateInfo->viewConfigurationType != sess->sys->view_config_type) { 259 - return oxr_error(&log, XR_ERROR_VIEW_CONFIGURATION_TYPE_UNSUPPORTED, 260 - "(viewConfigurationType == 0x%08x) " 261 - "unsupported view configuration type", 262 - viewLocateInfo->viewConfigurationType); 263 - } 264 - 265 261 return oxr_session_locate_views( // 266 262 &log, // 267 263 sess, // ··· 300 296 visibilityMask->indexCountOutput = 0; 301 297 302 298 OXR_VERIFY_VIEW_CONFIG_TYPE(&log, sess->sys->inst, viewConfigurationType); 303 - if (viewConfigurationType != sess->sys->view_config_type) { 304 - return oxr_error(&log, XR_ERROR_VIEW_CONFIGURATION_TYPE_UNSUPPORTED, 305 - "(viewConfigurationType == 0x%08x) unsupported view configuration type", 306 - viewConfigurationType); 307 - } 299 + OXR_VERIFY_VIEW_CONFIG_TYPE_SUPPORTED(&log, sess->sys, viewConfigurationType); 308 300 309 301 OXR_VERIFY_VIEW_INDEX(&log, viewIndex); 310 302
+4 -7
src/xrt/state_trackers/oxr/oxr_api_system.c
··· 134 134 OXR_VERIFY_INSTANCE_AND_INIT_LOG(&log, instance, inst, "xrEnumerateEnvironmentBlendModes"); 135 135 OXR_VERIFY_SYSTEM_AND_GET(&log, inst, systemId, sys); 136 136 OXR_VERIFY_VIEW_CONFIG_TYPE(&log, inst, viewConfigurationType); 137 - 138 - if (viewConfigurationType != sys->view_config_type) { 139 - return oxr_error(&log, XR_ERROR_VIEW_CONFIGURATION_TYPE_UNSUPPORTED, 140 - "(viewConfigurationType == 0x%08x) " 141 - "unsupported view configuration type", 142 - viewConfigurationType); 143 - } 137 + OXR_VERIFY_VIEW_CONFIG_TYPE_SUPPORTED(&log, sys, viewConfigurationType); 144 138 145 139 return oxr_system_enumerate_blend_modes(&log, sys, viewConfigurationType, environmentBlendModeCapacityInput, 146 140 environmentBlendModeCountOutput, environmentBlendModes); ··· 160 154 OXR_VERIFY_ARG_TYPE_AND_NOT_NULL(&log, configurationProperties, XR_TYPE_VIEW_CONFIGURATION_PROPERTIES); 161 155 OXR_VERIFY_SYSTEM_AND_GET(&log, inst, systemId, sys); 162 156 OXR_VERIFY_VIEW_CONFIG_TYPE(&log, inst, viewConfigurationType); 157 + OXR_VERIFY_VIEW_CONFIG_TYPE_SUPPORTED(&log, sys, viewConfigurationType); 163 158 164 159 return oxr_system_get_view_conf_properties(&log, sys, viewConfigurationType, configurationProperties); 165 160 } ··· 178 173 struct oxr_logger log; 179 174 OXR_VERIFY_INSTANCE_AND_INIT_LOG(&log, instance, inst, "xrEnumerateViewConfigurationViews"); 180 175 OXR_VERIFY_SYSTEM_AND_GET(&log, inst, systemId, sys); 176 + OXR_VERIFY_VIEW_CONFIG_TYPE(&log, inst, viewConfigurationType); 177 + OXR_VERIFY_VIEW_CONFIG_TYPE_SUPPORTED(&log, sys, viewConfigurationType); 181 178 182 179 for (uint32_t i = 0; i < viewCapacityInput; i++) { 183 180 OXR_VERIFY_ARG_ARRAY_ELEMENT_TYPE(&log, views, i, XR_TYPE_VIEW_CONFIGURATION_VIEW);
+15
src/xrt/state_trackers/oxr/oxr_api_verify.h
··· 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 ··· 273 274 } \ 274 275 } while (false) 275 276 277 + #define OXR_VERIFY_VIEW_CONFIG_TYPE_SUPPORTED(log, sys, view_conf) \ 278 + do { \ 279 + XrResult verify_ret = oxr_verify_view_config_type_supported(log, sys, view_conf, #view_conf); \ 280 + if (verify_ret != XR_SUCCESS) { \ 281 + return verify_ret; \ 282 + } \ 283 + } while (false) 284 + 276 285 #define OXR_VERIFY_VIEW_INDEX(log, index) \ 277 286 do { \ 278 287 if (index > 2) { \ ··· 435 444 struct oxr_instance *inst, 436 445 XrViewConfigurationType view_conf, 437 446 const char *view_conf_name); 447 + 448 + XrResult 449 + oxr_verify_view_config_type_supported(struct oxr_logger *log, 450 + struct oxr_system *sys, 451 + XrViewConfigurationType view_conf, 452 + const char *view_conf_name); 438 453 439 454 XrResult 440 455 oxr_verify_XrSessionCreateInfo(struct oxr_logger * /*log*/,
-12
src/xrt/state_trackers/oxr/oxr_session.c
··· 283 283 284 284 struct xrt_compositor *xc = sess->compositor; 285 285 if (xc != NULL) { 286 - XrViewConfigurationType view_type = beginInfo->primaryViewConfigurationType; 287 - 288 - // in a headless session there is no compositor and primaryViewConfigurationType must be ignored 289 - if (sess->compositor != NULL && view_type != sess->sys->view_config_type) { 290 - /*! @todo we only support a single view config type per 291 - * system right now */ 292 - return oxr_error(log, XR_ERROR_VIEW_CONFIGURATION_TYPE_UNSUPPORTED, 293 - "(beginInfo->primaryViewConfigurationType == " 294 - "0x%08x) view configuration type not supported", 295 - view_type); 296 - } 297 - 298 286 const struct oxr_extension_status *extensions = &sess->sys->inst->extensions; 299 287 300 288 const struct xrt_begin_session_info begin_session_info = {
+15
src/xrt/state_trackers/oxr/oxr_verify.c
··· 459 459 } 460 460 461 461 XrResult 462 + oxr_verify_view_config_type_supported(struct oxr_logger *log, 463 + struct oxr_system *sys, 464 + XrViewConfigurationType view_conf, 465 + const char *view_conf_name) 466 + { 467 + if (sys->view_config_type == view_conf) { 468 + return XR_SUCCESS; 469 + } 470 + 471 + return oxr_error(log, XR_ERROR_VIEW_CONFIGURATION_TYPE_UNSUPPORTED, 472 + "(%s == 0x%08x) unsupported view configuration type by system %zu", view_conf_name, view_conf, 473 + sys->systemId); 474 + } 475 + 476 + XrResult 462 477 oxr_verify_XrSessionCreateInfo(struct oxr_logger *log, 463 478 const struct oxr_instance *inst, 464 479 const XrSessionCreateInfo *createInfo)