diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp index 63fd7466..4926ebc0 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp @@ -98,12 +98,12 @@ namespace SHADE renderGraph.AddResource("Composite", SH_ATT_DESC_TYPE::COLOR, windowDims.first, windowDims.second, vk::Format::eR16G16B16A16Sfloat); renderGraph.AddResource("Downscale", SH_ATT_DESC_TYPE::COLOR, windowDims.first, windowDims.second, vk::Format::eR16G16B16A16Sfloat); renderGraph.AddResource("Present", SH_ATT_DESC_TYPE::COLOR_PRESENT, windowDims.first, windowDims.second); - auto node = renderGraph.AddNode("G-Buffer", { "Position", "Normals", "Composite" }, {}); // no predecessors + auto node = renderGraph.AddNode("G-Buffer", { "Composite", "Position", "Normals", "Present" }, {}); // no predecessors // First subpass to write to G-Buffer auto writeSubpass = node->AddSubpass("G-Buffer Write"); writeSubpass->AddColorOutput("Position"); - writeSubpass->AddColorOutput("Normals"); + writeSubpass->AddColorOutput("Present"); // Second subpass to read from G-Buffer auto compositeSubpass = node->AddSubpass("G-Buffer Composite"); @@ -111,11 +111,11 @@ namespace SHADE compositeSubpass->AddInput("Normals"); compositeSubpass->AddInput("Position"); - //auto compositeNode = renderGraph.AddNode("Bloom", { "Composite", "Downscale", "Present"}, {"G-Buffer"}); - //auto bloomSubpass = compositeNode->AddSubpass("Downsample"); - //bloomSubpass->AddInput("Composite"); - // bloomSubpass->AddColorOutput("Downscale"); - // bloomSubpass->AddColorOutput("Present"); + //auto compositeNode = renderGraph.AddNode("Bloom", { "Composite", "Downscale", "Present" }, { "G-Buffer" }); + //auto bloomSubpass = compositeNode->AddSubpass("Downsample"); + //bloomSubpass->AddInput("Composite"); + //bloomSubpass->AddColorOutput("Downscale"); + //bloomSubpass->AddColorOutput("Present"); renderGraph.Generate(); diff --git a/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraph.cpp b/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraph.cpp index 76106d67..a2647b74 100644 --- a/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraph.cpp +++ b/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraph.cpp @@ -459,10 +459,10 @@ namespace SHADE // We set this to clear first. If later we find out that some predecessor is writing to the same attachment, // we set the pred's storeOp to eStore and "this" loadOp to eLoad. newDesc.loadOp = vk::AttachmentLoadOp::eClear; - newDesc.storeOp = vk::AttachmentStoreOp::eDontCare; + newDesc.storeOp = vk::AttachmentStoreOp::eStore; newDesc.stencilLoadOp = vk::AttachmentLoadOp::eClear; - newDesc.stencilStoreOp = vk::AttachmentStoreOp::eDontCare; + newDesc.stencilStoreOp = vk::AttachmentStoreOp::eStore; newDesc.format = attResources[i]->resourceFormat; @@ -1030,6 +1030,8 @@ namespace SHADE auto& cmdBuffer = commandBuffers[frameIndex]; cmdBuffer->BeginRecording(); + cmdBuffer->SetviewportScissor(1920.0f, 1080.0f, 1920, 1080); + for (auto& node : nodes) { node->Execute(commandBuffers[frameIndex], frameIndex); diff --git a/SHADE_Engine/src/Graphics/Renderpass/SHVkRenderpass.cpp b/SHADE_Engine/src/Graphics/Renderpass/SHVkRenderpass.cpp index 53e3326e..29de5954 100644 --- a/SHADE_Engine/src/Graphics/Renderpass/SHVkRenderpass.cpp +++ b/SHADE_Engine/src/Graphics/Renderpass/SHVkRenderpass.cpp @@ -29,11 +29,17 @@ namespace SHADE /***************************************************************************/ SHVkRenderpass::SHVkRenderpass(Handle const& inLogicalDeviceHdl, std::span const vkDescriptions, std::vector const& subpasses) noexcept : logicalDeviceHdl {inLogicalDeviceHdl} + , numAttDescs {static_cast(vkDescriptions.size())} , clearColors{} { - // TODO: temporary only - clearColors[0].color = { {{0.0f, 0.0f, 0.0f, 1.0f}} }; - clearColors[1].depthStencil = vk::ClearDepthStencilValue(1.0f, 0); + for (uint32_t i = 0; i < vkDescriptions.size(); ++i) + { + if (SHVkUtil::IsDepthStencilAttachment(vkDescriptions[i].format)) + clearColors[i].depthStencil = vk::ClearDepthStencilValue(1.0f, 0); + else + clearColors[i].color = { {{0.0f, 0.0f, 0.0f, 1.0f}} }; + } + vk::RenderPassCreateInfo renderPassCreateInfo{}; std::vector subpassDeps; @@ -164,11 +170,16 @@ namespace SHADE SHVkRenderpass::SHVkRenderpass(Handle const& inLogicalDeviceHdl, std::span const vkDescriptions, std::span const spDescs, std::span const spDeps) noexcept : logicalDeviceHdl{ inLogicalDeviceHdl } + , numAttDescs{ static_cast(vkDescriptions.size()) } , clearColors{} { - // TODO: temporary only - clearColors[0].color = { {{0.0f, 0.0f, 0.0f, 1.0f}} }; - clearColors[1].depthStencil = vk::ClearDepthStencilValue(1.0f, 0); + for (uint32_t i = 0; i < vkDescriptions.size(); ++i) + { + if (SHVkUtil::IsDepthStencilAttachment(vkDescriptions[i].format)) + clearColors[i].depthStencil = vk::ClearDepthStencilValue(1.0f, 0); + else + clearColors[i].color = { {{0.0f, 0.0f, 0.0f, 1.0f}} }; + } subpassDescriptions.resize (spDescs.size()); for (uint32_t i = 0; i < subpassDescriptions.size(); ++i) diff --git a/SHADE_Engine/src/Graphics/Renderpass/SHVkRenderpass.h b/SHADE_Engine/src/Graphics/Renderpass/SHVkRenderpass.h index 6ffd6c38..b0ae7445 100644 --- a/SHADE_Engine/src/Graphics/Renderpass/SHVkRenderpass.h +++ b/SHADE_Engine/src/Graphics/Renderpass/SHVkRenderpass.h @@ -17,7 +17,7 @@ namespace SHADE /*-----------------------------------------------------------------------*/ /* STATIC CONSTEXPR VALUES */ /*-----------------------------------------------------------------------*/ - static constexpr uint32_t NUM_CLEAR_COLORS = 2; + static constexpr uint32_t NUM_CLEAR_COLORS = 10; /*-----------------------------------------------------------------------*/ /* PRIVATE MEMBER VARIABLES */ @@ -34,6 +34,9 @@ namespace SHADE //! Clear colors for the color and depth std::array clearColors; + // number of attachment descriptions + uint32_t numAttDescs; + public: /*-----------------------------------------------------------------------*/ /* CTOR AND DTOR */