bevy/examples/shader
Sven Niederberger 3ce2f46ae5
GpuReadbackPlugin: Allow reading only a part of a buffer (#20133)
# Objective

- So far only full buffer reads were supported. This adds the ability to
read a part of a buffer.

## Solution

- Allow passing in a start offset and a number of bytes to read when
creating the `Readback` component.
- I also removed the unused `src_start` and `dst_start` fields from
`ReadbackSource` as they were always 0.

## Testing

- Did you test these changes? If so, how?

I extended the example to also demonstrate partial reads.

- Are there any parts that need more testing?

Can't think of any.

- How can other people (reviewers) test your changes? Is there anything
specific they need to know?

Run the `gpu_readback` example. It now also reads and prints a partially
read buffer.

- If relevant, what platforms did you test these changes on, and are
there any important ones you can't test?

Only tested on Linux.

---

## Showcase

Example output:

<details>
  <summary>Click to view showcase</summary>

```
2025-07-14T14:05:15.614876Z  INFO gpu_readback: Buffer [257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272]
2025-07-14T14:05:15.614921Z  INFO gpu_readback: Buffer range [261, 262, 263, 264, 265, 266, 267, 268]
2025-07-14T14:05:15.614937Z  INFO gpu_readback: Image [257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
```

</details>
2025-07-14 21:01:16 +00:00
..
animate_shader.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
array_texture.rs Remove incorrect equality comparisons for asset load error types (#15890) 2024-10-14 01:00:45 +00:00
automatic_instancing.rs Add user supplied mesh tag (#17648) 2025-02-10 22:38:13 +00:00
compute_shader_game_of_life.rs Make render and compute pipeline descriptors defaultable. (#19903) 2025-07-02 18:47:27 +00:00
custom_phase_item.rs Make render and compute pipeline descriptors defaultable. (#19903) 2025-07-02 18:47:27 +00:00
custom_post_processing.rs Make render and compute pipeline descriptors defaultable. (#19903) 2025-07-02 18:47:27 +00:00
custom_render_phase.rs Make render and compute pipeline descriptors defaultable. (#19903) 2025-07-02 18:47:27 +00:00
custom_shader_instancing.rs Ugrade to wgpu version 25.0 (#19563) 2025-06-26 19:41:47 +00:00
custom_vertex_attribute.rs Type erased materials (#19667) 2025-06-27 22:57:24 +00:00
extended_material_bindless.rs Add bindless support back to ExtendedMaterial. (#18025) 2025-04-09 15:34:44 +00:00
extended_material.rs Fix the extended_material example on WebGL2 (#18812) 2025-07-07 19:34:12 +00:00
fallback_image.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
gpu_readback.rs GpuReadbackPlugin: Allow reading only a part of a buffer (#20133) 2025-07-14 21:01:16 +00:00
shader_defs.rs Type erased materials (#19667) 2025-06-27 22:57:24 +00:00
shader_material_2d.rs Add alpha mode implementation to shader_material_2d (#16603) 2025-01-28 05:09:30 +00:00
shader_material_bindless.rs Use global binding arrays for bindless resources. (#17898) 2025-02-21 05:55:36 +00:00
shader_material_glsl.rs Make render and compute pipeline descriptors defaultable. (#19903) 2025-07-02 18:47:27 +00:00
shader_material_screenspace_texture.rs aligning public apis of Time,Timer and Stopwatch (#15962) 2024-10-16 21:09:32 +00:00
shader_material_wesl.rs Type erased materials (#19667) 2025-06-27 22:57:24 +00:00
shader_material.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
shader_prepass.rs Update shader_prepass, testbed_2d, and first_person_view_model examples to use children! macro (#18270) 2025-03-22 22:35:20 +00:00
specialized_mesh_pipeline.rs Make render and compute pipeline descriptors defaultable. (#19903) 2025-07-02 18:47:27 +00:00
storage_buffer.rs Add user supplied mesh tag (#17648) 2025-02-10 22:38:13 +00:00
texture_binding_array.rs Type erased materials (#19667) 2025-06-27 22:57:24 +00:00