bevy/crates/bevy_render/src
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
..
batching bevy_render: fix clippy on wasm (#19872) 2025-06-29 22:09:37 +00:00
diagnostic Ugrade to wgpu version 25.0 (#19563) 2025-06-26 19:41:47 +00:00
experimental Remove Shader weak_handles from bevy_render. (#19362) 2025-05-26 20:20:25 +00:00
mesh Skip allocation of zero size meshes (#19938) 2025-07-07 02:32:51 +00:00
render_graph Split bevy_camera out of bevy_render (#19949) 2025-07-04 23:31:16 +00:00
render_phase Split bevy_camera out of bevy_render (#19949) 2025-07-04 23:31:16 +00:00
render_resource spec_v2: minor revisions (#19923) 2025-07-03 17:49:04 +00:00
renderer Fix adapter forcing breaking wasm builds (#20054) 2025-07-11 12:18:23 +00:00
texture Split bevy_camera out of bevy_render (#19949) 2025-07-04 23:31:16 +00:00
view Split bevy_camera out of bevy_render (#19949) 2025-07-04 23:31:16 +00:00
alpha.rs
bindless.wgsl Ugrade to wgpu version 25.0 (#19563) 2025-06-26 19:41:47 +00:00
camera.rs Fixing a crash when minimizing a window with custom viewport. (#16704) (#18916) 2025-07-14 20:11:55 +00:00
color_operations.wgsl
erased_render_asset.rs Type erased materials (#19667) 2025-06-27 22:57:24 +00:00
extract_component.rs Split bevy_camera out of bevy_render (#19949) 2025-07-04 23:31:16 +00:00
extract_impls.rs bevy_light (#19991) 2025-07-07 00:07:38 +00:00
extract_instances.rs Split bevy_camera out of bevy_render (#19949) 2025-07-04 23:31:16 +00:00
extract_param.rs Stop storing access for all systems (#19477) 2025-06-13 17:56:09 +00:00
extract_resource.rs
globals.rs Remove Shader weak_handles from bevy_render. (#19362) 2025-05-26 20:20:25 +00:00
globals.wgsl
gpu_component_array_buffer.rs Adopt consistent FooSystems naming convention for system sets (#18900) 2025-05-06 15:18:03 +00:00
gpu_readback.rs GpuReadbackPlugin: Allow reading only a part of a buffer (#20133) 2025-07-14 21:01:16 +00:00
lib.rs make optional crates for mesh, camera, and light (#19997) 2025-07-07 07:35:32 +00:00
maths.wgsl Factor out up-choice in shadow cubemap sampling orthonormalize (#20052) 2025-07-11 12:19:02 +00:00
pipelined_rendering.rs Rename send_event and similar methods to write_event (#20017) 2025-07-07 22:05:16 +00:00
render_asset.rs Type erased materials (#19667) 2025-06-27 22:57:24 +00:00
settings.rs Add options for selecting adapter by name and forcing fallback (#19921) 2025-07-03 22:26:34 +00:00
storage.rs Allow images to be resized on the GPU without losing data (#19462) 2025-06-24 06:22:50 +00:00
sync_component.rs
sync_world.rs Remove 's lifetime from WorldQuery::Fetch (#19720) 2025-06-19 00:58:21 +00:00