MCPcopy Create free account
hub / github.com/KhronosGroup/Vulkan-Samples / allocate

Method allocate

framework/core/descriptor_pool.cpp:95–126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

93}
94
95VkDescriptorSet DescriptorPool::allocate()
96{
97 pool_index = find_available_pool(pool_index);
98
99 // Increment allocated set count for the current pool
100 ++pool_sets_count[pool_index];
101
102 VkDescriptorSetLayout set_layout = get_descriptor_set_layout().get_handle();
103
104 VkDescriptorSetAllocateInfo alloc_info{VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO};
105 alloc_info.descriptorPool = pools[pool_index];
106 alloc_info.descriptorSetCount = 1;
107 alloc_info.pSetLayouts = &set_layout;
108
109 VkDescriptorSet handle = VK_NULL_HANDLE;
110
111 // Allocate a new descriptor set from the current pool
112 auto result = vkAllocateDescriptorSets(device.get_handle(), &alloc_info, &handle);
113
114 if (result != VK_SUCCESS)
115 {
116 // Decrement allocated set count for the current pool
117 --pool_sets_count[pool_index];
118
119 return VK_NULL_HANDLE;
120 }
121
122 // Store mapping between the descriptor set and the pool
123 set_pool_mapping.emplace(handle, pool_index);
124
125 return handle;
126}
127
128VkResult DescriptorPool::free(VkDescriptorSet descriptor_set)
129{

Callers 2

DescriptorSetMethod · 0.45
allocate_buffer_implMethod · 0.45

Calls 1

get_handleMethod · 0.45

Tested by

no test coverage detected