Skip to main content

Cache

Struct Cache 

Source
pub struct Cache<T, Tag = ()> { /* private fields */ }
Expand description

A memory-efficient resource cache for any Pool type.

Use Cache::tag to create a tag-scoped view that caches resources independently from other tags. Untagged access still behaves like the default cache wrapper.

§Examples

let mut shadow = cache.tag("shadow");
let image = shadow
    .resource(ImageInfo::image_2d(
        32,
        32,
        ash::vk::Format::R8G8B8A8_UNORM,
        ash::vk::ImageUsageFlags::SAMPLED,
    ))
    .unwrap();

Implementations§

Source§

impl<T, Tag> Cache<T, Tag>
where Tag: Eq + Hash,

Source

pub fn new(pool: T) -> Self

Creates a new cache wrapper over the given pool.

Source

pub fn tag(&mut self, tag: Tag) -> TaggedCache<'_, T, Tag>

Returns a tag-scoped cache view.

Source§

impl<T> Cache<T, ()>

Source

pub fn accel_struct( &mut self, info: AccelerationStructureInfo, ) -> Result<Arc<Lease<AccelerationStructure>>, DriverError>

Alias an acceleration structure using the default tag.

Source

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

Alias a buffer using the default tag.

Source

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

Alias an image using the default tag.

Trait Implementations§

Source§

impl<T, Tag> Deref for Cache<T, Tag>

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<T, Tag> DerefMut for Cache<T, Tag>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.

Auto Trait Implementations§

§

impl<T, Tag> Freeze for Cache<T, Tag>
where T: Freeze,

§

impl<T, Tag = ()> !RefUnwindSafe for Cache<T, Tag>

§

impl<T, Tag> Send for Cache<T, Tag>
where T: Send, Tag: Send,

§

impl<T, Tag> Sync for Cache<T, Tag>
where T: Sync, Tag: Sync,

§

impl<T, Tag> Unpin for Cache<T, Tag>
where T: Unpin, Tag: Unpin,

§

impl<T, Tag> UnsafeUnpin for Cache<T, Tag>
where T: UnsafeUnpin,

§

impl<T, Tag = ()> !UnwindSafe for Cache<T, Tag>

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<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<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, 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.