From e76bc6ef58985f524c65cede1f1e8f82923a8b70 Mon Sep 17 00:00:00 2001 From: Brandon Mak Date: Tue, 18 Oct 2022 02:41:27 +0800 Subject: [PATCH] World render graph now doesn't render to swapchain image. world render graph now only renders to "Scene" resource. Editor render graph renders to "Present" swapchain image. Removed some unnecessary if statements slowing down the resizing Printing for success also disabled for now --- .../Graphics/Debugging/SHVulkanDebugUtil.cpp | 2 +- .../MiddleEnd/Interface/SHGraphicsSystem.cpp | 34 ++++++------------- .../MiddleEnd/PerFrame/SHRenderContext.cpp | 1 - 3 files changed, 12 insertions(+), 25 deletions(-) diff --git a/SHADE_Engine/src/Graphics/Debugging/SHVulkanDebugUtil.cpp b/SHADE_Engine/src/Graphics/Debugging/SHVulkanDebugUtil.cpp index c8a1fe1a..fd39da24 100644 --- a/SHADE_Engine/src/Graphics/Debugging/SHVulkanDebugUtil.cpp +++ b/SHADE_Engine/src/Graphics/Debugging/SHVulkanDebugUtil.cpp @@ -99,7 +99,7 @@ namespace SHADE void SHVulkanDebugUtil::ReportVkSuccess(std::string_view message) noexcept { - SHLOGV_INFO(message); + //SHLOGV_INFO(message); } /***************************************************************************/ diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp index 929e5d54..c78cc58f 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp @@ -143,30 +143,22 @@ namespace SHADE // Initialize world render graph worldRenderGraph->Init(device, swapchain); - //worldRenderGraph->AddResource("Present", { SH_ATT_DESC_TYPE_FLAGS::COLOR_PRESENT }, windowDims.first, windowDims.second); worldRenderGraph->AddResource("Scene", { SH_ATT_DESC_TYPE_FLAGS::COLOR, SH_ATT_DESC_TYPE_FLAGS::INPUT }, windowDims.first, windowDims.second); worldRenderGraph->AddResource("Depth Buffer", { SH_ATT_DESC_TYPE_FLAGS::DEPTH_STENCIL }, windowDims.first, windowDims.second, vk::Format::eD32SfloatS8Uint); worldRenderGraph->AddResource("Entity ID", { SH_ATT_DESC_TYPE_FLAGS::COLOR }, windowDims.first, windowDims.second, vk::Format::eR32Uint, 1, vk::ImageUsageFlagBits::eTransferSrc); - auto node = worldRenderGraph->AddNode("G-Buffer", { /*"Present", */"Entity ID", "Depth Buffer", "Scene"}, {}); // no predecessors + auto node = worldRenderGraph->AddNode("G-Buffer", { "Entity ID", "Depth Buffer", "Scene"}, {}); // no predecessors //First subpass to write to G-Buffer auto gBufferWriteSubpass = node->AddSubpass("G-Buffer Write"); gBufferWriteSubpass->AddColorOutput("Scene"); gBufferWriteSubpass->AddColorOutput("Entity ID"); - //gBufferWriteSubpass->AddColorOutput("Present"); gBufferWriteSubpass->AddDepthOutput("Depth Buffer", SH_ATT_DESC_TYPE_FLAGS::DEPTH_STENCIL); // We do this to just transition our scene layout to shader read auto sceneLayoutTransitionSubpass = node->AddSubpass("Scene Layout Transition"); sceneLayoutTransitionSubpass->AddInput("Scene"); -//#ifdef SHEDITOR -// auto imguiNode = worldRenderGraph->AddNode("ImGui Node", { "Present" }, { "G-Buffer" }); -// auto imguiSubpass = imguiNode->AddSubpass("ImGui Draw"); -// imguiSubpass->AddColorOutput("Present"); -//#endif - // Generate world render graph worldRenderGraph->Generate(); @@ -297,12 +289,6 @@ namespace SHADE if (window->IsMinimized() || renderContext.GetWindowIsDead()) return; - if (renderContext.GetResized()) - { - return; - } - - // Frame data for the current frame auto const& frameData = renderContext.GetCurrentFrameData(); uint32_t frameIndex = renderContext.GetCurrentFrame(); @@ -463,12 +449,6 @@ namespace SHADE if (window->IsMinimized() || renderContext.GetWindowIsDead()) return; - if (renderContext.GetResized()) - { - return; - } - - const uint32_t CURR_FRAME_IDX = renderContext.GetCurrentFrame(); auto& currFrameData = renderContext.GetCurrentFrameData(); @@ -480,9 +460,7 @@ namespace SHADE // If swapchain is incompatible/outdated if (result == vk::Result::eErrorOutOfDateKHR || result == vk::Result::eSuboptimalKHR) { - HandleResize(); - } } @@ -692,9 +670,14 @@ namespace SHADE void SHGraphicsSystem::HandleResize(void) noexcept { + device->WaitIdle(); + if (window->IsMinimized() || renderContext.GetWindowIsDead()) return; + graphSemaphores[0].Free(); + graphSemaphores[1].Free(); + auto windowDims = window->GetWindowSize(); // Resize the swapchain @@ -712,6 +695,11 @@ namespace SHADE defaultViewport->SetHeight(static_cast(resizeHeight)); worldCamera->SetPerspective(90.0f, static_cast(resizeWidth), static_cast(resizeHeight), 0.0f, 100.0f); + + for (auto& semaHandle : graphSemaphores) + semaHandle = device->CreateSemaphore(); + + } void SHGraphicsSystem::AwaitGraphicsExecution() diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/PerFrame/SHRenderContext.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/PerFrame/SHRenderContext.cpp index 0ac7013a..8041adfd 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/PerFrame/SHRenderContext.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/PerFrame/SHRenderContext.cpp @@ -52,7 +52,6 @@ namespace SHADE { frameData[i].cmdPoolHdls.push_back(logicalDeviceHdl->CreateCommandPool(params.cmdPoolQueueFamilyType, params.cmdPoolResetMode, params.cmdBufferTransient)); } - } // Initialize all the info.