pub struct BorrowedTarget { /* private fields */ }Expand description
Frames drawn into the host’s textures, each given back to the host.
Implementations§
Source§impl BorrowedTarget
impl BorrowedTarget
Sourcepub fn new(
backend: &RendererBackend,
textures: BorrowedTextures,
producer: SyncKind,
) -> Result<Self, Error>
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.
Sourcepub fn release(
&mut self,
_slot: usize,
consumer: ConsumerSync,
) -> Result<(), Error>
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.
Sourcepub fn discard(&mut self, _slot: usize)
pub fn discard(&mut self, _slot: usize)
The host gave up the texture at slot, which is never drawn into
again.
Sourcepub fn replace(
&mut self,
gpu: &mut WebGpu,
textures: BorrowedTextures,
) -> Result<GpuSync, Error>
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.
Sourcepub fn release_textures(&mut self, gpu: &mut WebGpu) -> Result<GpuSync, Error>
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
impl FrameTarget for BorrowedTarget
Source§fn tear_down(&mut self, gpu: &mut WebGpu)
fn tear_down(&mut self, gpu: &mut WebGpu)
Forgets the textures of a frame begun and not ended.
Source§fn begin_frame(&mut self, gpu: &mut WebGpu) -> Option<FrameImage>
fn begin_frame(&mut self, gpu: &mut WebGpu) -> Option<FrameImage>
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.