mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-29 18:08:29 +00:00
st/oxr: Validate view configuration type
This commit is contained in:
parent
077087bb15
commit
dab96ef356
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_ARG_TYPE_AND_NOT_NULL(&log, beginInfo,
|
||||
XR_TYPE_SESSION_BEGIN_INFO);
|
||||
OXR_VERIFY_VIEW_CONFIG_TYPE(&log, sess->sys->inst,
|
||||
beginInfo->primaryViewConfigurationType);
|
||||
|
||||
return oxr_session_begin(&log, sess, beginInfo);
|
||||
}
|
||||
|
|
|
@ -101,23 +101,6 @@ oxr_xrEnumerateViewConfigurations(
|
|||
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
|
||||
oxr_xrEnumerateEnvironmentBlendModes(
|
||||
XrInstance instance,
|
||||
|
@ -129,15 +112,10 @@ oxr_xrEnumerateEnvironmentBlendModes(
|
|||
{
|
||||
struct oxr_instance *inst;
|
||||
struct oxr_logger log;
|
||||
XrResult ret;
|
||||
OXR_VERIFY_INSTANCE_AND_INIT_LOG(&log, instance, inst,
|
||||
"xrEnumerateEnvironmentBlendModes");
|
||||
OXR_VERIFY_SYSTEM_AND_GET(&log, inst, systemId, sys);
|
||||
|
||||
ret = check_view_config_type(&log, inst, viewConfigurationType);
|
||||
if (ret != XR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
OXR_VERIFY_VIEW_CONFIG_TYPE(&log, inst, viewConfigurationType);
|
||||
|
||||
if (viewConfigurationType != sys->view_config_type) {
|
||||
return oxr_error(&log,
|
||||
|
|
|
@ -171,6 +171,16 @@ extern "C" {
|
|||
} \
|
||||
} 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
|
||||
|
@ -241,6 +251,12 @@ oxr_verify_subaction_path_get(struct oxr_logger *log,
|
|||
struct oxr_sub_paths *out_sub_paths,
|
||||
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
|
||||
oxr_verify_XrSessionCreateInfo(struct oxr_logger *,
|
||||
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
|
||||
oxr_verify_XrSessionCreateInfo(struct oxr_logger *log,
|
||||
const struct oxr_instance *inst,
|
||||
|
|
Loading…
Reference in a new issue