Skip to main content

BorrowedTarget

Struct BorrowedTarget 

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

Frames drawn into the host’s textures, each given back to the host.

Implementations§

Source§

impl BorrowedTarget

Source

pub fn new( backend: &RendererBackend, textures: BorrowedTextures, producer: SyncKind, ) -> Result<Self, Error>

A target on backend that draws into textures, which are of its device, and hands each frame to the host with sync of the kind producer, one of BorrowedTextures::sync_kinds’s.

Fails as BorrowedTextures::check does, and with ErrorKind::Unsupported for a producer kind the target can’t hand over.

Source

pub fn select(&mut self, slot: usize)

Has the next frame draw into the texture at slot.

Source

pub fn release( &mut self, _slot: usize, consumer: ConsumerSync, ) -> Result<(), Error>

The host gave the texture at slot back. The host’s reads went to the queue before the next frame does, or have finished.

Source

pub fn discard(&mut self, _slot: usize)

The host gave up the texture at slot, which is never drawn into again.

Source

pub fn replace( &mut self, gpu: &mut WebGpu, textures: BorrowedTextures, ) -> Result<GpuSync, Error>

Draws into textures from now on, which must be as many, of the ring’s format. Returns the sync after which the host may use the old textures, as release_textures does.

Fails with ErrorKind::InvalidArgument for another number of textures, with ErrorKind::Unsupported for another format, with ErrorKind::InvalidState once the target let go of its textures, as BorrowedTextures::check does, and as release_textures does. The target then keeps its textures.

Source

pub fn release_textures(&mut self, gpu: &mut WebGpu) -> Result<GpuSync, Error>

Lets go of the textures, and returns the sync after which the host may use them, of the producer’s kind. The target draws no frame after.

Fails with ErrorKind::InvalidState once the target let go of its textures, and with ErrorKind::Native when it can’t submit its work, or wait for it for SyncKind::CpuComplete. It keeps its textures then.

Trait Implementations§

Source§

impl FrameTarget for BorrowedTarget

Source§

fn tear_down(&mut self, gpu: &mut WebGpu)

Forgets the textures of a frame begun and not ended.

Source§

type Gpu = WebGpu

The Gpu of the target’s backend, whose textures the target’s frames are.
Source§

fn begin_frame(&mut self, gpu: &mut WebGpu) -> Option<FrameImage>

Begins a frame, and returns the textures of gpu that the renderer draws it into, or None when the target has nothing to draw into now: it has no surface, or the surface is hidden or out of date. The caller then skips the frame. Until end_frame, each call returns the same image, so a caller may begin a frame and leave it for the next one.
Source§

fn end_frame(&mut self, gpu: &mut WebGpu) -> Handoff

Hands the frame’s image off, once the renderer has submitted the frame’s passes to gpu.
Source§

fn resize(&mut self, gpu: &mut Self::Gpu, size: Size)

Draws the next frames at size physical pixels. A target whose textures the host or the target’s owner sizes ignores it.

Auto Trait Implementations§

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,