]> git.tdb.fi Git - libs/gl.git/blob - source/backends/vulkan/descriptorpool.h
Add files which were forgotten earlier
[libs/gl.git] / source / backends / vulkan / descriptorpool.h
1 #ifndef MSP_GL_DESCRIPTORPOOL_H_
2 #define MSP_GL_DESCRIPTORPOOL_H_
3
4 #include <cstdint>
5 #include <vector>
6 #include <msp/core/noncopyable.h>
7 #include "handles.h"
8
9 namespace Msp {
10 namespace GL {
11
12 class Device;
13 class PipelineState;
14
15 class DescriptorPool: public NonCopyable
16 {
17 private:
18         static constexpr unsigned DYNAMIC_SLOT = 0x80000000U;
19
20         struct Counts
21         {
22                 unsigned sets = 0;
23                 unsigned buffers = 0;
24                 unsigned images = 0;
25
26                 Counts() = default;
27                 Counts(unsigned, unsigned, unsigned);
28
29                 Counts &operator+=(const Counts &);
30         };
31
32         struct HashSlot
33         {
34                 std::uint64_t hash;
35                 unsigned slot;
36
37                 HashSlot(std::uint64_t h, unsigned s): hash(h), slot(s) { }
38         };
39
40         Device &device;
41         std::vector<VkDescriptorPool> pools;
42         std::vector<std::vector<VkDescriptorSet>> sets;
43         std::vector<HashSlot> slots;
44         unsigned next_slot = 0;
45         Counts used;
46         Counts increment = { 100, 500, 500 };
47
48 public:
49         DescriptorPool(Device &);
50         ~DescriptorPool();
51
52 private:
53         void add_pool(const Counts &);
54
55 public:
56         void begin_frame();
57         unsigned get_descriptor_set_slot(const PipelineState &, unsigned);
58         VkDescriptorSet get_descriptor_set(unsigned, const PipelineState &, unsigned, unsigned);
59 };
60
61 } // namespace GL
62 } // namespace Msp
63
64 #endif