Expand description

Resource leasing and pooling types.

Screen 13 provides caching for acceleration structure, buffer, and image resources which may be leased from configurable pools using their corresponding information structure. Most programs will do fine with a single LazyPool.

Leased resources may be bound directly to a render graph and used in the same manner as regular resources. After rendering has finished, the leased resources will return to the pool for reuse.

Examples

Leasing an image:

let mut pool = LazyPool::new(&device);

let info = ImageInfo::new_2d(vk::Format::R8G8B8A8_UNORM, 8, 8, vk::ImageUsageFlags::STORAGE);
let my_image = pool.lease(info)?;

assert!(my_image.info.usage.contains(vk::ImageUsageFlags::STORAGE));

When Should You Use Which Pool?

These are fairly high-level break-downs of when each pool should be considered. You may need to investigate each type of pool individually or write your own implementation to provide the absolute best fit for your purpose.

Use a LazyPool when:

  • Memory usage is most important
  • Resources have different attributes each frame

Use a HashPool when:

  • Processor usage is most important
  • Resources have consistent attributes each frame

Modules

Pool which leases by exactly matching the information before creating new resources.
Pool which leases by looking for compatibile information before creating new resources.

Structs

Holds a leased resource and implements Drop in order to return the resource.

Traits

Allows leasing of resources using driver information structures.