#pragma once #include #define VMA_STATIC_VULKAN_FUNCTIONS 0 #define VMA_DYNAMIC_VULKAN_FUNCTIONS 0 #include #include #include struct GlobalMemory; struct Frame; /// The Rendering backend abstraction /// If this fails to initialize, we crash /// /// TODO: Fail elegantly. struct RenderDevice { struct CreateInfo { SDL_Window* window = nullptr; uint32_t width = 640; uint32_t height = 480; }; VkInstance instance; VkSurfaceKHR surface; VkPhysicalDevice physicalDeviceInUse; VkDevice device; VmaAllocator gpuAllocator; VkQueue directQueue; uint32_t directQueueFamilyIndex; VkFormat swapchainFormat; VkExtent2D swapchainExtent; VkSwapchainKHR swapchain; VkImage* swapchainImages; VkImageView* swapchainViews; Frame* frames; uint32_t swapchainImageCount; uint32_t frameIndex = 0; [[nodiscard]] bool isInit() const; void destroy(); void waitIdle() const; [[nodiscard]] uint32_t getNumFrames() const; RenderDevice( VkInstance instance, VkSurfaceKHR surface, VkPhysicalDevice physicalDeviceInUse, VkDevice device, VmaAllocator gpuAllocator, VkQueue directQueue, uint32_t directQueueFamilyIndex, VkFormat swapchainFormat, VkExtent2D swapchainExtent, VkSwapchainKHR swapchain, VkImage* swapchainImages, VkImageView* swapchainViews, Frame* frames, uint32_t swapchainImageCount ); RenderDevice( RenderDevice const& ) = delete; RenderDevice& operator=( RenderDevice const& ) = delete; RenderDevice( RenderDevice&& ) noexcept = delete; RenderDevice& operator=( RenderDevice&& ) noexcept = delete; ~RenderDevice(); }; RenderDevice* RenderDevice_Create( GlobalMemory* mem, RenderDevice::CreateInfo const& createInfo );