st/oxr: Check requested OpenXR API version.

Conformance.
This commit is contained in:
Ryan Pavlik 2019-06-05 17:55:30 -05:00
parent 0bdb4e4aeb
commit 06cb5d680b

View file

@ -66,6 +66,29 @@ oxr_xrCreateInstance(const XrInstanceCreateInfo* createInfo,
oxr_log_init(&log, "xrCreateInstance");
OXR_VERIFY_ARG_TYPE_AND_NULL(&log, createInfo,
XR_TYPE_INSTANCE_CREATE_INFO);
#if XR_VERSION_MAJOR != 0
#error "Must update this code following 1.0 release!"
#endif
const uint32_t major = XR_VERSION_MAJOR(XR_CURRENT_API_VERSION);
const uint32_t minor = XR_VERSION_MINOR(XR_CURRENT_API_VERSION);
/* const uint32_t patch = XR_VERSION_PATCH(XR_CURRENT_API_VERSION);*/
if (createInfo->applicationInfo.apiVersion <
XR_MAKE_VERSION(major, minor, 0)) {
return oxr_error(
&log, XR_ERROR_RUNTIME_VERSION_INCOMPATIBLE,
"(createInfo->applicationInfo.apiVersion) "
"Cannot satisfy request for version less than %d.%d.%d",
major, minor, 0);
}
/* This is a slight fib, to let us approximately run pre-release
* things between 0.90 and 1.0 */
if (createInfo->applicationInfo.apiVersion >=
XR_MAKE_VERSION(1, 0, 0)) {
return oxr_error(
&log, XR_ERROR_RUNTIME_VERSION_INCOMPATIBLE,
"(createInfo->applicationInfo.apiVersion) "
"Cannot satisfy request for version: too high");
}
struct oxr_instance* inst;
ret = oxr_instance_create(&log, createInfo, &inst);