-VkDescriptorSet PipelineCache::get_descriptor_set(const PipelineState &ps, unsigned index)
-{
- const VulkanFunctions &vk = device.get_functions();
-
- uint64_t key = ps.compute_descriptor_set_hash(index);
- auto i = descriptor_sets.find(key);
- if(i!=descriptor_sets.end())
- return i->second;
-
- VkDescriptorSetLayout layout = ps.get_descriptor_set_layout(index);
-
- VkDescriptorSetAllocateInfo alloc_info = { };
- alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO;
- alloc_info.descriptorPool = handle_cast<::VkDescriptorPool>(descriptor_pool);
- alloc_info.descriptorSetCount = 1;
- alloc_info.pSetLayouts = handle_cast<::VkDescriptorSetLayout *>(&layout);
-
- VkDescriptorSet desc_set;
- vk.AllocateDescriptorSets(alloc_info, &desc_set);
-
- vector<char> buffer;
- unsigned n_writes = ps.fill_descriptor_writes(index, buffer);
- VkWriteDescriptorSet *writes = reinterpret_cast<VkWriteDescriptorSet *>(buffer.data());
- for(unsigned j=0; j<n_writes; ++j)
- writes[j].dstSet = handle_cast<::VkDescriptorSet>(desc_set);
-
- vk.UpdateDescriptorSets(n_writes, writes, 0, 0);
-
- descriptor_sets.insert(make_pair(key, desc_set));
-
- return desc_set;
-}
-