Monado OpenXR Runtime
oxr_api_verify.h File Reference

File for verifying app input into api functions. More...

#include "oxr_frame_sync.h"
#include <stddef.h>
Include dependency graph for oxr_api_verify.h:

Go to the source code of this file.

Macros

#define OXR_VERIFY_AND_SET_AND_INIT(log, thing, new_thing, oxr_thing, THING, name, lookup)
 
#define OXR_VERIFY_SET(log, arg, new_arg, oxr_thing, THING)
 
#define OXR_VERIFY_INSTANCE_AND_INIT_LOG(log, thing, new_thing, name)    OXR_VERIFY_AND_SET_AND_INIT(log, thing, new_thing, oxr_instance, INSTANCE, name, new_thing)
 
#define OXR_VERIFY_MESSENGER_AND_INIT_LOG(log, thing, new_thing, name)    OXR_VERIFY_AND_SET_AND_INIT(log, thing, new_thing, oxr_messenger, MESSENGER, name, new_thing->inst)
 
#define OXR_VERIFY_SESSION_AND_INIT_LOG(log, thing, new_thing, name)    OXR_VERIFY_AND_SET_AND_INIT(log, thing, new_thing, oxr_session, SESSION, name, new_thing->sys->inst)
 
#define OXR_VERIFY_SPACE_AND_INIT_LOG(log, thing, new_thing, name)    OXR_VERIFY_AND_SET_AND_INIT(log, thing, new_thing, oxr_space, SPACE, name, new_thing->sess->sys->inst)
 
#define OXR_VERIFY_ACTION_AND_INIT_LOG(log, thing, new_thing, name)    OXR_VERIFY_AND_SET_AND_INIT(log, thing, new_thing, oxr_action, ACTION, name, new_thing->act_set->inst)
 
#define OXR_VERIFY_SWAPCHAIN_AND_INIT_LOG(log, thing, new_thing, name)    OXR_VERIFY_AND_SET_AND_INIT(log, thing, new_thing, oxr_swapchain, SWAPCHAIN, name, new_thing->sess->sys->inst)
 
#define OXR_VERIFY_ACTIONSET_AND_INIT_LOG(log, thing, new_thing, name)    OXR_VERIFY_AND_SET_AND_INIT(log, thing, new_thing, oxr_action_set, ACTIONSET, name, new_thing->inst)
 
#define OXR_VERIFY_HAND_TRACKER_AND_INIT_LOG(log, thing, new_thing, name)    OXR_VERIFY_AND_SET_AND_INIT(log, thing, new_thing, oxr_hand_tracker, HTRACKER, name, new_thing->sess->sys->inst)
 
#define OXR_VERIFY_FORCE_FEEDBACK_AND_INIT_LOG(log, thing, new_thing, name)    OXR_VERIFY_AND_SET_AND_INIT(log, thing, new_thing, oxr_force_feedback, FFB, name, new_thing->sess->sys->inst)
 
#define OXR_VERIFY_PASSTHROUGH_AND_INIT_LOG(log, thing, new_thing, name)    OXR_VERIFY_AND_SET_AND_INIT(log, thing, new_thing, oxr_passthrough, PASSTHROUGH, name, new_thing->sess->sys->inst)
 
#define OXR_VERIFY_PASSTHROUGH_LAYER_AND_INIT_LOG(log, thing, new_thing, name)    OXR_VERIFY_AND_SET_AND_INIT(log, thing, new_thing, oxr_passthrough_layer, PASSTHROUGH_LAYER, name, new_thing->sess->sys->inst)
 
#define OXR_VERIFY_FACE_TRACKER_HTC_AND_INIT_LOG(log, thing, new_thing, name)    OXR_VERIFY_AND_SET_AND_INIT(log, thing, new_thing, oxr_facial_tracker_htc, FTRACKER, name, new_thing->sess->sys->inst)
 
#define OXR_VERIFY_FACE_TRACKER2_FB_AND_INIT_LOG(log, thing, new_thing, name)    OXR_VERIFY_AND_SET_AND_INIT(log, thing, new_thing, oxr_face_tracker2_fb, FTRACKER, name, new_thing->sess->sys->inst)
 
#define OXR_VERIFY_BODY_TRACKER_FB_AND_INIT_LOG(log, thing, new_thing, name)    OXR_VERIFY_AND_SET_AND_INIT(log, thing, new_thing, oxr_body_tracker_fb, BTRACKER, name, new_thing->sess->sys->inst)
 
#define OXR_VERIFY_XDEVLIST_AND_INIT_LOG(log, thing, new_thing, name)    OXR_VERIFY_AND_SET_AND_INIT(log, thing, new_thing, oxr_xdev_list, XDEVLIST, name, new_thing->sess->sys->inst)
 
#define OXR_VERIFY_INSTANCE_NOT_NULL(log, arg, new_arg)   OXR_VERIFY_SET(log, arg, new_arg, oxr_instance, INSTANCE);
 
#define OXR_VERIFY_MESSENGER_NOT_NULL(log, arg, new_arg)   OXR_VERIFY_SET(log, arg, new_arg, oxr_messenger, MESSENGER);
 
#define OXR_VERIFY_SESSION_NOT_NULL(log, arg, new_arg)   OXR_VERIFY_SET(log, arg, new_arg, oxr_session, SESSION);
 
#define OXR_VERIFY_SPACE_NOT_NULL(log, arg, new_arg)   OXR_VERIFY_SET(log, arg, new_arg, oxr_space, SPACE);
 
#define OXR_VERIFY_ACTION_NOT_NULL(log, arg, new_arg)   OXR_VERIFY_SET(log, arg, new_arg, oxr_action, ACTION);
 
#define OXR_VERIFY_SWAPCHAIN_NOT_NULL(log, arg, new_arg)   OXR_VERIFY_SET(log, arg, new_arg, oxr_swapchain, SWAPCHAIN);
 
#define OXR_VERIFY_ACTIONSET_NOT_NULL(log, arg, new_arg)   OXR_VERIFY_SET(log, arg, new_arg, oxr_action_set, ACTIONSET);
 
#define OXR_VERIFY_XDEVLIST_NOT_NULL(log, arg, new_arg)   OXR_VERIFY_SET(log, arg, new_arg, oxr_xdev_list, XDEVLIST);
 
#define OXR_VERIFY_EXTENSION(log, inst, mixed_case_name)
 Checks if a required extension is enabled. More...
 
#define OXR_VERIFY_EXTENSIONS_OR(log, inst, mixed_case_name1, mixed_case_name2)
 Checks if either one of two required extensions is enabled. More...
 
#define OXR_API_VERSION_AT_LEAST(inst, major, minor)    ((inst)->openxr_version.major_minor >= XR_MAKE_VERSION(major, minor, 0))
 A condition if the instance is created with at least a given OpenXR version. More...
 
#define OXR_VERIFY_API_VERSION_AT_LEAST(log, inst, major, minor)
 Checks if the instance is created with at least a given OpenXR version. More...
 
#define OXR_VERIFY_ARG_NOT_NULL(log, arg)
 
#define OXR_VERIFY_ARG_NOT_ZERO(log, arg)
 
#define OXR_VERIFY_ARG_ZERO(log, arg)
 
#define OXR_VERIFY_ARG_TYPE_CAN_BE_NULL(log, arg, type_enum)
 
#define OXR_VERIFY_ARG_TYPE_AND_NOT_NULL(log, arg, type_enum)
 
#define OXR_VERIFY_ARG_ARRAY_ELEMENT_TYPE(log, array, index, type_enum)
 Must only be used with full typed arrays, aka non-basetyped arrays like that passed into xrEnumerateSwapchainImages. More...
 
#define OXR_VERIFY_SUBACTION_PATHS(log, count, paths)
 
#define OXR_VERIFY_ARG_SINGLE_LEVEL_FIXED_LENGTH_PATH(log, path)
 
#define OXR_VERIFY_ARG_LOCALIZED_NAME(log, string)
 
#define OXR_VERIFY_POSE(log, p)
 
#define OXR_VERIFY_VIEW_CONFIG_TYPE(log, inst, view_conf)
 
#define OXR_VERIFY_VIEW_INDEX(log, index)
 
#define OXR_VERIFY_SWAPCHAIN_USAGE_FLAGS_NOT_MUTUALLY_EXCLUSIVE(log, flags, mutually_exclusive_a, mutually_exclusive_b)
 
#define OXR_VERIFY_SESSION_NOT_LOST(log, sess)
 
#define OXR_VERIFY_SESSION_RUNNING(log, sess)
 
#define OXR_VERIFY_PASSTHROUGH_FLAGS(log, flags)
 
#define OXR_VERIFY_PASSTHROUGH_LAYER_PURPOSE(log, purpose)
 
#define OXR_VERIFY_PASSTHROUGH_LAYER_STYLE(log, style)
 

Functions

XrResult oxr_verify_full_path_c (struct oxr_logger *log, const char *path, const char *name)
 
XrResult oxr_verify_full_path (struct oxr_logger *log, const char *path, size_t length, const char *name)
 Verify a full path. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
XrResult oxr_verify_extensions (struct oxr_logger *log, const struct oxr_extension_status *extensions)
 
XrResult oxr_verify_view_config_type (struct oxr_logger *log, struct oxr_instance *inst, XrViewConfigurationType view_conf, const char *view_conf_name)
 
XrResult oxr_verify_XrSessionCreateInfo (struct oxr_logger *, const struct oxr_instance *, const XrSessionCreateInfo *)
 
XrResult oxr_verify_XrGraphicsBindingOpenGLXlibKHR (struct oxr_logger *, const XrGraphicsBindingOpenGLXlibKHR *)
 
XrResult oxr_verify_XrGraphicsBindingVulkanKHR (struct oxr_logger *, const XrGraphicsBindingVulkanKHR *)
 

Detailed Description

File for verifying app input into api functions.

Author
Jakob Bornecrantz jakob.nosp@m.@col.nosp@m.labor.nosp@m.a.co.nosp@m.m
Korcan Hussein korca.nosp@m.n.hu.nosp@m.ssein.nosp@m.@col.nosp@m.labor.nosp@m.a.co.nosp@m.m

Macro Definition Documentation

◆ OXR_VERIFY_AND_SET_AND_INIT

#define OXR_VERIFY_AND_SET_AND_INIT (   log,
  thing,
  new_thing,
  oxr_thing,
  THING,
  name,
  lookup 
)
Value:
do { \
oxr_log_init(log, name); \
if (thing == XR_NULL_HANDLE) { \
return oxr_error(log, XR_ERROR_HANDLE_INVALID, "(" #thing " == NULL)"); \
} \
new_thing = (struct oxr_thing *)((uintptr_t)thing); \
if (new_thing->handle.debug != OXR_XR_DEBUG_##THING) { \
return oxr_error(log, XR_ERROR_HANDLE_INVALID, "(" #thing " == %p)", (void *)new_thing); \
} \
if (new_thing->handle.state != OXR_HANDLE_STATE_LIVE) { \
return oxr_error(log, XR_ERROR_HANDLE_INVALID, "(" #thing " == %p) state == %s", \
(void *)new_thing, oxr_handle_state_to_string(new_thing->handle.state)); \
} \
oxr_log_set_instance(log, lookup); \
} while (0)
const char * oxr_handle_state_to_string(enum oxr_handle_state state)
Returns a human-readable label for a handle state.
Definition: oxr_handle_base.c:42
@ OXR_HANDLE_STATE_LIVE
State after successful oxr_handle_init.
Definition: oxr_defines.h:49
XrResult oxr_error(struct oxr_logger *logger, XrResult result, const char *fmt,...)
Definition: oxr_logger.c:203

◆ OXR_VERIFY_SET

#define OXR_VERIFY_SET (   log,
  arg,
  new_arg,
  oxr_thing,
  THING 
)
Value:
do { \
if (arg == XR_NULL_HANDLE) { \
return oxr_error(log, XR_ERROR_HANDLE_INVALID, "(" #arg " == NULL)"); \
} \
new_arg = (struct oxr_thing *)((uintptr_t)arg); \
if (new_arg->handle.debug != OXR_XR_DEBUG_##THING) { \
return oxr_error(log, XR_ERROR_HANDLE_INVALID, "(" #arg " == %p)", (void *)new_arg); \
} \
} while (0)