Skip to main content

LazyPool

Struct LazyPool 

Source
pub struct LazyPool {
    pub device: Device,
    pub info: PoolConfig,
    /* private fields */
}
Expand description

A balanced resource allocator.

The information for each resource request is compared against the stored resources for compatibility. If no acceptable resources are stored for the information provided a new resource is created and returned.

§Details

  • Acceleration structures may be larger than requested
  • Buffers may be larger than requested or have additional usage flags
  • Images may have additional usage flags

§Bucket Strategy

The information for each resource request is the key for a HashMap of buckets. If no bucket exists with compatible information a new bucket is created.

In practice this means that for a PoolConfig::image_capacity of 4, requests for a 1024x1024 image with certain attributes will store a maximum of 4 such images. Requests for any image having a different size or incompatible attributes will store an additional maximum of 4 images.

§Memory Management

If requests for varying resources are common LazyPool::clear_images_by_info and other memory management functions are necessary in order to avoid using all available device memory.

Fields§

§device: Device

The device which owns this pool.

Note: This field is read-only.

§info: PoolConfig

Information used to create this pool.

Note: This field is read-only.

Implementations§

Source§

impl LazyPool

Source

pub fn new(device: &Device) -> Self

Constructs a new LazyPool.

Source

pub fn with_capacity(device: &Device, info: impl Into<PoolConfig>) -> Self

Constructs a new LazyPool with the given capacity information.

Source

pub fn clear(&mut self)

Clears the pool, removing all resources.

Source

pub fn clear_accel_structs(&mut self)

Clears the pool of acceleration structure resources.

Source

pub fn clear_accel_structs_by_type( &mut self, accel_struct_ty: AccelerationStructureTypeKHR, )

Clears the pool of all acceleration structure resources matching the given type.

Source

pub fn clear_buffers(&mut self)

Clears the pool of buffer resources.

Source

pub fn clear_images(&mut self)

Clears the pool of image resources.

Source

pub fn clear_images_by_info(&mut self, info: impl Into<ImageInfo>)

Clears the pool of image resources matching the given information.

Source

pub fn retain_accel_structs<F>(&mut self, f: F)

Retains only the acceleration structure resources specified by the predicate.

In other words, remove all resources for which f(vk::AccelerationStructureTypeKHR) returns false.

The elements are visited in unsorted (and unspecified) order.

§Performance

Provides the same performance guarantees as HashMap::retain.

Trait Implementations§

Source§

impl Debug for LazyPool

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Pool<AccelerationStructureInfo, AccelerationStructure> for LazyPool

Source§

impl Pool<BufferInfo, Buffer> for LazyPool

Source§

fn resource(&mut self, info: BufferInfo) -> Result<Lease<Buffer>, DriverError>

Request a resource.
Source§

impl Pool<CommandBufferInfo, CommandBuffer> for LazyPool

Source§

fn resource( &mut self, info: CommandBufferInfo, ) -> Result<Lease<CommandBuffer>, DriverError>

Request a resource.
Source§

impl Pool<ImageInfo, Image> for LazyPool

Source§

fn resource(&mut self, info: ImageInfo) -> Result<Lease<Image>, DriverError>

Request a resource.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pool<AccelerationStructureInfoBuilder, AccelerationStructure> for T

Source§

impl<T> Pool<BufferInfoBuilder, Buffer> for T
where T: Pool<BufferInfo, Buffer>,

Source§

fn resource( &mut self, builder: BufferInfoBuilder, ) -> Result<Lease<Buffer>, DriverError>

Request a resource.
Source§

impl<T> Pool<ImageInfoBuilder, Image> for T
where T: Pool<ImageInfo, Image>,

Source§

fn resource( &mut self, builder: ImageInfoBuilder, ) -> Result<Lease<Image>, DriverError>

Request a resource.
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> SubmissionPool for T
where T: SubmissionPoolSealed,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.