28#define OXR_VERIFY_AND_SET_AND_INIT(log, thing, new_thing, oxr_thing, THING, name, lookup) \
30 oxr_log_init(log, name); \
31 if (thing == XR_NULL_HANDLE) { \
32 return oxr_error(log, XR_ERROR_HANDLE_INVALID, "(" #thing " == NULL)"); \
34 new_thing = (struct oxr_thing *)((uintptr_t)thing); \
35 if (new_thing->handle.debug != OXR_XR_DEBUG_##THING) { \
36 return oxr_error(log, XR_ERROR_HANDLE_INVALID, "(" #thing " == %p)", (void *)new_thing); \
38 if (new_thing->handle.state != OXR_HANDLE_STATE_LIVE) { \
39 return oxr_error(log, XR_ERROR_HANDLE_INVALID, "(" #thing " == %p) state == %s", \
40 (void *)new_thing, oxr_handle_state_to_string(new_thing->handle.state)); \
42 oxr_log_set_instance(log, lookup); \
45#define OXR_VERIFY_SET(log, arg, new_arg, oxr_thing, THING) \
47 if (arg == XR_NULL_HANDLE) { \
48 return oxr_error(log, XR_ERROR_HANDLE_INVALID, "(" #arg " == NULL)"); \
50 new_arg = (struct oxr_thing *)((uintptr_t)arg); \
51 if (new_arg->handle.debug != OXR_XR_DEBUG_##THING) { \
52 return oxr_error(log, XR_ERROR_HANDLE_INVALID, "(" #arg " == %p)", (void *)new_arg); \
63#define OXR_VERIFY_INSTANCE_AND_INIT_LOG(log, thing, new_thing, name) \
64 OXR_VERIFY_AND_SET_AND_INIT(log, thing, new_thing, oxr_instance, INSTANCE, name, new_thing)
65#define OXR_VERIFY_MESSENGER_AND_INIT_LOG(log, thing, new_thing, name) \
66 OXR_VERIFY_AND_SET_AND_INIT(log, thing, new_thing, oxr_messenger, MESSENGER, name, new_thing->inst)
67#define OXR_VERIFY_SESSION_AND_INIT_LOG(log, thing, new_thing, name) \
68 OXR_VERIFY_AND_SET_AND_INIT(log, thing, new_thing, oxr_session, SESSION, name, new_thing->sys->inst)
69#define OXR_VERIFY_SPACE_AND_INIT_LOG(log, thing, new_thing, name) \
70 OXR_VERIFY_AND_SET_AND_INIT(log, thing, new_thing, oxr_space, SPACE, name, new_thing->sess->sys->inst)
71#define OXR_VERIFY_ACTION_AND_INIT_LOG(log, thing, new_thing, name) \
72 OXR_VERIFY_AND_SET_AND_INIT(log, thing, new_thing, oxr_action, ACTION, name, new_thing->act_set->inst)
73#define OXR_VERIFY_SWAPCHAIN_AND_INIT_LOG(log, thing, new_thing, name) \
74 OXR_VERIFY_AND_SET_AND_INIT(log, thing, new_thing, oxr_swapchain, SWAPCHAIN, name, new_thing->sess->sys->inst)
75#define OXR_VERIFY_ACTIONSET_AND_INIT_LOG(log, thing, new_thing, name) \
76 OXR_VERIFY_AND_SET_AND_INIT(log, thing, new_thing, oxr_action_set, ACTIONSET, name, new_thing->inst)
77#define OXR_VERIFY_HAND_TRACKER_AND_INIT_LOG(log, thing, new_thing, name) \
78 OXR_VERIFY_AND_SET_AND_INIT(log, thing, new_thing, oxr_hand_tracker, HTRACKER, name, new_thing->sess->sys->inst)
79#define OXR_VERIFY_FORCE_FEEDBACK_AND_INIT_LOG(log, thing, new_thing, name) \
80 OXR_VERIFY_AND_SET_AND_INIT(log, thing, new_thing, oxr_force_feedback, FFB, name, new_thing->sess->sys->inst)
81#define OXR_VERIFY_PASSTHROUGH_AND_INIT_LOG(log, thing, new_thing, name) \
82 OXR_VERIFY_AND_SET_AND_INIT(log, thing, new_thing, oxr_passthrough, PASSTHROUGH, name, new_thing->sess->sys->inst)
83#define OXR_VERIFY_PASSTHROUGH_LAYER_AND_INIT_LOG(log, thing, new_thing, name) \
84 OXR_VERIFY_AND_SET_AND_INIT(log, thing, new_thing, oxr_passthrough_layer, PASSTHROUGH_LAYER, name, new_thing->sess->sys->inst)
85#define OXR_VERIFY_FACE_TRACKER_HTC_AND_INIT_LOG(log, thing, new_thing, name) \
86 OXR_VERIFY_AND_SET_AND_INIT(log, thing, new_thing, oxr_facial_tracker_htc, FTRACKER, name, new_thing->sess->sys->inst)
87#define OXR_VERIFY_FACE_TRACKER2_FB_AND_INIT_LOG(log, thing, new_thing, name) \
88 OXR_VERIFY_AND_SET_AND_INIT(log, thing, new_thing, oxr_face_tracker2_fb, FTRACKER, name, new_thing->sess->sys->inst)
89#define OXR_VERIFY_BODY_TRACKER_FB_AND_INIT_LOG(log, thing, new_thing, name) \
90 OXR_VERIFY_AND_SET_AND_INIT(log, thing, new_thing, oxr_body_tracker_fb, BTRACKER, name, new_thing->sess->sys->inst)
91#define OXR_VERIFY_XDEVLIST_AND_INIT_LOG(log, thing, new_thing, name) \
92 OXR_VERIFY_AND_SET_AND_INIT(log, thing, new_thing, oxr_xdev_list, XDEVLIST, name, new_thing->sess->sys->inst)
95#define OXR_VERIFY_INSTANCE_NOT_NULL(log, arg, new_arg) OXR_VERIFY_SET(log, arg, new_arg, oxr_instance, INSTANCE);
96#define OXR_VERIFY_MESSENGER_NOT_NULL(log, arg, new_arg) OXR_VERIFY_SET(log, arg, new_arg, oxr_messenger, MESSENGER);
97#define OXR_VERIFY_SESSION_NOT_NULL(log, arg, new_arg) OXR_VERIFY_SET(log, arg, new_arg, oxr_session, SESSION);
98#define OXR_VERIFY_SPACE_NOT_NULL(log, arg, new_arg) OXR_VERIFY_SET(log, arg, new_arg, oxr_space, SPACE);
99#define OXR_VERIFY_ACTION_NOT_NULL(log, arg, new_arg) OXR_VERIFY_SET(log, arg, new_arg, oxr_action, ACTION);
100#define OXR_VERIFY_SWAPCHAIN_NOT_NULL(log, arg, new_arg) OXR_VERIFY_SET(log, arg, new_arg, oxr_swapchain, SWAPCHAIN);
101#define OXR_VERIFY_ACTIONSET_NOT_NULL(log, arg, new_arg) OXR_VERIFY_SET(log, arg, new_arg, oxr_action_set, ACTIONSET);
102#define OXR_VERIFY_XDEVLIST_NOT_NULL(log, arg, new_arg) OXR_VERIFY_SET(log, arg, new_arg, oxr_xdev_list, XDEVLIST);
109#define OXR_VERIFY_EXTENSION(log, inst, mixed_case_name) \
111 if (!(inst)->extensions.mixed_case_name) { \
112 return oxr_error((log), XR_ERROR_FUNCTION_UNSUPPORTED, \
113 "Requires XR_" #mixed_case_name " extension enabled"); \
122#define OXR_VERIFY_EXTENSIONS_OR(log, inst, mixed_case_name1, mixed_case_name2) \
124 if (!(inst)->extensions.mixed_case_name1 && !(inst)->extensions.mixed_case_name2) { \
125 return oxr_error((log), XR_ERROR_FUNCTION_UNSUPPORTED, \
126 "Requires XR_" #mixed_case_name1 "or XR_" #mixed_case_name2 \
127 " extension enabled"); \
134#define OXR_API_VERSION_AT_LEAST(inst, major, minor) \
135 ((inst)->openxr_version.major_minor >= XR_MAKE_VERSION(major, minor, 0))
140#define OXR_VERIFY_API_VERSION_AT_LEAST(log, inst, major, minor) \
142 if (!OXR_VERSION_AT_LEAST(inst, major, minor)) { \
143 return oxr_error((log), XR_ERROR_FUNCTION_UNSUPPORTED, "Requires OpenXR version %d.%d.x", \
148#define OXR_VERIFY_ARG_NOT_NULL(log, arg) \
151 return oxr_error(log, XR_ERROR_VALIDATION_FAILURE, "(" #arg " == NULL)"); \
155#define OXR_VERIFY_ARG_NOT_ZERO(log, arg) \
158 return oxr_error(log, XR_ERROR_VALIDATION_FAILURE, "(" #arg " == 0) must be non-zero"); \
162#define OXR_VERIFY_ARG_ZERO(log, arg) \
165 return oxr_error(log, XR_ERROR_VALIDATION_FAILURE, "(" #arg " == 0) must be zero"); \
169#define OXR_VERIFY_ARG_TYPE_CAN_BE_NULL(log, arg, type_enum) \
171 if (arg != NULL && arg->type != type_enum) { \
172 return oxr_error(log, XR_ERROR_VALIDATION_FAILURE, "(" #arg "->type == %u)", arg->type); \
176#define OXR_VERIFY_ARG_TYPE_AND_NOT_NULL(log, arg, type_enum) \
179 return oxr_error(log, XR_ERROR_VALIDATION_FAILURE, "(" #arg " == NULL)"); \
181 OXR_VERIFY_ARG_TYPE_CAN_BE_NULL(log, arg, type_enum); \
188#define OXR_VERIFY_ARG_ARRAY_ELEMENT_TYPE(log, array, index, type_enum) \
190 if ((array)[index].type != type_enum) { \
191 return oxr_error(log, XR_ERROR_VALIDATION_FAILURE, \
192 "(" #array "[%u]->type == 0x%08x) expected 0x%08x", index, \
193 (array)[index].type, type_enum); \
197#define OXR_VERIFY_SUBACTION_PATHS(log, count, paths) \
199 if (count > 0 && paths == NULL) { \
200 return oxr_error(log, XR_ERROR_VALIDATION_FAILURE, \
201 "(" #count ") is not zero but " #paths " is NULL"); \
205#define OXR_VERIFY_ARG_SINGLE_LEVEL_FIXED_LENGTH_PATH(log, path) \
207 XrResult verify_ret = oxr_verify_fixed_size_single_level_path(log, path, ARRAY_SIZE(path), #path); \
208 if (verify_ret != XR_SUCCESS) { \
213#define OXR_VERIFY_ARG_LOCALIZED_NAME(log, string) \
215 XrResult verify_ret = oxr_verify_localized_name(log, string, ARRAY_SIZE(string), #string); \
216 if (verify_ret != XR_SUCCESS) { \
221#define OXR_VERIFY_POSE(log, p) \
223 if (!math_quat_validate((struct xrt_quat *)&p.orientation)) { \
224 return oxr_error(log, XR_ERROR_POSE_INVALID, "(" #p ".orientation) is not a valid quat"); \
227 if (!math_vec3_validate((struct xrt_vec3 *)&p.position)) { \
228 return oxr_error(log, XR_ERROR_POSE_INVALID, "(" #p ".position) is not valid"); \
232#define OXR_VERIFY_VIEW_CONFIG_TYPE(log, inst, view_conf) \
234 XrResult verify_ret = oxr_verify_view_config_type(log, inst, view_conf, #view_conf); \
235 if (verify_ret != XR_SUCCESS) { \
240#define OXR_VERIFY_VIEW_INDEX(log, index) \
243 return oxr_error(log, XR_ERROR_VALIDATION_FAILURE, \
244 "Invalid view index %d, only 2 views supported", index); \
248#define OXR_VERIFY_SWAPCHAIN_USAGE_FLAGS_NOT_MUTUALLY_EXCLUSIVE(log, flags, mutually_exclusive_a, \
249 mutually_exclusive_b) \
251 if (((flags) & (mutually_exclusive_a)) != 0 && ((flags) & (mutually_exclusive_b)) != 0) { \
252 return oxr_error(log, XR_ERROR_VALIDATION_FAILURE, \
253 "(" #flags ") Swapchain usage flags " #mutually_exclusive_a \
254 " and " #mutually_exclusive_b \
255 " are mutually exclusive in this graphics API"); \
259#define OXR_VERIFY_SESSION_NOT_LOST(log, sess) \
261 if (sess->has_lost) { \
262 return oxr_error(log, XR_ERROR_SESSION_LOST, "Session is lost"); \
266#define OXR_VERIFY_SESSION_RUNNING(log, sess) \
268 if (!oxr_frame_sync_is_session_running(&sess->frame_sync)) { \
269 return oxr_error(log, XR_ERROR_SESSION_NOT_RUNNING, "Session is not running"); \
273#define OXR_VERIFY_PASSTHROUGH_FLAGS(log, flags) \
275 (flags & (XR_PASSTHROUGH_IS_RUNNING_AT_CREATION_BIT_FB | XR_PASSTHROUGH_LAYER_DEPTH_BIT_FB)) == 0) \
276 return oxr_error(log, XR_ERROR_VALIDATION_FAILURE, \
277 "flags is not a valid combination of XrPassthroughFlagBitsFB values");
279#define OXR_VERIFY_PASSTHROUGH_LAYER_PURPOSE(log, purpose) \
280 if ((purpose != XR_PASSTHROUGH_LAYER_PURPOSE_RECONSTRUCTION_FB && \
281 purpose != XR_PASSTHROUGH_LAYER_PURPOSE_PROJECTED_FB && \
282 purpose != XR_PASSTHROUGH_LAYER_PURPOSE_TRACKED_KEYBOARD_HANDS_FB && \
283 purpose != XR_PASSTHROUGH_LAYER_PURPOSE_TRACKED_KEYBOARD_MASKED_HANDS_FB)) \
284 return oxr_error(log, XR_ERROR_VALIDATION_FAILURE, \
285 "purpose is not a valid XrPassthroughLayerPurposeFB value");
287#define OXR_VERIFY_PASSTHROUGH_LAYER_STYLE(log, style) \
289 uint32_t duplicate_check = 0; \
290 const XrPassthroughStyleFB *next = style->next; \
292 if (next->type != XR_TYPE_PASSTHROUGH_COLOR_MAP_MONO_TO_RGBA_FB && \
293 next->type != XR_TYPE_PASSTHROUGH_COLOR_MAP_MONO_TO_MONO_FB && \
294 next->type != XR_TYPE_PASSTHROUGH_BRIGHTNESS_CONTRAST_SATURATION_FB) \
295 return oxr_error(log, XR_ERROR_VALIDATION_FAILURE, \
296 "style next structure chain contains invalid pointers"); \
297 if ((next->type & duplicate_check) != 0) \
298 return oxr_error(log, XR_ERROR_VALIDATION_FAILURE, \
299 "style next structure chain contains duplicate items"); \
300 duplicate_check |= next->type; \
301 next = (const XrPassthroughStyleFB *)next->next; \
312oxr_verify_full_path_c(
struct oxr_logger *log,
const char *path,
const char *name);
343 uint32_t countSubactionPaths,
344 const XrPath *subactionPaths,
345 const char *variable);
366 const char *variable);
372oxr_verify_view_config_type(
struct oxr_logger *log,
374 XrViewConfigurationType view_conf,
375 const char *view_conf_name);
378oxr_verify_XrSessionCreateInfo(
struct oxr_logger * ,
380 const XrSessionCreateInfo * );
382#if defined(XR_USE_PLATFORM_XLIB) && defined(XR_USE_GRAPHICS_API_OPENGL)
384oxr_verify_XrGraphicsBindingOpenGLXlibKHR(
struct oxr_logger * ,
const XrGraphicsBindingOpenGLXlibKHR * );
387#if defined(XR_USE_PLATFORM_WIN32) && defined(XR_USE_GRAPHICS_API_OPENGL)
389oxr_verify_XrGraphicsBindingOpenGLWin32KHR(
struct oxr_logger * ,
390 const XrGraphicsBindingOpenGLWin32KHR * );
393#if defined(XR_USE_GRAPHICS_API_VULKAN)
395oxr_verify_XrGraphicsBindingVulkanKHR(
struct oxr_logger * ,
const XrGraphicsBindingVulkanKHR * );
398#if defined(XR_USE_PLATFORM_EGL) && defined(XR_USE_GRAPHICS_API_OPENGL)
400oxr_verify_XrGraphicsBindingEGLMNDX(
struct oxr_logger *log,
const XrGraphicsBindingEGLMNDX *next);
403#if defined(XR_USE_PLATFORM_ANDROID) && defined(XR_USE_GRAPHICS_API_OPENGL_ES)
405oxr_verify_XrGraphicsBindingOpenGLESAndroidKHR(
struct oxr_logger *,
const XrGraphicsBindingOpenGLESAndroidKHR *);
409#if defined(XR_USE_GRAPHICS_API_D3D11)
411oxr_verify_XrGraphicsBindingD3D11KHR(
struct oxr_logger *,
const XrGraphicsBindingD3D11KHR *);
414#if defined(XR_USE_GRAPHICS_API_D3D12)
416oxr_verify_XrGraphicsBindingD3D12KHR(
struct oxr_logger *,
const XrGraphicsBindingD3D12KHR *);
419#ifdef XR_EXT_dpad_binding
421oxr_verify_XrInteractionProfileDpadBindingEXT(
struct oxr_logger *,
422 const XrInteractionProfileDpadBindingEXT *,
423 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.
Definition: oxr_verify.c:298
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.
Definition: oxr_verify.c:319
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.
Definition: oxr_verify.c:349
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
The objects that handle session running status and blocking of xrWaitFrame.
A group of actions.
Definition: oxr_objects.h:2474
Structure tracking which extensions are enabled for a given instance.
Definition: oxr_objects.h:1612
Main object that ties everything together.
Definition: oxr_objects.h:1625
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:2051