What is the right way to implement single pass rendering with openXR?

Hello,

There are a couple of basic ways you can do single-pass rendering (and problably other methods as well):

  1. You can use texture arrays (arraySize=2 when allocating your swapchain) and have your shaders render to different indices in the array (eg: SV_RenderTargetArrayIndex). When submitting your XrCompositionLayerProjection, you will then specify the same XrSwapchain handle for both left and right views, but with a different imageArrayIndex in the XrSwapchainSubImage. The Microsoft BasicXrApp will show you how to do that with Direct3D: OpenXR-MixedReality/samples/BasicXrApp at main · microsoft/OpenXR-MixedReality (github.com)

  2. You can use a double-wide swapchain, allocated with width being twice the per-eye resolution, and use the imageRect to specify both views within the same swapchain when submitting a frame (this is the method you started describing above). You don’t need to worry about FOV/IPD, because when filling up your XrCompositionLayerProjection struct, you still specify the FOV and eye poses per-view, and the only overlap will be using the same XrSwapchain handle but with a different imageRect. I am not aware of any existing sample code that does this, but you can still take a look at the sample code above for texture arrays, and it will show you nearly the same thing: instead of submitting the same XrSwapchain with two different values of imageArrayIndex, you will specify two different imageRect.

Hope this helps!