The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

st/oxr: Check that VkPhysicalDevice in graphics binding matches suggested device

XR_KHR_vulkan_enable2:
physicalDevice VkPhysicalDevice must match the device specified by xrGetVulkanGraphicsDevice2KHR

XR_KHR_vulkan_enable:
physicalDevice VkPhysicalDevice must match the device specified by xrGetVulkanGraphicsDeviceKHR

XR_KHR_vulkan_enable:
Add a trivial check that xrGetVulkanGraphicsDeviceKHR is called before xrCreateSession.
(our cached suggested device will be XR_NULL_HANDLE if it has not been called).
The XR_KHR_vulkan_enable2 code path already contains this check.

+25 -5
+2 -2
src/xrt/state_trackers/oxr/oxr_api_system.c
··· 403 403 // VK_NULL_HANDLE is 0 404 404 OXR_VERIFY_ARG_NOT_NULL(&log, createInfo->vulkanPhysicalDevice); 405 405 406 - OXR_VERIFY_ARG_NOT_NULL(&log, sys->vulkan_enable2_physical_device); 406 + OXR_VERIFY_ARG_NOT_NULL(&log, sys->suggested_vulkan_physical_device); 407 407 OXR_VERIFY_ARG_NOT_NULL(&log, sys->vulkan_enable2_instance); 408 408 409 - if (sys->vulkan_enable2_physical_device != createInfo->vulkanPhysicalDevice) { 409 + if (sys->suggested_vulkan_physical_device != createInfo->vulkanPhysicalDevice) { 410 410 return oxr_error(&log, XR_ERROR_HANDLE_INVALID, 411 411 "createInfo->vulkanPhysicalDevice must be the device " 412 412 "returned by xrGetVulkanGraphicsDeviceKHR");
+3 -1
src/xrt/state_trackers/oxr/oxr_objects.h
··· 1095 1095 #ifdef XR_USE_GRAPHICS_API_VULKAN 1096 1096 //! The instance/device we create when vulkan_enable2 is used 1097 1097 VkInstance vulkan_enable2_instance; 1098 - VkPhysicalDevice vulkan_enable2_physical_device; 1098 + //! The device returned with the last xrGetVulkanGraphicsDeviceKHR or xrGetVulkanGraphicsDevice2KHR call. 1099 + //! XR_NULL_HANDLE if neither has been called. 1100 + VkPhysicalDevice suggested_vulkan_physical_device; 1099 1101 #endif 1100 1102 }; 1101 1103
+15
src/xrt/state_trackers/oxr/oxr_session.c
··· 2048 2048 "xrGetVulkanGraphicsRequirementsKHR"); 2049 2049 } 2050 2050 2051 + if (sys->suggested_vulkan_physical_device == VK_NULL_HANDLE) { 2052 + char *fn = sys->inst->extensions.KHR_vulkan_enable ? "xrGetVulkanGraphicsDeviceKHR" 2053 + : "xrGetVulkanGraphicsDevice2KHR"; 2054 + return oxr_error(log, XR_ERROR_VALIDATION_FAILURE, "Has not called %s", fn); 2055 + } 2056 + 2057 + if (sys->suggested_vulkan_physical_device != vulkan->physicalDevice) { 2058 + char *fn = sys->inst->extensions.KHR_vulkan_enable ? "xrGetVulkanGraphicsDeviceKHR" 2059 + : "xrGetVulkanGraphicsDevice2KHR"; 2060 + return oxr_error( 2061 + log, XR_ERROR_VALIDATION_FAILURE, 2062 + "XrGraphicsBindingVulkanKHR::physicalDevice %p must match device %p specified by %s", 2063 + (void *)vulkan->physicalDevice, (void *)sys->suggested_vulkan_physical_device, fn); 2064 + } 2065 + 2051 2066 OXR_SESSION_ALLOCATE(log, sys, *out_session); 2052 2067 OXR_ALLOCATE_NATIVE_COMPOSITOR(log, xsi, *out_session); 2053 2068 return oxr_session_populate_vk(log, sys, vulkan, *out_session);
+1 -1
src/xrt/state_trackers/oxr/oxr_system.c
··· 101 101 102 102 #ifdef XR_USE_GRAPHICS_API_VULKAN 103 103 sys->vulkan_enable2_instance = VK_NULL_HANDLE; 104 - sys->vulkan_enable2_physical_device = VK_NULL_HANDLE; 104 + sys->suggested_vulkan_physical_device = VK_NULL_HANDLE; 105 105 #endif 106 106 107 107 // Headless.
+4 -1
src/xrt/state_trackers/oxr/oxr_vulkan.c
··· 369 369 // vulkan_enable2 needs the physical device in xrCreateVulkanDeviceKHR 370 370 if (inst->extensions.KHR_vulkan_enable2) { 371 371 sys->vulkan_enable2_instance = vkInstance; 372 - sys->vulkan_enable2_physical_device = *vkPhysicalDevice; 372 + } 373 + sys->suggested_vulkan_physical_device = *vkPhysicalDevice; 374 + if (ll <= U_LOGGING_DEBUG) { 375 + oxr_log(log, "Suggesting vulkan physical device %p", (void *)*vkPhysicalDevice); 373 376 } 374 377 375 378 free(phys);