lovr icon indicating copy to clipboard operation
lovr copied to clipboard

Submit Depth Buffer to OpenXR

Open bjornbytes opened this issue 4 years ago • 1 comments

  • Enable XR_KHR_composition_layer_depth
  • Create a second swapchain for depth textures
  • Probably need to start using xrEnumerateSwapchainFormats to 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.handle entry in CanvasFlags
  • 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 XrCompositionLayerDepthInfoKHR struct to XrCompositionLayerProjectionView with depth info
  • Plug state.clipNear and state.clipFar into the nearZ/farZ fields.

bjornbytes avatar Apr 29 '21 16:04 bjornbytes

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.

bjornbytes avatar Apr 29 '21 20:04 bjornbytes

This is implemented on the dev branch.

bjornbytes avatar Aug 07 '22 06:08 bjornbytes