Blaze/RenderDevice.h

56 lines
1.1 KiB
C++

#pragma once
#include <volk.h>
#include <vector>
#include <SDL3/SDL_video.h>
#include <SDL3/SDL_vulkan.h>
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;
std::vector<VkImage> swapchainImages;
std::vector<VkImageView> swapchainViews;
std::vector<Frame> frames;
uint32_t frameIndex = 0;
[[nodiscard]] bool isInit() const;
void cleanup();
void waitIdle() const;
[[nodiscard]] uint32_t getNumFrames() const;
explicit RenderDevice(CreateInfo const& createInfo);
RenderDevice(RenderDevice const&) = delete;
RenderDevice& operator=(RenderDevice const&) = delete;
RenderDevice(RenderDevice&&) noexcept = delete;
RenderDevice& operator=(RenderDevice&&) noexcept = delete;
~RenderDevice();
};