Enable Vulkan multiview extension in OpenXR the right way?

Looking for sources on how do you enable VK_KHR_multiview for your OpenXR application, it actually seems fairly easy: you enable the extension on graphics api device creation, you include the additional VkRenderPassMultiviewCreateInfo data on renderpass creation, texture array on swapchain creation, and so on. Yet, when it comes to OpenXR itself, there is something that does not seem quite right.

At some point in the hello_xr app, the code performs the two expected xrEnumerateViewConfigurationViews() calls to get, among other things, the number of views that should be used to render. Thing is, despite doing everything to enable multiview rendering from the Vulkan side, these calls still report that there are 2 views to be used, instead of just the one. These calls are performed before creating the swapchains themselves - you’re expected, after all, to create one swapchain per view.

Am I forgetting something here? Is there something else I should be telling OpenXR besides enabling the extension in the Vulkan device, before getting the number of views from XR? Or am I just simply misunderstanding how does this work?

Any light you can shed on this will be highly appreciated!

Hi. I’m not positive, but I think you want to create one swapchain where each image has a layer depth of 2 (for stereo). I think the session knows how to present a two-layer image properly.

The fact that OpenXR still reports 2 views is correct, after all what you’re using the multi-view extension for is to render multiple views in a single pass. The function xrEnumerateViewConfigurationViews() doesn’t report anything about the number of render passes required, just the number of views.

Your misunderstanding comes from the assumption that OpenXR requires one swapchain per view, which is incorrect. You can submit multiple views in a single swapchain by either putting them side-by-side or in multiple layers as @bgaul mentioned. The way you do this is by using the same swapchain handle in XrSwapchainSubImage for both views. Then in the case of side-by-side rendering you specify different image rects and in the case of multiple layers you set the layer index of each view.

Given that you’re using the multi-view extension you’ll want to use multiple layers and create the swapchain with a depth of 2 as @bgaul mentioned.

1 Like

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.