Allocating descriptor sets
Descriptor sets gather shader resources (descriptors) in one container object. Its contents, types, and number of resources are defined by a descriptor set layout; storage is taken from pools, from which we can allocate descriptor sets.
How to do it...
- Take the logical device and store its handle in a variable of type
VkDevice
namedlogical_device
. - Prepare a descriptor pool from which descriptor sets should be allocated. Use the pool's handle to initialize a variable of type
VkDescriptorPool
nameddescriptor_pool
. - Create a variable of type
std::vector<VkDescriptorSetLayout>
nameddescriptor_set_layouts
. For each descriptor set that should be allocated from the pool, add a handle of a descriptor set layout that defines the structure of a corresponding descriptor set. - Create a variable of type
VkDescriptorSetAllocateInfo
nameddescriptor_set_allocate_info
and use the following values for its members:VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO
value forsType
nullptr...