pub struct Rgba8Readback { /* private fields */ }Expand description
A submitted texture readback whose buffer has not been mapped yet.
Owns its staging buffer, so it can move into an async browser task.
Implementations§
Source§impl Rgba8Readback
impl Rgba8Readback
Sourcepub const fn size(&self) -> RenderSize
pub const fn size(&self) -> RenderSize
The pixel dimensions of the result.
Sourcepub const fn staging_bytes(&self) -> u64
pub const fn staging_bytes(&self) -> u64
Bytes held by the staging buffer.
Sourcepub fn wait_ready(&self) -> Result<(), RenderError>
pub fn wait_ready(&self) -> Result<(), RenderError>
Blocks a native caller until this readback is mapped, without draining the whole queue.
§Errors
RenderError::TextureReadback when mapping or device polling fails.
Sourcepub fn wait(self) -> Result<Vec<u8>, RenderError>
pub fn wait(self) -> Result<Vec<u8>, RenderError>
Waits for this readback and returns tightly packed RGBA8 pixels.
§Errors
RenderError::TextureReadback when mapping, polling or row packing fails.
Sourcepub fn map_async(
&self,
on_ready: impl FnOnce(Result<(), RenderError>) + Send + 'static,
)
pub fn map_async( &self, on_ready: impl FnOnce(Result<(), RenderError>) + Send + 'static, )
Requests buffer mapping and reports readiness exactly once.
A refused or repeated request reports a failure, which callers must treat as a failed frame.
Sourcepub fn poll(&self)
pub fn poll(&self)
Polls backends that need it to resolve a mapping; browser WebGPU ignores this.
Sourcepub fn finish(self) -> Result<Vec<u8>, RenderError>
pub fn finish(self) -> Result<Vec<u8>, RenderError>
Packs the mapped rows into tightly packed premultiplied RGBA8.
§Errors
RenderError::TextureReadback when the buffer is not mapped, and
RenderError::GpuWorkDropped when the GPU did not run the copy; the buffer is then not
recycled and the renderer refuses further work.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Rgba8Readback
impl !RefUnwindSafe for Rgba8Readback
impl !UnwindSafe for Rgba8Readback
impl Send for Rgba8Readback
impl Sync for Rgba8Readback
impl Unpin for Rgba8Readback
impl UnsafeUnpin for Rgba8Readback
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more