pub struct DepthAttachment { /* private fields */ }Expand description
The engine’s depth attachment across frames: an owned texture when the caller supplies none, plus the caller’s pre-cleared statement.
Implementations§
Source§impl DepthAttachment
impl DepthAttachment
Sourcepub fn set_pre_cleared(&mut self, pre_cleared: bool)
pub fn set_pre_cleared(&mut self, pre_cleared: bool)
Records whether the attachment a caller supplies already holds the depth it wants tested against, in which case the frame loads it instead of clearing it.
Sticky across frames: a host compositing 2D over 3D does so every frame, so it states this once rather than per frame.
It is a statement about ordering, not about the buffer’s contents: it
is true when the caller’s own pass ran first in the encoder and the
frame must test against what that pass left, and false when the frame
runs first and the caller’s pass loads the depth the frame establishes.
Sourcepub fn is_pre_cleared(&self) -> bool
pub fn is_pre_cleared(&self) -> bool
Whether a caller-supplied attachment is treated as pre-cleared.
Sourcepub fn load_op(&self, caller_supplied: bool) -> LoadOp<f32>
pub fn load_op(&self, caller_supplied: bool) -> LoadOp<f32>
The load operation this frame’s depth clear resolves to.
Only a caller-supplied attachment can be pre-cleared — an engine-owned one holds nothing but the previous frame’s depth, which is never what this frame wants to test against.
Sourcepub fn owned(&self) -> Option<&DepthTexture>
pub fn owned(&self) -> Option<&DepthTexture>
The engine-owned attachment, if one has been allocated.
Sourcepub fn owned_view(&self) -> Option<&TextureView>
pub fn owned_view(&self) -> Option<&TextureView>
The engine-owned attachment’s view, if one has been allocated.
Sourcepub fn ensure(
&mut self,
device: &Device,
width: u32,
height: u32,
) -> &TextureView
pub fn ensure( &mut self, device: &Device, width: u32, height: u32, ) -> &TextureView
Allocates the engine-owned attachment if there is none at this extent, and returns its view.
Sourcepub fn discard(&mut self)
pub fn discard(&mut self)
Drops the engine-owned attachment, keeping the pre-cleared statement.
Sourcepub fn resize(&mut self, device: &Device, width: u32, height: u32)
pub fn resize(&mut self, device: &Device, width: u32, height: u32)
Re-establishes the engine-owned attachment at a new extent.
Only reallocates when one was already owned: a renderer that has never needed a depth buffer should not start holding one because the surface changed size. Doing the work here rather than on the next frame keeps the reallocation off the frame path, where a resize storm would otherwise pay for it mid-encode.