Closed
Description
Allowing users or even internal rendering logic access to compute shaders will provide a way of processing arbitrary data on the GPU. This can be used for everything from advanced lighting techniques, fast boid's calculations, and image processing.
Some key questions:
- How does compute fit within the current pipeline and graph implementation?
- Compute shaders run on their own and are not associated with fragment or vertex shaders. Currently the
ShaderStages
type expects to always have a vertex shader. I would suggest perhaps breaking this type up? - A clear API around how users can interact with compute shaders. If a compute shader keeps all of its data on the GPU the API can be relatively simple, however if a user needs access to the data that was processed in the compute shader we would need some sort of non-blocking(async) access to a wgpu buffer, but perhaps that's a separate issue?
As a reference for how a compute pass works here is a simple example of wgpu compute logic:
let pass = encoder.begin_compute_pass();
pass.set_pipeline(&pipeline.compute_pipeline);
pass.set_bind_group(0, &self.bind_group, &[]);
pass.dispatch(8, 8, 1); // The number of work groups(x, y, z).
I'm more than willing to work on adding compute shaders to bevy I just need some direction as to how I move forward considering the questions above. 🙂