mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-15 20:08:54 +03:00
39 lines
967 B
C++
39 lines
967 B
C++
#include "DescriptorLayoutBuilder.h"
|
|
|
|
#include "VulkanCheck.h"
|
|
|
|
using namespace Nuake;
|
|
|
|
void DescriptorLayoutBuilder::AddBinding(uint32_t binding, VkDescriptorType type)
|
|
{
|
|
VkDescriptorSetLayoutBinding newbind{};
|
|
newbind.binding = binding;
|
|
newbind.descriptorCount = 1;
|
|
newbind.descriptorType = type;
|
|
|
|
Bindings.push_back(newbind);
|
|
}
|
|
|
|
void DescriptorLayoutBuilder::Clear()
|
|
{
|
|
Bindings.clear();
|
|
}
|
|
|
|
VkDescriptorSetLayout DescriptorLayoutBuilder::Build(VkDevice device, VkShaderStageFlags shaderStages, void * pNext, VkDescriptorSetLayoutCreateFlags flags)
|
|
{
|
|
for (auto& b : Bindings) {
|
|
b.stageFlags |= shaderStages;
|
|
}
|
|
|
|
VkDescriptorSetLayoutCreateInfo info = { .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO };
|
|
info.pNext = pNext;
|
|
|
|
info.pBindings = Bindings.data();
|
|
info.bindingCount = (uint32_t)Bindings.size();
|
|
info.flags = flags;
|
|
|
|
VkDescriptorSetLayout set;
|
|
VK_CALL(vkCreateDescriptorSetLayout(device, &info, nullptr, &set));
|
|
|
|
return set;
|
|
} |