1 #ifndef MSP_GL_DEVICE_BACKEND_H_
2 #define MSP_GL_DEVICE_BACKEND_H_
4 #include <msp/core/noncopyable.h>
5 #include <msp/core/refptr.h>
6 #include <msp/graphics/vulkancontext.h>
7 #include "descriptorpool.h"
8 #include "destroyqueue.h"
10 #include "memoryallocator.h"
11 #include "pipelinecache.h"
12 #include "synchronizer.h"
13 #include "transferqueue.h"
18 struct VulkanFunctions;
20 constexpr unsigned MAX_FRAMES_IN_FLIGHT = 3;
22 class VulkanDevice: public NonCopyable
25 Graphics::VulkanContext context;
27 VkQueue graphics_queue;
28 RefPtr<VulkanFunctions> functions;
29 MemoryAllocator allocator;
30 DestroyQueue destroy_queue;
31 Synchronizer synchronizer;
32 TransferQueue transfer_queue;
33 PipelineCache pipeline_cache;
34 DescriptorPool descriptor_pool;
35 unsigned n_frames_in_flight = 3;
37 VulkanDevice(Graphics::Window &, const Graphics::VulkanOptions &);
40 static Graphics::VulkanOptions create_default_options();
44 Graphics::VulkanContext &get_context() { return context; }
47 const VulkanFunctions &get_functions() const { return *functions; }
48 MemoryAllocator &get_allocator() { return allocator; }
49 DestroyQueue &get_destroy_queue() { return destroy_queue; }
50 Synchronizer &get_synchronizer() { return synchronizer; }
51 TransferQueue &get_transfer_queue() { return transfer_queue; }
52 PipelineCache &get_pipeline_cache() { return pipeline_cache; }
53 DescriptorPool &get_descriptor_pool() { return descriptor_pool; }
54 unsigned get_n_frames_in_flight() const { return n_frames_in_flight; }
57 using DeviceBackend = VulkanDevice;
58 using DeviceOptions = Graphics::VulkanOptions;