#pragma once #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; VkQueue directQueue; uint32_t directQueueFamilyIndex; // TODO: Pack? VkFormat swapchainFormat; VkExtent2D swapchainExtent; VkSwapchainKHR swapchain; VkImage* swapchainImages; VkImageView* swapchainViews; Frame* frames; uint32_t swapchainImageCount; uint32_t frameIndex = 0; [[nodiscard]] bool isInit() const; void cleanup(); void waitIdle() const; [[nodiscard]] uint32_t getNumFrames() const; RenderDevice( VkInstance instance, VkSurfaceKHR surface, VkPhysicalDevice physicalDeviceInUse, VkDevice device, VkQueue directQueue, uint32_t directQueueFamilyIndex, // TODO: Pack? 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* CreateRenderDevice(GlobalMemory* mem, RenderDevice::CreateInfo const& createInfo);