Signed-off-by: Slendi <slendi@socopon.com>
This commit is contained in:
2025-12-03 00:02:17 +02:00
parent 94eb26d9bc
commit d7c5a05d02
13 changed files with 390 additions and 38 deletions

View File

@@ -0,0 +1,42 @@
#include "DescriptorLayoutBuilder.h"
#include "Util.h"
namespace Lunar {
auto DescriptorLayoutBuilder::add_binding(
uint32_t binding, VkDescriptorType type) -> DescriptorLayoutBuilder &
{
VkDescriptorSetLayoutBinding b {};
b.binding = binding;
b.descriptorCount = 1;
b.descriptorType = type;
bindings.emplace_back(b);
return *this;
}
auto DescriptorLayoutBuilder::build(Logger &logger, VkDevice dev,
VkShaderStageFlags shader_stages, void *pNext,
VkDescriptorSetLayoutCreateFlags flags) -> VkDescriptorSetLayout
{
for (auto &&b : bindings) {
b.stageFlags |= shader_stages;
}
VkDescriptorSetLayoutCreateInfo ci {};
ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
ci.pNext = pNext;
ci.pBindings = bindings.data();
ci.bindingCount = static_cast<uint32_t>(bindings.size());
ci.flags = flags;
VkDescriptorSetLayout set;
VK_CHECK(logger, vkCreateDescriptorSetLayout(dev, &ci, nullptr, &set));
return set;
}
} // namespace Lunar