Major Cleanup.

This commit is contained in:
Anish Bhobe 2025-06-12 23:37:07 +02:00
parent e7d74e6b0f
commit 9fe2815ab4
17 changed files with 956 additions and 928 deletions

View File

@ -3,15 +3,15 @@
#include <SDL3/SDL_log.h>
#include "GlobalMemory.h"
#include "RenderDevice.h"
#include "MiscData.h"
#include "RenderDevice.h"
bool AppState::isInit() const
{
return window and renderDevice and renderDevice->isInit();
}
void AppState::cleanup()
void AppState::destroy()
{
if (!isInit()) return;
@ -19,19 +19,23 @@ void AppState::cleanup()
Take(miscData)->cleanup(*renderDevice);
Take(renderDevice)->cleanup();
Take(renderDevice)->destroy();
SDL_DestroyWindow(Take(window));
}
AppState::AppState(SDL_Window* window, RenderDevice* renderDevice, MiscData* miscData): window{ window }
AppState::AppState(SDL_Window* window, RenderDevice* renderDevice, MiscData* miscData)
: window{ window }
, renderDevice{ renderDevice }
, miscData{ miscData }
{
, miscData{ miscData } {
}
AppState* CreateAppState(GlobalMemory* memory, uint32_t const width, uint32_t const height)
{
SDL_Window* window = SDL_CreateWindow("Blaze Test", static_cast<int>(width), static_cast<int>(height), SDL_WINDOW_VULKAN);
SDL_Window* window = SDL_CreateWindow(
"Blaze Test",
static_cast<int>(width),
static_cast<int>(height),
SDL_WINDOW_VULKAN);
if (!window)
{
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s", SDL_GetError());
@ -49,16 +53,16 @@ AppState* CreateAppState(GlobalMemory* memory, uint32_t const width, uint32_t co
auto* miscDataAllocation = memory->allocate(sizeof(MiscData));
MiscData* miscData = new (miscDataAllocation) MiscData{};
MiscData* miscData = new(miscDataAllocation) MiscData{};
miscData->init(*renderDevice);
auto* allocation = memory->allocate(sizeof(AppState));
AppState* appState = new (allocation) AppState{ window, renderDevice, miscData };
AppState* appState = new(allocation) AppState{ window, renderDevice, miscData };
return appState;
}
AppState::~AppState()
{
cleanup();
ASSERT(!isInit());
}

View File

@ -2,8 +2,9 @@
#include <memory>
struct GlobalMemory;
struct SDL_Window;
struct GlobalMemory;
struct RenderDevice;
struct MiscData;
@ -13,18 +14,19 @@ struct AppState
RenderDevice* renderDevice;
MiscData* miscData;
[[nodiscard]] bool isInit() const;
void cleanup();
[[nodiscard]]
bool isInit() const;
void destroy();
AppState(SDL_Window* window, RenderDevice* renderDevice, MiscData* miscData);
AppState( SDL_Window* window, RenderDevice* renderDevice, MiscData* miscData );
AppState(AppState const& other) = delete;
AppState(AppState&& other) noexcept = delete;
AppState( AppState const& other ) = delete;
AppState( AppState&& other ) noexcept = delete;
AppState& operator=(AppState const& other) = delete;
AppState& operator=(AppState&& other) noexcept = delete;
AppState& operator=( AppState const& other ) = delete;
AppState& operator=( AppState&& other ) noexcept = delete;
~AppState();
};
AppState* CreateAppState(GlobalMemory* memory, uint32_t const width, uint32_t const height);
AppState* CreateAppState( GlobalMemory* memory, uint32_t const width, uint32_t const height );

View File

@ -29,39 +29,38 @@ constexpr uint32_t NUM_FRAMES = 3;
using Byte = uint8_t;
constexpr size_t operator ""_KiB(size_t const value)
constexpr size_t operator ""_KiB( size_t const value )
{
return value * 1024;
}
constexpr size_t operator ""_MiB(size_t const value)
constexpr size_t operator ""_MiB( size_t const value )
{
return value * 1024_KiB;
}
constexpr size_t operator ""_GiB(size_t const value)
constexpr size_t operator ""_GiB( size_t const value )
{
return value * 1024_MiB;
}
namespace Blaze::Global
{
GlobalMemory g_Memory;
GlobalMemory g_Memory;
}
SDL_AppResult SDL_AppInit(void** pAppState, int, char**)
SDL_AppResult SDL_AppInit( void** pAppState, int, char** )
{
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS);
SDL_Init( SDL_INIT_VIDEO | SDL_INIT_EVENTS );
Blaze::Global::g_Memory.init(128_MiB);
Blaze::Global::g_Memory.init( 128_MiB );
*pAppState = CreateAppState(&Blaze::Global::g_Memory, WIDTH, HEIGHT);
if (!*pAppState)
return SDL_APP_FAILURE;
*pAppState = CreateAppState( &Blaze::Global::g_Memory, WIDTH, HEIGHT );
if ( !*pAppState ) return SDL_APP_FAILURE;
AppState& appState = *static_cast<AppState*>(*pAppState);
if (!appState.isInit())
if ( !appState.isInit() )
{
return SDL_APP_FAILURE;
}
@ -69,21 +68,25 @@ SDL_AppResult SDL_AppInit(void** pAppState, int, char**)
return SDL_APP_CONTINUE;
}
SDL_AppResult SDL_AppIterate(void* appstate)
SDL_AppResult SDL_AppIterate( void* appstate )
{
AppState& appState = *static_cast<AppState*>(appstate);
RenderDevice& renderDevice = *appState.renderDevice;
MiscData& misc = *appState.miscData;
Frame& currentFrame = renderDevice.frames[renderDevice.frameIndex];
VK_CHECK(vkWaitForFences(renderDevice.device, 1, &currentFrame.frameReadyToReuse, VK_TRUE, std::numeric_limits<uint32_t>::max()));
VK_CHECK(
vkWaitForFences(renderDevice.device, 1, &currentFrame.frameReadyToReuse, VK_TRUE, std::numeric_limits<uint32_t>::max
()) );
// All resources of frame 'frameIndex' are free.
uint32_t currentImageIndex;
VK_CHECK(vkAcquireNextImageKHR(renderDevice.device, renderDevice.swapchain, std::numeric_limits<uint32_t>::max(), currentFrame.imageAcquiredSemaphore, nullptr, &currentImageIndex));
VK_CHECK(
vkAcquireNextImageKHR(renderDevice.device, renderDevice.swapchain, std::numeric_limits<uint32_t>::max(),
currentFrame.imageAcquiredSemaphore, nullptr, &currentImageIndex) );
VK_CHECK(vkResetFences(renderDevice.device, 1, &currentFrame.frameReadyToReuse));
VK_CHECK(vkResetCommandPool(renderDevice.device, currentFrame.commandPool, 0));
VK_CHECK( vkResetFences(renderDevice.device, 1, &currentFrame.frameReadyToReuse) );
VK_CHECK( vkResetCommandPool(renderDevice.device, currentFrame.commandPool, 0) );
misc.acquireToRenderBarrier.image = renderDevice.swapchainImages[currentImageIndex];
misc.renderToPresentBarrier.image = renderDevice.swapchainImages[currentImageIndex];
@ -101,7 +104,7 @@ SDL_AppResult SDL_AppIterate(void* appstate)
.float32 = { 0.0f, 0.0f, 0.0f, 1.0f },
};
VK_CHECK(vkBeginCommandBuffer(cmd, &beginInfo));
VK_CHECK( vkBeginCommandBuffer(cmd, &beginInfo) );
{
VkRenderingAttachmentInfo const attachmentInfo = {
.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO,
@ -113,14 +116,14 @@ SDL_AppResult SDL_AppIterate(void* appstate)
.resolveImageLayout = VK_IMAGE_LAYOUT_UNDEFINED,
.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR,
.storeOp = VK_ATTACHMENT_STORE_OP_STORE,
.clearValue = {.color = BLACK_CLEAR},
.clearValue = { .color = BLACK_CLEAR },
};
VkRenderingInfo renderingInfo = {
.sType = VK_STRUCTURE_TYPE_RENDERING_INFO,
.pNext = nullptr,
.flags = 0,
.renderArea = {.offset = {0,0}, .extent = renderDevice.swapchainExtent},
.renderArea = { .offset = { 0, 0 }, .extent = renderDevice.swapchainExtent },
.layerCount = 1,
.viewMask = 0,
.colorAttachmentCount = 1,
@ -129,8 +132,8 @@ SDL_AppResult SDL_AppIterate(void* appstate)
.pStencilAttachment = nullptr,
};
vkCmdPipelineBarrier2(cmd, &misc.acquireToRenderDependency);
vkCmdBeginRendering(cmd, &renderingInfo);
vkCmdPipelineBarrier2( cmd, &misc.acquireToRenderDependency );
vkCmdBeginRendering( cmd, &renderingInfo );
{
VkViewport viewport = {
.x = 0,
@ -140,22 +143,21 @@ SDL_AppResult SDL_AppIterate(void* appstate)
.minDepth = 0.0f,
.maxDepth = 1.0f,
};
vkCmdSetViewport(cmd, 0, 1, &viewport);
vkCmdSetViewport( cmd, 0, 1, &viewport );
VkRect2D scissor = {
.offset = {0, 0},
.offset = { 0, 0 },
.extent = renderDevice.swapchainExtent,
};
vkCmdSetScissor(cmd, 0, 1, &scissor);
vkCmdSetScissor( cmd, 0, 1, &scissor );
// Render Something?
vkCmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, misc.trianglePipeline);
vkCmdDraw(cmd, 3, 1, 0, 0);
vkCmdBindPipeline( cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, misc.trianglePipeline );
vkCmdDraw( cmd, 3, 1, 0, 0 );
}
vkCmdEndRendering(cmd);
vkCmdPipelineBarrier2(cmd, &misc.renderToPresentDependency);
vkCmdEndRendering( cmd );
vkCmdPipelineBarrier2( cmd, &misc.renderToPresentDependency );
}
VK_CHECK(vkEndCommandBuffer(cmd));
VK_CHECK( vkEndCommandBuffer(cmd) );
VkPipelineStageFlags stageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
VkSubmitInfo const submitInfo = {
@ -169,7 +171,7 @@ SDL_AppResult SDL_AppIterate(void* appstate)
.signalSemaphoreCount = 1,
.pSignalSemaphores = &currentFrame.renderFinishedSemaphore,
};
VK_CHECK(vkQueueSubmit(renderDevice.directQueue, 1, &submitInfo, currentFrame.frameReadyToReuse));
VK_CHECK( vkQueueSubmit(renderDevice.directQueue, 1, &submitInfo, currentFrame.frameReadyToReuse) );
VkPresentInfoKHR const presentInfo = {
.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR,
@ -182,16 +184,16 @@ SDL_AppResult SDL_AppIterate(void* appstate)
.pResults = nullptr,
};
VK_CHECK(vkQueuePresentKHR(renderDevice.directQueue, &presentInfo));
VK_CHECK( vkQueuePresentKHR(renderDevice.directQueue, &presentInfo) );
renderDevice.frameIndex = (renderDevice.frameIndex + 1) % NUM_FRAMES;
return SDL_APP_CONTINUE;
}
SDL_AppResult SDL_AppEvent(void*, SDL_Event* event)
SDL_AppResult SDL_AppEvent( void*, SDL_Event* event )
{
if (event->type == SDL_EVENT_QUIT)
if ( event->type == SDL_EVENT_QUIT )
{
return SDL_APP_SUCCESS;
}
@ -199,11 +201,11 @@ SDL_AppResult SDL_AppEvent(void*, SDL_Event* event)
return SDL_APP_CONTINUE;
}
void SDL_AppQuit(void* appstate, SDL_AppResult)
void SDL_AppQuit( void* appstate, SDL_AppResult )
{
AppState* appState = static_cast<AppState*> (appstate);
AppState* appState = static_cast<AppState*>(appstate);
appState->cleanup();
appState->destroy();
Blaze::Global::g_Memory.destroy();
}

View File

@ -183,7 +183,6 @@
<ClInclude Include="AppState.h" />
<ClInclude Include="Frame.h" />
<ClInclude Include="GlobalMemory.h" />
<ClInclude Include="MemoryUtils.h" />
<ClInclude Include="MacroUtils.h" />
<ClInclude Include="MathUtil.h" />
<ClInclude Include="MiscData.h" />

View File

@ -75,9 +75,6 @@
<ClInclude Include="MathUtil.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="MemoryUtils.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="AppState.h">
<Filter>Header Files</Filter>
</ClInclude>

View File

@ -10,7 +10,7 @@ bool Frame::isInit() const
return static_cast<bool>(commandPool);
}
Frame::Frame(VkDevice const device, uint32_t const directQueueFamilyIndex)
Frame::Frame( VkDevice const device, uint32_t const directQueueFamilyIndex )
{
VkCommandPoolCreateInfo const commandPoolCreateInfo = {
.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,
@ -18,7 +18,7 @@ Frame::Frame(VkDevice const device, uint32_t const directQueueFamilyIndex)
.flags = VK_COMMAND_POOL_CREATE_TRANSIENT_BIT,
.queueFamilyIndex = directQueueFamilyIndex,
};
VK_CHECK(vkCreateCommandPool(device, &commandPoolCreateInfo, nullptr, &commandPool));
VK_CHECK( vkCreateCommandPool(device, &commandPoolCreateInfo, nullptr, &commandPool) );
VkCommandBufferAllocateInfo const commandBufferAllocateInfo = {
.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO,
@ -27,38 +27,38 @@ Frame::Frame(VkDevice const device, uint32_t const directQueueFamilyIndex)
.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY,
.commandBufferCount = 1,
};
VK_CHECK(vkAllocateCommandBuffers(device, &commandBufferAllocateInfo, &commandBuffer));
VK_CHECK( vkAllocateCommandBuffers(device, &commandBufferAllocateInfo, &commandBuffer) );
VkSemaphoreCreateInfo constexpr semaphoreCreateInfo = {
.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO,
.pNext = nullptr,
.flags = 0
};
VK_CHECK(vkCreateSemaphore(device, &semaphoreCreateInfo, nullptr, &imageAcquiredSemaphore));
VK_CHECK(vkCreateSemaphore(device, &semaphoreCreateInfo, nullptr, &renderFinishedSemaphore));
VK_CHECK( vkCreateSemaphore(device, &semaphoreCreateInfo, nullptr, &imageAcquiredSemaphore) );
VK_CHECK( vkCreateSemaphore(device, &semaphoreCreateInfo, nullptr, &renderFinishedSemaphore) );
VkFenceCreateInfo constexpr fenceCreateInfo = {
.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO,
.pNext = nullptr,
.flags = VK_FENCE_CREATE_SIGNALED_BIT,
};
VK_CHECK(vkCreateFence(device, &fenceCreateInfo, nullptr, &frameReadyToReuse));
VK_CHECK( vkCreateFence(device, &fenceCreateInfo, nullptr, &frameReadyToReuse) );
}
void Frame::cleanup(RenderDevice const& renderDevice)
void Frame::destroy( RenderDevice const& renderDevice )
{
if (!isInit()) return;
if ( !isInit() ) return;
VkDevice const device = renderDevice.device;
vkDestroyCommandPool(device, Take(commandPool), nullptr);
vkDestroyFence(device, Take(frameReadyToReuse), nullptr);
vkDestroySemaphore(device, Take(imageAcquiredSemaphore), nullptr);
vkDestroySemaphore(device, Take(renderFinishedSemaphore), nullptr);
vkDestroyCommandPool( device, Take( commandPool ), nullptr );
vkDestroyFence( device, Take( frameReadyToReuse ), nullptr );
vkDestroySemaphore( device, Take( imageAcquiredSemaphore ), nullptr );
vkDestroySemaphore( device, Take( renderFinishedSemaphore ), nullptr );
}
Frame::~Frame()
{
// Manual Cleanup Required.
ASSERT(not isInit());
ASSERT( not isInit() );
}

View File

@ -15,10 +15,9 @@ struct Frame
[[nodiscard]] bool isInit() const;
Frame(VkDevice device, uint32_t directQueueFamilyIndex);
Frame( VkDevice device, uint32_t directQueueFamilyIndex );
void cleanup(RenderDevice const& renderDevice);
void destroy( RenderDevice const& renderDevice );
~Frame();
};

View File

@ -2,7 +2,7 @@
#include <SDL3/SDL_log.h>
void GlobalMemory::init(size_t const size)
void GlobalMemory::init( size_t const size )
{
memory = new Byte[size];
capacity = size;
@ -18,48 +18,54 @@ void GlobalMemory::destroy()
capacity = 0;
}
Byte* GlobalMemory::allocate(size_t const size)
Byte* GlobalMemory::allocate( size_t const size )
{
assert(size <= available && "No enough space available");
assert( size <= available && "No enough space available" );
Byte* retVal = memory;
memory += size;
available -= size;
SDL_LogInfo(SDL_LOG_CATEGORY_SYSTEM, "ALLOC: %p -> %p (%llu) (avail: %llu)", reinterpret_cast<void*>(retVal), reinterpret_cast<void*>(memory), size, available);
SDL_LogInfo(
SDL_LOG_CATEGORY_SYSTEM,
"ALLOC: %p -> %p (%llu) (avail: %llu)",
reinterpret_cast<void*>(retVal),
reinterpret_cast<void*>(memory),
size,
available );
return retVal;
}
Byte* GlobalMemory::allocate(size_t const size, size_t const alignment)
Byte* GlobalMemory::allocate( size_t const size, size_t const alignment )
{
uintptr_t const addr = reinterpret_cast<uintptr_t>(memory);
uintptr_t const foundOffset = addr % alignment;
if (foundOffset == 0)
if ( foundOffset == 0 )
{
return allocate(size);
return allocate( size );
}
uintptr_t const offset = alignment - foundOffset;
size_t const allocationSize = size + offset;
return offset + allocate(allocationSize);
return offset + allocate( allocationSize );
}
GlobalMemory::State GlobalMemory::getState() const
{
SDL_LogInfo(SDL_LOG_CATEGORY_SYSTEM, "TEMP: %p %llu", reinterpret_cast<void*>(memory), available);
SDL_LogInfo( SDL_LOG_CATEGORY_SYSTEM, "TEMP: %p %llu", reinterpret_cast<void*>(memory), available );
return {
.memory = memory,
.available = available,
};
}
void GlobalMemory::restoreState(State const& state)
void GlobalMemory::restoreState( State const& state )
{
assert(memory >= state.memory); //< Behind top of allocator
assert(memory - (capacity - available) <= state.memory); //< Ahead of start of allocator
SDL_LogInfo(SDL_LOG_CATEGORY_SYSTEM, "RESTORE: %p %llu", reinterpret_cast<void*>(memory), available);
ASSERT( memory >= state.memory ); //< Behind top of allocator
ASSERT( memory - (capacity - available) <= state.memory ); //< Ahead of start of allocator
SDL_LogInfo( SDL_LOG_CATEGORY_SYSTEM, "RESTORE: %p %llu", reinterpret_cast<void*>(memory), available );
memory = state.memory;
available = state.available;
}

View File

@ -18,17 +18,17 @@ struct GlobalMemory
size_t available;
size_t capacity;
void init(size_t const size);
void init( size_t size );
void destroy();
Byte* allocate(size_t const size);
Byte* allocate( size_t size );
Byte* allocate(size_t const size, size_t const alignment);
Byte* allocate( size_t size, size_t alignment );
// Do not do any permanent allocations after calling this.
[[nodiscard]] State getState() const;
// Call this before permanent allocations.
void restoreState(State const& state);
void restoreState( State const& state );
};

View File

@ -2,8 +2,8 @@
#include <utility>
template <std::totally_ordered T>
T Clamp(T const val, T const minVal, T const maxVal)
template < std::totally_ordered T >
T Clamp( T const val, T const minVal, T const maxVal )
{
return std::min(maxVal, std::max(val, minVal));
return std::min( maxVal, std::max( val, minVal ) );
}

View File

@ -1,10 +0,0 @@
#pragma once
#include <foonathan/memory/memory_arena.hpp>
#include <foonathan/memory/memory_stack.hpp>
#include <foonathan/memory/temporary_allocator.hpp>
using global_allocator_t = foonathan::memory::memory_stack<foonathan::memory::virtual_block_allocator>;
using subsystem_allocator_t = foonathan::memory::memory_stack<foonathan::memory::fixed_block_allocator<global_allocator_t>>;
using temporary_allocator_t = foonathan::memory::temporary_allocator;

View File

@ -7,17 +7,17 @@
#include "RenderDevice.h"
void MiscData::init(RenderDevice const& renderDevice)
void MiscData::init( RenderDevice const& renderDevice )
{
VkDevice const device = renderDevice.device;
{
size_t dataSize;
void* rawData = SDL_LoadFile("Triangle.spv", &dataSize);
ASSERT(dataSize % 4 == 0);
void* rawData = SDL_LoadFile( "Triangle.spv", &dataSize );
ASSERT( dataSize % 4 == 0 );
if (not rawData)
if ( !rawData )
{
SDL_LogError(SDL_LOG_CATEGORY_SYSTEM, "%s", SDL_GetError());
SDL_LogError( SDL_LOG_CATEGORY_SYSTEM, "%s", SDL_GetError() );
abort();
}
@ -32,7 +32,7 @@ void MiscData::init(RenderDevice const& renderDevice)
};
VkShaderModule shaderModule;
VK_CHECK(vkCreateShaderModule(device, &shaderModuleCreateInfo, nullptr, &shaderModule));
VK_CHECK( vkCreateShaderModule(device, &shaderModuleCreateInfo, nullptr, &shaderModule) );
VkPipelineLayoutCreateInfo constexpr pipelineLayoutCreateInfo = {
.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,
@ -43,7 +43,7 @@ void MiscData::init(RenderDevice const& renderDevice)
.pushConstantRangeCount = 0,
.pPushConstantRanges = nullptr,
};
VK_CHECK(vkCreatePipelineLayout(device, &pipelineLayoutCreateInfo, nullptr, &pipelineLayout));
VK_CHECK( vkCreatePipelineLayout(device, &pipelineLayoutCreateInfo, nullptr, &pipelineLayout) );
std::array stages = {
VkPipelineShaderStageCreateInfo{
@ -166,7 +166,7 @@ void MiscData::init(RenderDevice const& renderDevice)
.logicOp = VK_LOGIC_OP_COPY,
.attachmentCount = 1,
.pAttachments = &colorBlendAttachmentState,
.blendConstants = {0.0f, 0.0f, 0.0f, 0.0f},
.blendConstants = { 0.0f, 0.0f, 0.0f, 0.0f },
};
std::array constexpr dynamicStates = {
@ -210,11 +210,11 @@ void MiscData::init(RenderDevice const& renderDevice)
.basePipelineIndex = 0,
};
VK_CHECK(vkCreateGraphicsPipelines(device, nullptr, 1, &graphicsPipelineCreateInfo, nullptr, &trianglePipeline));
VK_CHECK( vkCreateGraphicsPipelines(device, nullptr, 1, &graphicsPipelineCreateInfo, nullptr, &trianglePipeline) );
vkDestroyShaderModule(device, shaderModule, nullptr);
vkDestroyShaderModule( device, shaderModule, nullptr );
SDL_free(rawData);
SDL_free( rawData );
}
acquireToRenderBarrier = {
@ -280,10 +280,10 @@ void MiscData::init(RenderDevice const& renderDevice)
};
}
void MiscData::cleanup(RenderDevice const& renderDevice)
void MiscData::cleanup( RenderDevice const& renderDevice )
{
VkDevice const device = renderDevice.device;
vkDestroyPipeline(device, trianglePipeline, nullptr);
vkDestroyPipelineLayout(device, pipelineLayout, nullptr);
vkDestroyPipeline( device, trianglePipeline, nullptr );
vkDestroyPipelineLayout( device, pipelineLayout, nullptr );
}

View File

@ -14,6 +14,6 @@ struct MiscData
VkImageMemoryBarrier2 renderToPresentBarrier;
VkDependencyInfo renderToPresentDependency;
void init(RenderDevice const& renderDevice);
void cleanup(RenderDevice const& renderDevice);
void init( RenderDevice const& renderDevice );
void cleanup( RenderDevice const& renderDevice );
};

View File

@ -14,13 +14,13 @@
RenderDevice::~RenderDevice()
{
ASSERT(!isInit());
ASSERT( !isInit() );
}
// TODO: Failure Handling
RenderDevice* CreateRenderDevice(GlobalMemory* mem, RenderDevice::CreateInfo const& createInfo)
RenderDevice* CreateRenderDevice( GlobalMemory* mem, RenderDevice::CreateInfo const& createInfo )
{
ASSERT(createInfo.window);
ASSERT( createInfo.window );
volkInitialize();
@ -31,14 +31,14 @@ RenderDevice* CreateRenderDevice(GlobalMemory* mem, RenderDevice::CreateInfo con
.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO,
.pNext = nullptr,
.pApplicationName = "Test",
.applicationVersion = VK_MAKE_API_VERSION(0, 0, 1, 0),
.applicationVersion = VK_MAKE_API_VERSION( 0, 0, 1, 0 ),
.pEngineName = "Blaze",
.engineVersion = VK_MAKE_API_VERSION(0, 0, 1, 0),
.engineVersion = VK_MAKE_API_VERSION( 0, 0, 1, 0 ),
.apiVersion = VK_API_VERSION_1_3,
};
uint32_t instanceExtensionCount;
char const* const* instanceExtensions = SDL_Vulkan_GetInstanceExtensions(&instanceExtensionCount);
char const* const* instanceExtensions = SDL_Vulkan_GetInstanceExtensions( &instanceExtensionCount );
VkInstanceCreateInfo const instanceCreateInfo = {
.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
@ -51,13 +51,13 @@ RenderDevice* CreateRenderDevice(GlobalMemory* mem, RenderDevice::CreateInfo con
.ppEnabledExtensionNames = instanceExtensions,
};
VK_CHECK(vkCreateInstance(&instanceCreateInfo, nullptr, &instance));
volkLoadInstance(instance);
VK_CHECK( vkCreateInstance(&instanceCreateInfo, nullptr, &instance) );
volkLoadInstance( instance );
}
VkSurfaceKHR surface;
// Create Surface
ASSERT(SDL_Vulkan_CreateSurface(createInfo.window, instance, nullptr, &surface));
ASSERT( SDL_Vulkan_CreateSurface(createInfo.window, instance, nullptr, &surface) );
VkPhysicalDevice physicalDeviceInUse = nullptr;
VkDevice device = nullptr;
@ -69,44 +69,48 @@ RenderDevice* CreateRenderDevice(GlobalMemory* mem, RenderDevice::CreateInfo con
auto tempAllocStart = mem->getState();
uint32_t physicalDeviceCount;
VK_CHECK(vkEnumeratePhysicalDevices(instance, &physicalDeviceCount, nullptr));
SDL_LogInfo(SDL_LOG_CATEGORY_GPU, "Found %u GPUs", physicalDeviceCount);
VK_CHECK( vkEnumeratePhysicalDevices(instance, &physicalDeviceCount, nullptr) );
SDL_LogInfo( SDL_LOG_CATEGORY_GPU, "Found %u GPUs", physicalDeviceCount );
VkPhysicalDevice* physicalDevices = reinterpret_cast<VkPhysicalDevice*>(mem->allocate(sizeof(VkPhysicalDevice) * physicalDeviceCount));
VK_CHECK(vkEnumeratePhysicalDevices(instance, &physicalDeviceCount, physicalDevices));
VkPhysicalDevice* physicalDevices = reinterpret_cast<VkPhysicalDevice*>(mem->allocate(
sizeof( VkPhysicalDevice ) * physicalDeviceCount ));
VK_CHECK( vkEnumeratePhysicalDevices(instance, &physicalDeviceCount, physicalDevices) );
for (VkPhysicalDevice const physicalDevice : std::span{ physicalDevices, physicalDeviceCount })
for ( VkPhysicalDevice const physicalDevice : std::span{ physicalDevices, physicalDeviceCount } )
{
auto tempAllocQueueProperties = mem->getState();
VkPhysicalDeviceProperties properties;
vkGetPhysicalDeviceProperties(physicalDevice, &properties);
vkGetPhysicalDeviceProperties( physicalDevice, &properties );
SDL_LogInfo(SDL_LOG_CATEGORY_GPU, "GPU: %s", properties.deviceName);
SDL_LogInfo( SDL_LOG_CATEGORY_GPU, "GPU: %s", properties.deviceName );
SDL_LogInfo(SDL_LOG_CATEGORY_GPU, "- API Version %d.%d.%d",
VK_API_VERSION_MAJOR(properties.apiVersion),
VK_API_VERSION_MINOR(properties.apiVersion),
VK_API_VERSION_PATCH(properties.apiVersion));
SDL_LogInfo(
SDL_LOG_CATEGORY_GPU,
"- API Version %d.%d.%d",
VK_API_VERSION_MAJOR( properties.apiVersion ),
VK_API_VERSION_MINOR( properties.apiVersion ),
VK_API_VERSION_PATCH( properties.apiVersion ) );
constexpr static uint32_t API_PATCH_BITS = 0xFFF;
if ((properties.apiVersion & (~API_PATCH_BITS)) < VK_API_VERSION_1_3)
if ( (properties.apiVersion & (~API_PATCH_BITS)) < VK_API_VERSION_1_3 )
{
continue;
}
if (properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_CPU)
if ( properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_CPU )
{
continue;
}
uint32_t queueFamilyCount;
vkGetPhysicalDeviceQueueFamilyProperties(physicalDevice, &queueFamilyCount, nullptr);
VkQueueFamilyProperties* queueFamilyProperties = reinterpret_cast<VkQueueFamilyProperties*>(mem->allocate(sizeof(VkQueueFamilyProperties) * queueFamilyCount));
vkGetPhysicalDeviceQueueFamilyProperties(physicalDevice, &queueFamilyCount, queueFamilyProperties);
vkGetPhysicalDeviceQueueFamilyProperties( physicalDevice, &queueFamilyCount, nullptr );
VkQueueFamilyProperties* queueFamilyProperties = reinterpret_cast<VkQueueFamilyProperties*>(mem->allocate(
sizeof( VkQueueFamilyProperties ) * queueFamilyCount ));
vkGetPhysicalDeviceQueueFamilyProperties( physicalDevice, &queueFamilyCount, queueFamilyProperties );
for (uint32_t queueFamilyIndex = 0; queueFamilyIndex != queueFamilyCount;
++queueFamilyIndex)
for ( uint32_t queueFamilyIndex = 0; queueFamilyIndex != queueFamilyCount;
++queueFamilyIndex )
{
VkQueueFamilyProperties const& qfp = queueFamilyProperties[queueFamilyIndex];
@ -115,46 +119,46 @@ RenderDevice* CreateRenderDevice(GlobalMemory* mem, RenderDevice::CreateInfo con
bool hasTransferSupport = false;
bool hasPresentSupport = false;
SDL_LogInfo(SDL_LOG_CATEGORY_GPU, "- Queue [%d]", queueFamilyIndex);
if (qfp.queueFlags & VK_QUEUE_GRAPHICS_BIT)
SDL_LogInfo( SDL_LOG_CATEGORY_GPU, "- Queue [%d]", queueFamilyIndex );
if ( qfp.queueFlags & VK_QUEUE_GRAPHICS_BIT )
{
hasGraphicsSupport = true;
SDL_LogInfo(SDL_LOG_CATEGORY_GPU, "-- Graphic");
SDL_LogInfo( SDL_LOG_CATEGORY_GPU, "-- Graphic" );
}
if (qfp.queueFlags & VK_QUEUE_COMPUTE_BIT)
if ( qfp.queueFlags & VK_QUEUE_COMPUTE_BIT )
{
hasComputeSupport = true;
SDL_LogInfo(SDL_LOG_CATEGORY_GPU, "-- Compute");
SDL_LogInfo( SDL_LOG_CATEGORY_GPU, "-- Compute" );
}
if (qfp.queueFlags & VK_QUEUE_TRANSFER_BIT)
if ( qfp.queueFlags & VK_QUEUE_TRANSFER_BIT )
{
hasTransferSupport = true;
SDL_LogInfo(SDL_LOG_CATEGORY_GPU, "-- Transfer");
SDL_LogInfo( SDL_LOG_CATEGORY_GPU, "-- Transfer" );
}
VkBool32 isSurfaceSupported;
VK_CHECK(vkGetPhysicalDeviceSurfaceSupportKHR(physicalDevice, queueFamilyIndex, surface, &isSurfaceSupported));
VK_CHECK(
vkGetPhysicalDeviceSurfaceSupportKHR(physicalDevice, queueFamilyIndex, surface, &isSurfaceSupported) );
if (isSurfaceSupported)
if ( isSurfaceSupported )
{
hasPresentSupport = true;
SDL_LogInfo(SDL_LOG_CATEGORY_GPU, "-- Present");
SDL_LogInfo( SDL_LOG_CATEGORY_GPU, "-- Present" );
}
if (hasGraphicsSupport and hasComputeSupport and hasTransferSupport and hasPresentSupport)
if ( hasGraphicsSupport and hasComputeSupport and hasTransferSupport and hasPresentSupport )
{
physicalDeviceInUse = physicalDevice;
directQueueFamilyIndex = queueFamilyIndex;
break;
}
}
mem->restoreState(tempAllocQueueProperties);
mem->restoreState( tempAllocQueueProperties );
}
ASSERT(physicalDeviceInUse);
ASSERT(directQueueFamilyIndex.has_value());
ASSERT( physicalDeviceInUse );
ASSERT( directQueueFamilyIndex.has_value() );
float priority = 1.0f;
VkDeviceQueueCreateInfo queueCreateInfo = {
@ -195,8 +199,8 @@ RenderDevice* CreateRenderDevice(GlobalMemory* mem, RenderDevice::CreateInfo con
.pEnabledFeatures = &features,
};
VK_CHECK(vkCreateDevice(physicalDeviceInUse, &deviceCreateInfo, nullptr, &device));
volkLoadDevice(device);
VK_CHECK( vkCreateDevice(physicalDeviceInUse, &deviceCreateInfo, nullptr, &device) );
volkLoadDevice( device );
VmaAllocatorCreateInfo allocatorCreateInfo = {
.flags = 0,
@ -213,14 +217,14 @@ RenderDevice* CreateRenderDevice(GlobalMemory* mem, RenderDevice::CreateInfo con
};
VmaVulkanFunctions vkFunctions;
VK_CHECK(vmaImportVulkanFunctionsFromVolk(&allocatorCreateInfo, &vkFunctions));
VK_CHECK( vmaImportVulkanFunctionsFromVolk(&allocatorCreateInfo, &vkFunctions) );
allocatorCreateInfo.pVulkanFunctions = &vkFunctions;
VK_CHECK(vmaCreateAllocator(&allocatorCreateInfo, &gpuAllocator));
VK_CHECK( vmaCreateAllocator(&allocatorCreateInfo, &gpuAllocator) );
vkGetDeviceQueue(device, directQueueFamilyIndex.value(), 0, &directQueue);
vkGetDeviceQueue( device, directQueueFamilyIndex.value(), 0, &directQueue );
mem->restoreState(tempAllocStart);
mem->restoreState( tempAllocStart );
}
// Swapchain creation
@ -234,75 +238,80 @@ RenderDevice* CreateRenderDevice(GlobalMemory* mem, RenderDevice::CreateInfo con
auto tempAllocStart = mem->getState();
VkSurfaceCapabilitiesKHR capabilities;
VK_CHECK(vkGetPhysicalDeviceSurfaceCapabilitiesKHR(physicalDeviceInUse, surface, &capabilities));
VK_CHECK( vkGetPhysicalDeviceSurfaceCapabilitiesKHR(physicalDeviceInUse, surface, &capabilities) );
// Image Count Calculation
swapchainImageCount = 3;
if (capabilities.maxImageCount > 0)
if ( capabilities.maxImageCount > 0 )
{
swapchainImageCount = std::min(swapchainImageCount, capabilities.maxImageCount);
swapchainImageCount = std::min( swapchainImageCount, capabilities.maxImageCount );
}
swapchainImageCount = std::max(swapchainImageCount, capabilities.minImageCount + 1);
swapchainImageCount = std::max( swapchainImageCount, capabilities.minImageCount + 1 );
// Image Size calculation
{
auto [minWidth, minHeight] = capabilities.minImageExtent;
auto [maxWidth, maxHeight] = capabilities.maxImageExtent;
swapchainExtent.width = Clamp(swapchainExtent.width, minWidth, maxWidth);
swapchainExtent.height = Clamp(swapchainExtent.height, minHeight, maxHeight);
swapchainExtent.width = Clamp( swapchainExtent.width, minWidth, maxWidth );
swapchainExtent.height = Clamp( swapchainExtent.height, minHeight, maxHeight );
}
uint32_t surfaceFormatCount;
vkGetPhysicalDeviceSurfaceFormatsKHR(physicalDeviceInUse, surface, &surfaceFormatCount, nullptr);
VkSurfaceFormatKHR* surfaceFormats = reinterpret_cast<VkSurfaceFormatKHR*>(mem->allocate(sizeof(VkSurfaceFormatKHR*) * surfaceFormatCount));
vkGetPhysicalDeviceSurfaceFormatsKHR(physicalDeviceInUse, surface, &surfaceFormatCount, surfaceFormats);
vkGetPhysicalDeviceSurfaceFormatsKHR( physicalDeviceInUse, surface, &surfaceFormatCount, nullptr );
VkSurfaceFormatKHR* surfaceFormats = reinterpret_cast<VkSurfaceFormatKHR*>(mem->allocate(
sizeof( VkSurfaceFormatKHR* ) * surfaceFormatCount ));
vkGetPhysicalDeviceSurfaceFormatsKHR( physicalDeviceInUse, surface, &surfaceFormatCount, surfaceFormats );
VkSurfaceFormatKHR format = {
.format = VK_FORMAT_UNDEFINED,
.colorSpace = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR,
};
for (auto& surfaceFormat : std::span{ surfaceFormats, surfaceFormatCount })
for ( auto& surfaceFormat : std::span{ surfaceFormats, surfaceFormatCount } )
{
if (surfaceFormat.colorSpace == VK_COLOR_SPACE_SRGB_NONLINEAR_KHR)
if ( surfaceFormat.colorSpace == VK_COLOR_SPACE_SRGB_NONLINEAR_KHR )
{
SDL_LogInfo( SDL_LOG_CATEGORY_GPU, "Color Space SRGB Found %d", surfaceFormat.format );
if ( surfaceFormat.format == VK_FORMAT_R8G8B8A8_SRGB )
{
SDL_LogInfo(SDL_LOG_CATEGORY_GPU, "Color Space SRGB Found %d", surfaceFormat.format);
if (surfaceFormat.format == VK_FORMAT_R8G8B8A8_SRGB) {
format = surfaceFormat;
break;
}
if (surfaceFormat.format == VK_FORMAT_B8G8R8A8_SRGB) {
if ( surfaceFormat.format == VK_FORMAT_B8G8R8A8_SRGB )
{
format = surfaceFormat;
break;
}
if (surfaceFormat.format == VK_FORMAT_R8G8B8A8_UNORM) {
if ( surfaceFormat.format == VK_FORMAT_R8G8B8A8_UNORM )
{
format = surfaceFormat;
}
}
}
ASSERT(format.format != VK_FORMAT_UNDEFINED);
ASSERT( format.format != VK_FORMAT_UNDEFINED );
swapchainFormat = format.format;
uint32_t presentModeCount;
vkGetPhysicalDeviceSurfacePresentModesKHR(physicalDeviceInUse, surface, &presentModeCount, nullptr);
VkPresentModeKHR* presentModes = reinterpret_cast<VkPresentModeKHR*>(mem->allocate(sizeof(VkPresentModeKHR*) * presentModeCount));
vkGetPhysicalDeviceSurfacePresentModesKHR(physicalDeviceInUse, surface, &presentModeCount, presentModes);
vkGetPhysicalDeviceSurfacePresentModesKHR( physicalDeviceInUse, surface, &presentModeCount, nullptr );
VkPresentModeKHR* presentModes = reinterpret_cast<VkPresentModeKHR*>(mem->allocate(
sizeof( VkPresentModeKHR* ) * presentModeCount ));
vkGetPhysicalDeviceSurfacePresentModesKHR( physicalDeviceInUse, surface, &presentModeCount, presentModes );
VkPresentModeKHR presentMode = VK_PRESENT_MODE_FIFO_KHR;
for (VkPresentModeKHR presentModeIter : std::span{ presentModes, presentModeCount })
for ( VkPresentModeKHR presentModeIter : std::span{ presentModes, presentModeCount } )
{
if (presentModeIter == VK_PRESENT_MODE_FIFO_RELAXED_KHR)
if ( presentModeIter == VK_PRESENT_MODE_FIFO_RELAXED_KHR )
{
presentMode = presentModeIter;
break;
}
if (presentModeIter == VK_PRESENT_MODE_MAILBOX_KHR)
if ( presentModeIter == VK_PRESENT_MODE_MAILBOX_KHR )
{
presentMode = presentModeIter;
}
}
mem->restoreState(tempAllocStart);
mem->restoreState( tempAllocStart );
VkSwapchainCreateInfoKHR const swapchainCreateInfo = {
.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR,
@ -325,15 +334,16 @@ RenderDevice* CreateRenderDevice(GlobalMemory* mem, RenderDevice::CreateInfo con
.oldSwapchain = nullptr,
};
VK_CHECK(vkCreateSwapchainKHR(device, &swapchainCreateInfo, nullptr, &swapchain));
VK_CHECK( vkCreateSwapchainKHR(device, &swapchainCreateInfo, nullptr, &swapchain) );
swapchainImageCount = 0;
vkGetSwapchainImagesKHR(device, swapchain, &swapchainImageCount, nullptr);
swapchainImages = reinterpret_cast<VkImage*>(mem->allocate(sizeof(VkImage) * swapchainImageCount));
vkGetSwapchainImagesKHR(device, swapchain, &swapchainImageCount, swapchainImages);
vkGetSwapchainImagesKHR( device, swapchain, &swapchainImageCount, nullptr );
swapchainImages = reinterpret_cast<VkImage*>(mem->allocate( sizeof( VkImage ) * swapchainImageCount ));
vkGetSwapchainImagesKHR( device, swapchain, &swapchainImageCount, swapchainImages );
swapchainViews = reinterpret_cast<VkImageView*>(mem->allocate(sizeof(VkImageView) * swapchainImageCount));
for (uint32_t i = 0; i != swapchainImageCount; ++i) {
swapchainViews = reinterpret_cast<VkImageView*>(mem->allocate( sizeof( VkImageView ) * swapchainImageCount ));
for ( uint32_t i = 0; i != swapchainImageCount; ++i )
{
VkImageViewCreateInfo const viewCreateInfo = {
.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
.pNext = nullptr,
@ -356,23 +366,34 @@ RenderDevice* CreateRenderDevice(GlobalMemory* mem, RenderDevice::CreateInfo con
}
};
VK_CHECK(vkCreateImageView(device, &viewCreateInfo, nullptr, &swapchainViews[i]));
VK_CHECK( vkCreateImageView(device, &viewCreateInfo, nullptr, &swapchainViews[i]) );
}
}
// Init frames.
Frame* frames = reinterpret_cast<Frame*>(mem->allocate(sizeof(Frame) * swapchainImageCount));
for (uint32_t i = 0; i != swapchainImageCount; ++i)
Frame* frames = reinterpret_cast<Frame*>(mem->allocate( sizeof( Frame ) * swapchainImageCount ));
for ( uint32_t i = 0; i != swapchainImageCount; ++i )
{
new (frames + i) Frame(device, directQueueFamilyIndex.value());
new( frames + i ) Frame( device, directQueueFamilyIndex.value() );
}
Byte* allocation = mem->allocate(sizeof(RenderDevice), alignof(RenderDevice));
return new (allocation) RenderDevice{
instance, surface, physicalDeviceInUse,
device, gpuAllocator, directQueue, directQueueFamilyIndex.value(),
swapchainFormat, swapchainExtent, swapchain, swapchainImages, swapchainViews, frames, swapchainImageCount,
Byte* allocation = mem->allocate( sizeof( RenderDevice ), alignof( RenderDevice ) );
return new( allocation ) RenderDevice{
instance,
surface,
physicalDeviceInUse,
device,
gpuAllocator,
directQueue,
directQueueFamilyIndex.value(),
swapchainFormat,
swapchainExtent,
swapchain,
swapchainImages,
swapchainViews,
frames,
swapchainImageCount,
};
}
@ -381,35 +402,34 @@ inline bool RenderDevice::isInit() const
return instance and device;
}
void RenderDevice::cleanup()
void RenderDevice::destroy()
{
if (not isInit())
return;
if ( not isInit() ) return;
for (Frame& frame : std::span{ frames, swapchainImageCount })
for ( Frame& frame : std::span{ frames, swapchainImageCount } )
{
frame.cleanup(*this);
frame.destroy( *this );
}
for (auto const& view : std::span{ swapchainViews, swapchainImageCount })
for ( auto const& view : std::span{ swapchainViews, swapchainImageCount } )
{
vkDestroyImageView(device, view, nullptr);
vkDestroyImageView( device, view, nullptr );
}
vkDestroySwapchainKHR(device, Take(swapchain), nullptr);
vkDestroySwapchainKHR( device, Take( swapchain ), nullptr );
vkDestroyDevice(Take(device), nullptr);
vkDestroyDevice( Take( device ), nullptr );
SDL_Vulkan_DestroySurface(instance, Take(surface), nullptr);
SDL_Vulkan_DestroySurface( instance, Take( surface ), nullptr );
vkDestroyInstance(Take(instance), nullptr);
vkDestroyInstance( Take( instance ), nullptr );
volkFinalize();
}
void RenderDevice::waitIdle() const
{
VK_CHECK(vkDeviceWaitIdle(device));
VK_CHECK( vkDeviceWaitIdle(device) );
}
uint32_t RenderDevice::getNumFrames() const
@ -417,10 +437,21 @@ uint32_t RenderDevice::getNumFrames() const
return swapchainImageCount;
}
RenderDevice::RenderDevice(VkInstance const instance, VkSurfaceKHR const surface, VkPhysicalDevice const physicalDeviceInUse,
VkDevice const device, VmaAllocator gpuAllocator, VkQueue const directQueue, uint32_t const directQueueFamilyIndex,
VkFormat const swapchainFormat, VkExtent2D const swapchainExtent, VkSwapchainKHR const swapchain, VkImage* swapchainImages,
VkImageView* swapchainViews, Frame* frames, uint32_t const swapchainImageCount)
RenderDevice::RenderDevice(
VkInstance const instance,
VkSurfaceKHR const surface,
VkPhysicalDevice const physicalDeviceInUse,
VkDevice const device,
VmaAllocator gpuAllocator,
VkQueue const directQueue,
uint32_t const directQueueFamilyIndex,
VkFormat const swapchainFormat,
VkExtent2D const swapchainExtent,
VkSwapchainKHR const swapchain,
VkImage* swapchainImages,
VkImageView* swapchainViews,
Frame* frames,
uint32_t const swapchainImageCount )
: instance{ instance }
, surface{ surface }
, physicalDeviceInUse{ physicalDeviceInUse }
@ -434,6 +465,4 @@ RenderDevice::RenderDevice(VkInstance const instance, VkSurfaceKHR const surface
, swapchainImages{ swapchainImages }
, swapchainViews{ swapchainViews }
, frames{ frames }
, swapchainImageCount{ swapchainImageCount }
{
}
, swapchainImageCount{ swapchainImageCount } {}

View File

@ -44,7 +44,7 @@ struct RenderDevice
uint32_t frameIndex = 0;
[[nodiscard]] bool isInit() const;
void cleanup();
void destroy();
void waitIdle() const;
[[nodiscard]] uint32_t getNumFrames() const;
@ -68,13 +68,13 @@ struct RenderDevice
uint32_t swapchainImageCount
);
RenderDevice(RenderDevice const&) = delete;
RenderDevice& operator=(RenderDevice const&) = delete;
RenderDevice( RenderDevice const& ) = delete;
RenderDevice& operator=( RenderDevice const& ) = delete;
RenderDevice(RenderDevice&&) noexcept = delete;
RenderDevice& operator=(RenderDevice&&) noexcept = delete;
RenderDevice( RenderDevice&& ) noexcept = delete;
RenderDevice& operator=( RenderDevice&& ) noexcept = delete;
~RenderDevice();
};
RenderDevice* CreateRenderDevice(GlobalMemory* mem, RenderDevice::CreateInfo const& createInfo);
RenderDevice* CreateRenderDevice( GlobalMemory* mem, RenderDevice::CreateInfo const& createInfo );