UraniumCompute 0.1.0
A GPU accelerated parallel task scheduler
VulkanDescriptorAllocator.h
1#pragma once
2#include <UnCompute/Backend/DeviceObjectBase.h>
3#include <UnCompute/Memory/Object.h>
4#include <UnCompute/VulkanBackend/VulkanInclude.h>
5
6namespace UN
7{
9 {
10 std::array<float, DescriptorTypeMaxValue> Sizes{};
11 VkDescriptorPoolCreateFlags PoolFlags = VK_FLAGS_NONE;
12 };
13
15 {
16 public:
18
19 [[nodiscard]] virtual const DescriptorType& GetDesc() const = 0;
20
21 virtual ResultCode Init(const DescriptorType& desc) = 0;
22 };
23
24 class VulkanDescriptorAllocator final : public DeviceObjectBase<IVulkanDescriptorAllocator>
25 {
26 VkDescriptorPool m_CurrentPool = VK_NULL_HANDLE;
27 std::vector<VkDescriptorPool> m_UsedPools;
28 std::vector<VkDescriptorPool> m_FreePools;
29
30 UInt32 m_NextPoolSize = 128;
31
32 inline UInt32 GetPoolSize()
33 {
34 auto result = m_NextPoolSize;
35 m_NextPoolSize *= 2;
36 return result;
37 }
38
39 VkDescriptorPool CreatePool(UInt32 count, VkDescriptorPoolCreateFlags flags);
40 VkDescriptorPool GetPool();
41
42 public:
45
46 ResultCode Init(const DescriptorType& desc) override;
47 void Reset() override;
48 void ResetPools();
49
50 ResultCode AllocateSet(VkDescriptorSetLayout setLayout, VkDescriptorSet* pDescriptorSet);
51
52 static ResultCode Create(IComputeDevice* pDevice, VulkanDescriptorAllocator** ppDescriptorAllocator);
53 };
54} // namespace UN
Base class for all compute backend objects.
Definition: DeviceObjectBase.h:18
Interface for all backend-specific compute devices.
Definition: IComputeDevice.h:38
Base interface for all compute backend objects.
Definition: IDeviceObject.h:30
Definition: VulkanDescriptorAllocator.h:15
Definition: VulkanDescriptorAllocator.h:25
void Reset() override
Reset the object to uninitialized state.
Definition: VulkanDescriptorAllocator.cpp:17
Definition: VulkanDescriptorAllocator.h:9