NAP
Public Member Functions | List of all members
DescriptorSetCache Class Referencefinal

#include <descriptorsetcache.h>

Public Member Functions

 DescriptorSetCache (RenderService &renderService, VkDescriptorSetLayout layout, DescriptorSetAllocator &descriptorSetAllocator)
 
 ~DescriptorSetCache ()
 
const DescriptorSetacquire (const std::vector< UniformBufferObject > &uniformBufferObjects, int numStorageBufferObjects, int numSamplers)
 
void release (int frameIndex)
 

Description

Responsible for caching DescriptorSets and allocating them when the DescriptorSet is not in the cache. A DescriptorSetAllocator allocates DescriptorSets for a specific VkDescriptorSetLayout. Any DescriptorSet that is returned will be compatible with that VkDescriptorSetLayout.

Internally it will maintain a free-list of available DescriptorSets. When a VkDescriptorSet is acquired, it is marked for use by that frame (the current RenderService frame is used). When a frame is fully completed, release should be called for that frame so that the resources are return to the free-list, to be used by subsequent frames.

Constructor & Destructor Documentation

◆ DescriptorSetCache()

DescriptorSetCache ( RenderService renderService,
VkDescriptorSetLayout  layout,
DescriptorSetAllocator descriptorSetAllocator 
)

◆ ~DescriptorSetCache()

Member Function Documentation

◆ acquire()

const DescriptorSet& acquire ( const std::vector< UniformBufferObject > &  uniformBufferObjects,
int  numStorageBufferObjects,
int  numSamplers 
)

Acquires a DescriptorSet from the cache (or allocated it if not in the cache). For new DescriptorSets, also allocates Buffers for each UBO from the global Vulkan allocator. The result is a DescriptorSet that is fully compatible with the DescriptorSetLayout.

Parameters
uniformBufferObjectsThe list of UBOs for this DescriptorSet.
numStorageBufferObjectsThe number of HBOs for this DescriptorSet.
numSamplersThe number of samplers for this DescriptorSet
Returns
A DescriptorSet that is compatible with the VkDescriptorLayout that was passed upon creation.

◆ release()

void release ( int  frameIndex)

Releases all DescriptorSets to the internal pool for use by other frames.

Parameters
frameIndexThe frame index that was completed by the render system and for which no resources are in use anymore.