The open source OpenXR runtime
0
fork

Configure Feed

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

st/oxr: Validate XrReferenceSpaceType in common code

Also deal with the different types of error code returns that the CTS expects.

+77 -55
+39 -11
src/xrt/state_trackers/oxr/oxr_api_space.c
··· 16 16 17 17 #include "oxr_objects.h" 18 18 #include "oxr_logger.h" 19 + #include "oxr_conversions.h" 19 20 #include "oxr_two_call.h" 20 21 21 22 #include "oxr_api_funcs.h" ··· 34 35 */ 35 36 36 37 static XrResult 38 + is_reference_space_type_valid(struct oxr_logger *log, 39 + struct oxr_system *sys, 40 + const char *field_name, 41 + XrReferenceSpaceType referenceSpaceType) 42 + { 43 + switch (referenceSpaceType) { 44 + case XR_REFERENCE_SPACE_TYPE_VIEW: 45 + case XR_REFERENCE_SPACE_TYPE_LOCAL: 46 + case XR_REFERENCE_SPACE_TYPE_STAGE: return XR_SUCCESS; 47 + default: break; 48 + } 49 + 50 + return oxr_error(log, XR_ERROR_VALIDATION_FAILURE, "(%s == 0x%08x) is not a valid XrReferenceSpaceType", 51 + field_name, referenceSpaceType); 52 + } 53 + 54 + static XrResult 37 55 is_reference_space_type_supported(struct oxr_logger *log, 38 56 struct oxr_system *sys, 39 57 const char *field_name, ··· 45 63 } 46 64 } 47 65 66 + /* 67 + * This function assumes that the referenceSpaceType has 68 + * been validated with is_reference_space_type_valid first. 69 + */ 48 70 return oxr_error(log, XR_ERROR_REFERENCE_SPACE_UNSUPPORTED, 49 - "(%s == 0x%08x) is not a supported XrReferenceSpaceType", field_name, referenceSpaceType); 71 + "(%s == %s) is not a supported XrReferenceSpaceType", field_name, 72 + xr_ref_space_to_string(referenceSpaceType)); 50 73 } 51 74 52 75 ··· 114 137 OXR_VERIFY_SESSION_AND_INIT_LOG(&log, session, sess, "xrGetReferenceSpaceBoundsRect"); 115 138 OXR_VERIFY_ARG_NOT_NULL(&log, bounds); 116 139 117 - 118 - switch (referenceSpaceType) { 119 - case XR_REFERENCE_SPACE_TYPE_VIEW: 120 - case XR_REFERENCE_SPACE_TYPE_LOCAL: 121 - case XR_REFERENCE_SPACE_TYPE_STAGE: break; 122 - default: 123 - return oxr_error(&log, XR_ERROR_VALIDATION_FAILURE, 124 - "(referenceSpaceType == 0x%08x) is not a " 125 - "valid XrReferenceSpaceType", 126 - referenceSpaceType); 140 + ret = is_reference_space_type_valid(&log, sess->sys, "referenceSpaceType", referenceSpaceType); 141 + if (ret != XR_SUCCESS) { 142 + return ret; 127 143 } 128 144 129 145 ret = is_reference_space_type_supported(&log, sess->sys, "referenceSpaceType", referenceSpaceType); ··· 151 167 OXR_VERIFY_SESSION_NOT_LOST(&log, sess); 152 168 OXR_VERIFY_ARG_TYPE_AND_NOT_NULL(&log, createInfo, XR_TYPE_REFERENCE_SPACE_CREATE_INFO); 153 169 OXR_VERIFY_POSE(&log, createInfo->poseInReferenceSpace); 170 + 171 + ret = is_reference_space_type_valid(&log, sess->sys, "createInfo->referenceSpaceType", 172 + createInfo->referenceSpaceType); 173 + if (ret != XR_SUCCESS) { 174 + // The CTS currently requiers us to return XR_ERROR_REFERENCE_SPACE_UNSUPPORTED. 175 + if (sess->sys->inst->quirks.no_validation_error_in_create_ref_space && 176 + ret == XR_ERROR_VALIDATION_FAILURE) { 177 + return XR_ERROR_REFERENCE_SPACE_UNSUPPORTED; 178 + } else { 179 + return ret; 180 + } 181 + } 154 182 155 183 ret = is_reference_space_type_supported(&log, sess->sys, "createInfo->referenceSpaceType", 156 184 createInfo->referenceSpaceType);
+15
src/xrt/state_trackers/oxr/oxr_conversions.h
··· 84 84 // wrap around or negative depending on enum data type, invalid value either way. 85 85 return (enum oxr_space_type) - 1; 86 86 } 87 + 88 + static inline const char * 89 + xr_ref_space_to_string(XrReferenceSpaceType space_type) 90 + { 91 + switch (space_type) { 92 + case XR_REFERENCE_SPACE_TYPE_VIEW: return "XR_REFERENCE_SPACE_TYPE_VIEW"; 93 + case XR_REFERENCE_SPACE_TYPE_LOCAL: return "XR_REFERENCE_SPACE_TYPE_LOCAL"; 94 + case XR_REFERENCE_SPACE_TYPE_LOCAL_FLOOR_EXT: return "XR_REFERENCE_SPACE_TYPE_LOCAL_FLOOR_EXT"; 95 + case XR_REFERENCE_SPACE_TYPE_STAGE: return "XR_REFERENCE_SPACE_TYPE_STAGE"; 96 + case XR_REFERENCE_SPACE_TYPE_UNBOUNDED_MSFT: return "XR_REFERENCE_SPACE_TYPE_UNBOUNDED_MSFT"; 97 + case XR_REFERENCE_SPACE_TYPE_COMBINED_EYE_VARJO: return "XR_REFERENCE_SPACE_TYPE_COMBINED_EYE_VARJO"; 98 + case XR_REFERENCE_SPACE_TYPE_MAX_ENUM: return "XR_REFERENCE_SPACE_TYPE_MAX_ENUM"; 99 + default: return "UNKNOWN REFERENCE SPACE"; 100 + } 101 + }
+17 -10
src/xrt/state_trackers/oxr/oxr_instance.c
··· 169 169 static void 170 170 apply_quirks(struct oxr_logger *log, struct oxr_instance *inst) 171 171 { 172 + // Reset. 172 173 inst->quirks.skip_end_session = false; 173 174 inst->quirks.disable_vulkan_format_depth_stencil = false; 175 + inst->quirks.no_validation_error_in_create_ref_space = false; 174 176 175 177 if (starts_with("UnrealEngine", inst->appinfo.detected.engine.name) && // 176 178 inst->appinfo.detected.engine.major == 4 && // 177 179 inst->appinfo.detected.engine.minor <= 27) { 178 180 inst->quirks.skip_end_session = true; 179 181 } 182 + 183 + // Currently always true. 184 + inst->quirks.no_validation_error_in_create_ref_space = true; 180 185 } 181 186 182 187 XrResult ··· 365 370 "\tcreateInfo->applicationInfo.engineVersion: %i\n" 366 371 "\tappinfo.detected.engine.name: %s\n" 367 372 "\tappinfo.detected.engine.version: %i.%i.%i\n" 368 - "\tquirks.disable_vulkan_format_depth_stencil: %s", 369 - createInfo->applicationInfo.applicationName, // 370 - createInfo->applicationInfo.applicationVersion, // 371 - createInfo->applicationInfo.engineName, // 372 - createInfo->applicationInfo.engineVersion, // 373 - inst->appinfo.detected.engine.name, // 374 - inst->appinfo.detected.engine.major, // 375 - inst->appinfo.detected.engine.minor, // 376 - inst->appinfo.detected.engine.patch, // 377 - inst->quirks.disable_vulkan_format_depth_stencil ? "true" : "false"); // 373 + "\tquirks.disable_vulkan_format_depth_stencil: %s" 374 + "\tquirks.no_validation_error_in_create_ref_space: %s", 375 + createInfo->applicationInfo.applicationName, // 376 + createInfo->applicationInfo.applicationVersion, // 377 + createInfo->applicationInfo.engineName, // 378 + createInfo->applicationInfo.engineVersion, // 379 + inst->appinfo.detected.engine.name, // 380 + inst->appinfo.detected.engine.major, // 381 + inst->appinfo.detected.engine.minor, // 382 + inst->appinfo.detected.engine.patch, // 383 + inst->quirks.disable_vulkan_format_depth_stencil ? "true" : "false", // 384 + inst->quirks.no_validation_error_in_create_ref_space ? "true" : "false"); // 378 385 379 386 debug_print_devices(log, sys); 380 387
+6
src/xrt/state_trackers/oxr/oxr_objects.h
··· 1459 1459 bool disable_vulkan_format_depth_stencil; 1460 1460 //! Unreal 4 has a bug calling xrEndSession; the function should just exit 1461 1461 bool skip_end_session; 1462 + 1463 + /*! 1464 + * Return XR_ERROR_REFERENCE_SPACE_UNSUPPORTED instead of 1465 + * XR_ERROR_VALIDATION_FAILURE in xrCreateReferenceSpace. 1466 + */ 1467 + bool no_validation_error_in_create_ref_space; 1462 1468 } quirks; 1463 1469 1464 1470 //! Debug messengers
-34
src/xrt/state_trackers/oxr/oxr_space.c
··· 31 31 32 32 /* 33 33 * 34 - * Helper functions. 35 - * 36 - */ 37 - 38 - static XrResult 39 - check_reference_space_type(struct oxr_logger *log, XrReferenceSpaceType type) 40 - { 41 - switch (type) { 42 - case XR_REFERENCE_SPACE_TYPE_VIEW: return XR_SUCCESS; 43 - case XR_REFERENCE_SPACE_TYPE_LOCAL: return XR_SUCCESS; 44 - case XR_REFERENCE_SPACE_TYPE_STAGE: 45 - // For now stage space is always supported. 46 - if (true) { 47 - return XR_SUCCESS; 48 - } 49 - return oxr_error(log, XR_ERROR_REFERENCE_SPACE_UNSUPPORTED, 50 - "(createInfo->referenceSpaceType == XR_REFERENCE_SPACE_TYPE_STAGE)" 51 - " Stage space is unsupported on this device."); 52 - default: 53 - return oxr_error(log, XR_ERROR_REFERENCE_SPACE_UNSUPPORTED, 54 - "(createInfo->referenceSpaceType == 0x%08x)", type); 55 - } 56 - } 57 - 58 - 59 - /* 60 - * 61 34 * To xrt_space functions. 62 35 * 63 36 */ ··· 187 160 const XrReferenceSpaceCreateInfo *createInfo, 188 161 struct oxr_space **out_space) 189 162 { 190 - XrResult ret; 191 - 192 - ret = check_reference_space_type(log, createInfo->referenceSpaceType); 193 - if (ret != XR_SUCCESS) { 194 - return ret; 195 - } 196 - 197 163 if (!math_pose_validate((struct xrt_pose *)&createInfo->poseInReferenceSpace)) { 198 164 return oxr_error(log, XR_ERROR_POSE_INVALID, "(createInfo->poseInReferenceSpace)"); 199 165 }