st/oxr: Ignore graphics bindings from disabled extensions

This commit is contained in:
Benjamin Saunders 2019-03-24 14:13:35 -07:00
parent 3c9eafc1f0
commit c8515e142d
3 changed files with 24 additions and 4 deletions

View file

@ -89,10 +89,18 @@ oxr_instance_create(struct oxr_logger *log,
inst->timekeeping = time_state_create();
inst->headless = false;
inst->opengl_enable = false;
inst->vulkan_enable = false;
for (uint32_t i = 0; i < createInfo->enabledExtensionCount; ++i) {
if (strcmp(createInfo->enabledExtensionNames[i],
XR_KHR_HEADLESS_EXTENSION_NAME) == 0) {
inst->headless = true;
} else if (strcmp(createInfo->enabledExtensionNames[i],
XR_KHR_OPENGL_ENABLE_EXTENSION_NAME) == 0) {
inst->opengl_enable = true;
} else if (strcmp(createInfo->enabledExtensionNames[i],
XR_KHR_VULKAN_ENABLE_EXTENSION_NAME) == 0) {
inst->vulkan_enable = true;
}
}

View file

@ -429,10 +429,10 @@ struct oxr_instance
uint64_t debug;
struct xrt_prober *prober;
/*!
* Whether headless sessions can be created
*/
// Enabled extensions
bool headless;
bool opengl_enable;
bool vulkan_enable;
// Hardcoded single system.
struct oxr_system system;

View file

@ -92,12 +92,24 @@ oxr_verify_XrSessionCreateInfo(struct oxr_logger* log,
XrStructureType* next_type = (XrStructureType*)createInfo->next;
#ifdef XR_USE_PLATFORM_XLIB
if (*next_type == XR_TYPE_GRAPHICS_BINDING_OPENGL_XLIB_KHR) {
if (!inst->opengl_enable) {
return oxr_error(
log, XR_ERROR_VALIDATION_FAILURE,
"OpenGL "
"requires " XR_KHR_OPENGL_ENABLE_EXTENSION_NAME);
}
return oxr_verify_XrGraphicsBindingOpenGLXlibKHR(
log, (XrGraphicsBindingOpenGLXlibKHR*)createInfo->next);
} else
#endif
#ifdef XR_USE_GRAPHICS_API_VULKAN
if (*next_type == XR_TYPE_GRAPHICS_BINDING_VULKAN_KHR) {
if (*next_type == XR_TYPE_GRAPHICS_BINDING_VULKAN_KHR) {
if (!inst->vulkan_enable) {
return oxr_error(
log, XR_ERROR_VALIDATION_FAILURE,
"Vulkan "
"requires " XR_KHR_VULKAN_ENABLE_EXTENSION_NAME);
}
return oxr_verify_XrGraphicsBindingVulkanKHR(
log, (XrGraphicsBindingVulkanKHR*)createInfo->next);
} else