Big cleanup to utilize C++20 designated initializers https://en.cppreference.com/w/cpp/language/aggregate_initialization.html#Designated_initializers
This commit is contained in:
parent
a996440c61
commit
d1d57ab682
4 changed files with 170 additions and 199 deletions
|
|
@ -3,10 +3,11 @@
|
|||
void DescriptorLayoutBuilder::add_binding(uint32_t binding, VkDescriptorType type)
|
||||
{
|
||||
|
||||
VkDescriptorSetLayoutBinding newbind {};
|
||||
newbind.binding = binding;
|
||||
newbind.descriptorCount = 1;
|
||||
newbind.descriptorType = type;
|
||||
VkDescriptorSetLayoutBinding newbind{
|
||||
.binding = binding,
|
||||
.descriptorType = type,
|
||||
.descriptorCount = 1,
|
||||
};
|
||||
|
||||
bindings.push_back(newbind);
|
||||
}
|
||||
|
|
@ -25,18 +26,16 @@ VkDescriptorSetLayout DescriptorLayoutBuilder::build(VkDevice device,
|
|||
b.stageFlags |= shaderStages;
|
||||
}
|
||||
|
||||
VkDescriptorSetLayoutCreateInfo info = {
|
||||
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO
|
||||
VkDescriptorSetLayoutCreateInfo info{
|
||||
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
|
||||
.pNext = pNext,
|
||||
.flags = flags,
|
||||
.bindingCount = (uint32_t)bindings.size(),
|
||||
.pBindings = bindings.data(),
|
||||
};
|
||||
info.pNext = pNext;
|
||||
|
||||
info.pBindings = bindings.data();
|
||||
info.bindingCount = (uint32_t)bindings.size();
|
||||
info.flags = flags;
|
||||
|
||||
VkDescriptorSetLayout set;
|
||||
VK_CHECK(vkCreateDescriptorSetLayout(device,
|
||||
&info, nullptr, &set));
|
||||
VK_CHECK(vkCreateDescriptorSetLayout(device, &info, nullptr, &set));
|
||||
|
||||
return set;
|
||||
}
|
||||
|
|
@ -46,19 +45,19 @@ void DescriptorAllocator::init_pool(VkDevice device, uint32_t maxSets,
|
|||
{
|
||||
std::vector<VkDescriptorPoolSize> poolSizes;
|
||||
for(PoolSizeRatio ratio : poolRatios) {
|
||||
poolSizes.push_back(VkDescriptorPoolSize{
|
||||
poolSizes.push_back({
|
||||
.type = ratio.type,
|
||||
.descriptorCount = uint32_t(ratio.ratio * maxSets)
|
||||
});
|
||||
}
|
||||
|
||||
VkDescriptorPoolCreateInfo pool_info = {
|
||||
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO
|
||||
VkDescriptorPoolCreateInfo pool_info{
|
||||
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO,
|
||||
.flags = 0,
|
||||
.maxSets = maxSets,
|
||||
.poolSizeCount = (uint32_t)poolSizes.size(),
|
||||
.pPoolSizes = poolSizes.data(),
|
||||
};
|
||||
pool_info.flags = 0;
|
||||
pool_info.maxSets = maxSets;
|
||||
pool_info.poolSizeCount = (uint32_t)poolSizes.size();
|
||||
pool_info.pPoolSizes = poolSizes.data();
|
||||
|
||||
vkCreateDescriptorPool(device, &pool_info, nullptr, &pool);
|
||||
}
|
||||
|
|
@ -75,15 +74,13 @@ void DescriptorAllocator::destroy_pool(VkDevice device)
|
|||
|
||||
VkDescriptorSet DescriptorAllocator::allocate(VkDevice device, VkDescriptorSetLayout layout)
|
||||
{
|
||||
VkDescriptorSetAllocateInfo allocInfo = {
|
||||
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO
|
||||
VkDescriptorSetAllocateInfo allocInfo{
|
||||
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO,
|
||||
.descriptorPool = pool,
|
||||
.descriptorSetCount = 1,
|
||||
.pSetLayouts = &layout,
|
||||
};
|
||||
|
||||
allocInfo.pNext = nullptr;
|
||||
allocInfo.descriptorPool = pool;
|
||||
allocInfo.descriptorSetCount = 1;
|
||||
allocInfo.pSetLayouts = &layout;
|
||||
|
||||
VkDescriptorSet ds;
|
||||
VK_CHECK(vkAllocateDescriptorSets(device, &allocInfo, &ds));
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue