vOOlkan
An object oriented approach to Vulkan
DescriptorSetPool.h
Go to the documentation of this file.
1#ifndef VULKAN_DESCRIPTORSETPOOL
2#define VULKAN_DESCRIPTORSETPOOL
3
4#include <vulkan/vulkan.h>
5
6#include "VulkanException.h"
7#include "LogicalDevice.h"
8
9
10namespace Vulkan { class DescriptorSetPool; }
11
12
17public:
18
26 template<std::same_as<VkDescriptorType>... DT>
27 DescriptorSetPool(const LogicalDevice& virtualGpu, unsigned int size, DT... types) : virtualGpu{ virtualGpu } {
28 //varaargs to vector
29 std::vector<VkDescriptorType> typesArray;
30 (typesArray.push_back(types), ...);
31
32 //for each type create the info struct for each type
33 std::vector<VkDescriptorPoolSize> typesInfo;
34 for (const auto& poolType : typesArray) {
35 VkDescriptorPoolSize poolSize;
36 poolSize.type = poolType;
37 poolSize.descriptorCount = static_cast<uint32_t>(size);
38 typesInfo.push_back(poolSize);
39 }
40
41 //struct to create the pool
42 VkDescriptorPoolCreateInfo poolInfo{};
43 poolInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
44 poolInfo.poolSizeCount = typesInfo.size();
45 poolInfo.pPoolSizes = typesInfo.data();
46 poolInfo.maxSets = static_cast<uint32_t>(size);
47
48 //actually create the pool
49 if (VkResult result = vkCreateDescriptorPool(+virtualGpu, &poolInfo, nullptr, &descriptorPool); result != VK_SUCCESS) {
50 throw VulkanException("Failed to create descriptor pool!", result);
51 }
52 }
53
54
59
60
62 vkDestroyDescriptorPool(+virtualGpu, descriptorPool, nullptr);
63 }
64
65
66 const VkDescriptorPool& operator+() const {
67 return descriptorPool;
68 }
69
70private:
71 VkDescriptorPool descriptorPool;
72 const LogicalDevice& virtualGpu;
73};
74
75#endif
Class used to allocate DescriptorSet(s).
Definition: DescriptorSetPool.h:16
const VkDescriptorPool & operator+() const
Definition: DescriptorSetPool.h:66
DescriptorSetPool & operator=(DescriptorSetPool &&)=delete
DescriptorSetPool(DescriptorSetPool &&)=delete
~DescriptorSetPool()
Definition: DescriptorSetPool.h:61
DescriptorSetPool & operator=(const DescriptorSetPool &)=delete
DescriptorSetPool(const DescriptorSetPool &)=delete
DescriptorSetPool(const LogicalDevice &virtualGpu, unsigned int size, DT... types)
Creates a DescriptorSetPool object of the specified size. There is one pool of size size for each typ...
Definition: DescriptorSetPool.h:27
A logical device is an abstraction of the physical GPU which we can mainly use to send commands.
Definition: LogicalDevice.h:15
Generic runtime exception thrown by Vulkan-related functions.
Definition: VulkanException.h:13
Types of queue families.
Definition: Animations.h:17