pub struct DepthComposite { /* private fields */ }Expand description
Viewport-owned offscreen scene target + depth buffer + blit pipeline.
Created through DepthComposite::ensure (per viewport id), drawn into
with DepthComposite::begin_scene, composited back with
DepthComposite::blit. Textures recreate on format/sample/size
change; buffer contents are per-frame and never retained.
Implementations§
Source§impl DepthComposite
impl DepthComposite
Sourcepub fn get(resources: &mut CallbackResources) -> &mut Self
pub fn get(resources: &mut CallbackResources) -> &mut Self
Fetch the composite store from callback resources (creating it on first use). One store per render pass; ids disambiguate viewports.
pub fn begin_frame(&mut self)
pub fn end_frame(&mut self)
Sourcepub fn ensure(
&mut self,
device: &Device,
screen: &ScreenDescriptor,
id: &str,
w: u32,
h: u32,
) -> Result<()>
pub fn ensure( &mut self, device: &Device, screen: &ScreenDescriptor, id: &str, w: u32, h: u32, ) -> Result<()>
Ensure the offscreen target for id at wxh (recreates on
format/sample/size change, like every other viewport-owned target).
Dimensions clamp to >= 1. Errors name the reason the target could
not be allocated; the other viewports are left untouched.
Sourcepub fn begin_scene<'a>(
&'a self,
id: &str,
encoder: &'a mut CommandEncoder,
clear: [f32; 4],
) -> Option<RenderPass<'a>>
pub fn begin_scene<'a>( &'a self, id: &str, encoder: &'a mut CommandEncoder, clear: [f32; 4], ) -> Option<RenderPass<'a>>
Begin the offscreen scene pass for id (clearing color to clear
and depth to 1.0). The caller issues its depth-tested draws inside
the returned pass, then ends it; blit composites in
paint. Returns false when id has no target (call ensure first).
The depth and stencil attachments are discarded when the pass ends:
blit only samples the color target, so nothing in
this crate reads them afterwards. A caller that needs the depth
buffer afterwards must keep its own copy.
clear uses straight (un-premultiplied) alpha, which the blit
premultiplies before compositing.
Sourcepub fn depth_format(&self, id: &str) -> Option<TextureFormat>
pub fn depth_format(&self, id: &str) -> Option<TextureFormat>
Depth format backing the scene target (for caller pipelines).
Sourcepub fn blit<P: BlitRenderPass>(&self, id: &str, rpass: &mut P)
pub fn blit<P: BlitRenderPass>(&self, id: &str, rpass: &mut P)
Composite the offscreen scene for id into the main pass. The
renderer has already set the viewport to the callback rect, which
matches the offscreen texture 1:1 (both come from the painted frame
geometry). Composites over the UI already drawn this frame, so a
transparent scene keeps it visible. No-op when id has no target.
pub fn blit_callback(&self, id: &str, rpass: &mut CallbackRenderPass<'_, '_>)
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for DepthComposite
impl !UnwindSafe for DepthComposite
impl Freeze for DepthComposite
impl Send for DepthComposite
impl Sync for DepthComposite
impl Unpin for DepthComposite
impl UnsafeUnpin for DepthComposite
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.