18 #define OXR_VERIFY_AND_SET_AND_INIT(log, thing, new_thing, oxr_thing, THING, name, lookup) \
20 oxr_log_init(log, name); \
21 if (thing == XR_NULL_HANDLE) { \
22 return oxr_error(log, XR_ERROR_HANDLE_INVALID, "(" #thing " == NULL)"); \
24 new_thing = (struct oxr_thing *)((uintptr_t)thing); \
25 if (new_thing->handle.debug != OXR_XR_DEBUG_##THING) { \
26 return oxr_error(log, XR_ERROR_HANDLE_INVALID, "(" #thing " == %p)", (void *)new_thing); \
28 if (new_thing->handle.state != OXR_HANDLE_STATE_LIVE) { \
29 return oxr_error(log, XR_ERROR_HANDLE_INVALID, "(" #thing " == %p) state == %s", \
30 (void *)new_thing, oxr_handle_state_to_string(new_thing->handle.state)); \
32 oxr_log_set_instance(log, lookup); \
35 #define OXR_VERIFY_SET(log, arg, new_arg, oxr_thing, THING) \
37 if (arg == XR_NULL_HANDLE) { \
38 return oxr_error(log, XR_ERROR_HANDLE_INVALID, "(" #arg " == NULL)"); \
40 new_arg = (struct oxr_thing *)((uintptr_t)arg); \
41 if (new_arg->handle.debug != OXR_XR_DEBUG_##THING) { \
42 return oxr_error(log, XR_ERROR_HANDLE_INVALID, "(" #arg " == %p)", (void *)new_arg); \
53 #define OXR_VERIFY_INSTANCE_AND_INIT_LOG(log, thing, new_thing, name) \
54 OXR_VERIFY_AND_SET_AND_INIT(log, thing, new_thing, oxr_instance, INSTANCE, name, new_thing)
55 #define OXR_VERIFY_MESSENGER_AND_INIT_LOG(log, thing, new_thing, name) \
56 OXR_VERIFY_AND_SET_AND_INIT(log, thing, new_thing, oxr_messenger, MESSENGER, name, new_thing->inst)
57 #define OXR_VERIFY_SESSION_AND_INIT_LOG(log, thing, new_thing, name) \
58 OXR_VERIFY_AND_SET_AND_INIT(log, thing, new_thing, oxr_session, SESSION, name, new_thing->sys->inst)
59 #define OXR_VERIFY_SPACE_AND_INIT_LOG(log, thing, new_thing, name) \
60 OXR_VERIFY_AND_SET_AND_INIT(log, thing, new_thing, oxr_space, SPACE, name, new_thing->sess->sys->inst)
61 #define OXR_VERIFY_ACTION_AND_INIT_LOG(log, thing, new_thing, name) \
62 OXR_VERIFY_AND_SET_AND_INIT(log, thing, new_thing, oxr_action, ACTION, name, new_thing->act_set->inst)
63 #define OXR_VERIFY_SWAPCHAIN_AND_INIT_LOG(log, thing, new_thing, name) \
64 OXR_VERIFY_AND_SET_AND_INIT(log, thing, new_thing, oxr_swapchain, SWAPCHAIN, name, new_thing->sess->sys->inst)
65 #define OXR_VERIFY_ACTIONSET_AND_INIT_LOG(log, thing, new_thing, name) \
66 OXR_VERIFY_AND_SET_AND_INIT(log, thing, new_thing, oxr_action_set, ACTIONSET, name, new_thing->inst)
67 #define OXR_VERIFY_HAND_TRACKER_AND_INIT_LOG(log, thing, new_thing, name) \
68 OXR_VERIFY_AND_SET_AND_INIT(log, thing, new_thing, oxr_hand_tracker, HTRACKER, name, new_thing->sess->sys->inst)
69 #define OXR_VERIFY_FORCE_FEEDBACK_AND_INIT_LOG(log, thing, new_thing, name) \
70 OXR_VERIFY_AND_SET_AND_INIT(log, thing, new_thing, oxr_force_feedback, FFB, name, new_thing->sess->sys->inst)
71 #define OXR_VERIFY_PASSTHROUGH_AND_INIT_LOG(log, thing, new_thing, name) \
72 OXR_VERIFY_AND_SET_AND_INIT(log, thing, new_thing, oxr_passthrough, PASSTHROUGH, name, new_thing->sess->sys->inst)
73 #define OXR_VERIFY_PASSTHROUGH_LAYER_AND_INIT_LOG(log, thing, new_thing, name) \
74 OXR_VERIFY_AND_SET_AND_INIT(log, thing, new_thing, oxr_passthrough_layer, PASSTHROUGH_LAYER, name, new_thing->sess->sys->inst)
75 #define OXR_VERIFY_FACE_TRACKER_HTC_AND_INIT_LOG(log, thing, new_thing, name) \
76 OXR_VERIFY_AND_SET_AND_INIT(log, thing, new_thing, oxr_facial_tracker_htc, FTRACKER, name, new_thing->sess->sys->inst)
79 #define OXR_VERIFY_INSTANCE_NOT_NULL(log, arg, new_arg) OXR_VERIFY_SET(log, arg, new_arg, oxr_instance, INSTANCE);
80 #define OXR_VERIFY_MESSENGER_NOT_NULL(log, arg, new_arg) OXR_VERIFY_SET(log, arg, new_arg, oxr_messenger, MESSENGER);
81 #define OXR_VERIFY_SESSION_NOT_NULL(log, arg, new_arg) OXR_VERIFY_SET(log, arg, new_arg, oxr_session, SESSION);
82 #define OXR_VERIFY_SPACE_NOT_NULL(log, arg, new_arg) OXR_VERIFY_SET(log, arg, new_arg, oxr_space, SPACE);
83 #define OXR_VERIFY_ACTION_NOT_NULL(log, arg, new_arg) OXR_VERIFY_SET(log, arg, new_arg, oxr_action, ACTION);
84 #define OXR_VERIFY_SWAPCHAIN_NOT_NULL(log, arg, new_arg) OXR_VERIFY_SET(log, arg, new_arg, oxr_swapchain, SWAPCHAIN);
85 #define OXR_VERIFY_ACTIONSET_NOT_NULL(log, arg, new_arg) OXR_VERIFY_SET(log, arg, new_arg, oxr_action_set, ACTIONSET);
92 #define OXR_VERIFY_EXTENSION(log, inst, mixed_case_name) \
94 if (!(inst)->extensions.mixed_case_name) { \
95 return oxr_error((log), XR_ERROR_FUNCTION_UNSUPPORTED, \
96 "Requires XR_" #mixed_case_name " extension enabled"); \
105 #define OXR_VERIFY_EXTENSIONS_OR(log, inst, mixed_case_name1, mixed_case_name2) \
107 if (!(inst)->extensions.mixed_case_name1 && !(inst)->extensions.mixed_case_name2) { \
108 return oxr_error((log), XR_ERROR_FUNCTION_UNSUPPORTED, \
109 "Requires XR_" #mixed_case_name1 "or XR_" #mixed_case_name2 \
110 " extension enabled"); \
114 #define OXR_VERIFY_ARG_NOT_NULL(log, arg) \
117 return oxr_error(log, XR_ERROR_VALIDATION_FAILURE, "(" #arg " == NULL)"); \
121 #define OXR_VERIFY_ARG_NOT_ZERO(log, arg) \
124 return oxr_error(log, XR_ERROR_VALIDATION_FAILURE, "(" #arg " == 0) must be non-zero"); \
128 #define OXR_VERIFY_ARG_ZERO(log, arg) \
131 return oxr_error(log, XR_ERROR_VALIDATION_FAILURE, "(" #arg " == 0) must be zero"); \
135 #define OXR_VERIFY_ARG_TYPE_CAN_BE_NULL(log, arg, type_enum) \
137 if (arg != NULL && arg->type != type_enum) { \
138 return oxr_error(log, XR_ERROR_VALIDATION_FAILURE, "(" #arg "->type == %u)", arg->type); \
142 #define OXR_VERIFY_ARG_TYPE_AND_NOT_NULL(log, arg, type_enum) \
145 return oxr_error(log, XR_ERROR_VALIDATION_FAILURE, "(" #arg " == NULL)"); \
147 OXR_VERIFY_ARG_TYPE_CAN_BE_NULL(log, arg, type_enum); \
154 #define OXR_VERIFY_ARG_ARRAY_ELEMENT_TYPE(log, array, index, type_enum) \
156 if ((array)[index].type != type_enum) { \
157 return oxr_error(log, XR_ERROR_VALIDATION_FAILURE, \
158 "(" #array "[%u]->type == 0x%08x) expected 0x%08x", index, \
159 (array)[index].type, type_enum); \
163 #define OXR_VERIFY_SUBACTION_PATHS(log, count, paths) \
165 if (count > 0 && paths == NULL) { \
166 return oxr_error(log, XR_ERROR_VALIDATION_FAILURE, \
167 "(" #count ") is not zero but " #paths " is NULL"); \
171 #define OXR_VERIFY_ARG_SINGLE_LEVEL_FIXED_LENGTH_PATH(log, path) \
173 XrResult verify_ret = oxr_verify_fixed_size_single_level_path(log, path, ARRAY_SIZE(path), #path); \
174 if (verify_ret != XR_SUCCESS) { \
179 #define OXR_VERIFY_ARG_LOCALIZED_NAME(log, string) \
181 XrResult verify_ret = oxr_verify_localized_name(log, string, ARRAY_SIZE(string), #string); \
182 if (verify_ret != XR_SUCCESS) { \
187 #define OXR_VERIFY_POSE(log, p) \
189 if (!math_quat_validate((struct xrt_quat *)&p.orientation)) { \
190 return oxr_error(log, XR_ERROR_POSE_INVALID, "(" #p ".orientation) is not a valid quat"); \
193 if (!math_vec3_validate((struct xrt_vec3 *)&p.position)) { \
194 return oxr_error(log, XR_ERROR_POSE_INVALID, "(" #p ".position) is not valid"); \
198 #define OXR_VERIFY_VIEW_CONFIG_TYPE(log, inst, view_conf) \
200 XrResult verify_ret = oxr_verify_view_config_type(log, inst, view_conf, #view_conf); \
201 if (verify_ret != XR_SUCCESS) { \
206 #define OXR_VERIFY_VIEW_INDEX(log, index) \
209 return oxr_error(log, XR_ERROR_VALIDATION_FAILURE, \
210 "Invalid view index %d, only 2 views supported", index); \
214 #define OXR_VERIFY_SWAPCHAIN_USAGE_FLAGS_NOT_MUTUALLY_EXCLUSIVE(log, flags, mutually_exclusive_a, \
215 mutually_exclusive_b) \
217 if (((flags) & (mutually_exclusive_a)) != 0 && ((flags) & (mutually_exclusive_b)) != 0) { \
218 return oxr_error(log, XR_ERROR_VALIDATION_FAILURE, \
219 "(" #flags ") Swapchain usage flags " #mutually_exclusive_a \
220 " and " #mutually_exclusive_b \
221 " are mutually exclusive in this graphics API"); \
225 #define OXR_VERIFY_SESSION_NOT_LOST(log, sess) \
227 if (sess->has_lost) { \
228 return oxr_error(log, XR_ERROR_SESSION_LOST, "Session is lost"); \
232 #define OXR_VERIFY_SESSION_RUNNING(log, sess) \
234 if (!sess->has_begun) { \
235 return oxr_error(log, XR_ERROR_SESSION_NOT_RUNNING, "Session is not running"); \
239 #define OXR_VERIFY_PASSTHROUGH_FLAGS(log, flags) \
241 (flags & (XR_PASSTHROUGH_IS_RUNNING_AT_CREATION_BIT_FB | XR_PASSTHROUGH_LAYER_DEPTH_BIT_FB)) == 0) \
242 return oxr_error(log, XR_ERROR_VALIDATION_FAILURE, \
243 "flags is not a valid combination of XrPassthroughFlagBitsFB values");
245 #define OXR_VERIFY_PASSTHROUGH_LAYER_PURPOSE(log, purpose) \
246 if ((purpose != XR_PASSTHROUGH_LAYER_PURPOSE_RECONSTRUCTION_FB && \
247 purpose != XR_PASSTHROUGH_LAYER_PURPOSE_PROJECTED_FB && \
248 purpose != XR_PASSTHROUGH_LAYER_PURPOSE_TRACKED_KEYBOARD_HANDS_FB && \
249 purpose != XR_PASSTHROUGH_LAYER_PURPOSE_TRACKED_KEYBOARD_MASKED_HANDS_FB)) \
250 return oxr_error(log, XR_ERROR_VALIDATION_FAILURE, \
251 "purpose is not a valid XrPassthroughLayerPurposeFB value");
253 #define OXR_VERIFY_PASSTHROUGH_LAYER_STYLE(log, style) \
255 uint32_t duplicate_check = 0; \
256 const XrPassthroughStyleFB *next = style->next; \
258 if (next->type != XR_TYPE_PASSTHROUGH_COLOR_MAP_MONO_TO_RGBA_FB && \
259 next->type != XR_TYPE_PASSTHROUGH_COLOR_MAP_MONO_TO_MONO_FB && \
260 next->type != XR_TYPE_PASSTHROUGH_BRIGHTNESS_CONTRAST_SATURATION_FB) \
261 return oxr_error(log, XR_ERROR_VALIDATION_FAILURE, \
262 "style next structure chain contains invalid pointers"); \
263 if ((next->type & duplicate_check) != 0) \
264 return oxr_error(log, XR_ERROR_VALIDATION_FAILURE, \
265 "style next structure chain contains duplicate items"); \
266 duplicate_check |= next->type; \
267 next = (const XrPassthroughStyleFB *)next->next; \
278 oxr_verify_full_path_c(
struct oxr_logger *log,
const char *path,
const char *name);
309 uint32_t countSubactionPaths,
310 const XrPath *subactionPaths,
311 const char *variable);
332 const char *variable);
338 oxr_verify_view_config_type(
struct oxr_logger *log,
340 XrViewConfigurationType view_conf,
341 const char *view_conf_name);
344 oxr_verify_XrSessionCreateInfo(
struct oxr_logger * ,
346 const XrSessionCreateInfo * );
348 #if defined(XR_USE_PLATFORM_XLIB) && defined(XR_USE_GRAPHICS_API_OPENGL)
350 oxr_verify_XrGraphicsBindingOpenGLXlibKHR(
struct oxr_logger * ,
const XrGraphicsBindingOpenGLXlibKHR * );
353 #if defined(XR_USE_PLATFORM_WIN32) && defined(XR_USE_GRAPHICS_API_OPENGL)
355 oxr_verify_XrGraphicsBindingOpenGLWin32KHR(
struct oxr_logger * ,
356 const XrGraphicsBindingOpenGLWin32KHR * );
359 #if defined(XR_USE_GRAPHICS_API_VULKAN)
361 oxr_verify_XrGraphicsBindingVulkanKHR(
struct oxr_logger * ,
const XrGraphicsBindingVulkanKHR * );
364 #if defined(XR_USE_PLATFORM_EGL) && defined(XR_USE_GRAPHICS_API_OPENGL)
366 oxr_verify_XrGraphicsBindingEGLMNDX(
struct oxr_logger *log,
const XrGraphicsBindingEGLMNDX *next);
369 #if defined(XR_USE_PLATFORM_ANDROID) && defined(XR_USE_GRAPHICS_API_OPENGL_ES)
371 oxr_verify_XrGraphicsBindingOpenGLESAndroidKHR(
struct oxr_logger *,
const XrGraphicsBindingOpenGLESAndroidKHR *);
375 #if defined(XR_USE_GRAPHICS_API_D3D11)
377 oxr_verify_XrGraphicsBindingD3D11KHR(
struct oxr_logger *,
const XrGraphicsBindingD3D11KHR *);
380 #if defined(XR_USE_GRAPHICS_API_D3D12)
382 oxr_verify_XrGraphicsBindingD3D12KHR(
struct oxr_logger *,
const XrGraphicsBindingD3D12KHR *);
385 #ifdef XR_EXT_dpad_binding
387 oxr_verify_XrInteractionProfileDpadBindingEXT(
struct oxr_logger *,
388 const XrInteractionProfileDpadBindingEXT *,
389 const char *error_prefix);
XrResult oxr_verify_subaction_paths_create(struct oxr_logger *log, struct oxr_instance *inst, uint32_t countSubactionPaths, const XrPath *subactionPaths, const char *variable)
Verify a set of subaction paths for action creation.
XrResult oxr_verify_subaction_path_sync(struct oxr_logger *log, const struct oxr_instance *inst, const struct oxr_action_set *act_set, XrPath path, uint32_t index)
Verify a set of subaction paths for action sync.
XrResult oxr_verify_fixed_size_single_level_path(struct oxr_logger *, const char *path, uint32_t array_size, const char *name)
Verify a single path level that sits inside of a fixed sized array.
Definition: oxr_verify.c:64
XrResult oxr_verify_subaction_path_get(struct oxr_logger *log, struct oxr_instance *inst, XrPath path, const struct oxr_subaction_paths *act_subaction_paths, struct oxr_subaction_paths *out_subaction_paths, const char *variable)
Verify a set of subaction paths for action state get.
XrResult oxr_verify_full_path(struct oxr_logger *log, const char *path, size_t length, const char *name)
Verify a full path.
Definition: oxr_verify.c:139
XrResult oxr_verify_localized_name(struct oxr_logger *, const char *string, uint32_t array_size, const char *name)
Verify an arbitrary UTF-8 string that sits inside of a fixed sized array.
Definition: oxr_verify.c:95
A group of actions.
Definition: oxr_objects.h:2352
Structure tracking which extensions are enabled for a given instance.
Definition: oxr_objects.h:1491
Main object that ties everything together.
Definition: oxr_objects.h:1504
Logger struct that lives on the stack, one for each call client call.
Definition: oxr_logger.h:40
A parsed equivalent of a list of sub-action paths.
Definition: oxr_objects.h:1935