]> git.tdb.fi Git - libs/gl.git/blob - source/backends/vulkan/device_backend.h
Rewrite descriptor set management
[libs/gl.git] / source / backends / vulkan / device_backend.h
1 #ifndef MSP_GL_DEVICE_BACKEND_H_
2 #define MSP_GL_DEVICE_BACKEND_H_
3
4 #include <msp/core/noncopyable.h>
5 #include <msp/graphics/vulkancontext.h>
6 #include "descriptorpool.h"
7 #include "destroyqueue.h"
8 #include "handles.h"
9 #include "memoryallocator.h"
10 #include "pipelinecache.h"
11 #include "synchronizer.h"
12 #include "transferqueue.h"
13
14 namespace Msp {
15 namespace GL {
16
17 struct VulkanFunctions;
18
19 constexpr unsigned MAX_FRAMES_IN_FLIGHT = 3;
20
21 class VulkanDevice: public NonCopyable
22 {
23 protected:
24         Graphics::VulkanContext context;
25         VkDevice device;
26         VkQueue graphics_queue;
27         RefPtr<VulkanFunctions> functions;
28         MemoryAllocator allocator;
29         DestroyQueue destroy_queue;
30         Synchronizer synchronizer;
31         TransferQueue transfer_queue;
32         PipelineCache pipeline_cache;
33         DescriptorPool descriptor_pool;
34         unsigned n_frames_in_flight = 3;
35
36         VulkanDevice(Graphics::Window &, const Graphics::VulkanOptions &);
37         ~VulkanDevice();
38
39         static Graphics::VulkanOptions create_default_options();
40
41         void fill_info();
42
43         Graphics::VulkanContext &get_context() { return context; }
44
45 public:
46         const VulkanFunctions &get_functions() const { return *functions; }
47         MemoryAllocator &get_allocator() { return allocator; }
48         DestroyQueue &get_destroy_queue() { return destroy_queue; }
49         Synchronizer &get_synchronizer() { return synchronizer; }
50         TransferQueue &get_transfer_queue() { return transfer_queue; }
51         PipelineCache &get_pipeline_cache() { return pipeline_cache; }
52         DescriptorPool &get_descriptor_pool() { return descriptor_pool; }
53         unsigned get_n_frames_in_flight() const { return n_frames_in_flight; }
54 };
55
56 using DeviceBackend = VulkanDevice;
57 using DeviceOptions = Graphics::VulkanOptions;
58
59 } // namespace GL
60 } // namespace Msp
61
62 #endif