pub struct RenderAttachments {
color_view: Option<TextureView>,
depth_stencil_view: Option<TextureView>,
msaa_view: Option<TextureView>,
}Expand description
The attachments a frame renders into.
Every view is caller-owned; the set allocates nothing. Build one with
Self::from_views.
Fields§
§color_view: Option<TextureView>The color attachment, or None for a depth-only pass.
depth_stencil_view: Option<TextureView>The depth attachment, or None for a pass without depth.
msaa_view: Option<TextureView>The multisample attachment the pass draws into, resolved into
Self::color_view; None when multisampling is disabled or the
pass is depth-only.
Implementations§
Source§impl RenderAttachments
impl RenderAttachments
Sourcepub fn from_views(
color_view: Option<TextureView>,
depth_stencil_view: Option<TextureView>,
msaa_view: Option<TextureView>,
) -> Self
pub fn from_views( color_view: Option<TextureView>, depth_stencil_view: Option<TextureView>, msaa_view: Option<TextureView>, ) -> Self
Assemble an attachment set entirely from the caller’s views: the color view, the depth-stencil view and an optional multisample view.
A TextureView carries the format it was created with, so the color
format is the color view’s own even when it reinterprets its texture —
an sRGB view over a non-sRGB swap-chain image, the only way to get
correct gamma on the web. Size and sample count are read from the views
themselves, so they must agree across views (the caller’s
responsibility).
The depth attachment’s transience is read from its texture’s usage: a
depth texture created with
TextureUsages::TRANSIENT_ATTACHMENT
is treated as transient (cleared and discarded within a single pass),
any other as persistent (a pass stores into it so a later pass may
sample the results).
msaa_view must be None for a non-multisampled pass; when Some, its
format and size must match the color view and its sample count must be
greater than one.
§Panics
If neither the color nor the depth view is present, or if the multisample view is present without a color view.
Sourcepub fn color_view(&self) -> Option<&TextureView>
pub fn color_view(&self) -> Option<&TextureView>
The color attachment, or None for a depth-only pass.
Sourcepub fn msaa_view(&self) -> Option<&TextureView>
pub fn msaa_view(&self) -> Option<&TextureView>
The multisample attachment, if any.
Sourcepub fn color_format(&self) -> Option<TextureFormat>
pub fn color_format(&self) -> Option<TextureFormat>
The color format the pass renders into, or None for a depth-only
pass.
The color view’s own — the MSAA view’s when one is set, since the resolve writes into the color view in that view’s format.
Sourcepub fn depth_stencil_format(&self) -> Option<TextureFormat>
pub fn depth_stencil_format(&self) -> Option<TextureFormat>
The depth format the pass renders into, or None for a pass without
depth.
Sourcepub fn sample_count(&self) -> u32
pub fn sample_count(&self) -> u32
The sample count the pass renders with: the MSAA attachment’s when one
is set, 1 otherwise.
Sourcepub fn surface_key(&self) -> SurfaceKey
pub fn surface_key(&self) -> SurfaceKey
The SurfaceKey of the attachments this set owns: their color format, depth format and sample count.
The color format and sample count come from
Self::color_format and Self::sample_count, so they always
describe the same attachment.
Sourcepub fn width(&self) -> u32
pub fn width(&self) -> u32
The width of the attachments, in pixels.
Taken from whichever attachment is present; they must agree.
Sourcepub fn height(&self) -> u32
pub fn height(&self) -> u32
The height of the attachments, in pixels.
Taken from whichever attachment is present; they must agree.
Sourcefn attachment_view(&self) -> Option<&TextureView>
fn attachment_view(&self) -> Option<&TextureView>
The view the attachment dimensions are read from: the MSAA view when one is set, the color view otherwise, the depth view last.
Sourcefn depth_is_transient(&self) -> bool
fn depth_is_transient(&self) -> bool
Whether the depth attachment is transient — created with
TextureUsages::TRANSIENT_ATTACHMENT
— and so only accepts Clear + Discard within a single pass. false
when there is no depth attachment.
Sourcepub fn begin_pass<'a>(
&'a self,
encoder: &'a mut CommandEncoder,
color_load: LoadOp<Color>,
depth_load: LoadOp<f32>,
stencil_load: LoadOp<u32>,
) -> RenderPass<'a>
pub fn begin_pass<'a>( &'a self, encoder: &'a mut CommandEncoder, color_load: LoadOp<Color>, depth_load: LoadOp<f32>, stencil_load: LoadOp<u32>, ) -> RenderPass<'a>
Begin a render pass over the attachments.
Each *_load value is the load op of its attachment:
wgpu::LoadOp::Clear(value) clears it to value,
[wgpu::LoadOp::Load] keeps its previous contents. The color
attachment discards on store with MSAA (the resolve carries the pixels
into the color view) and stores without it (the color view is the
attachment). The depth attachment discards after a clear and stores
after a load: a transient depth texture (see
depth_is_transient) only accepts Clear + Discard, while a
persistent depth texture — a shadow map, a preprocessed depth buffer —
keeps the results for a later pass to sample. The stencil aspect
follows the same rules (the renderer never writes it, so Clear
clears it and Load leaves a persistent buffer’s contents alone).
§Panics
If the attachment set has no attachments, if a clear value is given without the matching attachment, or if an existing attachment is given no op.
Auto Trait Implementations§
impl !RefUnwindSafe for RenderAttachments
impl !UnwindSafe for RenderAttachments
impl Forget for RenderAttachments
impl Freeze for RenderAttachments
impl Send for RenderAttachments
impl Sync for RenderAttachments
impl Unpin for RenderAttachments
impl UnsafeUnpin for RenderAttachments
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more