pub struct Scene {
pub draws: Vec<DrawEntry>,
pub viewport: Option<ViewportRect>,
}Expand description
A frame’s worth of draws.
The order of DrawEntrys is the order they are recorded in. Recording
compares every set_* against the state the previous draw left behind, so
consecutive draws that share a pipeline or bind group skip the redundant
call: ordering draws by pipeline, and then so that neighbours share their
bind groups, minimizes state changes without changing what is drawn. A
caller is also free to order the draws for opaque-then-transparent
compositing, which is a correctness requirement rather than a performance
one; across scenes, DrawOrder and Scene::record_composited
take that job over.
Fields§
§draws: Vec<DrawEntry>The draws to run, in order.
viewport: Option<ViewportRect>The region of the target every draw is recorded into, or None to
leave the pass’s own viewport alone.
Whole-scene state rather than per-draw: wgpu’s viewport has no reset call, so a scene that letterboxes itself states one here and a scene that draws full-target states none.
Implementations§
Source§impl Scene
impl Scene
Sourcefn resolved_viewport(
&self,
fallback: Option<ViewportRect>,
) -> Option<ViewportRect>
fn resolved_viewport( &self, fallback: Option<ViewportRect>, ) -> Option<ViewportRect>
The region the scene records into when fallback may stand in for the
viewport the scene itself states.
Split out from Scene::record so the choice is testable without a
render pass: the recording needs a real one, and which region a scene
ends up with is the rule that matters.
Sourcepub fn record(&self, pass: &mut RenderPass<'_>, fallback: Option<ViewportRect>)
pub fn record(&self, pass: &mut RenderPass<'_>, fallback: Option<ViewportRect>)
Record the scene into pass, drawing into fallback when the scene
states no viewport of its own.
wgpu has no call that resets a viewport, so a caller recording several
scenes into one pass has to pass the whole target as fallback: a scene
that states none would otherwise inherit the region the previous scene
set. None leaves the pass’s region exactly as it is, for a caller that
set one itself.
Sourcepub fn record_composited(
pass: &mut RenderPass<'_>,
scenes: &[&Scene],
fallback: Option<ViewportRect>,
)
pub fn record_composited( pass: &mut RenderPass<'_>, scenes: &[&Scene], fallback: Option<ViewportRect>, )
Record the draws of several scenes into pass as one composite,
drawing into fallback where a scene states no viewport of its own.
The scenes’ draws are grouped by their DrawOrder rather than kept
in scene order: the sequenced ones of every scene first, then the
depth-sorted ones of every scene pooled together back-to-front, then
the trailing ones. The pool spanning scenes is what lets blended
geometry from one source composite by depth against another’s, instead
of by which scene recorded first. A scene whose draws state no order
keeps its place, so a caller that never tags a draw sees the frame
Scene::record would have given.
Every draw draws into the region its own scene resolves to — the
scene’s Scene::viewport or fallback — so the pool interleaving
scenes never moves a draw out of its scene’s letterbox; the
deduplicated set_* recording keeps the repeated regions from
repeating the calls.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Scene
impl !UnwindSafe for Scene
impl Forget for Scene
impl Freeze for Scene
impl Send for Scene
impl Sync for Scene
impl Unpin for Scene
impl UnsafeUnpin for Scene
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§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