pub trait Readback: Debug {
// Required methods
fn resolve(
&self,
offset: u64,
size: u64,
) -> impl Future<Output = Result<Vec<u8>, GpuError>> + '_;
fn resolve_into<'a>(
&'a self,
offset: u64,
size: u64,
output: &'a mut [u8],
) -> impl Future<Output = Result<(), GpuError>> + 'a;
}Expand description
A detached readback over one buffer.
The handle owns everything it needs to await a mapped range, so a caller can release every borrow of the renderer that submitted the copy before the wait begins. On the browser’s single JavaScript thread that is what lets a frame render while a pick is still resolving its readback.
Required Methods§
Sourcefn resolve(
&self,
offset: u64,
size: u64,
) -> impl Future<Output = Result<Vec<u8>, GpuError>> + '_
fn resolve( &self, offset: u64, size: u64, ) -> impl Future<Output = Result<Vec<u8>, GpuError>> + '_
Awaits the mapped range and returns its bytes.
§Errors
The device was lost, or the buffer was not readable.
Sourcefn resolve_into<'a>(
&'a self,
offset: u64,
size: u64,
output: &'a mut [u8],
) -> impl Future<Output = Result<(), GpuError>> + 'a
fn resolve_into<'a>( &'a self, offset: u64, size: u64, output: &'a mut [u8], ) -> impl Future<Output = Result<(), GpuError>> + 'a
Copies a mapped range into caller-owned scratch without allocating bytes.
Only the first size bytes are written; the remaining output is unchanged.
The future borrows this detached handle and the scratch, not the renderer.
§Errors
Returns device or mapping errors, or an invalid, unaligned, overflowing
range or output shorter than size, before writing any output.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".