mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-02-17 19:20:13 +00:00
st/oxr: Validate view configuration type
This commit is contained in:
parent
077087bb15
commit
dab96ef356
doc/changes/state_trackers
src/xrt/state_trackers/oxr
3
doc/changes/state_trackers/mr.368.md
Normal file
3
doc/changes/state_trackers/mr.368.md
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
OpenXR: Where used make sure we verify the view configuration type is a valid
|
||||||
|
enum value, the code is setup so that we in the future can support new values
|
||||||
|
via extensions easily.
|
|
@ -86,6 +86,8 @@ oxr_xrBeginSession(XrSession session, const XrSessionBeginInfo *beginInfo)
|
||||||
OXR_VERIFY_SESSION_AND_INIT_LOG(&log, session, sess, "xrBeginSession");
|
OXR_VERIFY_SESSION_AND_INIT_LOG(&log, session, sess, "xrBeginSession");
|
||||||
OXR_VERIFY_ARG_TYPE_AND_NOT_NULL(&log, beginInfo,
|
OXR_VERIFY_ARG_TYPE_AND_NOT_NULL(&log, beginInfo,
|
||||||
XR_TYPE_SESSION_BEGIN_INFO);
|
XR_TYPE_SESSION_BEGIN_INFO);
|
||||||
|
OXR_VERIFY_VIEW_CONFIG_TYPE(&log, sess->sys->inst,
|
||||||
|
beginInfo->primaryViewConfigurationType);
|
||||||
|
|
||||||
return oxr_session_begin(&log, sess, beginInfo);
|
return oxr_session_begin(&log, sess, beginInfo);
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,23 +101,6 @@ oxr_xrEnumerateViewConfigurations(
|
||||||
viewConfigurationTypeCountOutput, viewConfigurationTypes);
|
viewConfigurationTypeCountOutput, viewConfigurationTypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
static XrResult
|
|
||||||
check_view_config_type(struct oxr_logger *log,
|
|
||||||
struct oxr_instance *inst,
|
|
||||||
XrViewConfigurationType view_conf)
|
|
||||||
{
|
|
||||||
// These are always valid.
|
|
||||||
if (view_conf == XR_VIEW_CONFIGURATION_TYPE_PRIMARY_MONO ||
|
|
||||||
view_conf == XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO) {
|
|
||||||
return XR_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
return oxr_error(
|
|
||||||
log, XR_ERROR_VALIDATION_FAILURE,
|
|
||||||
"(viewConfigurationType == 0x%08x) invalid view configuration type",
|
|
||||||
view_conf);
|
|
||||||
}
|
|
||||||
|
|
||||||
XrResult
|
XrResult
|
||||||
oxr_xrEnumerateEnvironmentBlendModes(
|
oxr_xrEnumerateEnvironmentBlendModes(
|
||||||
XrInstance instance,
|
XrInstance instance,
|
||||||
|
@ -129,15 +112,10 @@ oxr_xrEnumerateEnvironmentBlendModes(
|
||||||
{
|
{
|
||||||
struct oxr_instance *inst;
|
struct oxr_instance *inst;
|
||||||
struct oxr_logger log;
|
struct oxr_logger log;
|
||||||
XrResult ret;
|
|
||||||
OXR_VERIFY_INSTANCE_AND_INIT_LOG(&log, instance, inst,
|
OXR_VERIFY_INSTANCE_AND_INIT_LOG(&log, instance, inst,
|
||||||
"xrEnumerateEnvironmentBlendModes");
|
"xrEnumerateEnvironmentBlendModes");
|
||||||
OXR_VERIFY_SYSTEM_AND_GET(&log, inst, systemId, sys);
|
OXR_VERIFY_SYSTEM_AND_GET(&log, inst, systemId, sys);
|
||||||
|
OXR_VERIFY_VIEW_CONFIG_TYPE(&log, inst, viewConfigurationType);
|
||||||
ret = check_view_config_type(&log, inst, viewConfigurationType);
|
|
||||||
if (ret != XR_SUCCESS) {
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (viewConfigurationType != sys->view_config_type) {
|
if (viewConfigurationType != sys->view_config_type) {
|
||||||
return oxr_error(&log,
|
return oxr_error(&log,
|
||||||
|
|
|
@ -171,6 +171,16 @@ extern "C" {
|
||||||
} \
|
} \
|
||||||
} while (false)
|
} while (false)
|
||||||
|
|
||||||
|
#define OXR_VERIFY_VIEW_CONFIG_TYPE(log, inst, view_conf) \
|
||||||
|
do { \
|
||||||
|
XrResult verify_ret = oxr_verify_view_config_type( \
|
||||||
|
log, inst, view_conf, #view_conf); \
|
||||||
|
if (verify_ret != XR_SUCCESS) { \
|
||||||
|
return verify_ret; \
|
||||||
|
} \
|
||||||
|
} while (false)
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* Implementation in oxr_verify.cpp
|
* Implementation in oxr_verify.cpp
|
||||||
|
@ -241,6 +251,12 @@ oxr_verify_subaction_path_get(struct oxr_logger *log,
|
||||||
struct oxr_sub_paths *out_sub_paths,
|
struct oxr_sub_paths *out_sub_paths,
|
||||||
const char *variable);
|
const char *variable);
|
||||||
|
|
||||||
|
XrResult
|
||||||
|
oxr_verify_view_config_type(struct oxr_logger *log,
|
||||||
|
struct oxr_instance *inst,
|
||||||
|
XrViewConfigurationType view_conf,
|
||||||
|
const char *view_conf_name);
|
||||||
|
|
||||||
XrResult
|
XrResult
|
||||||
oxr_verify_XrSessionCreateInfo(struct oxr_logger *,
|
oxr_verify_XrSessionCreateInfo(struct oxr_logger *,
|
||||||
const struct oxr_instance *,
|
const struct oxr_instance *,
|
||||||
|
|
|
@ -454,6 +454,23 @@ oxr_verify_subaction_path_get(struct oxr_logger *log,
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
XrResult
|
||||||
|
oxr_verify_view_config_type(struct oxr_logger *log,
|
||||||
|
struct oxr_instance *inst,
|
||||||
|
XrViewConfigurationType view_conf,
|
||||||
|
const char *view_conf_name)
|
||||||
|
{
|
||||||
|
// These are always valid.
|
||||||
|
if (view_conf == XR_VIEW_CONFIGURATION_TYPE_PRIMARY_MONO ||
|
||||||
|
view_conf == XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO) {
|
||||||
|
return XR_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
return oxr_error(log, XR_ERROR_VALIDATION_FAILURE,
|
||||||
|
"(%s == 0x%08x) invalid view configuration type",
|
||||||
|
view_conf_name, view_conf);
|
||||||
|
}
|
||||||
|
|
||||||
XrResult
|
XrResult
|
||||||
oxr_verify_XrSessionCreateInfo(struct oxr_logger *log,
|
oxr_verify_XrSessionCreateInfo(struct oxr_logger *log,
|
||||||
const struct oxr_instance *inst,
|
const struct oxr_instance *inst,
|
||||||
|
|
Loading…
Reference in a new issue