mirror of
https://github.com/bevyengine/bevy
synced 2024-11-25 06:00:20 +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> |
||
---|---|---|
.. | ||
animate_shader.wgsl | ||
array_texture.wgsl | ||
cubemap_unlit.wgsl | ||
custom_gltf_2d.wgsl | ||
custom_material.frag | ||
custom_material.vert | ||
custom_material.wgsl | ||
custom_material_2d.wgsl | ||
custom_material_import.wgsl | ||
custom_material_screenspace_texture.wgsl | ||
custom_phase_item.wgsl | ||
custom_ui_material.wgsl | ||
custom_vertex_attribute.wgsl | ||
extended_material.wgsl | ||
fallback_image_test.wgsl | ||
game_of_life.wgsl | ||
gpu_readback.wgsl | ||
instancing.wgsl | ||
irradiance_volume_voxel_visualization.wgsl | ||
line_material.wgsl | ||
post_processing.wgsl | ||
shader_defs.wgsl | ||
show_prepass.wgsl | ||
specialized_mesh_pipeline.wgsl | ||
storage_buffer.wgsl | ||
texture_binding_array.wgsl | ||
tonemapping_test_patterns.wgsl | ||
water_material.wgsl |