Compute Shader separate from renderer
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 161
Description
Hi, I have a scenario where occasionally I need to generate a large mesh. I want to use a compute shader to run a noise function and marching cubes. The only compute shader example I see is directly tied to the renderer as a node on the graph. I need my compute shader to be dispatched entirely separate from rendering, since it only happens every so often as determined by external game logic.
I would propose a system where the shader can be created, buffers would be loaded, and it would be dispatched, which would return a handle. This handle can be a future which can be polled, or it can have some other non-rust-async design, but it should have a flag to check if the shader has finished running. The handle can be stored in a resource or in a component, and on another frame later on the handle can be checked to see if the shader is finished. If so, data can be copied back from the buffers and used.
This seems like a much more general use of compute shaders than the current system which is very specialized and imo doesn't address most use cases of compute shaders.
EDIT: I should note that Unity has this feature, which is what I based my proposal off of. Obviously I wouldn't expect a direct copy for bevy, but something along these lines would be huge for any game requiring a lot of computation. For furthur reading: https://docs.unity3d.com/Manual/class-ComputeShader.html
Contributor guide
Research direction
Start by locating the existing compute shader example and the renderer graph node it uses, then trace how dispatch and buffer handling are connected to rendering. Done would mean a design and implementation for independently creating, buffering, dispatching, polling completion, and retrieving compute results without tying the work to a render graph node.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- game-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100