#ifndef GAMINGCORE_VULKAN_WRAPPER_HPP #define GAMINGCORE_VULKAN_WRAPPER_HPP #include #include #include #include #include "core/VulkanBase.hpp" namespace Core::Vulkan { bool init(); void render(); void destroy(); template struct BaseWrapper { VkDevice device = VK_NULL_HANDLE; T handle = VK_NULL_HANDLE; BaseWrapper() = default; BaseWrapper(const BaseWrapper&) = delete; BaseWrapper(BaseWrapper&& o) : BaseWrapper() { swap(o); } BaseWrapper& operator=(const BaseWrapper&) = delete; BaseWrapper& operator=(BaseWrapper&& o) { swap(o); o = BaseWrapper(); } void swap(BaseWrapper& o) { Core::swap(device, o.device); Core::swap(handle, o.handle); } operator T() { return handle; } operator T*() { return &handle; } operator const T*() const { return &handle; } }; struct ImageView : public BaseWrapper { ImageView() = default; ImageView(ImageView&&) = default; ~ImageView(); bool init(VkDevice d, VkImage image, VkFormat format); }; struct Framebuffer : public BaseWrapper { Framebuffer() = default; Framebuffer(Framebuffer&&) = default; ~Framebuffer(); bool init(const ImageView& iv, VkRenderPass rp, u32 width, u32 height); }; struct Semaphore : public BaseWrapper { Semaphore() = default; Semaphore(Semaphore&&) = default; ~Semaphore(); bool init(VkDevice d); }; struct Fence : public BaseWrapper { Fence() = default; Fence(Fence&&) = default; ~Fence(); bool init(VkDevice d); }; struct Swapchain : public BaseWrapper { Swapchain() = default; Swapchain(Swapchain&&) = default; ~Swapchain(); struct Data { Base& base; VkExtent2D size{}; VkSurfaceFormatKHR surfaceFormat{}; VkPresentModeKHR presentMode{}; VkSharingMode sharingMode{}; List queueFamilies{}; }; bool init(Data& d); }; struct ShaderModule : public BaseWrapper { ShaderModule() = default; ShaderModule(ShaderModule&&) = default; ~ShaderModule(); bool init(VkDevice d, const char* path); }; struct PipelineLayout : public BaseWrapper { PipelineLayout() = default; PipelineLayout(PipelineLayout&&) = default; ~PipelineLayout(); bool init(VkDevice d); }; struct SwapchainImages { List images{}; List imageViews{}; bool init(const Swapchain& s, VkFormat format); }; struct CommandBuffer : public BaseWrapper { CommandBuffer() = default; CommandBuffer(CommandBuffer&&) = default; bool init(VkDevice d, VkCommandPool cp); }; } #endif