st/oxr: Ensure get gfx requirements has been called

This commit is contained in:
Jakob Bornecrantz 2020-05-30 12:42:41 +01:00
parent 12d78144f6
commit 185036489c
5 changed files with 31 additions and 1 deletions

View file

@ -0,0 +1,2 @@
OpenXR: Correctly ensure that the application has called the required get
graphics requirements function when creating a session.

View file

@ -224,6 +224,8 @@ oxr_xrGetOpenGLESGraphicsRequirementsKHR(
graphicsRequirements->maxApiVersionSupported =
XR_MAKE_VERSION(ver.max_major, ver.max_minor, ver.max_patch);
sys->gotten_requirements = true;
return XR_SUCCESS;
}
@ -262,6 +264,8 @@ oxr_xrGetOpenGLGraphicsRequirementsKHR(
graphicsRequirements->maxApiVersionSupported =
XR_MAKE_VERSION(ver.max_major, ver.max_minor, ver.max_patch);
sys->gotten_requirements = true;
return XR_SUCCESS;
}

View file

@ -903,6 +903,9 @@ struct oxr_system
XrSystemId systemId;
//! Have the client application called the gfx api requirements func?
bool gotten_requirements;
XrFormFactor form_factor;
XrViewConfigurationType view_config_type;
XrViewConfigurationView views[2];

View file

@ -873,6 +873,13 @@ oxr_session_create_impl(struct oxr_logger *log,
XR_TYPE_GRAPHICS_BINDING_OPENGL_XLIB_KHR,
XrGraphicsBindingOpenGLXlibKHR);
if (opengl_xlib != NULL) {
if (!sys->gotten_requirements) {
return oxr_error(
log, XR_ERROR_VALIDATION_FAILURE,
"Has not called "
"xrGetOpenGL[ES]GraphicsRequirementsKHR");
}
OXR_SESSION_ALLOCATE(log, sys, *out_session);
return oxr_session_populate_gl_xlib(log, sys, opengl_xlib,
*out_session);
@ -884,6 +891,12 @@ oxr_session_create_impl(struct oxr_logger *log,
createInfo, XR_TYPE_GRAPHICS_BINDING_VULKAN_KHR,
XrGraphicsBindingVulkanKHR);
if (vulkan != NULL) {
if (!sys->gotten_requirements) {
return oxr_error(log, XR_ERROR_VALIDATION_FAILURE,
"Has not called "
"xrGetVulkanGraphicsRequirementsKHR");
}
OXR_SESSION_ALLOCATE(log, sys, *out_session);
return oxr_session_populate_vk(log, sys, vulkan, *out_session);
}
@ -894,6 +907,13 @@ oxr_session_create_impl(struct oxr_logger *log,
createInfo, XR_TYPE_GRAPHICS_BINDING_EGL_MNDX,
XrGraphicsBindingEGLMNDX);
if (egl != NULL) {
if (!sys->gotten_requirements) {
return oxr_error(
log, XR_ERROR_VALIDATION_FAILURE,
"Has not called "
"xrGetOpenGL[ES]GraphicsRequirementsKHR");
}
OXR_SESSION_ALLOCATE(log, sys, *out_session);
return oxr_session_populate_egl(log, sys, egl, *out_session);
}
@ -927,7 +947,6 @@ oxr_session_create(struct oxr_logger *log,
/* Try allocating and populating. */
XrResult ret = oxr_session_create_impl(log, sys, createInfo, &sess);
if (ret != XR_SUCCESS) {
if (sess != NULL) {
/* clean up allocation first */

View file

@ -63,6 +63,8 @@ oxr_vk_get_requirements(struct oxr_logger *log,
graphicsRequirements->maxApiVersionSupported =
XR_MAKE_VERSION(ver.max_major, ver.max_minor, ver.max_patch);
sys->gotten_requirements = true;
return XR_SUCCESS;
}