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

**URL:** <https://community.khronos.org/t/what-is-the-right-way-to-implement-single-pass-rendering-with-openxr/109157>\
**Category:** OpenXR\
**Created:** [October 22, 2022, 10:21pm UTC](https://community.khronos.org/t/what-is-the-right-way-to-implement-single-pass-rendering-with-openxr/109157 "2022-10-22T22:21:56Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![mbucchia1](https://community.khronos.org/user_avatar/community.khronos.org/mbucchia1/32/8441_2.png) [@mbucchia1](https://community.khronos.org/u/mbucchia1)\
**Post date:** [October 24, 2022, 6:51pm UTC](https://community.khronos.org/t/what-is-the-right-way-to-implement-single-pass-rendering-with-openxr/109157/3 "2022-10-24T18:51:54Z")

</div>

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)](https://github.com/microsoft/OpenXR-MixedReality/tree/main/samples/BasicXrApp)

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!

---

_[View the full topic](https://community.khronos.org/t/what-is-the-right-way-to-implement-single-pass-rendering-with-openxr/109157)._
