Skip to main content

FrameReader

Struct FrameReader 

Source
pub struct FrameReader { /* private fields */ }
Expand description

Ring of staging buffers reading back a width x height target with 4 bytes per texel (Rgba8Unorm, Bgra8Unorm, …). Make a new one when the size changes.

Implementations§

Source§

impl FrameReader

Source

pub fn new(device: &Device, width: u32, height: u32, depth: usize) -> Self

A reader with depth staging buffers (at least 1; 3 keeps the GPU busy without dropping frames at a steady frame rate).

Source

pub fn width(&self) -> u32

Source

pub fn height(&self) -> u32

Source

pub fn frame_len(&self) -> usize

Bytes one frame takes in the output of the read functions: tightly packed rows, row 0 on top.

Source

pub fn copy(&mut self, encoder: &mut CommandEncoder, texture: &Texture) -> bool

Record a copy of texture (the reader’s size) into a free staging buffer. A finished frame nobody read yet is given up for it, the oldest first. Returns false, recording nothing, when every buffer still waits for the GPU: the frame is then not captured. Call Self::submitted once encoder has been submitted.

Source

pub fn submitted(&mut self)

Request the mapping of the buffers Self::copy recorded into. Call after submitting the encoder holding those copies.

Source

pub fn read_latest( &mut self, device: &Device, out: &mut [u8], ) -> Result<bool, String>

Write the newest frame the GPU has finished into out (at least Self::frame_len bytes) without waiting. Ok(false) when no new frame is ready since the last read. Older finished frames are dropped. A failed map is reported once; the buffer is reused afterwards.

Source

pub fn read_blocking( &mut self, device: &Device, out: &mut [u8], ) -> Result<bool, String>

Wait for every submitted copy, then write the newest frame into out like Self::read_latest. Ok(false) only when nothing was copied since the last read.

Auto Trait Implementations§

§

impl !RefUnwindSafe for FrameReader

§

impl !UnwindSafe for FrameReader

§

impl Forget for FrameReader

§

impl Freeze for FrameReader
where *const u8 is !null: Freeze, PhantomData<Slot>: Freeze,

§

impl Move for FrameReader

§

impl Send for FrameReader
where RawVecInner: Send, DispatchBuffer: Send, Arc<Mutex<RawMutex, MapContext>>: Send, Arc<Atomic<u8>>: Send,

§

impl Sync for FrameReader
where RawVecInner: Sync, DispatchBuffer: Sync, Arc<Mutex<RawMutex, MapContext>>: Sync, Arc<Atomic<u8>>: Sync,

§

impl Unpin for FrameReader
where *const u8 is !null: Unpin, Arc<Buffer>: Unpin, Arc<Mutex<RawMutex, MapContext>>: Unpin, Arc<Atomic<u8>>: Unpin,

§

impl UnsafeUnpin for FrameReader
where *const u8 is !null: UnsafeUnpin, PhantomData<Slot>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,