| Crates.io | bevy_compute_readback |
| lib.rs | bevy_compute_readback |
| version | 0.1.2 |
| created_at | 2025-07-11 06:57:23.563289+00 |
| updated_at | 2025-09-14 23:59:25.153255+00 |
| description | Simplify compute shaders with readback in the Bevy game engine. |
| homepage | https://github.com/Katsutoshii/bevy_compute_readback |
| repository | https://github.com/Katsutoshii/bevy_compute_readback |
| max_upload_size | |
| id | 1747464 |
| size | 178,692 |
bevy_compute_readbackCrate to abstract away the boilerplate of creating compute shaders with readback in the Bevy game engine.
This based on the GPU readback example (gpu_readback.rs).
use bevy_compute_readback::{
ComputeShader, ComputeShaderPlugin, ReadbackLimit
};
/// Custom compute shader input.
#[derive(AsBindGroup, Resource, Clone, Debug, ExtractResource)]
pub struct CustomComputeShader {
// Texture for the GPU to write to.
#[storage_texture(0, image_format=Rgba32Float, access=WriteOnly)]
texture: Handle<Image>,
}
impl ComputeShader for CustomComputeShader {
/// Path to your compute shader WGSL file.
fn compute_shader() -> ShaderRef {
"shaders/texture_readback.wgsl".into()
}
/// Workgroup size for the compute shader.
fn workgroup_size() -> UVec3 {
UVec3::new(64, 64, 1)
}
/// Indicate which buffer/texture should be read back to CPU.
fn readback(&self) -> Option<Readback> {
Some(Readback::texture(self.texture.clone()))
}
/// Handle readback events.
fn on_readback(trigger: Trigger<ReadbackComplete>, mut world: DeferredWorld) {
// ...
}
}
fn main() {
App::new()
.add_plugins((
ComputeShaderPlugin::<CustomComputeShader> {
limit: ReadbackLimit::Finite(1),
remove_on_complete: false,
..default()
},
))
.run();
}
See examples for a working demo.
| bevy | bevy_compute_readback |
|---|---|
| 0.16 | 0.1.2 |