BabylonJS / BabylonNative

Build cross-platform native applications with the power of the Babylon.js JavaScript framework
MIT License
779 stars 133 forks source link

Support D3D12 view instancing for multiview rendering on OpenXR #904

Closed rgerd closed 2 months ago

rgerd commented 3 years ago

We currently hand two framebuffers to Babylon.js per-frame, one for each eye, pointing to different layers in the color & depth texture arrays provided by the OpenXR runtime. Ideally, we would use one framebuffer per-frame with the entire texture arrays attached and render to it in one set of draw calls (instead of two, one per eye) using the GL_OVR_multiview2 extension. This will allow us to avoid two full renders per frame. In rendering-dominated scenarios, we could see up to a ~40% decrease in frame time, almost doubling our framerate.

Babylon.js currently has support for WebXR Projection Layers, which means that there already exists a path in Babylon.js to render stereo views to a texture array in a single pass, although there still remains lots of work to get BabylonNative to provide the multiview render target and set up view instanced rendering.

D3D12 supports view instancing, which will allow us to use a built-in variable, SV_ViewID in our hlsl shaders that will closely match the gl_ViewID_OVR built-in variable provided by the GL_OVR_multiview2 extension.

Here's a breakdown of what would need to get done to connect these two:

bghgary commented 2 months ago

Closing for now. Reopen if we still want this.