1 #ifndef MSP_GL_DEVICE_BACKEND_H_
2 #define MSP_GL_DEVICE_BACKEND_H_
4 #include <msp/core/noncopyable.h>
5 #include <msp/graphics/vulkancontext.h>
6 #include "descriptorpool.h"
7 #include "destroyqueue.h"
9 #include "memoryallocator.h"
10 #include "pipelinecache.h"
11 #include "synchronizer.h"
12 #include "transferqueue.h"
17 struct VulkanFunctions;
19 constexpr unsigned MAX_FRAMES_IN_FLIGHT = 3;
21 class VulkanDevice: public NonCopyable
24 Graphics::VulkanContext context;
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;
36 VulkanDevice(Graphics::Window &, const Graphics::VulkanOptions &);
39 static Graphics::VulkanOptions create_default_options();
43 Graphics::VulkanContext &get_context() { return context; }
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; }
56 using DeviceBackend = VulkanDevice;
57 using DeviceOptions = Graphics::VulkanOptions;