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