Skip to main content

readback_buffer

Function readback_buffer 

Source
pub fn readback_buffer(
    device: &Device,
    queue: &Queue,
    source: &Buffer,
    offset: u64,
    size: u64,
) -> Vec<u8> ⓘ
Expand description

Copy size bytes of source, starting at offset, back to the host.

The bytes are copied into a staging buffer and mapped, so the call blocks until the copy has run. offset and size are the same pair [wgpu::CommandEncoder::copy_buffer_to_buffer] takes, and must satisfy the same alignment: a multiple of [wgpu::COPY_BUFFER_ALIGNMENT] each, and within source.

§Panics

If the copy is misaligned or out of range, if the device poll fails, or if the buffer cannot be mapped.