FastEngine 0.9.3
A multiplayer oriented 2D engine made with Vulkan.
Loading...
Searching...
No Matches
C_descriptorPool.hpp
1/*
2 * Copyright 2024 Guillaume Guillet
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef _FGE_VULKAN_C_DESCRIPTORPOOL_HPP_INCLUDED
18#define _FGE_VULKAN_C_DESCRIPTORPOOL_HPP_INCLUDED
19
20#include "FastEngine/fge_extern.hpp"
21#include "volk.h"
22#include "FastEngine/vulkan/C_contextAware.hpp"
23#include <optional>
24#include <vector>
25
26namespace fge::vulkan
27{
28
29class DescriptorSet;
30
40class FGE_API DescriptorPool : public ContextAware
41{
42public:
43 explicit DescriptorPool(Context const& context);
44 DescriptorPool(DescriptorPool const& r) = delete;
45 DescriptorPool(DescriptorPool&& r) noexcept;
46 ~DescriptorPool() override;
47
48 DescriptorPool& operator=(DescriptorPool const& r) = delete;
49 DescriptorPool& operator=(DescriptorPool&& r) noexcept = delete;
50
62 void create(std::vector<VkDescriptorPoolSize>&& descriptorPoolSizes,
63 uint32_t maxSetsPerPool,
64 bool isUnique,
65 bool individuallyFree);
66 void destroy() final;
67
78 [[nodiscard]] std::optional<DescriptorSet> allocateDescriptorSet(VkDescriptorSetLayout layout,
79 uint32_t variableElements = 0) const;
80
89 void freeDescriptorSet(VkDescriptorSet descriptorSet, VkDescriptorPool descriptorPool) const;
95 void resetPools() const;
96
97 [[nodiscard]] uint32_t getMaxSetsPerPool() const;
98 [[nodiscard]] bool isUnique() const;
99 [[nodiscard]] bool isCreated() const;
100
101private:
102 struct Pool
103 {
104 VkDescriptorPool _pool;
105 uint32_t _count;
106 };
107
108 [[nodiscard]] Pool createPool() const;
109
110 std::vector<VkDescriptorPoolSize> g_descriptorPoolSizes;
111
112 uint32_t g_maxSetsPerPool;
113 mutable std::vector<Pool> g_descriptorPools;
114 bool g_isUnique;
115 bool g_isCreated;
116 bool g_individuallyFree;
117};
118
119} // namespace fge::vulkan
120
121#endif //_FGE_VULKAN_C_DESCRIPTORPOOL_HPP_INCLUDED
Definition C_contextAware.hpp:28
Vulkan context.
Definition C_context.hpp:70
This class abstract the vulkan descriptor pool for easier use.
Definition C_descriptorPool.hpp:41
void create(std::vector< VkDescriptorPoolSize > &&descriptorPoolSizes, uint32_t maxSetsPerPool, bool isUnique, bool individuallyFree)
Create the descriptor pool.
This class abstract the vulkan descriptor set for easier use.
Definition C_descriptorSet.hpp:41