95 lines
3.3 KiB
C++
95 lines
3.3 KiB
C++
#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<VkSurfaceFormatKHR> formats;
|
|
std::vector<VkPresentModeKHR> 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<VkSurfaceFormatKHR>& availableFormats);
|
|
static VkPresentModeKHR ChoosePresentMode(const std::vector<VkPresentModeKHR>& 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<VkImage> s_SwapChainImages;
|
|
static std::vector<VkImageView> s_SwapChainImageViews;
|
|
static VkFormat s_SwapChainImageFormat;
|
|
static VkExtent2D s_SwapChainExtent;
|
|
|
|
static VkRenderPass s_RenderPass;
|
|
static std::vector<VkFramebuffer> s_Framebuffers;
|
|
|
|
static VkPipelineLayout s_PipelineLayout;
|
|
static VkPipeline s_RenderPipeline;
|
|
|
|
static VkCommandPool s_CommandPool;
|
|
static std::vector<VkCommandBuffer> s_CommandBuffers;
|
|
|
|
static VkSemaphore s_ImageAvailableSemaphore;
|
|
static VkSemaphore s_RenderFinishedSemaphore;
|
|
};
|
|
}
|