pub struct GlobalLayoutPool { /* private fields */ }Expand description
A named pool of bind group layouts shared across materials/compute passes — register a
layout once (e.g. a camera’s, under "camera") as soon as it exists, then anywhere a
material/compute wants it, pull it with get and wrap it in
GroupEntry::Layout at whatever position that material/compute’s shader declares it.
WGPUPlugin inserts an empty pool as a resource, so it’s
always there from the start — grab it with Res<GlobalLayoutPool>/
ResMut<GlobalLayoutPool> rather than constructing your own; a LazyResource that builds a
shared layout (a camera, lights, …) registers it into that same pool from its own
construct (or a follow-up system, once it has ResMut<GlobalLayoutPool> alongside it) —
there’s no separate “finished pool” step, entries just accumulate as their sources become
ready.
Implementations§
Source§impl GlobalLayoutPool
impl GlobalLayoutPool
pub fn new() -> Self
Sourcepub fn register(&mut self, name: &'static str, layout: BindGroupLayout)
pub fn register(&mut self, name: &'static str, layout: BindGroupLayout)
Register layout under name. Panics if name is already registered — almost always
two sources registering under the same name by mistake, not an intentional overwrite.
Sourcepub fn get(&self, name: &str) -> Option<BindGroupLayout>
pub fn get(&self, name: &str) -> Option<BindGroupLayout>
The layout registered under name, if any — clone it into a GroupEntry::Layout at
whatever position your shader declares it. None if nothing has registered under that
name (yet, or ever — a typo’d name and “not built yet” look the same from here, so
callers with a hard requirement on a given global should treat a miss as “not ready”
the same way any other Option-returning lookup in this engine does). Reach for
GroupEntry::Global instead of calling this directly wherever possible — it defers
this same lookup to upload time, so name doesn’t need to be registered yet at the
point a material/compute is described.
Trait Implementations§
Source§impl Default for GlobalLayoutPool
impl Default for GlobalLayoutPool
Source§fn default() -> GlobalLayoutPool
fn default() -> GlobalLayoutPool
Auto Trait Implementations§
impl !RefUnwindSafe for GlobalLayoutPool
impl !UnwindSafe for GlobalLayoutPool
impl Freeze for GlobalLayoutPool
impl Send for GlobalLayoutPool
impl Sync for GlobalLayoutPool
impl Unpin for GlobalLayoutPool
impl UnsafeUnpin for GlobalLayoutPool
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> Component for T
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.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().