Hello,
There are a couple of basic ways you can do single-pass rendering (and problably other methods as well):
-
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 yourXrCompositionLayerProjection, you will then specify the sameXrSwapchainhandle for both left and right views, but with a differentimageArrayIndexin theXrSwapchainSubImage. The Microsoft BasicXrApp will show you how to do that with Direct3D: OpenXR-MixedReality/samples/BasicXrApp at main · microsoft/OpenXR-MixedReality (github.com) -
You can use a double-wide swapchain, allocated with width being twice the per-eye resolution, and use the
imageRectto 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 yourXrCompositionLayerProjectionstruct, you still specify the FOV and eye poses per-view, and the only overlap will be using the sameXrSwapchainhandle but with a differentimageRect. 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 sameXrSwapchainwith two different values ofimageArrayIndex, you will specify two differentimageRect.
Hope this helps!