From 485b60c6d86c6960881f758ce4ad228ab95046eb Mon Sep 17 00:00:00 2001 From: Brandon Mak Date: Mon, 21 Nov 2022 00:38:45 +0800 Subject: [PATCH 1/4] Added debug check in SHGraphicsSystem to compile assets only in debug --- .../src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp index 160e82c6..17dcf2d7 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp @@ -119,6 +119,7 @@ namespace SHADE SHFreetypeInstance::Init(); +#ifdef _DEBUG SHAssetManager::CompileAsset("../../Assets/Shaders/Text_VS.glsl", false); SHAssetManager::CompileAsset("../../Assets/Shaders/Text_FS.glsl", false); SHAssetManager::CompileAsset("../../Assets/Shaders/TestCube_VS.glsl", false); @@ -126,6 +127,8 @@ namespace SHADE SHAssetManager::CompileAsset("../../Assets/Shaders/UI_FS.glsl", false); SHAssetManager::CompileAsset("../../Assets/Models/Quad.gltf", false); +#endif + // Load Built In Shaders static constexpr AssetID VS_DEFAULT = 39210065; defaultVertShader = SHResourceManager::LoadOrGet(VS_DEFAULT); -- 2.40.1 From 964b375ccdb10d0ed0627531f01cefc7a64a29d4 Mon Sep 17 00:00:00 2001 From: Brandon Mak Date: Tue, 22 Nov 2022 09:05:56 +0800 Subject: [PATCH 2/4] Write to swapchain image without SHEDITOR defined WIP --- Assets/Fonts/ALGER.shfont | Bin 698700 -> 698700 bytes Assets/Fonts/SegoeUI.shfont | Bin 559876 -> 559876 bytes Assets/Shaders/ToSwapchain_FS.glsl | 9 ++---- Assets/Shaders/ToSwapchain_FS.shshaderb | Bin 0 -> 881 bytes .../Shaders/ToSwapchain_FS.shshaderb.shmeta | 3 ++ Assets/Shaders/ToSwapchain_VS.glsl | 8 +---- Assets/Shaders/ToSwapchain_VS.shshaderb | Bin 0 -> 1597 bytes .../Shaders/ToSwapchain_VS.shshaderb.shmeta | 3 ++ .../MiddleEnd/Interface/SHGraphicsSystem.cpp | 10 +++++-- .../MiddleEnd/Interface/SHGraphicsSystem.h | 2 ++ .../SHRenderToSwapchainImageSystem.cpp | 28 ++++++++++++++++-- .../src/Graphics/RenderGraph/SHSubpass.cpp | 2 +- 12 files changed, 45 insertions(+), 20 deletions(-) create mode 100644 Assets/Shaders/ToSwapchain_FS.shshaderb create mode 100644 Assets/Shaders/ToSwapchain_FS.shshaderb.shmeta create mode 100644 Assets/Shaders/ToSwapchain_VS.shshaderb create mode 100644 Assets/Shaders/ToSwapchain_VS.shshaderb.shmeta diff --git a/Assets/Fonts/ALGER.shfont b/Assets/Fonts/ALGER.shfont index 1acab9da4e7191479536fae42fe4d0181cc87dae..738af82d86df84ae1df6bf24a46f82732e7c7bf1 100644 GIT binary patch delta 1272 zcmYk*KWNlY90%~;_0Oe$Y-=yIJrwOA9F#5&;)6?a2o;?!f`|pTr{gUmqyYzq7Hczz z5~MCUQ5-vXQ-f!66z;&GF4w^;MF&B;WGI3)P*A@wzj&|18$SHHLY6*eq-_R{wN{L2L0s1KAf*UOX-U{%j#Souij0ixB1 z>1=?xFhRS;0H4X1EuJ%6Hi4e)du93#0G^wqaePsEpi?CVEWVb`Hi^f!CY#g))VeQp z%2ZS~W~dS;m60H7J;Q9L#RQkbcBQJhHlQ{(0>|rWt`Eq3fN1e?n$Oh9d=mW62ax#y zGM_vuy?g+f4G8`5R3+cAHcZXpwXFEj7Fo)7ySSx zK7o-)+~_%H-(?6JezWiF-n|!o7lYr$;A>TBCdo&dB;za(6<6Xl&0Uq~WZLmU4|vG( zLbwE`$OvP=Wx1;{Gs0;&zzbi%BQl!^LV=x6+_S~Z3JAyuPryf-7Xm*^(mV)rV2;c- zGi5nm=*9{P;Rm1bJwg*ZfU7e@TxYo#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ZHFPiBawEqM^s<|L%dZUs?3T+en@CQRa=TFbAX9oz4m>8wKbV$IP@DmaA7Fs z8cd!8JeYpE=h^aZ^bM#eA7%m;Q1d)X6;RSq&ZRr{IY4=3mHdnY-Q#0L@_m5oEqTlr uT!nujgOXNfy!}2veqL8(DAZFtqn>9tu%fV{v0|`dvEs0%-RBu(Q}ut-FUd&& delta 1238 zcmYk)FK<*q6b10vcH2H+f!BZV1cEdO1Y$%*MfbfG6%`0X1)`#Y4{$^H0GqH0$R;mo zkSmenYFAbwkto65b8FBN!RDW8E^|s+dgg) zO&7w4t~X(cigkSwE>XEaMz|=5+suTrfe8!Xq3u(tpe-OHL{x5Z&XAcoupIX$aGbZu z2rJ+k86o&NJIrt#Ol?9gNb3q`6DnlRyFTu2W`uvppe?O|w!8)^agP~qGl8?!$Osbv zx03}9Iz*;ohJ()A-UP2CffvHrge$atM&=1K@5`Vj@Ov;$5^7YK5#E%x_>`GHrOku~ z&j@T|M&Jg#gJ;Z4JtO=AaEVFqtIC3J9Y@Se$_6I*1W7pca|E9{K4<0(75pwHjLHT{ zU>j!>9^dB$GaQs}D!lWI@U0*V{4M!CFPS+iuuUZ42IqXiIl>aSMy6)QD<<%tj z%z-H~g12QMc;<*1zRw65fo(t%c)ge)3w~%kX2xLx{{v=(1;C8(8#u*mubA8!0yF>s diff --git a/Assets/Shaders/ToSwapchain_FS.glsl b/Assets/Shaders/ToSwapchain_FS.glsl index 9a35d1c4..a68fa0c7 100644 --- a/Assets/Shaders/ToSwapchain_FS.glsl +++ b/Assets/Shaders/ToSwapchain_FS.glsl @@ -3,17 +3,12 @@ #extension GL_ARB_shading_language_420pack : enable #extension GL_EXT_nonuniform_qualifier : require -layout (input_attachment_index = 0, set = 4, binding = 0) uniform subpassInput vec4 sceneTexture; +layout (input_attachment_index = 0, set = 4, binding = 0) uniform subpassInput sceneTexture; -layout(location = 0) in struct -{ - vec2 uv; // location = 0 - -} In; layout(location = 0) out vec4 fragColor; void main() { - fragColor = vec4 (texture (sceneTexture, In.uv).rgb, 1.0f); + fragColor = vec4 (subpassLoad(sceneTexture).rgb, 1.0f); } \ No newline at end of file diff --git a/Assets/Shaders/ToSwapchain_FS.shshaderb b/Assets/Shaders/ToSwapchain_FS.shshaderb new file mode 100644 index 0000000000000000000000000000000000000000..b10a9d6cc18532c8501c040dbbba8899a7e9af1a GIT binary patch literal 881 zcmY+B-A~j|5XA?U0xklJ2#616(H9d4AqI_!QKN?RWs~)T2j6Z=_wG_H?b;8cZ~krm zRlb;be%)@ePBNXDbI(09ciOw|SYw^#M{8zF*0oK$KZ9(?mW5aoA1iLyYEy@UPlMC4 z8l9d$J%hSsGZDDk;;bm*H&K!)*e!Wa956Le){(N=Z(Uf?X*h6iKE8FOpGHMgc~@RX zBVV}u>Wh!7@_&wwl5FDAD4W#L#Jlq+XVWPDDxGz7E9Hz8nrV#}1T(!JT9GT8z8z)s23Ka_+tz_br&)pj}X2e`J6J{@g%(Te~F=pJ9Vqb5Z zHmd!oU9D|Ag>u#8V{n$Qvb;Vy`5z({bVI%2)Q^wrjn_`A+jaWU z$G~#}KlGfo-}73Lf9}B>%kccL6%5*0LQ#zDT}AbHMRy$bJU8-A25x(Gu)b?dQJ-<) z=Uy-JF5Vt#DsMi)KYW$u~Rw7%RoSe+Zm+$+58QU2v{oD#~}=o_m(^p395Z z^m++Zp*krUa2B~v-;exGD0DQ&(JRLNFgo==X$)=3gEynU_+?>m*w2Z@ zb1KVNWyQP-418Y9u^2aILAguX6DM_e879WyQ)^PbEThLt8c$_nYR<~IpFHt`j5VvO z*X6;v<0hb%jc>)#mwkKgwqp9B=lk;XVB-hc(*ynNDo>2gwlC^GmTB#;NpsFsWndVy z@`Hhgj`q%V?WwUS^qD+)uq91`&h`vBjNWSU%uAkLh?Cz~QkNb#Wi0sm3B-JAZK^l4 zrUw>vehVqeQ;WG*WXw*CucYywVroB>G5cr5=*>F=d!=e{iFZ;B*0kq03H~+3o@ft_ zKAhn`FzTb*mJIAfeDv5(F}WeOlVWJsRF};5LI#%{-!E&ttjuidEoq;vcSkYr8{F0_YY(2Sx2zc4)@!D^ P+!e-M(VS_DEFAULT); @@ -137,6 +138,8 @@ namespace SHADE static constexpr AssetID SSAO_BLUR = 39760835; ssaoBlurShader = SHResourceManager::LoadOrGet(SSAO_BLUR); static constexpr AssetID TEXT_VS = 39816727; textVS = SHResourceManager::LoadOrGet(TEXT_VS); static constexpr AssetID TEXT_FS = 38024754; textFS = SHResourceManager::LoadOrGet(TEXT_FS); + static constexpr AssetID RENDER_SC_VS = 48082949; renderToSwapchainVS = SHResourceManager::LoadOrGet(RENDER_SC_VS); + static constexpr AssetID RENDER_SC_FS = 36869006; renderToSwapchainFS = SHResourceManager::LoadOrGet(RENDER_SC_FS); } void SHGraphicsSystem::InitSceneRenderGraph(void) noexcept @@ -300,6 +303,7 @@ namespace SHADE textRenderingSubSystem->Render(cmdBuffer, frameIndex); }); +#ifdef SHEDITOR { // Dummy Node to transition scene render graph resource auto dummyNode = screenRenderGraph->AddNode("Dummy Pass", { "Scene" }, { "Screen Space Pass" }); // no predecessors @@ -307,7 +311,9 @@ namespace SHADE dummySubpass->AddInput("Scene"); } - //screenRenderGraph->AddRenderToSwapchainNode ("Scene", "Present", ) +#else + screenRenderGraph->AddRenderToSwapchainNode("Scene", "Present", {"Screen Space Pass"}, {renderToSwapchainVS, renderToSwapchainFS}); +#endif screenRenderGraph->Generate(); diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.h b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.h index c201e9a5..8c65f233 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.h +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.h @@ -444,6 +444,8 @@ namespace SHADE Handle ssaoBlurShader; Handle textVS; Handle textFS; + Handle renderToSwapchainVS; + Handle renderToSwapchainFS; // Fonts Handle testFont; diff --git a/SHADE_Engine/src/Graphics/RenderGraph/SHRenderToSwapchainImageSystem.cpp b/SHADE_Engine/src/Graphics/RenderGraph/SHRenderToSwapchainImageSystem.cpp index e4f020e4..770217ee 100644 --- a/SHADE_Engine/src/Graphics/RenderGraph/SHRenderToSwapchainImageSystem.cpp +++ b/SHADE_Engine/src/Graphics/RenderGraph/SHRenderToSwapchainImageSystem.cpp @@ -3,6 +3,8 @@ #include "Graphics/Devices/SHVkLogicalDevice.h" #include "Graphics/MiddleEnd/GlobalData/SHGraphicsGlobalData.h" #include "Graphics/RenderGraph/SHRenderGraphNode.h" +#include "Graphics/RenderGraph/SHSubpass.h" +#include "Graphics/SHVkUtil.h" namespace SHADE { @@ -25,14 +27,34 @@ namespace SHADE .globalDescSetLayouts = SHGraphicsGlobalData::GetDescSetLayouts(), }); - auto newPipeline = logicalDevice->CreateGraphicsPipeline(pipelineLayout, nullptr, renderGraphNode->GetRenderpass(), subpass); + pipeline = logicalDevice->CreateGraphicsPipeline(pipelineLayout, nullptr, renderGraphNode->GetRenderpass(), subpass); SHInputAssemblyState inputAssembly{}; inputAssembly.topology = vk::PrimitiveTopology::eTriangleFan; - newPipeline->GetPipelineState().SetInputAssemblyState(inputAssembly); + pipeline->GetPipelineState().SetInputAssemblyState(inputAssembly); - newPipeline->ConstructPipeline(); + SHColorBlendState colorBlendState{}; + colorBlendState.logic_op_enable = VK_FALSE; + colorBlendState.logic_op = vk::LogicOp::eCopy; + + auto const& subpassColorReference = subpass->GetColorAttachmentReferences()[0]; + colorBlendState.attachments.push_back(vk::PipelineColorBlendAttachmentState + { + .blendEnable = SHVkUtil::IsBlendCompatible(subpass->GetFormatFromAttachmentReference(subpassColorReference.attachment)), + .srcColorBlendFactor = vk::BlendFactor::eSrcAlpha, + .dstColorBlendFactor = vk::BlendFactor::eOneMinusSrcAlpha, + .colorBlendOp = vk::BlendOp::eAdd, + .srcAlphaBlendFactor = vk::BlendFactor::eOne, + .dstAlphaBlendFactor = vk::BlendFactor::eZero, + .alphaBlendOp = vk::BlendOp::eAdd, + .colorWriteMask = vk::ColorComponentFlagBits::eR | vk::ColorComponentFlagBits::eG | vk::ColorComponentFlagBits::eB | vk::ColorComponentFlagBits::eA, + } + ); + + pipeline->GetPipelineState().SetColorBlenState(colorBlendState); + + pipeline->ConstructPipeline(); } diff --git a/SHADE_Engine/src/Graphics/RenderGraph/SHSubpass.cpp b/SHADE_Engine/src/Graphics/RenderGraph/SHSubpass.cpp index 1eae9768..0900852c 100644 --- a/SHADE_Engine/src/Graphics/RenderGraph/SHSubpass.cpp +++ b/SHADE_Engine/src/Graphics/RenderGraph/SHSubpass.cpp @@ -281,7 +281,7 @@ namespace SHADE } //// maybe do this in handle resize? - //UpdateWriteDescriptors(); + UpdateWriteDescriptors(); } void SHSubpass::UpdateWriteDescriptors(void) noexcept -- 2.40.1 From 4377972315becdda76684a6e26d63ba4d2d2b589 Mon Sep 17 00:00:00 2001 From: Brandon Mak Date: Tue, 22 Nov 2022 10:09:52 +0800 Subject: [PATCH 3/4] Added functionality for graphics system to render to swapchain image - Added functionality for graphics system to render to swapchain image when SHEDITOR is disabled. This is done via rendering a simple quad on screen and using an input attachment as a texture to the shader. --- Assets/Fonts/ALGER.shfont | Bin 698700 -> 698700 bytes Assets/Fonts/SegoeUI.shfont | Bin 559876 -> 559876 bytes Assets/Shaders/ToSwapchain_VS.glsl | 2 +- Assets/Shaders/ToSwapchain_VS.shshaderb | Bin 1597 -> 1633 bytes .../src/Application/SBApplication.cpp | 4 ++-- .../Graphics/RenderGraph/SHRenderGraph.cpp | 4 +++- .../src/Graphics/RenderGraph/SHSubpass.cpp | 22 ++++++++++++++---- .../src/Graphics/RenderGraph/SHSubpass.h | 8 +++++-- 8 files changed, 29 insertions(+), 11 deletions(-) diff --git a/Assets/Fonts/ALGER.shfont b/Assets/Fonts/ALGER.shfont index 738af82d86df84ae1df6bf24a46f82732e7c7bf1..1acab9da4e7191479536fae42fe4d0181cc87dae 100644 GIT binary patch delta 1272 zcmYk*FH=H66b0}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/Assets/Shaders/ToSwapchain_VS.glsl b/Assets/Shaders/ToSwapchain_VS.glsl index b230301f..eee22015 100644 --- a/Assets/Shaders/ToSwapchain_VS.glsl +++ b/Assets/Shaders/ToSwapchain_VS.glsl @@ -10,6 +10,6 @@ vec2 CreateQuad(in uint vertexID) void main() { - vec2 vertexPos = CreateQuad(gl_VertexIndex) - vec2(0.5f); + vec2 vertexPos = 2 * (CreateQuad(gl_VertexIndex) - vec2(0.5f)); gl_Position = vec4 (vertexPos, 0.0f, 1.0f); } \ No newline at end of file diff --git a/Assets/Shaders/ToSwapchain_VS.shshaderb b/Assets/Shaders/ToSwapchain_VS.shshaderb index 1868d251be4744e6adef0a130d2b456d86c6cdc9..4c3157f98268ef9a629bdd8d60286af9c8b449a9 100644 GIT binary patch literal 1633 zcmYk6YflqF6o!Z1KoJqSc|j~15e2I#R}rcKvzj!agv9u5Q`?Q%WZ5?DmZ0&2iQoMn z#(!Z<{7Zh(_&&Qkb*DL;Iq!Mr%$av*7yMyZH2IhbXWVGHMnQJc@I&VJWSg?QemVIcA{MlRQ*)ieL#OuAZFV|t zFZvL8Zs3QW+w!|!GxAS8cq18}A2x%2D@!Pfk=?7P9xrH*{jS%DyrX`jwbWnTF{Y^B zsPI#-8+m814>T2$SMSEWi|0kND4*o(?Ou$P;@;l}?we#;*z(R;S1>EecN*QsNy=N7 z7q9Mh6RJXWQZnESa_ycU`R!2XaEzl@jQe49?0?j0S(D_@NxA*N?;QBOs1Y{3K@PRa z^@CuL<1A>*aMT}~bKd*1SL)dI0miUc@?H7j|1tK4$3B+F91N`;WvB;lQh)Ia!r(BU z7K`gtmNCkTxfK}rjF=-aZp^H5=QJly>TokmjKQbYxO`bgkIQL%DHBt3O2+==iDzYu zDOJ5956&Lf05xoUJ&rzC?YbL^>4%>0$kPL{<=@p@<2m^yP3VdKcG4K#ZJ+E{k!e&{ z^bM%qrpp}So}4x^V1dCpIsUWk)7m(-=lEg1v; zt~`8dZKyZ2rw0c3Zy`l_YN5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); + //std::system("FontCompiler.exe ../../Assets/Fonts/SegoeUI.ttf"); + //std::system("FontCompiler.exe ../../Assets/Fonts/ALGER.ttf"); SHSystemManager::CreateSystem(); SHGraphicsSystem* graphicsSystem = static_cast(SHSystemManager::GetSystem()); diff --git a/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraph.cpp b/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraph.cpp index 0580d650..2ffd6d13 100644 --- a/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraph.cpp +++ b/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraph.cpp @@ -565,8 +565,10 @@ namespace SHADE { cmdBuffer->BindPipeline(renderToSwapchainImageSystem->GetPipeline()); + newSubpass->BindDescriptorInputDescriptorSets (cmdBuffer, frameIndex); + // draw a quad. - cmdBuffer->DrawIndexed(4, 0, 0); + cmdBuffer->DrawArrays(4, 1, 0, 0); }); } } diff --git a/SHADE_Engine/src/Graphics/RenderGraph/SHSubpass.cpp b/SHADE_Engine/src/Graphics/RenderGraph/SHSubpass.cpp index 0900852c..c1d53632 100644 --- a/SHADE_Engine/src/Graphics/RenderGraph/SHSubpass.cpp +++ b/SHADE_Engine/src/Graphics/RenderGraph/SHSubpass.cpp @@ -40,7 +40,7 @@ namespace SHADE , inputReferences{} , name { name } , graphStorage{ renderGraphStorage } - , inputImageDescriptors {SHGraphicsConstants::NUM_FRAME_BUFFERS} + , inputImageDescriptorSets{} { } @@ -67,7 +67,7 @@ namespace SHADE , exteriorDrawCalls{ std::move(rhs.exteriorDrawCalls) } , graphStorage{ rhs.graphStorage } , inputNames{ std::move(rhs.inputNames) } - , inputImageDescriptors{ std::move(rhs.inputImageDescriptors) } + , inputImageDescriptorSets{ std::move(rhs.inputImageDescriptorSets) } , inputDescriptorLayout{ rhs.inputDescriptorLayout } , inputSamplers{ rhs.inputSamplers } , name { rhs.name } @@ -102,7 +102,7 @@ namespace SHADE exteriorDrawCalls = std::move(rhs.exteriorDrawCalls); graphStorage = rhs.graphStorage; inputNames = std::move(rhs.inputNames); - inputImageDescriptors = std::move(rhs.inputImageDescriptors); + inputImageDescriptorSets = std::move(rhs.inputImageDescriptorSets); inputDescriptorLayout = rhs.inputDescriptorLayout; inputSamplers = rhs.inputSamplers; name = std::move(rhs.name); @@ -202,6 +202,8 @@ namespace SHADE void SHSubpass::Execute(Handle& commandBuffer, Handle descPool, uint32_t frameIndex) noexcept { commandBuffer->BeginLabeledSegment(name); + + // Ensure correct transforms are provided superBatch->UpdateBuffers(frameIndex, descPool); @@ -221,6 +223,14 @@ namespace SHADE UpdateWriteDescriptors(); } + void SHSubpass::BindDescriptorInputDescriptorSets(Handle cmdBuffer, uint32_t frameIndex) const noexcept + { + if (!inputImageDescriptorSets.empty()) + { + cmdBuffer->BindDescriptorSet(inputImageDescriptorSets[frameIndex], SH_PIPELINE_TYPE::GRAPHICS, SHGraphicsConstants::DescriptorSetIndex::RENDERGRAPH_RESOURCE, { }); + } + } + void SHSubpass::AddExteriorDrawCalls(std::function&, uint32_t)> const& newDrawCall) noexcept { exteriorDrawCalls.push_back(newDrawCall); @@ -237,6 +247,8 @@ namespace SHADE if (inputNames.empty()) return; + inputImageDescriptorSets.resize(SHGraphicsConstants::NUM_FRAME_BUFFERS); + std::vector bindings{}; for (auto& input : inputReferences) @@ -280,7 +292,7 @@ namespace SHADE } } - //// maybe do this in handle resize? + // maybe do this in handle resize? UpdateWriteDescriptors(); } @@ -296,7 +308,7 @@ namespace SHADE // For every frame's descriptor set - for (auto& group : inputImageDescriptors) + for (auto& group : inputImageDescriptorSets) { if (group) group.Free(); diff --git a/SHADE_Engine/src/Graphics/RenderGraph/SHSubpass.h b/SHADE_Engine/src/Graphics/RenderGraph/SHSubpass.h index c28ff919..69b8fd56 100644 --- a/SHADE_Engine/src/Graphics/RenderGraph/SHSubpass.h +++ b/SHADE_Engine/src/Graphics/RenderGraph/SHSubpass.h @@ -55,8 +55,11 @@ namespace SHADE //! For getting attachment reference indices using handles std::unordered_map const* resourceAttachmentMapping; - //! Descriptor set group to hold the images for input - std::vector> inputImageDescriptors; + //! Descriptor set group to hold the images for input. We have 3 here just in case + //! one of the images is a swapchain image. Practically speaking its not likely not + //! swapchain images will end up being images used in descriptor sets, but this is + //! to have the support for it. The cost is not much. + std::vector> inputImageDescriptorSets; //! Descriptor set layout for allocating descriptor set for inputs Handle inputDescriptorLayout; @@ -104,6 +107,7 @@ namespace SHADE // Runtime functions void Execute(Handle& commandBuffer, Handle descPool, uint32_t frameIndex) noexcept; void HandleResize (void) noexcept; + void BindDescriptorInputDescriptorSets (Handle cmdBuffer, uint32_t frameIndex) const noexcept; void Init(SHResourceHub& resourceManager) noexcept; -- 2.40.1 From dfe86ce7db8cdd32acd92d9ad1e0af10fcaeb2d7 Mon Sep 17 00:00:00 2001 From: Brandon Mak Date: Tue, 22 Nov 2022 10:43:59 +0800 Subject: [PATCH 4/4] Fixed resizing bug --- .../src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp index 6aa988a5..af09c819 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp @@ -84,7 +84,7 @@ namespace SHADE if (width == 0 || height == 0) return; - PrepareResize(resizeWidth, resizeHeight); + PrepareResize(width, height); }); window->RegisterWindowCloseCallback([&](void) -- 2.40.1