st/oxr: Verify width and height on swapchain create

This commit is contained in:
Jakob Bornecrantz 2019-08-01 07:39:50 +01:00
parent 4ebc308a37
commit 5fa58efcbf
2 changed files with 11 additions and 4 deletions

View file

@ -59,10 +59,9 @@ oxr_xrCreateSwapchain(XrSession session,
OXR_VERIFY_ARG_NOT_NULL(&log, out_swapchain); OXR_VERIFY_ARG_NOT_NULL(&log, out_swapchain);
// Save people from shooting themselves in the foot. // Save people from shooting themselves in the foot.
if (createInfo->arraySize <= 0) { OXR_VERIFY_ARG_NOT_ZERO(&log, createInfo->arraySize);
return oxr_error(&log, XR_ERROR_VALIDATION_FAILURE, OXR_VERIFY_ARG_NOT_ZERO(&log, createInfo->width);
"(createInfo->arraySize) must be non-zero"); OXR_VERIFY_ARG_NOT_ZERO(&log, createInfo->height);
}
ret = sess->create_swapchain(&log, sess, createInfo, &sc); ret = sess->create_swapchain(&log, sess, createInfo, &sc);
if (ret != XR_SUCCESS) { if (ret != XR_SUCCESS) {

View file

@ -91,6 +91,14 @@ extern "C" {
} \ } \
} while (false) } while (false)
#define OXR_VERIFY_ARG_NOT_ZERO(log, arg) \
do { \
if (arg == 0) { \
return oxr_error(log, XR_ERROR_VALIDATION_FAILURE, \
"(" #arg " == 0) must be non-zero"); \
} \
} while (false)
#define OXR_VERIFY_ARG_TYPE_AND_NULL(log, arg, type_enum) \ #define OXR_VERIFY_ARG_TYPE_AND_NULL(log, arg, type_enum) \
do { \ do { \
if (arg == NULL) { \ if (arg == NULL) { \