Blaze/RenderDevice.h

80 lines
1.7 KiB
C

#pragma once
#include <volk.h>
#define VMA_STATIC_VULKAN_FUNCTIONS 0
#define VMA_DYNAMIC_VULKAN_FUNCTIONS 0
#include <vma/vk_mem_alloc.h>
#include <SDL3/SDL_video.h>
#include <SDL3/SDL_vulkan.h>
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 cleanup();
void waitIdle() const;
[[nodiscard]] uint32_t getNumFrames() const;
RenderDevice(
VkInstance instance,
VkSurfaceKHR surface,
VkPhysicalDevice physicalDeviceInUse,
VkDevice device,
VmaAllocator gpuAllocator,
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);