vengine  0.0.1
3D graphics engine
Loading...
Searching...
No Matches
setLayout.cpp
Go to the documentation of this file.
1#include <cassert>
2
4
5ven::DescriptorSetLayout::Builder &ven::DescriptorSetLayout::Builder::addBinding(const uint32_t binding, const VkDescriptorType descriptorType, const VkShaderStageFlags stageFlags, const uint32_t count)
6{
7 assert(m_bindings.contains(binding) == 0 && "Binding already exists in layout");
8 VkDescriptorSetLayoutBinding layoutBinding{};
9 layoutBinding.binding = binding;
10 layoutBinding.descriptorType = descriptorType;
11 layoutBinding.descriptorCount = count;
12 layoutBinding.stageFlags = stageFlags;
13 m_bindings[binding] = layoutBinding;
14 return *this;
15}
16
17ven::DescriptorSetLayout::DescriptorSetLayout(Device &device, const std::unordered_map<uint32_t, VkDescriptorSetLayoutBinding>& bindings) : m_device{device}, m_bindings{bindings}
18{
19 std::vector<VkDescriptorSetLayoutBinding> setLayoutBindings{};
20 setLayoutBindings.reserve(bindings.size());
21 for (auto [fst, snd] : bindings) {
22 setLayoutBindings.push_back(snd);
23 }
24
25 VkDescriptorSetLayoutCreateInfo descriptorSetLayoutInfo{};
26 descriptorSetLayoutInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
27 descriptorSetLayoutInfo.bindingCount = static_cast<uint32_t>(setLayoutBindings.size());
28 descriptorSetLayoutInfo.pBindings = setLayoutBindings.data();
29
30 if (vkCreateDescriptorSetLayout(
32 &descriptorSetLayoutInfo,
33 nullptr,
34 &m_descriptorSetLayout) != VK_SUCCESS) {
35 throw std::runtime_error("failed to create descriptor set layout!");
36 }
37}
This file contains the DescriptorSetLayout class.
std::unordered_map< uint32_t, VkDescriptorSetLayoutBinding > m_bindings
Definition SetLayout.hpp:37
Builder & addBinding(uint32_t binding, VkDescriptorType descriptorType, VkShaderStageFlags stageFlags, uint32_t count=1)
Definition setLayout.cpp:5
std::unordered_map< uint32_t, VkDescriptorSetLayoutBinding > m_bindings
Definition SetLayout.hpp:55
DescriptorSetLayout(Device &device, const std::unordered_map< uint32_t, VkDescriptorSetLayoutBinding > &bindings)
Definition setLayout.cpp:17
VkDescriptorSetLayout m_descriptorSetLayout
Definition SetLayout.hpp:54
Class for device.
Definition Device.hpp:35
VkDevice device() const
Definition Device.hpp:54