I just completed the graphics section of the OpenXR tutorial (which is awesome BTW) using OpenGL ES, and I have cubes rendering on my Meta Quest 3 headset. I’d like to now add an overlay layer using XR_TYPE_COMPOSITION_LAYER_QUAD, but I’m a little confused on the swapchain and image buffer set up for the views.

I see in the documentation there is the ability to set a XR_EYE_VISIBILITY_BOTH flag for this type of layer. Does that mean that I don’t need to enumerate all of the configuration views (stereo in my case) and create multiple image buffers for each view during the swapchain set up?

Any advice or examples for setting up and rendering to an overlay layer with XR_TYPE_COMPOSITION_LAYER_QUAD for a stereo configuration would be much appreciated.


I assume by “overlay” you mean just superimposed on your own app. There is an extension called EXTX_overlay for providing an overlay over a different app, but it is experimental and not widely implemented.

In that case, yes, you can allocate just a single swapchain, single view, for a quad layer, I believe. If you’re displaying a constant texture on it, as we do with some instructions/titles in the CTS, you can even allocate it as a “static” swapchain meaning only one image, only acquired and released once. ( see OpenXR-CTS/src/conformance/framework/composition_utils.cpp at devel · KhronosGroup/OpenXR-CTS · GitHub - it populates an image, uploads it to that static swapchain, then constructs the quad layer structure for submission in xrEndFrame, and re-uses that same layer structure every frame.) Important note: In general, do not use the CTS as sample or model code, since it is often either a: trying to do the minimum possible that tests a given thing, or b: intentionally doing things wrong or in a non-recommended way to test the edges of runtime behavior. So e.g. you wouldn’t organize your code the same way it is organized to show that title, you might re-use a swapchain and thus not have it static, etc. But the basics of creating the swapchain, passing the whole thing as the subrect for the quad layer, and using the same layer struct in every xrEndFrame, all that stuff is sound.

Enumerating view configuration views is primarily for projection views.

Thanks @ryliepavlik - that’s good to know that I only need to create a single swapchain and view for the quad layer. I did get it working by enumerating the views and their swapchains and then acquiring an image like in the example for the projection layer, but that probably means that I’m doing some redundant work there. Thanks for the info!