From 7eac238226c6677206c2b0cf0b727da211c38771 Mon Sep 17 00:00:00 2001 From: Brandon Mak Date: Fri, 24 Feb 2023 11:47:58 +0800 Subject: [PATCH] Accounted for subpass input descriptors Silhouette shader is working --- Assets/Materials/Silhouette.shmat | 8 +++ Assets/Materials/Silhouette.shmat.shmeta | 3 + Assets/Shaders/Silhouette_FS.glsl | 67 +++++++++++++++++ Assets/Shaders/Silhouette_FS.shshaderb | Bin 0 -> 2409 bytes Assets/Shaders/Silhouette_FS.shshaderb.shmeta | 3 + Assets/Shaders/Silhouette_VS.glsl | 68 ++++++++++++++++++ Assets/Shaders/Silhouette_VS.shshaderb | Bin 0 -> 4133 bytes Assets/Shaders/Silhouette_VS.shshaderb.shmeta | 3 + Assets/Shaders/ToSwapchain_FS.glsl | 2 +- Assets/Shaders/ToSwapchain_FS.shshaderb | Bin 881 -> 881 bytes .../GlobalData/SHGraphicsPredefinedData.cpp | 7 +- .../MiddleEnd/Interface/SHGraphicsConstants.h | 4 +- .../MiddleEnd/Interface/SHGraphicsSystem.cpp | 10 ++- .../Graphics/RenderGraph/SHRenderGraph.cpp | 10 +-- .../RenderGraph/SHRenderGraphNode.cpp | 10 +-- .../src/Graphics/RenderGraph/SHSubpass.cpp | 31 ++++++++ .../src/Graphics/RenderGraph/SHSubpass.h | 8 +++ 17 files changed, 219 insertions(+), 15 deletions(-) create mode 100644 Assets/Materials/Silhouette.shmat create mode 100644 Assets/Materials/Silhouette.shmat.shmeta create mode 100644 Assets/Shaders/Silhouette_FS.glsl create mode 100644 Assets/Shaders/Silhouette_FS.shshaderb create mode 100644 Assets/Shaders/Silhouette_FS.shshaderb.shmeta create mode 100644 Assets/Shaders/Silhouette_VS.glsl create mode 100644 Assets/Shaders/Silhouette_VS.shshaderb create mode 100644 Assets/Shaders/Silhouette_VS.shshaderb.shmeta diff --git a/Assets/Materials/Silhouette.shmat b/Assets/Materials/Silhouette.shmat new file mode 100644 index 00000000..912775f0 --- /dev/null +++ b/Assets/Materials/Silhouette.shmat @@ -0,0 +1,8 @@ +- VertexShader: 38847805 + FragmentShader: 42962441 + SubPass: Object VFX Subpass No Depth + Properties: + data.color: {x: 1, y: 1, z: 1, w: 1} + data.textureIndex: 0 + data.alpha: 0 + data.beta: {x: 1, y: 1, z: 1} \ No newline at end of file diff --git a/Assets/Materials/Silhouette.shmat.shmeta b/Assets/Materials/Silhouette.shmat.shmeta new file mode 100644 index 00000000..be1f7bde --- /dev/null +++ b/Assets/Materials/Silhouette.shmat.shmeta @@ -0,0 +1,3 @@ +Name: Silhouette +ID: 126391182 +Type: 7 diff --git a/Assets/Shaders/Silhouette_FS.glsl b/Assets/Shaders/Silhouette_FS.glsl new file mode 100644 index 00000000..292bdfe7 --- /dev/null +++ b/Assets/Shaders/Silhouette_FS.glsl @@ -0,0 +1,67 @@ +#version 450 +#extension GL_ARB_separate_shader_objects : enable +#extension GL_ARB_shading_language_420pack : enable +#extension GL_EXT_nonuniform_qualifier : require + +struct MatPropData +{ + vec4 color; +}; + +struct GenericData +{ + //! Delta time + float dt; + + //! Elapsed time of the application + float elapsedTime; + + //! Viewport width of the scene (excluding imgui, that means smaller than window) + uint viewportWidth; + + //! Ditto but for height + uint viewportHeight; +}; + +layout(location = 0) in struct +{ + vec4 vertPos; // location 0 + vec2 uv; // location = 1 + vec4 normal; // location = 2 + vec4 worldPos; // location = 3 +} In; + +// material stuff +layout(location = 4) flat in struct +{ + int materialIndex; + uint eid; + uint lightLayerIndex; +} In2; + +layout (set = 0, binding = 1) uniform sampler2D textures[]; // for textures (global) +layout (std430, set = 2, binding = 0) buffer MaterialProperties // For materials +{ + MatPropData data[]; +} MatProp; + +layout (set = 0, binding = 0) uniform GenericDataBuffer +{ + GenericData data; +} genericDataBuffer; + +layout(location = 0) out vec4 objectVFX; +layout(input_attachment_index = 0, set = 3, binding = 0) uniform subpassInput depthBuffer; + +void main() +{ + // Sample depth buffer using UV and save it + float currentDepth = subpassLoad (depthBuffer).r; + + // Use depth buffer to check against current fragment's depth. If fragment is behind depth buffer, render fragment. + if (currentDepth > gl_FragCoord.z) + discard; + + objectVFX = MatProp.data[In2.materialIndex].color; + +} \ No newline at end of file diff --git a/Assets/Shaders/Silhouette_FS.shshaderb b/Assets/Shaders/Silhouette_FS.shshaderb new file mode 100644 index 0000000000000000000000000000000000000000..4710b8a6b5036d5c62522adbafc8f285133bfca0 GIT binary patch literal 2409 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 literal 0 HcmV?d00001 diff --git a/Assets/Shaders/Silhouette_VS.shshaderb.shmeta b/Assets/Shaders/Silhouette_VS.shshaderb.shmeta new file mode 100644 index 00000000..508a8788 --- /dev/null +++ b/Assets/Shaders/Silhouette_VS.shshaderb.shmeta @@ -0,0 +1,3 @@ +Name: Silhouette_VS +ID: 38847805 +Type: 2 diff --git a/Assets/Shaders/ToSwapchain_FS.glsl b/Assets/Shaders/ToSwapchain_FS.glsl index 3cf1752f..d353c15f 100644 --- a/Assets/Shaders/ToSwapchain_FS.glsl +++ b/Assets/Shaders/ToSwapchain_FS.glsl @@ -3,7 +3,7 @@ #extension GL_ARB_shading_language_420pack : enable #extension GL_EXT_nonuniform_qualifier : require -layout (input_attachment_index = 0, set = 0, binding = 0) uniform subpassInput sceneTexture; +layout (input_attachment_index = 0, set = 3, binding = 0) uniform subpassInput sceneTexture; layout(location = 0) out vec4 fragColor; diff --git a/Assets/Shaders/ToSwapchain_FS.shshaderb b/Assets/Shaders/ToSwapchain_FS.shshaderb index 0bee0ac67036b416f1ad7249d12b6e7ea411b98d..24cb54feb17daf6424b28de97ba12ec39b15e21d 100644 GIT binary patch delta 14 Vcmey!_K|HvCnF>C<}SwPi~uZS1ycY3 delta 14 Vcmey!_K|HvCnF=n<}SwPi~uZA1yBG0 diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.cpp index 63b39c9f..85559bc7 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.cpp @@ -25,9 +25,10 @@ namespace SHADE { perSystemData[SHUtilities::ConvertEnum(SystemType::BATCHING)].descMappings.AddMappings ({ - {SHPredefinedDescriptorTypes::STATIC_DATA, 0}, - {SHPredefinedDescriptorTypes::CAMERA, 1}, - {SHPredefinedDescriptorTypes::PER_INSTANCE_BATCH, 2}, + {SHPredefinedDescriptorTypes::STATIC_DATA, 0}, + {SHPredefinedDescriptorTypes::CAMERA, 1}, + {SHPredefinedDescriptorTypes::PER_INSTANCE_BATCH, 2}, + {SHPredefinedDescriptorTypes::RENDER_GRAPH_RESOURCE, 3}, }); perSystemData[SHUtilities::ConvertEnum(SystemType::BATCHING_ANIM)].descMappings.AddMappings diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsConstants.h b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsConstants.h index 38fe9aa3..54b02608 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsConstants.h +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsConstants.h @@ -129,11 +129,13 @@ namespace SHADE static constexpr std::string_view GBUFFER_WRITE_SUBPASS = "G-Buffer Write"; static constexpr std::string_view UI_SUBPASS = "UI"; static constexpr std::string_view VFX_SUBPASS = "VFX"; + static constexpr std::string_view OBJ_VFX_SUBPASS = "Object VFX Subpass No Depth"; static constexpr std::array USABLE_SUBPASSES = { GBUFFER_WRITE_SUBPASS, - UI_SUBPASS + UI_SUBPASS, + OBJ_VFX_SUBPASS }; }; diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp index 70a7d34f..ebd9ba8c 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp @@ -215,7 +215,7 @@ namespace SHADE renderGraph->AddResource("Normals", { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR, SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT, SH_RENDER_GRAPH_RESOURCE_FLAGS::STORAGE }, true, windowDims.first, windowDims.second, vk::Format::eR32G32B32A32Sfloat); //worldRenderGraph->AddResource("Tangents", { SH_ATT_DESC_TYPE_FLAGS::COLOR, SH_ATT_DESC_TYPE_FLAGS::INPUT, SH_ATT_DESC_TYPE_FLAGS::STORAGE }, windowDims.first, windowDims.second, vk::Format::eR32G32B32A32Sfloat); renderGraph->AddResource("Albedo", { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR, SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT, SH_RENDER_GRAPH_RESOURCE_FLAGS::STORAGE }, true, windowDims.first, windowDims.second); - renderGraph->AddResource("Depth Buffer", { SH_RENDER_GRAPH_RESOURCE_FLAGS::DEPTH_STENCIL }, true, windowDims.first, windowDims.second, vk::Format::eD32SfloatS8Uint); + renderGraph->AddResource("Depth Buffer", { SH_RENDER_GRAPH_RESOURCE_FLAGS::DEPTH, SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT }, true, windowDims.first, windowDims.second, vk::Format::eD32SfloatS8Uint); renderGraph->AddResource("Entity ID", { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR, SH_RENDER_GRAPH_RESOURCE_FLAGS::SHARED }, true, windowDims.first, windowDims.second, vk::Format::eR32Uint, 1, vk::ImageUsageFlagBits::eTransferSrc); renderGraph->AddResource("Light Layer Indices", { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR, SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT, SH_RENDER_GRAPH_RESOURCE_FLAGS::STORAGE }, true, windowDims.first, windowDims.second, vk::Format::eR32Uint, 1, vk::ImageUsageFlagBits::eTransferSrc); renderGraph->AddResource("Scene", { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR, SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT, SH_RENDER_GRAPH_RESOURCE_FLAGS::STORAGE, SH_RENDER_GRAPH_RESOURCE_FLAGS::SHARED }, true, windowDims.first, windowDims.second); @@ -255,7 +255,13 @@ namespace SHADE gBufferSubpass->AddColorOutput("Object VFX"); gBufferSubpass->AddDepthOutput("Depth Buffer", SH_RENDER_GRAPH_RESOURCE_FLAGS::DEPTH_STENCIL); - usableSubpassesMapping.emplace (std::string (SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_WRITE_SUBPASS.data()), gBufferSubpass); + // We add the object VFX render target and depth buffer as input just in case we want to make comparisons + auto objectVfxSubpassNoDepth = gBufferNode->AddSubpass(SHGraphicsConstants::RenderGraphEntityNames::OBJ_VFX_SUBPASS.data(), worldViewport, worldRenderer); + objectVfxSubpassNoDepth->AddColorOutput("Object VFX"); + objectVfxSubpassNoDepth->AddInput ("Depth Buffer"); + + usableSubpassesMapping.emplace(std::string(SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_WRITE_SUBPASS.data()), gBufferSubpass); + usableSubpassesMapping.emplace(std::string(SHGraphicsConstants::RenderGraphEntityNames::OBJ_VFX_SUBPASS.data()), objectVfxSubpassNoDepth); /*-----------------------------------------------------------------------*/ /* SSAO PASS AND DATA INIT */ diff --git a/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraph.cpp b/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraph.cpp index 654cae77..ea650274 100644 --- a/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraph.cpp +++ b/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraph.cpp @@ -512,8 +512,9 @@ namespace SHADE uint32_t h = static_cast(resource->GetHeight()); cmdBuffer->SetViewportScissor(static_cast(w), static_cast(h), w, h); - static constexpr uint32_t INPUT_IMAGE_SET_INDEX = 0; - newSubpass->BindInputDescriptorSets (cmdBuffer, INPUT_IMAGE_SET_INDEX, frameIndex); + //static constexpr uint32_t INPUT_IMAGE_SET_INDEX = 0; + auto const& mappings = SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::BATCHING); + newSubpass->BindInputDescriptorSets (cmdBuffer, mappings.at(SHPredefinedDescriptorTypes::RENDER_GRAPH_RESOURCE), frameIndex); // draw a quad. cmdBuffer->DrawArrays(4, 1, 0, 0); @@ -570,9 +571,10 @@ namespace SHADE auto cmdBuffer = commandBuffers[frameIndex]; cmdBuffer->BeginLabeledSegment(name); - auto batchingSystemData = SHGraphicsPredefinedData::GetSystemData(SHGraphicsPredefinedData::SystemType::BATCHING); + auto const& batchingSystemData = SHGraphicsPredefinedData::GetSystemData(SHGraphicsPredefinedData::SystemType::BATCHING); - // Force bind pipeline layout + + // Force bind pipeline layout cmdBuffer->ForceSetPipelineLayout(batchingSystemData.dummyPipelineLayout, SH_PIPELINE_TYPE::GRAPHICS); cmdBuffer->ForceSetPipelineLayout(batchingSystemData.dummyPipelineLayout, SH_PIPELINE_TYPE::COMPUTE); diff --git a/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraphNode.cpp b/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraphNode.cpp index b032ca1e..e5cc231c 100644 --- a/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraphNode.cpp +++ b/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraphNode.cpp @@ -184,12 +184,13 @@ namespace SHADE for (auto& inputAtt : subpass->inputReferences) { auto resource = attResources[inputAtt.attachment]; - if (resource->resourceTypeFlags & static_cast(SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT)) + auto typeFlags = resource->resourceTypeFlags; + if (typeFlags & static_cast(SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT)) { - if (resource->resourceTypeFlags & static_cast(SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR) || - resource->resourceTypeFlags & static_cast(SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR_PRESENT)) + if (typeFlags & static_cast(SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR) || + typeFlags & static_cast(SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR_PRESENT)) colorRead |= (1 << i); - else if (resource->resourceTypeFlags & static_cast(SH_RENDER_GRAPH_RESOURCE_FLAGS::DEPTH_STENCIL)) + else if (typeFlags & static_cast(SH_RENDER_GRAPH_RESOURCE_FLAGS::DEPTH_STENCIL) || typeFlags & static_cast(SH_RENDER_GRAPH_RESOURCE_FLAGS::DEPTH)) depthRead |= (1 << i); } else @@ -265,6 +266,7 @@ namespace SHADE // initialize input descriptors subpasses[i]->CreateInputDescriptors(); + subpasses[i]->GenerateDummyPipielineLayout(); ++i; } diff --git a/SHADE_Engine/src/Graphics/RenderGraph/SHSubpass.cpp b/SHADE_Engine/src/Graphics/RenderGraph/SHSubpass.cpp index 96207d7a..d45789ce 100644 --- a/SHADE_Engine/src/Graphics/RenderGraph/SHSubpass.cpp +++ b/SHADE_Engine/src/Graphics/RenderGraph/SHSubpass.cpp @@ -226,11 +226,15 @@ namespace SHADE commandBuffer->SetViewportScissor(static_cast(w), static_cast(h), w, h); } + commandBuffer->ForceSetPipelineLayout(dummyPipelineLayout, SH_PIPELINE_TYPE::GRAPHICS); + auto const& descMappings = SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::BATCHING); if (renderer) renderer->BindDescriptorSet(commandBuffer, SH_PIPELINE_TYPE::GRAPHICS, descMappings.at(SHPredefinedDescriptorTypes::CAMERA), frameIndex); + BindInputDescriptorSets (commandBuffer, descMappings.at(SHPredefinedDescriptorTypes::RENDER_GRAPH_RESOURCE), frameIndex); + // If companion subpass is not a valid handle, render super batch normally if (!companionSubpass.companion) { @@ -439,6 +443,33 @@ namespace SHADE } } + /***************************************************************************/ + /*! + + \brief + Generates the dummy pipeline layout for subpass; specifically add the + input descriptor set layout if it exists. + + + \return + + */ + /***************************************************************************/ + void SHSubpass::GenerateDummyPipielineLayout(void) noexcept + { + auto const& batchingSystemData = SHGraphicsPredefinedData::GetSystemData(SHGraphicsPredefinedData::SystemType::BATCHING); + std::vector newLayouts = batchingSystemData.descSetLayouts; + if (inputDescriptorLayout) + { + newLayouts.push_back(inputDescriptorLayout); + } + + dummyPipelineLayout = graphStorage->logicalDevice->CreatePipelineLayoutDummy + ( + SHPipelineLayoutParamsDummy{ newLayouts } + ); + } + /***************************************************************************/ /*! diff --git a/SHADE_Engine/src/Graphics/RenderGraph/SHSubpass.h b/SHADE_Engine/src/Graphics/RenderGraph/SHSubpass.h index 811cc70c..1300ee2b 100644 --- a/SHADE_Engine/src/Graphics/RenderGraph/SHSubpass.h +++ b/SHADE_Engine/src/Graphics/RenderGraph/SHSubpass.h @@ -22,6 +22,7 @@ namespace SHADE class SHRenderer; class SHViewport; class SHVkPipeline; + class SHVkPipelineLayout; class SH_API SHSubpass : public ISelfHandle { @@ -87,6 +88,12 @@ namespace SHADE std::vector> inputSamplers; + //! Dummy pipeline layout for subpass to bind before draw. + //! // IMPORTANT NOTE: After implementing input descriptors, every subpass differs in number input descriptors. + //! Before binding the input descriptors, a pipeline layout containing the desc set layouts + //! for the input descriptors is required, making this umbrella initial dummy bind invalid. + Handle dummyPipelineLayout; + ////! subpass compute image barriers. We do this because every frame has a different ////! swapchain image. If the resource we want to transition is not a swapchain image, @@ -146,6 +153,7 @@ namespace SHADE //void InitComputeBarriers (void) noexcept; void CreateInputDescriptors (void) noexcept; void UpdateWriteDescriptors (void) noexcept; + void GenerateDummyPipielineLayout (void) noexcept; private: /*-----------------------------------------------------------------------*/