]> git.tdb.fi Git - libs/gl.git/blobdiff - source/backends/vulkan/device_backend.h
Initial implementation of Vulkan backend
[libs/gl.git] / source / backends / vulkan / device_backend.h
diff --git a/source/backends/vulkan/device_backend.h b/source/backends/vulkan/device_backend.h
new file mode 100644 (file)
index 0000000..9c11566
--- /dev/null
@@ -0,0 +1,56 @@
+#ifndef MSP_GL_DEVICE_BACKEND_H_
+#define MSP_GL_DEVICE_BACKEND_H_
+
+#include <msp/core/noncopyable.h>
+#include <msp/graphics/vulkancontext.h>
+#include "destroyqueue.h"
+#include "handles.h"
+#include "memoryallocator.h"
+#include "pipelinecache.h"
+#include "transferqueue.h"
+
+namespace Msp {
+namespace GL {
+
+struct VulkanFunctions;
+
+constexpr unsigned MAX_FRAMES_IN_FLIGHT = 3;
+
+class VulkanDevice: public NonCopyable
+{
+protected:
+       Graphics::VulkanContext context;
+       VkDevice device;
+       VkQueue graphics_queue;
+       RefPtr<VulkanFunctions> functions;
+       MemoryAllocator allocator;
+       DestroyQueue destroy_queue;
+       TransferQueue transfer_queue;
+       PipelineCache pipeline_cache;
+       unsigned n_frames_in_flight = 3;
+
+       VulkanDevice(Graphics::Window &, const Graphics::VulkanOptions &);
+       ~VulkanDevice();
+
+       static Graphics::VulkanOptions create_default_options();
+
+       void fill_info();
+
+       Graphics::VulkanContext &get_context() { return context; }
+
+public:
+       const VulkanFunctions &get_functions() const { return *functions; }
+       MemoryAllocator &get_allocator() { return allocator; }
+       DestroyQueue &get_destroy_queue() { return destroy_queue; }
+       TransferQueue &get_transfer_queue() { return transfer_queue; }
+       PipelineCache &get_pipeline_cache() { return pipeline_cache; }
+       unsigned get_n_frames_in_flight() const { return n_frames_in_flight; }
+};
+
+using DeviceBackend = VulkanDevice;
+using DeviceOptions = Graphics::VulkanOptions;
+
+} // namespace GL
+} // namespace Msp
+
+#endif