mirror of
https://github.com/bevyengine/bevy
synced 2024-11-22 04:33:37 +00:00
40c26f80aa
# Objective Adds a new `Readback` component to request for readback of a `Handle<Image>` or `Handle<ShaderStorageBuffer>` to the CPU in a future frame. ## Solution We track the `Readback` component and allocate a target buffer to write the gpu resource into and map it back asynchronously, which then fires a trigger on the entity in the main world. This proccess is asynchronous, and generally takes a few frames. ## Showcase ```rust let mut buffer = ShaderStorageBuffer::from(vec![0u32; 16]); buffer.buffer_description.usage |= BufferUsages::COPY_SRC; let buffer = buffers.add(buffer); commands .spawn(Readback::buffer(buffer.clone())) .observe(|trigger: Trigger<ReadbackComplete>| { info!("Buffer data from previous frame {:?}", trigger.event()); }); ``` --------- Co-authored-by: Kristoffer Søholm <k.soeholm@gmail.com> Co-authored-by: IceSentry <IceSentry@users.noreply.github.com> |
||
---|---|---|
.. | ||
android-res/mipmap-mdpi | ||
animation_graphs | ||
branding | ||
data | ||
docs | ||
environment_maps | ||
fonts | ||
irradiance_volumes | ||
lightmaps | ||
models | ||
pixel | ||
scenes | ||
shaders | ||
sounds | ||
textures | ||
volumes |