#pragma once #include "../VulkanRenderer.h" namespace PB::Renderer { struct QueueFamilyIndices { static constexpr uint32_t UNDEFINED_UINT32_VALUE = 0xFFFFFFFF; uint32_t graphicsFamily = UNDEFINED_UINT32_VALUE; uint32_t presentFamily = UNDEFINED_UINT32_VALUE; [[nodiscard]] bool Complete() const { return graphicsFamily != UNDEFINED_UINT32_VALUE && presentFamily != UNDEFINED_UINT32_VALUE; } }; struct SwapChainSupportDetails { VkSurfaceCapabilitiesKHR capabilities; std::vector formats; std::vector presentModes; }; class VulkanManager { public: /* Static class so (de)constructors have been deleted to stop accidental creation */ VulkanManager() = delete; ~VulkanManager() = delete; static bool Init(GLFWwindow* window); static bool Cleanup(); static bool CreateInstance(); static bool CreateSurface(GLFWwindow* window); static bool PickPhysicalDevice(); static bool CreateLogicalDevice(); static bool CreateSwapChain(GLFWwindow* window); static bool CreateImageViews(); static bool CreateRenderPass(); static bool CreateFramebuffer(); static bool CreateGraphicsPipeline(); static bool CreateCommandBuffers(); static bool CreateSemaphores(); static bool RenderPass(); private: static bool IsDeviceSuitable(const VkPhysicalDevice& device); static QueueFamilyIndices FindQueueFamilies(const VkPhysicalDevice& device); static bool CheckDeviceExtensionSupport(const VkPhysicalDevice& device); static SwapChainSupportDetails QuerySwapChainSupport(); static VkSurfaceFormatKHR ChooseSurfaceFormat(const std::vector& availableFormats); static VkPresentModeKHR ChoosePresentMode(const std::vector& availablePresentModes); static VkExtent2D ChooseSwapExtent(const VkSurfaceCapabilitiesKHR& capabilities, GLFWwindow* window); static VkShaderModule CreateShaderModule(const std::string& filename); static VkInstance s_Instance; static VkSurfaceKHR s_Surface; static VkPhysicalDevice s_PhysicalDevice; static QueueFamilyIndices s_QueueIndices; static VkDevice s_Device; static VkQueue s_GraphicsQueue; static VkQueue s_PresentQueue; static VkSwapchainKHR s_SwapChain; static std::vector s_SwapChainImages; static std::vector s_SwapChainImageViews; static VkFormat s_SwapChainImageFormat; static VkExtent2D s_SwapChainExtent; static VkRenderPass s_RenderPass; static std::vector s_Framebuffers; static VkPipelineLayout s_PipelineLayout; static VkPipeline s_RenderPipeline; static VkCommandPool s_CommandPool; static std::vector s_CommandBuffers; static VkSemaphore s_ImageAvailableSemaphore; static VkSemaphore s_RenderFinishedSemaphore; }; }