Struct nannou::wgpu::TextureCapturer
source · pub struct TextureCapturer { /* private fields */ }
Expand description
A type dedicated to capturing a texture as a non-linear sRGBA image that can be read on the CPU.
Calling capture will return a Snapshot that may be read after the given command encoder has been submitted. Snapshots can be read on the current thread via read or on a thread pool via read_threaded.
If the Capturer is dropped while threaded callbacks are still being processed, the drop implementation will block the current thread.
Implementations§
source§impl Capturer
impl Capturer
sourcepub const DST_FORMAT: TextureFormat = wgpu::TextureFormat::Rgba8UnormSrgb
pub const DST_FORMAT: TextureFormat = wgpu::TextureFormat::Rgba8UnormSrgb
The format to which textures will be converted before being mapped back to the CPU.
sourcepub fn new(workers: Option<u32>, timeout: Option<Duration>) -> Capturer
pub fn new(workers: Option<u32>, timeout: Option<Duration>) -> Capturer
Create a new TextureCapturer.
Note that a TextureCapturer must only be used with a single texture. If you require capturing multiple textures, you may create multiple TextureCapturers.
workers
refers to the number of worker threads used to await GPU buffers to be mapped for
reading and for running user callbacks. If None
is specified, a threadpool will be
spawned with a number of threads equal to the number of CPUs available on the system.
timeout
specifies how long to block and wait for an available worker in the case that all
workers are busy at the time a Snapshot::read
occurs. If None
is specified, calls to
Snapshot::read
will never time out (the default behaviour).
Note that the specified parameters are only relevant to calls to Snapshot::read
. In the
case that the user uses Snapshot::read_async
, it is the responsibility of the user to
execute the future.
sourcepub fn active_snapshots(&self) -> u32
pub fn active_snapshots(&self) -> u32
The number of futures currently running on the inner ThreadPool
.
Note that futures are only run on the threadpool when the Snapshot::read
method is used.
In the case that Snapshot::read_async
is used it is up to the user to track their
futures.
If the inner thread pool mutex has been poisoned, or if the thread pool has not been
created due to no calls to read
, this will return 0
.
sourcepub fn workers(&self) -> u32
pub fn workers(&self) -> u32
The number of worker threads used to await GPU buffers to be mapped for reading and for running user callbacks.
sourcepub fn capture(
&self,
device: &Device,
encoder: &mut CommandEncoder,
src_texture: &Texture
) -> Snapshot
pub fn capture( &self, device: &Device, encoder: &mut CommandEncoder, src_texture: &Texture ) -> Snapshot
Capture the given texture at the state of the given command encoder.
sourcepub fn await_active_snapshots(
&self,
device: &Device
) -> Result<(), AwaitWorkerTimeout<()>>
pub fn await_active_snapshots( &self, device: &Device ) -> Result<(), AwaitWorkerTimeout<()>>
Await for the completion of all Snapshot::read
active futures, polling the device as
necessary until all futures have reached completion or until a timeout is reached.
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for Capturer
impl Send for Capturer
impl Sync for Capturer
impl Unpin for Capturer
impl UnwindSafe for Capturer
Blanket Implementations§
source§impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<Swp, Dwp, T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<Swp, Dwp, T>,
source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
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
source§impl<T, U> ConvertInto<U> for Twhere
U: ConvertFrom<T>,
impl<T, U> ConvertInto<U> for Twhere
U: ConvertFrom<T>,
source§fn convert_into(self) -> U
fn convert_into(self) -> U
source§fn convert_unclamped_into(self) -> U
fn convert_unclamped_into(self) -> U
source§fn try_convert_into(self) -> Result<U, OutOfBounds<U>>
fn try_convert_into(self) -> Result<U, OutOfBounds<U>>
OutOfBounds
error is returned which contains the unclamped color. Read more