Plugin aims to provide easy way access data created or modified on the GPU, back in app world. Current approach uses channel to send data back to app world. Uses Events to trigger and notify compute is complete.
Note: This is a work in progress, and an experment. I got it working and plan on dog fooding it for a while.
Currently requires:
- bevy fork for modified AsBindGroup macro
- bevy-inspector-egui fork - Also a few image formats and change detection
See Compute in App branch for first attempt at this. It duplicating render resources in app world like from bevy-app-compute Kinda worked. For context see PR #8440
See AsBindGroup for more information on how to use the attributes.
The only additional option is 'staging', which when used with ComputePlugin will arrange to have copied back to the app world after the compute shader is run.
- uniform - TODO (haven't found a need for this myself)
- storage - 'staging' - have resource updated after compute
Vec<T>
works ifT: Pod
, Color doesn't work- TODO: Look into encase ReadFrom and WriteTo
- storage_texture - 'staging' - image transfered after compute and
Assets<Image>
updated with AssetModified event - buffer - TODO
You will most likely want to run in release mode. See Examples:
- basic-wgsl - The Simplest use case
- image-wgsl - Compute image and use it in material, and save image it to file
- terrain - generates mesh and collider from image, brush to let you paint on it
- paint - (doesn't use staging), lets you paint to different standard materials entities
- many-(uses basic) - Multiple ComputePlugins
-
Data:
- Uniform
- Storage
- StorageTexture
- Tested with R32Float, R8uint, Rgba8Unorm
- add error to macro when and check for readwrite support depending on format notes
- Buffer
- Texture
-
Examples:
- Basic
- Inspect
- Image
- Many - Multiple ComputeWorkerPlugins
-
AssetEvent::Modified
- Egui Inspector - added patch to bevy-inspector-egui to clear resized images on asset modified events
- Any Material - See mark_shader_modified, StandardMaterial added by default
-
Instancing
-
Components - Big TODO
-
Multiple Entry Points
-
Multiple Passes
-
Many Plugin Instances
- WebGPU Storage Textures
- bevy-app-compute - Closest thing to what I want, but no texture support, and magic strings.
- wgpu hello-compute - Example of using compute shaders in wgpu.
- wgpu capture
- AsBindGroup docs - Documenation for AsBindGroup, which is duplicated here for now.
- PR #8440 - Issue for adding support for compute shaders in bevy.
bevy | bevy_sly_compute |
---|---|
0.13 *forked | 0.2 |