Add indirect building of TLASes
Continuation of discussion in #9877
Is your feature request related to a problem? Please describe. Currently, wgpu only has direct tlas building where one writes to a CPU based array of tlas instances which is then uploaded to the GPU. This conversion can be very slow (for large numbers of instances), and although it could be optimised, there still are bottlenecks caused by slower ram on the cpu.
Describe the solution you'd like The only part of the tlas instance that needs to be validated on the CPU are the blases. We should have a way of building where only the blases are passed from the cpu and combined using an internal shader with a buffer containing tlas instances with indexes into the blas array instead of blases like the direct build
Describe alternatives you've considered
- Keep with the current direct only API (slow)
- Redesign the direct API to be better (as in #10450 )
- Note: This isn't really an alternative, if anything, it makes both explaining this and (maybe) implementing it easier.
Additional context Apple's API might not support a zero value to disable the instance, I asked for clarification in FB24392978. There are some ways around this such as building an empty blas and using that.
Source: gfx-rs/wgpu