lovr
lovr copied to clipboard
Submit Depth Buffer to OpenXR
- Enable
XR_KHR_composition_layer_depth - Create a second swapchain for depth textures
- Probably need to start using
xrEnumerateSwapchainFormatsto see if depth formats are supported - Question: what if depth swapchain and color swapchain lengths don't match? Fail?
- Need a way to set the depth buffer of a Canvas (at creation time), maybe
.depth.handleentry inCanvasFlags - Each Canvas gets one of the depth swapchain images
- Can always fall back to old lovr-managed depth texture (extension not supported, format not supported, etc.)
- Add
XrCompositionLayerDepthInfoKHRstruct toXrCompositionLayerProjectionViewwith depth info - Plug
state.clipNearandstate.clipFarinto the nearZ/farZ fields.
Started working on openxr-depth, very WIP/incomplete but uncovers some issues:
- Since the order that swapchain images are given to you is completely arbitrary, we can't guarantee that color/depth indices will match for a frame. This makes it impossible to precreate Canvases with color/depth textures, since we don't know which ones will be used together. The solution is to just create a Canvas for each color image, then create native Textures for each depth image, then dynamically attach whatever depth texture OpenXR gives us to the current color Canvas every frame.
- This also lets us tolerate different numbers of depth and color images.
- Other than that there's just a lot of reorganization around having 2 of everything -- swapchains, image counts/indices, etc.
This is implemented on the dev branch.