Expand description
Copying GPU resources back to the host.
A readback is the one GPU operation that produces something on the CPU:
render a frame into a texture, or fill a buffer, then copy it into a
MAP_READ buffer and map it. The two functions here do that in one
blocking call each, so a caller that wants to inspect a frame — a test, a
screenshot, a debug tool — does not have to write the staging dance.
Both are deliberately low-level: they take the wgpu handles and return raw bytes, with no opinion about what the bytes mean. Decoding them into an image, a vertex stream or anything else is the caller’s.
§Blocking
Both calls submit the copy, poll the device to completion and map the staging buffer, so they block until the GPU has finished. That is what a readback is for: the bytes cannot exist before then. A frame loop should only call one where it actually needs the pixels.
Re-exports§
use ringbuf::StaticRb;🔒use ringbuf::traits::Consumer;🔒use ringbuf::traits::Producer;🔒use ringbuf::traits::Split;🔒
Functions§
- readback_
buffer - Copy
sizebytes ofsource, starting atoffset, back to the host. - readback_
texture - Copy
textureback to the host as tight rows.