gfx-rs / wgpu

A cross-platform, safe, pure-Rust graphics API.
https://wgpu.rs
Apache License 2.0
12.3k stars 903 forks source link

Multi-view rendering #2186

Closed LaylBongers closed 2 years ago

LaylBongers commented 2 years ago

Is your feature request related to a problem? Please describe.

With the recent move to wgpu-hal, and now being able to access the raw backing types, it has become possible to use OpenXR with the current released version of WGPU. (It works pretty well too!)

However, for efficient VR stereo rendering, multi-view has become the standard in most engines. Multi-view allows rendering to two different targets (array layers on the same texture), using different matrices. Currently WGPU does not provide multi-view support.

Describe the solution you'd like

Preferably, multi-view support at least for the Vulkan target would be nice, as almost all platforms supporting VR currently support the Vulkan extension. (With the exception of WMR, which only supports DX11 and DX12, but SteamVR can act as a bridge for that to provide support)

Multi-view has become core in Vulkan 1.1, and in 1.0 is broadly supported through an identical VK_KHR_multiview extension.

Describe alternatives you've considered

Other alternative options are mostly impractical. Older solutions such as using geometry shaders are no longer necessary because of multi-view's broad support. Multi-view could be implemented using raw handle access but because of the simplicity of adding support this isn't really necessary.

Edit: Multi-view-like functionality can also be accomplished through a compute shader, though I haven't measured the difference in performance and I don't know how this affects support for mobile targets such as the Quest.

Additional context

VK_KHR_multiview VkRenderPassMultiviewCreateInfo

schell commented 2 years ago

@LaylBongers in your PR description you said that OpenXR and wgpu was "working pretty well" - which sounds great! Do you have any pointers or links to getting the two working together?

philpax commented 1 year ago

@LaylBongers in your PR description you said that OpenXR and wgpu was "working pretty well" - which sounds great! Do you have any pointers or links to getting the two working together?

I just publicised my example of integrating OpenXR and wgpu (I came across this issue while looking for example code) - you can find more details here: https://github.com/gfx-rs/wgpu/issues/602#issuecomment-1288217600