compute.readback¶
Summary¶
compute.readback is the compute service's shared staging ring for asynchronous GPU-to-CPU copies. Use typed reads for results you want to keep, or a snapshot callback to consume bytes while a staging buffer is mapped.
Syntax¶
readonly Compute.readback: ReadbackRing
const values = await wgpu.compute.readback.readF32(storage, 0, 2);
Available APIs¶
- read, readAs, readF32 and readU32 return caller-owned copies.
- readScalarF32 and readScalarU32 read one value at a byte offset.
- snapshot gives a callback access to temporary mapped bytes.
- readIntoWasmMemory copies into a caller-provided WebAssembly memory range.
Notes¶
GPU copies use a source with COPY_SRC usage on the compute device. Submit commands that produce the values before invoking a read. The readback copy follows them on the queue. Leave the shared ring alive while the compute service is in use and let the service destroy it during teardown. Create a separate ring for caller-managed staging.