NarcEngine 0.1.1
C++ Vulkan game engine
 
Loading...
Searching...
No Matches
DescriptorPoolBuilder.h
1#pragma once
2
3namespace narc_engine {
4 struct DescriptorPoolBuilder
5 {
6 friend class DescriptorPool;
7
8 inline DescriptorPoolBuilder* setMaxSet(const uint32_t maxSets)
9 {
10 m_poolInfo.maxSets = maxSets * m_poolCount;
11
12 return this;
13 }
14
15 inline DescriptorPoolBuilder* addPoolSize(VkDescriptorType type, uint32_t count)
16 {
17 VkDescriptorPoolSize poolSize{};
18 poolSize.type = type;
19 poolSize.descriptorCount = count * m_poolCount;
20
21 m_poolSizes.push_back(poolSize);
22
23 return this;
24 }
25
26
27 explicit DescriptorPoolBuilder(const uint32_t poolCount = 1)
28 : m_poolCount(poolCount)
29 {
30 m_poolInfo = {};
31 m_poolInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
32 m_poolInfo.maxSets = 0;
33 }
34 protected:
35
36 VkDescriptorPoolCreateInfo* build()
37 {
38 m_poolInfo.poolSizeCount = static_cast<uint32_t>(m_poolSizes.size());
39 m_poolInfo.pPoolSizes = m_poolSizes.data();
40
41 return &m_poolInfo;
42 }
43
44 private:
45 const uint32_t m_poolCount = 1;
46 VkDescriptorPoolCreateInfo m_poolInfo{};
47
48 std::vector<VkDescriptorPoolSize> m_poolSizes;
49 };
50}