]> git.tdb.fi Git - libs/gl.git/blob - source/backends/vulkan/device_backend.h
Initial implementation of Vulkan backend
[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 "destroyqueue.h"
7 #include "handles.h"
8 #include "memoryallocator.h"
9 #include "pipelinecache.h"
10 #include "transferqueue.h"
11
12 namespace Msp {
13 namespace GL {
14
15 struct VulkanFunctions;
16
17 constexpr unsigned MAX_FRAMES_IN_FLIGHT = 3;
18
19 class VulkanDevice: public NonCopyable
20 {
21 protected:
22         Graphics::VulkanContext context;
23         VkDevice device;
24         VkQueue graphics_queue;
25         RefPtr<VulkanFunctions> functions;
26         MemoryAllocator allocator;
27         DestroyQueue destroy_queue;
28         TransferQueue transfer_queue;
29         PipelineCache pipeline_cache;
30         unsigned n_frames_in_flight = 3;
31
32         VulkanDevice(Graphics::Window &, const Graphics::VulkanOptions &);
33         ~VulkanDevice();
34
35         static Graphics::VulkanOptions create_default_options();
36
37         void fill_info();
38
39         Graphics::VulkanContext &get_context() { return context; }
40
41 public:
42         const VulkanFunctions &get_functions() const { return *functions; }
43         MemoryAllocator &get_allocator() { return allocator; }
44         DestroyQueue &get_destroy_queue() { return destroy_queue; }
45         TransferQueue &get_transfer_queue() { return transfer_queue; }
46         PipelineCache &get_pipeline_cache() { return pipeline_cache; }
47         unsigned get_n_frames_in_flight() const { return n_frames_in_flight; }
48 };
49
50 using DeviceBackend = VulkanDevice;
51 using DeviceOptions = Graphics::VulkanOptions;
52
53 } // namespace GL
54 } // namespace Msp
55
56 #endif