Blaze/Blaze/RenderDevice.h

79 lines
2.1 KiB
C

#pragma once
#include <SDL3/SDL_video.h>
#include <SDL3/SDL_vulkan.h>
#include "TextureManager.h"
#include "VulkanHeader.h"
struct GlobalMemory;
struct Frame;
struct TextureManager;
/// 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;
TextureManager* textureManager;
[[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 );