Is OpenXR's swapchain "fake"?


I want to double check my understanding that OpenXR’s swapchain is not actually a swapchain-grade texture but rather a simple offscreen render target that is later consumed by so called compositor to render to the actual swapchain. Is it true?

If so, does it mean I can directly write to OpenXR’s swapchain using DirectX 12 compute shaders? (writing directly to swapchain is forbidden in pure DX12). If so, what state can I count OpenXR swapchain resources to come and what state should I transition it back before submitting?


Yes, more or less. It’s not “fake” in that it is a swapchain-type structure/usage, but it is not a capital-S Swapchain as in VkSwapchain, it’s a collection of textures used for offscreen rendering. So I would suspect it probably does not have the limitation you mention. That is a good point, though, that we don’t explicitly say that this restriction doesn’t apply, so I guess technically somebody might be able to implement it with a Swapchain? Hmm. Can you file an issue on KhronosGroup/OpenXR-Docs: OpenXR Specification sources and related material to clarify this? (That will get it into the internal issue tracker and the meeting agendas.)

All the graphics binding extensions list in them the relevant states for the textures, so for D3D12, see XR_KHR_D3D12_enable in the section “Swapchain Image Resource State”.

Remember to create the swapchain with XR_SWAPCHAIN_USAGE_UNORDERED_ACCESS_BIT in order to be able to write to it from a CS.

Also be careful that OpenXR will return to you TYPELESS textures, so be sure to handle typing accordingly when you create your views. And also beware of sRBG conversion if needed.

@ryliepavlik @mbucchia1

thank you for insights! so I’m using my compute shaders now to write directly into swapchain, which is nice!

I’ll file a clarification request to the spec!

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