pub struct GpuBindGroupPool {
pool: DynamicResourcePool<GpuBindGroupHandle, BindGroupDesc, BindGroup>,
}
Expand description
Resource pool for bind groups.
Implementation notes: Requirements regarding ownership & resource lifetime:
- owned [
wgpu::BindGroup
] should keep buffer/texture alive (user should not need to hold buffer/texture manually) GpuBindGroupPool
should try to re-use previously created bind groups if they happen to match- mustn’t prevent buffer/texture re-use on next frame
i.e. a internally cached
GpuBindGroupPool
s without owner shouldn’t keep textures/buffers alive
We satisfy these by retrieving the “weak” buffer/texture handles and make them part of the GpuBindGroup
.
Internally, the GpuBindGroupPool
does not hold any strong reference to any resource,
i.e. it does not interfere with the ownership tracking of buffer/texture pools.
The question whether a bind groups happen to be re-usable becomes again a simple question of matching
bind group descs which itself does not contain any ref counted objects!
Fields§
§pool: DynamicResourcePool<GpuBindGroupHandle, BindGroupDesc, BindGroup>
Implementations§
source§impl GpuBindGroupPool
impl GpuBindGroupPool
sourcepub fn alloc(
&self,
device: &Device,
pools: &WgpuResourcePools,
desc: &BindGroupDesc
) -> GpuBindGroup
pub fn alloc( &self, device: &Device, pools: &WgpuResourcePools, desc: &BindGroupDesc ) -> GpuBindGroup
Returns a reference-counted, currently unused bind-group. Once ownership to the handle is given up, the bind group may be reclaimed in future frames. The handle also keeps alive any dependent resources.
pub fn begin_frame( &mut self, frame_index: u64, _textures: &mut GpuTexturePool, _buffers: &mut GpuBufferPool, _samplers: &mut GpuSamplerPool )
pub fn num_resources(&self) -> usize
Trait Implementations§
source§impl Default for GpuBindGroupPool
impl Default for GpuBindGroupPool
source§fn default() -> GpuBindGroupPool
fn default() -> GpuBindGroupPool
Auto Trait Implementations§
impl !Freeze for GpuBindGroupPool
impl !RefUnwindSafe for GpuBindGroupPool
impl Send for GpuBindGroupPool
impl Sync for GpuBindGroupPool
impl Unpin for GpuBindGroupPool
impl !UnwindSafe for GpuBindGroupPool
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<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§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
.§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
.§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.§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.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§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