From bff72f6c23814ca1ba74f14fa794392d041d7724 Mon Sep 17 00:00:00 2001 From: Christoph Haag Date: Tue, 5 Mar 2024 03:10:24 +0100 Subject: [PATCH] st/oxr: Add OXR_VERIFY_API_VERSION_AT_LEAST verification macro Part-of: --- src/xrt/state_trackers/oxr/oxr_api_verify.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/xrt/state_trackers/oxr/oxr_api_verify.h b/src/xrt/state_trackers/oxr/oxr_api_verify.h index abc5596f1..559c1a95e 100644 --- a/src/xrt/state_trackers/oxr/oxr_api_verify.h +++ b/src/xrt/state_trackers/oxr/oxr_api_verify.h @@ -116,6 +116,23 @@ extern "C" { } \ } while (false) +/*! + * A condition if the instance is created with at least a given OpenXR version + */ +#define OXR_API_VERSION_AT_LEAST(inst, major, minor) \ + ((inst)->openxr_version.major_minor >= XR_MAKE_VERSION(major, minor, 0)) + +/*! + * Checks if the instance is created with at least a given OpenXR version + */ +#define OXR_VERIFY_API_VERSION_AT_LEAST(log, inst, major, minor) \ + do { \ + if (!OXR_VERSION_AT_LEAST(inst, major, minor)) { \ + return oxr_error((log), XR_ERROR_FUNCTION_UNSUPPORTED, "Requires OpenXR version %d.%d.x", \ + major, minor); \ + } \ + } while (false) + #define OXR_VERIFY_ARG_NOT_NULL(log, arg) \ do { \ if (arg == NULL) { \