Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support creating PhysicalDevice from raw value for OpenXR #1396

Closed
tmfink opened this issue Jul 6, 2020 · 2 comments
Closed

Support creating PhysicalDevice from raw value for OpenXR #1396

tmfink opened this issue Jul 6, 2020 · 2 comments

Comments

@tmfink
Copy link
Contributor

tmfink commented Jul 6, 2020

Summary

There are some problems in trying to use Vulkano with the OpenXR API (Rust bindings available via openxrs crate). The OpenXR API wants to create the Vulkan structs VkPhysicalDevice (instead of taking one that is already created).

The existing Vulkano APIs do not support taking in an externally created VkPhysicalDevice.

Details

Support for Vulkan in OpenXR comes via XR_KHR_vulkan_enable OpenXR extension.

The workflow to initialize OpenXR with Vulkan support (skipping some non-Vulkan details):

  1. Get XrInstance from OpenXR by calling xrCreateInstance().
  2. Get XrSystemId from OpenXR xrGetSystem()
  3. Determine OpenXR runtime's Vulkan version info with XrGraphicsRequirementsVulkanKHR()
  4. Determine OpenXR runtime's required Vulkan extensions with xrGetVulkanInstanceExtensionsKHR()
  5. Get VkInstance from Vulkan by calling vkCreateInstance().
  6. Get VkPhysicalDevice from OpenXR by calling xrGetVulkanGraphicsDeviceKHR().
    • Input: VkInstance
  7. Get VkDevice from Vulkan by calling vkCreateDevice()
  8. Get XrSession from OpenXR by calling xrCreateSession()

According to XR_KHR_vulkan_enable spec:

physicalDevice VkPhysicalDevice must match the device specified by xrGetVulkanGraphicsDeviceKHR.

Vulkano cannot just create the the VkPhysicalDevice with Vulkan APIs.

Possible Solutions

  1. Add an unsafe function to create vulkano::instance::PhysicalDevice from a raw VkPhysicalDevice.
    • This could be added through a new FromVulkanObject trait (opposite of the existing VulkanObject trait)
    • Downstream crates (such as openxrs) could do this for users to avoid exposing/requiring unsafe calls.
  2. Call into OpenXR functions (such as xrGetVulkanGraphicsDeviceKHR()) to create a vulkano::instance::PhysicalDevice.
    • Would add a dependency (although optional) on OpenXR, which is non-trivial because it can be loaded in different ways

Thoughts? I'm not that familiar with Vulkan (or Vulkano).

@dyc3
Copy link

dyc3 commented Jul 21, 2021

I was trying to do this, and ran into trouble when trying to create a session. I was unable to figure out how to provide any of these parameters, not just physical device.

@marc0246
Copy link
Contributor

marc0246 commented Jul 7, 2023

This was added in #1967, see also #1935 for the state of the overall effort.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants