diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/DisplayMapper/DisplayMapperFullScreenPass.h b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/DisplayMapper/DisplayMapperFullScreenPass.h index 94e52d41b0..23c4cd1a0a 100644 --- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/DisplayMapper/DisplayMapperFullScreenPass.h +++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/DisplayMapper/DisplayMapperFullScreenPass.h @@ -42,7 +42,7 @@ namespace AZ void SetInputReferenceAttachmentName(const Name& attachmentName); // Pass behavior overrides - virtual void BuildAttachmentsInternal() override; + virtual void BuildInternal() override; protected: explicit DisplayMapperFullScreenPass(const RPI::PassDescriptor& descriptor); diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/DisplayMapper/DisplayMapperPass.h b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/DisplayMapper/DisplayMapperPass.h index 67d9eae9ae..15ada4dd94 100644 --- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/DisplayMapper/DisplayMapperPass.h +++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/DisplayMapper/DisplayMapperPass.h @@ -76,7 +76,7 @@ namespace AZ DisplayMapperPass(const RPI::PassDescriptor& descriptor); // Pass behavior overrides - void BuildAttachmentsInternal() final; + void BuildInternal() final; void FrameBeginInternal(FramePrepareParams params) final; void FrameEndInternal() final; void CreateChildPassesInternal() final; diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/LuxCore/LuxCoreTexturePass.h b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/LuxCore/LuxCoreTexturePass.h index 23e9c220b2..2ad2af3efd 100644 --- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/LuxCore/LuxCoreTexturePass.h +++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/LuxCore/LuxCoreTexturePass.h @@ -42,7 +42,7 @@ namespace AZ protected: // Pass behavior overrides void CreateChildPassesInternal() final; - void BuildAttachmentsInternal() final; + void BuildInternal() final; void FrameBeginInternal(FramePrepareParams params) final; private: diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/LuxCore/RenderTexturePass.h b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/LuxCore/RenderTexturePass.h index 5ae5008a92..cd148d3452 100644 --- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/LuxCore/RenderTexturePass.h +++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/LuxCore/RenderTexturePass.h @@ -46,7 +46,7 @@ namespace AZ private: - void BuildAttachmentsInternal() override; + void BuildInternal() override; void FrameBeginInternal(FramePrepareParams params) override; void UpdataAttachment(); diff --git a/Gems/Atom/Feature/Common/Code/Source/Checkerboard/CheckerboardColorResolvePass.cpp b/Gems/Atom/Feature/Common/Code/Source/Checkerboard/CheckerboardColorResolvePass.cpp index 3ebb6b370c..a6c440cf39 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Checkerboard/CheckerboardColorResolvePass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/Checkerboard/CheckerboardColorResolvePass.cpp @@ -60,7 +60,7 @@ namespace AZ Base::FrameBeginInternal(params); } - void CheckerboardColorResolvePass::BuildAttachmentsInternal() + void CheckerboardColorResolvePass::BuildInternal() { // For each bound attachments they are the inputs from current frame. // We use them to get their owner CheckerboardPass then find the render targets from last frame @@ -99,7 +99,7 @@ namespace AZ // reset frame offset to 0 since attachments are rebuilt m_frameOffset = 0; - Base::BuildAttachmentsInternal(); + Base::BuildInternal(); } void CheckerboardColorResolvePass::CompileResources(const RHI::FrameGraphCompileContext& context) @@ -135,7 +135,7 @@ namespace AZ void CheckerboardColorResolvePass::FrameEndInternal() { // For the input slots for current frame, they always get updated when CheckerboardPass updates the render targets - // But for the input slots for previous frame, we need to manually update them since they were manually attached in BuildAttachmentsInternal() + // But for the input slots for previous frame, we need to manually update them since they were manually attached in BuildInternal() // // When pass attachment was built, CheckerboardPass creates two resources for each render target. // For example, diffuse_0 and diffuse_1 which diffuse_0 is for even frame and diffuse_1 is for odd frame. diff --git a/Gems/Atom/Feature/Common/Code/Source/Checkerboard/CheckerboardColorResolvePass.h b/Gems/Atom/Feature/Common/Code/Source/Checkerboard/CheckerboardColorResolvePass.h index 8cb15d5f49..93930e2bbc 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Checkerboard/CheckerboardColorResolvePass.h +++ b/Gems/Atom/Feature/Common/Code/Source/Checkerboard/CheckerboardColorResolvePass.h @@ -52,7 +52,7 @@ namespace AZ protected: // Pass overrides... void FrameBeginInternal(FramePrepareParams params) override; - void BuildAttachmentsInternal() override; + void BuildInternal() override; void FrameEndInternal() override; // Scope producer functions... diff --git a/Gems/Atom/Feature/Common/Code/Source/Checkerboard/CheckerboardPass.cpp b/Gems/Atom/Feature/Common/Code/Source/Checkerboard/CheckerboardPass.cpp index 09c69dfe18..a781c460f5 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Checkerboard/CheckerboardPass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/Checkerboard/CheckerboardPass.cpp @@ -50,7 +50,7 @@ namespace AZ Base::FrameBeginInternal(params); } - void CheckerboardPass::BuildAttachmentsInternal() + void CheckerboardPass::BuildInternal() { Data::Instance pool = RPI::ImageSystemInterface::Get()->GetSystemAttachmentPool(); @@ -101,7 +101,7 @@ namespace AZ // reset frame offset to 0 since attachments are rebuilt m_frameOffset = 0; - Base::BuildAttachmentsInternal(); + Base::BuildInternal(); } diff --git a/Gems/Atom/Feature/Common/Code/Source/Checkerboard/CheckerboardPass.h b/Gems/Atom/Feature/Common/Code/Source/Checkerboard/CheckerboardPass.h index 3b905cc3db..02429bb837 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Checkerboard/CheckerboardPass.h +++ b/Gems/Atom/Feature/Common/Code/Source/Checkerboard/CheckerboardPass.h @@ -40,7 +40,7 @@ namespace AZ protected: // Pass overrides... void FrameBeginInternal(FramePrepareParams params); - void BuildAttachmentsInternal() override; + void BuildInternal() override; void FrameEndInternal() override; private: diff --git a/Gems/Atom/Feature/Common/Code/Source/CoreLights/CascadedShadowmapsPass.cpp b/Gems/Atom/Feature/Common/Code/Source/CoreLights/CascadedShadowmapsPass.cpp index d83201533c..4c7e69f2ae 100644 --- a/Gems/Atom/Feature/Common/Code/Source/CoreLights/CascadedShadowmapsPass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/CoreLights/CascadedShadowmapsPass.cpp @@ -100,7 +100,7 @@ namespace AZ m_arraySize = arraySize; m_updateChildren = true; - QueueForBuildAttachments(); + QueueForBuild(); m_atlas.Initialize(); for (size_t cascadeIndex = 0; cascadeIndex < m_arraySize; ++cascadeIndex) @@ -149,7 +149,7 @@ namespace AZ return m_atlas; } - void CascadedShadowmapsPass::BuildAttachmentsInternal() + void CascadedShadowmapsPass::BuildInternal() { UpdateChildren(); @@ -159,7 +159,7 @@ namespace AZ } UpdateShadowmapImageSize(); - Base::BuildAttachmentsInternal(); + Base::BuildInternal(); } void CascadedShadowmapsPass::GetPipelineViewTags(RPI::SortedPipelineViewTags& outTags) const @@ -215,7 +215,7 @@ namespace AZ AZ_RPI_PASS_WARNING(child, "CascadedShadowmapsPass child Pass creation failed for %d", cascadeIndex); if (child) { - child->QueueForBuildAttachments(); + child->QueueForBuild(); AddChild(child); } } diff --git a/Gems/Atom/Feature/Common/Code/Source/CoreLights/CascadedShadowmapsPass.h b/Gems/Atom/Feature/Common/Code/Source/CoreLights/CascadedShadowmapsPass.h index aa95e0af44..772be9466d 100644 --- a/Gems/Atom/Feature/Common/Code/Source/CoreLights/CascadedShadowmapsPass.h +++ b/Gems/Atom/Feature/Common/Code/Source/CoreLights/CascadedShadowmapsPass.h @@ -53,7 +53,7 @@ namespace AZ explicit CascadedShadowmapsPass(const RPI::PassDescriptor& descriptor); // RPI::Pass overrides... - void BuildAttachmentsInternal() override; + void BuildInternal() override; void GetPipelineViewTags(RPI::SortedPipelineViewTags& outTags) const override; void GetViewDrawListInfo(RHI::DrawListMask& outDrawListMask, RPI::PassesByDrawList& outPassesByDrawList, const RPI::PipelineViewTag& viewTag) const override; diff --git a/Gems/Atom/Feature/Common/Code/Source/CoreLights/DirectionalLightFeatureProcessor.cpp b/Gems/Atom/Feature/Common/Code/Source/CoreLights/DirectionalLightFeatureProcessor.cpp index 9b40097716..cdbe431949 100644 --- a/Gems/Atom/Feature/Common/Code/Source/CoreLights/DirectionalLightFeatureProcessor.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/CoreLights/DirectionalLightFeatureProcessor.cpp @@ -1106,7 +1106,7 @@ namespace AZ { for (EsmShadowmapsPass* pass : it.second) { - pass->QueueForBuildAttachments(); + pass->QueueForBuild(); } } } diff --git a/Gems/Atom/Feature/Common/Code/Source/CoreLights/LightCullingPass.cpp b/Gems/Atom/Feature/Common/Code/Source/CoreLights/LightCullingPass.cpp index 987ed299b3..88a063b499 100644 --- a/Gems/Atom/Feature/Common/Code/Source/CoreLights/LightCullingPass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/CoreLights/LightCullingPass.cpp @@ -163,7 +163,6 @@ namespace AZ void LightCullingPass::ResetInternal() { - m_initialized = false; m_tileDataIndex = -1; m_constantDataIndex.Reset(); @@ -260,7 +259,7 @@ namespace AZ return gridPixelSize; } - void LightCullingPass::BuildAttachmentsInternal() + void LightCullingPass::BuildInternal() { m_tileDataIndex = FindInputBinding(AZ::Name("TileLightData")); CreateLightList(); diff --git a/Gems/Atom/Feature/Common/Code/Source/CoreLights/LightCullingPass.h b/Gems/Atom/Feature/Common/Code/Source/CoreLights/LightCullingPass.h index d8699ea0c7..8080379716 100644 --- a/Gems/Atom/Feature/Common/Code/Source/CoreLights/LightCullingPass.h +++ b/Gems/Atom/Feature/Common/Code/Source/CoreLights/LightCullingPass.h @@ -50,7 +50,7 @@ namespace AZ // Pass behavior overrides... void ResetInternal()override; - void BuildAttachmentsInternal() override; + void BuildInternal() override; // Scope producer functions... void CompileResources(const RHI::FrameGraphCompileContext& context) override; @@ -96,7 +96,6 @@ namespace AZ AZ::RHI::ShaderInputNameIndex m_constantDataIndex = "m_constantData"; - bool m_initialized = false; Data::Instance m_lightList; uint32_t m_tileDataIndex = -1; diff --git a/Gems/Atom/Feature/Common/Code/Source/CoreLights/LightCullingRemap.cpp b/Gems/Atom/Feature/Common/Code/Source/CoreLights/LightCullingRemap.cpp index 42882cec6e..a12ba48751 100644 --- a/Gems/Atom/Feature/Common/Code/Source/CoreLights/LightCullingRemap.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/CoreLights/LightCullingRemap.cpp @@ -108,7 +108,7 @@ namespace AZ return -1; } - void LightCullingRemap::BuildAttachmentsInternal() + void LightCullingRemap::BuildInternal() { m_tileDataIndex = FindInputOutputBinding(AZ::Name("TileLightData")); m_tileDim = GetTileDataBufferResolution(); diff --git a/Gems/Atom/Feature/Common/Code/Source/CoreLights/LightCullingRemap.h b/Gems/Atom/Feature/Common/Code/Source/CoreLights/LightCullingRemap.h index 0738acd459..6d60f93a64 100644 --- a/Gems/Atom/Feature/Common/Code/Source/CoreLights/LightCullingRemap.h +++ b/Gems/Atom/Feature/Common/Code/Source/CoreLights/LightCullingRemap.h @@ -55,7 +55,7 @@ namespace AZ // Pass behavior overrides... void ResetInternal()override; - void BuildAttachmentsInternal() override; + void BuildInternal() override; // RHI::ScopeProducer overrides... void SetupFrameGraphDependencies(RHI::FrameGraphInterface frameGraph) override; diff --git a/Gems/Atom/Feature/Common/Code/Source/CoreLights/LightCullingTilePreparePass.cpp b/Gems/Atom/Feature/Common/Code/Source/CoreLights/LightCullingTilePreparePass.cpp index 816ef25bc6..c144525cec 100644 --- a/Gems/Atom/Feature/Common/Code/Source/CoreLights/LightCullingTilePreparePass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/CoreLights/LightCullingTilePreparePass.cpp @@ -167,37 +167,36 @@ namespace AZ AZ_Assert(setOk, "LightCullingTilePreparePass::SetConstantData() - could not set constant data"); } - void LightCullingTilePreparePass::BuildAttachmentsInternal() + void LightCullingTilePreparePass::BuildInternal() { ChooseShaderVariant(); } - void LightCullingTilePreparePass::OnShaderReinitialized(const AZ::RPI::Shader&) + void LightCullingTilePreparePass::OnShaderReloaded() { LoadShader(); - if (!m_flags.m_queuedForBuildAttachment && !m_flags.m_isBuildingAttachments) + AZ_Assert(GetPassState() != RPI::PassState::Rendering, "LightCullingTilePreparePass: Trying to reload shader during rendering"); + if (GetPassState() == RPI::PassState::Initialized) { ChooseShaderVariant(); } } + + void LightCullingTilePreparePass::OnShaderReinitialized(const AZ::RPI::Shader&) + { + OnShaderReloaded(); + } + void LightCullingTilePreparePass::OnShaderAssetReinitialized(const Data::Asset&) { - LoadShader(); - if (!m_flags.m_queuedForBuildAttachment && !m_flags.m_isBuildingAttachments) - { - ChooseShaderVariant(); - } + OnShaderReloaded(); } void LightCullingTilePreparePass::OnShaderVariantReinitialized( const AZ::RPI::Shader&, const AZ::RPI::ShaderVariantId&, AZ::RPI::ShaderVariantStableId) { - LoadShader(); - if (!m_flags.m_queuedForBuildAttachment && !m_flags.m_isBuildingAttachments) - { - ChooseShaderVariant(); - } + OnShaderReloaded(); } } // namespace Render diff --git a/Gems/Atom/Feature/Common/Code/Source/CoreLights/LightCullingTilePreparePass.h b/Gems/Atom/Feature/Common/Code/Source/CoreLights/LightCullingTilePreparePass.h index efba105912..0febb66e3d 100644 --- a/Gems/Atom/Feature/Common/Code/Source/CoreLights/LightCullingTilePreparePass.h +++ b/Gems/Atom/Feature/Common/Code/Source/CoreLights/LightCullingTilePreparePass.h @@ -50,7 +50,7 @@ namespace AZ LightCullingTilePreparePass(const RPI::PassDescriptor& descriptor); // Pass behavior overrides... - void BuildAttachmentsInternal() override; + void BuildInternal() override; /////////////////////////////////////////////////////////////////// // ShaderReloadNotificationBus overrides... @@ -73,6 +73,7 @@ namespace AZ const AZ::RPI::ShaderVariant& CreateShaderVariant(); void CreatePipelineStateFromShaderVariant(const RPI::ShaderVariant& shaderVariant); void SetConstantData(); + void OnShaderReloaded(); AZ::RHI::ShaderInputNameIndex m_constantDataIndex = "m_constantData"; diff --git a/Gems/Atom/Feature/Common/Code/Source/CoreLights/ProjectedShadowmapsPass.cpp b/Gems/Atom/Feature/Common/Code/Source/CoreLights/ProjectedShadowmapsPass.cpp index d77419fe8f..87cacbb345 100644 --- a/Gems/Atom/Feature/Common/Code/Source/CoreLights/ProjectedShadowmapsPass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/CoreLights/ProjectedShadowmapsPass.cpp @@ -73,7 +73,7 @@ namespace AZ { m_sizes = sizes; m_updateChildren = true; - QueueForBuildAttachments(); + QueueForBuild(); m_atlas.Initialize(); for (const auto& it : m_sizes) @@ -156,7 +156,7 @@ namespace AZ return m_atlas; } - void ProjectedShadowmapsPass::BuildAttachmentsInternal() + void ProjectedShadowmapsPass::BuildInternal() { UpdateChildren(); @@ -177,7 +177,7 @@ namespace AZ imageDescriptor.m_size = RHI::Size(shadowmapWidth, shadowmapWidth, 1); imageDescriptor.m_arraySize = m_atlas.GetArraySliceCount(); - Base::BuildAttachmentsInternal(); + Base::BuildInternal(); } void ProjectedShadowmapsPass::GetPipelineViewTags(RPI::SortedPipelineViewTags& outTags) const diff --git a/Gems/Atom/Feature/Common/Code/Source/CoreLights/ProjectedShadowmapsPass.h b/Gems/Atom/Feature/Common/Code/Source/CoreLights/ProjectedShadowmapsPass.h index 63640d22c6..f1963cc885 100644 --- a/Gems/Atom/Feature/Common/Code/Source/CoreLights/ProjectedShadowmapsPass.h +++ b/Gems/Atom/Feature/Common/Code/Source/CoreLights/ProjectedShadowmapsPass.h @@ -71,7 +71,7 @@ namespace AZ explicit ProjectedShadowmapsPass(const RPI::PassDescriptor& descriptor); // RPI::Pass overrides... - void BuildAttachmentsInternal() override; + void BuildInternal() override; void GetPipelineViewTags(RPI::SortedPipelineViewTags& outTags) const override; void GetViewDrawListInfo(RHI::DrawListMask& outDrawListMask, RPI::PassesByDrawList& outPassesByDrawList, const RPI::PipelineViewTag& viewTag) const override; diff --git a/Gems/Atom/Feature/Common/Code/Source/CoreLights/ShadowmapPass.cpp b/Gems/Atom/Feature/Common/Code/Source/CoreLights/ShadowmapPass.cpp index 087a73a94d..d31947da5a 100644 --- a/Gems/Atom/Feature/Common/Code/Source/CoreLights/ShadowmapPass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/CoreLights/ShadowmapPass.cpp @@ -107,7 +107,7 @@ namespace AZ m_scissorState = scissor; } - void ShadowmapPass::BuildAttachmentsInternal() + void ShadowmapPass::BuildInternal() { RPI::Ptr parentPass = GetParent(); if (!parentPass) @@ -135,7 +135,7 @@ namespace AZ action.m_loadAction = m_clearEnabled ? RHI::AttachmentLoadAction::Clear : RHI::AttachmentLoadAction::DontCare; binding.m_unifiedScopeDesc = RHI::UnifiedScopeAttachmentDescriptor(attachmentId, imageViewDescriptor, action); - Base::BuildAttachmentsInternal(); + Base::BuildInternal(); } } // namespace Render diff --git a/Gems/Atom/Feature/Common/Code/Source/CoreLights/ShadowmapPass.h b/Gems/Atom/Feature/Common/Code/Source/CoreLights/ShadowmapPass.h index 9c308dc4df..2814761a69 100644 --- a/Gems/Atom/Feature/Common/Code/Source/CoreLights/ShadowmapPass.h +++ b/Gems/Atom/Feature/Common/Code/Source/CoreLights/ShadowmapPass.h @@ -58,7 +58,7 @@ namespace AZ explicit ShadowmapPass(const RPI::PassDescriptor& descriptor); // RHI::Pass overrides... - void BuildAttachmentsInternal() override; + void BuildInternal() override; uint16_t m_arraySlice = 0; bool m_clearEnabled = true; diff --git a/Gems/Atom/Feature/Common/Code/Source/DisplayMapper/DisplayMapperFullScreenPass.cpp b/Gems/Atom/Feature/Common/Code/Source/DisplayMapper/DisplayMapperFullScreenPass.cpp index ba83fabed3..096179d5b6 100644 --- a/Gems/Atom/Feature/Common/Code/Source/DisplayMapper/DisplayMapperFullScreenPass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/DisplayMapper/DisplayMapperFullScreenPass.cpp @@ -34,7 +34,7 @@ namespace AZ { } - void DisplayMapperFullScreenPass::BuildAttachmentsInternal() + void DisplayMapperFullScreenPass::BuildInternal() { RPI::PassConnection inConnection; inConnection.m_localSlot = InputAttachmentName; diff --git a/Gems/Atom/Feature/Common/Code/Source/DisplayMapper/DisplayMapperPass.cpp b/Gems/Atom/Feature/Common/Code/Source/DisplayMapper/DisplayMapperPass.cpp index 8ae790e12c..be3e05163a 100644 --- a/Gems/Atom/Feature/Common/Code/Source/DisplayMapper/DisplayMapperPass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/DisplayMapper/DisplayMapperPass.cpp @@ -46,8 +46,6 @@ namespace AZ DisplayMapperPass::DisplayMapperPass(const RPI::PassDescriptor& descriptor) : RPI::ParentPass(descriptor) { - m_flags.m_alreadyCreated = false; - AzFramework::NativeWindowHandle windowHandle = nullptr; AzFramework::WindowSystemRequestBus::BroadcastResult( windowHandle, @@ -137,7 +135,7 @@ namespace AZ } } - void DisplayMapperPass::BuildAttachmentsInternal() + void DisplayMapperPass::BuildInternal() { const Name outputName = Name{ "Output" }; Name inputPass = Name{ "Parent" }; @@ -187,7 +185,7 @@ namespace AZ m_swapChainAttachmentBinding = FindAttachmentBinding(Name("SwapChainOutput")); - ParentPass::BuildAttachmentsInternal(); + ParentPass::BuildInternal(); } void DisplayMapperPass::FrameBeginInternal(FramePrepareParams params) diff --git a/Gems/Atom/Feature/Common/Code/Source/ImGui/ImGuiPass.cpp b/Gems/Atom/Feature/Common/Code/Source/ImGui/ImGuiPass.cpp index a29354f723..fe5d9a16fe 100644 --- a/Gems/Atom/Feature/Common/Code/Source/ImGui/ImGuiPass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/ImGui/ImGuiPass.cpp @@ -519,13 +519,13 @@ namespace AZ io.Fonts->TexID = reinterpret_cast(m_fontAtlas.get()); } - void ImGuiPass::OnBuildAttachmentsFinishedInternal() + void ImGuiPass::OnBuildFinishedInternal() { // Set output format and finalize pipeline state m_pipelineState->SetOutputFromPass(this); m_pipelineState->Finalize(); - Base::OnBuildAttachmentsFinishedInternal(); + Base::OnBuildFinishedInternal(); } void ImGuiPass::SetupFrameGraphDependencies(RHI::FrameGraphInterface frameGraph) diff --git a/Gems/Atom/Feature/Common/Code/Source/ImGui/ImGuiPass.h b/Gems/Atom/Feature/Common/Code/Source/ImGui/ImGuiPass.h index c8be0d7ee6..30449820bb 100644 --- a/Gems/Atom/Feature/Common/Code/Source/ImGui/ImGuiPass.h +++ b/Gems/Atom/Feature/Common/Code/Source/ImGui/ImGuiPass.h @@ -94,7 +94,7 @@ namespace AZ explicit ImGuiPass(const RPI::PassDescriptor& descriptor); // Pass Behaviour Overrides... - void OnBuildAttachmentsFinishedInternal() override; + void OnBuildFinishedInternal() override; void FrameBeginInternal(FramePrepareParams params) override; // Scope producer functions diff --git a/Gems/Atom/Feature/Common/Code/Source/LuxCore/LuxCoreTexturePass.cpp b/Gems/Atom/Feature/Common/Code/Source/LuxCore/LuxCoreTexturePass.cpp index 9a921205ab..3c7233e747 100644 --- a/Gems/Atom/Feature/Common/Code/Source/LuxCore/LuxCoreTexturePass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/LuxCore/LuxCoreTexturePass.cpp @@ -28,8 +28,6 @@ namespace AZ LuxCoreTexturePass::LuxCoreTexturePass(const RPI::PassDescriptor& descriptor) : ParentPass(descriptor) { - m_flags.m_alreadyCreated = false; - RPI::PassSystemInterface* passSystem = RPI::PassSystemInterface::Get(); // Create render target pass @@ -61,9 +59,9 @@ namespace AZ AddChild(m_renderTargetPass); } - void LuxCoreTexturePass::BuildAttachmentsInternal() + void LuxCoreTexturePass::BuildInternal() { - ParentPass::BuildAttachmentsInternal(); + ParentPass::BuildInternal(); } void LuxCoreTexturePass::FrameBeginInternal(FramePrepareParams params) diff --git a/Gems/Atom/Feature/Common/Code/Source/LuxCore/RenderTexturePass.cpp b/Gems/Atom/Feature/Common/Code/Source/LuxCore/RenderTexturePass.cpp index 0782e12278..aa991e270a 100644 --- a/Gems/Atom/Feature/Common/Code/Source/LuxCore/RenderTexturePass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/LuxCore/RenderTexturePass.cpp @@ -38,13 +38,13 @@ namespace AZ m_attachmentSize = image->GetRHIImage()->GetDescriptor().m_size; m_attachmentFormat = format; m_shaderResourceGroup->SetImage(m_textureIndex, image); - QueueForBuildAttachments(); + QueueForBuild(); } - void RenderTexturePass::BuildAttachmentsInternal() + void RenderTexturePass::BuildInternal() { UpdataAttachment(); - FullscreenTrianglePass::BuildAttachmentsInternal(); + FullscreenTrianglePass::BuildInternal(); } void RenderTexturePass::FrameBeginInternal(FramePrepareParams params) diff --git a/Gems/Atom/Feature/Common/Code/Source/MorphTargets/MorphTargetComputePass.cpp b/Gems/Atom/Feature/Common/Code/Source/MorphTargets/MorphTargetComputePass.cpp index 1bb537ecef..42acd5c447 100644 --- a/Gems/Atom/Feature/Common/Code/Source/MorphTargets/MorphTargetComputePass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/MorphTargets/MorphTargetComputePass.cpp @@ -44,7 +44,7 @@ namespace AZ m_skinnedMeshFeatureProcessor = skinnedMeshFeatureProcessor; } - void MorphTargetComputePass::BuildAttachmentsInternal() + void MorphTargetComputePass::BuildInternal() { // The same buffer that skinning writes to is used to manage the computed vertex deltas that are passed from the // morph target pass to the skinning pass. This simplifies things by only requiring one class to manage the memory diff --git a/Gems/Atom/Feature/Common/Code/Source/MorphTargets/MorphTargetComputePass.h b/Gems/Atom/Feature/Common/Code/Source/MorphTargets/MorphTargetComputePass.h index 61fa485fbc..d346edd908 100644 --- a/Gems/Atom/Feature/Common/Code/Source/MorphTargets/MorphTargetComputePass.h +++ b/Gems/Atom/Feature/Common/Code/Source/MorphTargets/MorphTargetComputePass.h @@ -37,7 +37,7 @@ namespace AZ void SetFeatureProcessor(SkinnedMeshFeatureProcessor* m_skinnedMeshFeatureProcessor); private: - void BuildAttachmentsInternal() override; + void BuildInternal() override; void BuildCommandListInternal(const RHI::FrameGraphExecuteContext& context) override; SkinnedMeshFeatureProcessor* m_skinnedMeshFeatureProcessor = nullptr; diff --git a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/BloomBlurPass.cpp b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/BloomBlurPass.cpp index 1427adeb08..af95a76718 100644 --- a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/BloomBlurPass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/BloomBlurPass.cpp @@ -252,10 +252,10 @@ namespace AZ } } - void BloomBlurPass::BuildAttachmentsInternal() + void BloomBlurPass::BuildInternal() { BuildChildPasses(); - ParentPass::BuildAttachmentsInternal(); + ParentPass::BuildInternal(); } void BloomBlurPass::FrameBeginInternal(FramePrepareParams params) diff --git a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/BloomBlurPass.h b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/BloomBlurPass.h index e87d831382..4c65368506 100644 --- a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/BloomBlurPass.h +++ b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/BloomBlurPass.h @@ -47,7 +47,7 @@ namespace AZ BloomBlurPass(const RPI::PassDescriptor& descriptor); // Pass behaviour overrides... - void BuildAttachmentsInternal() override; + void BuildInternal() override; void FrameBeginInternal(FramePrepareParams params) override; void GetInputInfo(); diff --git a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/BloomCompositePass.cpp b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/BloomCompositePass.cpp index fbb020cbf3..810353aab1 100644 --- a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/BloomCompositePass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/BloomCompositePass.cpp @@ -56,10 +56,10 @@ namespace AZ m_passData = *passData; } - void BloomCompositePass::BuildAttachmentsInternal() + void BloomCompositePass::BuildInternal() { BuildChildPasses(); - ParentPass::BuildAttachmentsInternal(); + ParentPass::BuildInternal(); } void BloomCompositePass::FrameBeginInternal(FramePrepareParams params) diff --git a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/BloomCompositePass.h b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/BloomCompositePass.h index 86d897ae7d..a19947e1d0 100644 --- a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/BloomCompositePass.h +++ b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/BloomCompositePass.h @@ -44,7 +44,7 @@ namespace AZ BloomCompositePass(const RPI::PassDescriptor& descriptor); // Pass behaviour overrides... - void BuildAttachmentsInternal() override; + void BuildInternal() override; void FrameBeginInternal(FramePrepareParams params) override; void GetAttachmentInfo(); diff --git a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/BloomDownsamplePass.cpp b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/BloomDownsamplePass.cpp index 647177a1ce..63779beb16 100644 --- a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/BloomDownsamplePass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/BloomDownsamplePass.cpp @@ -74,10 +74,10 @@ namespace AZ AddAttachmentBinding(outBinding); } - ComputePass::BuildAttachmentsInternal(); + ComputePass::BuildInternal(); } - void BloomDownsamplePass::BuildAttachmentsInternal() + void BloomDownsamplePass::BuildInternal() { BuildOutAttachmentBinding(); } diff --git a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/BloomDownsamplePass.h b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/BloomDownsamplePass.h index 824f703417..3eb0ac8740 100644 --- a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/BloomDownsamplePass.h +++ b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/BloomDownsamplePass.h @@ -37,7 +37,7 @@ namespace AZ BloomDownsamplePass(const RPI::PassDescriptor& descriptor); // Pass Behaviour Overrides... - void BuildAttachmentsInternal() override; + void BuildInternal() override; void FrameBeginInternal(FramePrepareParams params) override; void BuildOutAttachmentBinding(); diff --git a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/DepthOfFieldCopyFocusDepthToCpuPass.cpp b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/DepthOfFieldCopyFocusDepthToCpuPass.cpp index d64bba1957..00d5ad93c3 100644 --- a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/DepthOfFieldCopyFocusDepthToCpuPass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/DepthOfFieldCopyFocusDepthToCpuPass.cpp @@ -52,7 +52,7 @@ namespace AZ return depth; } - void DepthOfFieldCopyFocusDepthToCpuPass::BuildAttachmentsInternal() + void DepthOfFieldCopyFocusDepthToCpuPass::BuildInternal() { SetScopeId(RHI::ScopeId(GetPathName())); } diff --git a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/DepthOfFieldCopyFocusDepthToCpuPass.h b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/DepthOfFieldCopyFocusDepthToCpuPass.h index 64301b6e0c..7e8d041e96 100644 --- a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/DepthOfFieldCopyFocusDepthToCpuPass.h +++ b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/DepthOfFieldCopyFocusDepthToCpuPass.h @@ -48,7 +48,7 @@ namespace AZ void BuildCommandList(const RHI::FrameGraphExecuteContext& context) override; // Pass overrides - void BuildAttachmentsInternal() override; + void BuildInternal() override; void FrameBeginInternal(FramePrepareParams params) override; RPI::Ptr m_bufferRef; diff --git a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/DepthOfFieldWriteFocusDepthFromGpuPass.cpp b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/DepthOfFieldWriteFocusDepthFromGpuPass.cpp index e7ac891198..4aaf936426 100644 --- a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/DepthOfFieldWriteFocusDepthFromGpuPass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/DepthOfFieldWriteFocusDepthFromGpuPass.cpp @@ -62,9 +62,9 @@ namespace AZ m_bufferRef = bufferRef; } - void DepthOfFieldWriteFocusDepthFromGpuPass::BuildAttachmentsInternal() + void DepthOfFieldWriteFocusDepthFromGpuPass::BuildInternal() { - AZ_Assert(m_bufferRef != nullptr, "%s has a null buffer when calling BuildAttachmentsInternal.", GetPathName().GetCStr()); + AZ_Assert(m_bufferRef != nullptr, "%s has a null buffer when calling BuildInternal.", GetPathName().GetCStr()); AttachBufferToSlot(Name("DofDepthInputOutput"), m_bufferRef); } diff --git a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/DepthOfFieldWriteFocusDepthFromGpuPass.h b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/DepthOfFieldWriteFocusDepthFromGpuPass.h index 592ab64c01..881ef9df94 100644 --- a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/DepthOfFieldWriteFocusDepthFromGpuPass.h +++ b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/DepthOfFieldWriteFocusDepthFromGpuPass.h @@ -51,7 +51,7 @@ namespace AZ void CompileResources(const RHI::FrameGraphCompileContext& context) override; // Pass overrides - void BuildAttachmentsInternal() override; + void BuildInternal() override; }; } // namespace Render } // namespace AZ diff --git a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/EyeAdaptationPass.cpp b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/EyeAdaptationPass.cpp index e7d4c47f02..879abf6418 100644 --- a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/EyeAdaptationPass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/EyeAdaptationPass.cpp @@ -62,7 +62,7 @@ namespace AZ m_buffer = RPI::BufferSystemInterface::Get()->CreateBufferFromCommonPool(desc); } - void EyeAdaptationPass::BuildAttachmentsInternal() + void EyeAdaptationPass::BuildInternal() { if (!m_buffer) { diff --git a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/EyeAdaptationPass.h b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/EyeAdaptationPass.h index cef168a122..d53569a9f9 100644 --- a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/EyeAdaptationPass.h +++ b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/EyeAdaptationPass.h @@ -58,7 +58,7 @@ namespace AZ float m_exposureValue = 1.0f; }; - void BuildAttachmentsInternal() override; + void BuildInternal() override; void FrameBeginInternal(FramePrepareParams params) override; diff --git a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/LookModificationTransformPass.cpp b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/LookModificationTransformPass.cpp index 98c842042b..9f792370fc 100644 --- a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/LookModificationTransformPass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/LookModificationTransformPass.cpp @@ -36,10 +36,10 @@ namespace AZ &AzFramework::WindowSystemRequestBus::Events::GetDefaultWindowHandle); } - void LookModificationPass::BuildAttachmentsInternal() + void LookModificationPass::BuildInternal() { m_swapChainAttachmentBinding = FindAttachmentBinding(Name("SwapChainOutput")); - ParentPass::BuildAttachmentsInternal(); + ParentPass::BuildInternal(); } void LookModificationPass::FrameBeginInternal([[maybe_unused]] FramePrepareParams params) diff --git a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/LookModificationTransformPass.h b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/LookModificationTransformPass.h index 5102015e82..8203530918 100644 --- a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/LookModificationTransformPass.h +++ b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/LookModificationTransformPass.h @@ -52,7 +52,7 @@ namespace AZ //! Pass overrides ... void FrameBeginInternal(FramePrepareParams params) override; - void BuildAttachmentsInternal() override; + void BuildInternal() override; private: const RPI::PassAttachmentBinding* m_swapChainAttachmentBinding = nullptr; diff --git a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/LuminanceHistogramGeneratorPass.cpp b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/LuminanceHistogramGeneratorPass.cpp index 758c21bc4e..2fe8b01089 100644 --- a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/LuminanceHistogramGeneratorPass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/LuminanceHistogramGeneratorPass.cpp @@ -86,7 +86,7 @@ namespace AZ return colorBuffer->m_descriptor.m_image.m_size; } - void LuminanceHistogramGeneratorPass::BuildAttachmentsInternal() + void LuminanceHistogramGeneratorPass::BuildInternal() { CreateHistogramBuffer(); AttachHistogramBuffer(); diff --git a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/LuminanceHistogramGeneratorPass.h b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/LuminanceHistogramGeneratorPass.h index ee8a10fe16..9691daab6f 100644 --- a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/LuminanceHistogramGeneratorPass.h +++ b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/LuminanceHistogramGeneratorPass.h @@ -42,7 +42,7 @@ namespace AZ protected: LuminanceHistogramGeneratorPass(const RPI::PassDescriptor& descriptor); - virtual void BuildAttachmentsInternal() override; + virtual void BuildInternal() override; void CreateHistogramBuffer(); void AttachHistogramBuffer(); AZ::RHI::Size GetColorBufferResolution(); diff --git a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/SsaoPasses.cpp b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/SsaoPasses.cpp index 68472115ce..1aa16a4417 100644 --- a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/SsaoPasses.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/SsaoPasses.cpp @@ -41,9 +41,9 @@ namespace AZ return ParentPass::IsEnabled(); } - void SsaoParentPass::OnBuildAttachmentsFinishedInternal() + void SsaoParentPass::OnBuildFinishedInternal() { - ParentPass::OnBuildAttachmentsFinishedInternal(); + ParentPass::OnBuildFinishedInternal(); m_blurParentPass = FindChildPass(Name("SsaoBlur"))->AsParent(); AZ_Assert(m_blurParentPass, "[SsaoParentPass] Could not retrieve parent blur pass."); diff --git a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/SsaoPasses.h b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/SsaoPasses.h index 9abd04e306..20aa554414 100644 --- a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/SsaoPasses.h +++ b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/SsaoPasses.h @@ -36,7 +36,7 @@ namespace AZ protected: // Behavior functions override... - void OnBuildAttachmentsFinishedInternal() override; + void OnBuildFinishedInternal() override; void FrameBeginInternal(FramePrepareParams params) override; private: diff --git a/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingAccelerationStructurePass.cpp b/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingAccelerationStructurePass.cpp index 92cd41b4e8..f1fcd2de35 100644 --- a/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingAccelerationStructurePass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingAccelerationStructurePass.cpp @@ -42,7 +42,7 @@ namespace AZ } } - void RayTracingAccelerationStructurePass::BuildAttachmentsInternal() + void RayTracingAccelerationStructurePass::BuildInternal() { SetScopeId(RHI::ScopeId(GetPathName())); } diff --git a/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingAccelerationStructurePass.h b/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingAccelerationStructurePass.h index 6d90d752e3..127669301e 100644 --- a/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingAccelerationStructurePass.h +++ b/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingAccelerationStructurePass.h @@ -44,7 +44,7 @@ namespace AZ void BuildCommandList(const RHI::FrameGraphExecuteContext& context) override; // Pass overrides - void BuildAttachmentsInternal() override; + void BuildInternal() override; void FrameBeginInternal(FramePrepareParams params) override; // buffer view descriptor for the TLAS diff --git a/Gems/Atom/Feature/Common/Code/Source/ReflectionScreenSpace/ReflectionCopyFrameBufferPass.cpp b/Gems/Atom/Feature/Common/Code/Source/ReflectionScreenSpace/ReflectionCopyFrameBufferPass.cpp index 5137b66bf9..9a9064bdf7 100644 --- a/Gems/Atom/Feature/Common/Code/Source/ReflectionScreenSpace/ReflectionCopyFrameBufferPass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/ReflectionScreenSpace/ReflectionCopyFrameBufferPass.cpp @@ -30,7 +30,7 @@ namespace AZ { } - void ReflectionCopyFrameBufferPass::BuildAttachmentsInternal() + void ReflectionCopyFrameBufferPass::BuildInternal() { RPI::PassHierarchyFilter passFilter(AZ::Name("ReflectionScreenSpaceBlurPass")); const AZStd::vector& passes = RPI::PassSystemInterface::Get()->FindPasses(passFilter); @@ -43,7 +43,7 @@ namespace AZ AttachImageToSlot(outputBinding.m_name, frameBufferAttachment); } - FullscreenTrianglePass::BuildAttachmentsInternal(); + FullscreenTrianglePass::BuildInternal(); } } // namespace RPI } // namespace AZ diff --git a/Gems/Atom/Feature/Common/Code/Source/ReflectionScreenSpace/ReflectionCopyFrameBufferPass.h b/Gems/Atom/Feature/Common/Code/Source/ReflectionScreenSpace/ReflectionCopyFrameBufferPass.h index 2a2fecea40..f0b8c80d72 100644 --- a/Gems/Atom/Feature/Common/Code/Source/ReflectionScreenSpace/ReflectionCopyFrameBufferPass.h +++ b/Gems/Atom/Feature/Common/Code/Source/ReflectionScreenSpace/ReflectionCopyFrameBufferPass.h @@ -37,7 +37,7 @@ namespace AZ explicit ReflectionCopyFrameBufferPass(const RPI::PassDescriptor& descriptor); // Pass Overrides... - void BuildAttachmentsInternal() override; + void BuildInternal() override; }; } // namespace RPI } // namespace AZ diff --git a/Gems/Atom/Feature/Common/Code/Source/ReflectionScreenSpace/ReflectionScreenSpaceBlurPass.cpp b/Gems/Atom/Feature/Common/Code/Source/ReflectionScreenSpace/ReflectionScreenSpaceBlurPass.cpp index 883686ac5b..680d117b98 100644 --- a/Gems/Atom/Feature/Common/Code/Source/ReflectionScreenSpace/ReflectionScreenSpaceBlurPass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/ReflectionScreenSpace/ReflectionScreenSpaceBlurPass.cpp @@ -113,7 +113,7 @@ namespace AZ } } - void ReflectionScreenSpaceBlurPass::BuildAttachmentsInternal() + void ReflectionScreenSpaceBlurPass::BuildInternal() { RemoveChildren(); @@ -166,9 +166,9 @@ namespace AZ // create child passes, one vertical and one horizontal blur per mip level CreateChildPasses(mipLevels - 1); - // call ParentPass::BuildAttachmentsInternal() first to configure the slots and auto-add the empty bindings, + // call ParentPass::BuildInternal() first to configure the slots and auto-add the empty bindings, // then we will assign attachments to the bindings - ParentPass::BuildAttachmentsInternal(); + ParentPass::BuildInternal(); // setup attachment bindings on vertical blur child passes uint32_t attachmentIndex = 0; diff --git a/Gems/Atom/Feature/Common/Code/Source/ReflectionScreenSpace/ReflectionScreenSpaceBlurPass.h b/Gems/Atom/Feature/Common/Code/Source/ReflectionScreenSpace/ReflectionScreenSpaceBlurPass.h index 53f4026aef..f344fc8e9b 100644 --- a/Gems/Atom/Feature/Common/Code/Source/ReflectionScreenSpace/ReflectionScreenSpaceBlurPass.h +++ b/Gems/Atom/Feature/Common/Code/Source/ReflectionScreenSpace/ReflectionScreenSpaceBlurPass.h @@ -44,7 +44,7 @@ namespace AZ // Pass Overrides... void ResetInternal() override; - void BuildAttachmentsInternal() override; + void BuildInternal() override; AZStd::vector> m_verticalBlurChildPasses; AZStd::vector> m_horizontalBlurChildPasses; diff --git a/Gems/Atom/Feature/Common/Code/Source/Shadows/ProjectedShadowFeatureProcessor.cpp b/Gems/Atom/Feature/Common/Code/Source/Shadows/ProjectedShadowFeatureProcessor.cpp index 216a126953..8484fdddc2 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Shadows/ProjectedShadowFeatureProcessor.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/Shadows/ProjectedShadowFeatureProcessor.cpp @@ -526,7 +526,7 @@ namespace AZ::Render for (EsmShadowmapsPass* esmPass : m_esmShadowmapsPasses) { - esmPass->QueueForBuildAttachments(); + esmPass->QueueForBuild(); } for (ProjectedShadowmapsPass* shadowPass : m_projectedShadowmapsPasses) diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/CopyPass.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/CopyPass.h index ede14564cd..fd5cdabc83 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/CopyPass.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/CopyPass.h @@ -49,7 +49,7 @@ namespace AZ void CopyImageToBuffer(const RHI::FrameGraphCompileContext& context); // Pass behavior overrides - void BuildAttachmentsInternal() override; + void BuildInternal() override; // Scope producer functions... void SetupFrameGraphDependencies(RHI::FrameGraphInterface frameGraph) override; diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/MSAAResolvePass.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/MSAAResolvePass.h index 91ae1536c3..71776982b3 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/MSAAResolvePass.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/MSAAResolvePass.h @@ -40,7 +40,7 @@ namespace AZ MSAAResolvePass(const PassDescriptor& descriptor); // Pass behavior overrides... - void BuildAttachmentsInternal() override; + void BuildInternal() override; void FrameBeginInternal(FramePrepareParams params) override; private: diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/ParentPass.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/ParentPass.h index b4f63a7099..0e1e12e620 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/ParentPass.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/ParentPass.h @@ -109,8 +109,9 @@ namespace AZ // --- Pass Behaviour Overrides --- void ResetInternal() override; - void BuildAttachmentsInternal() override; - void OnBuildAttachmentsFinishedInternal() override; + void BuildInternal() override; + void OnBuildFinishedInternal() override; + void InitializeInternal() override; void FrameBeginInternal(FramePrepareParams params) override; void FrameEndInternal() override; diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Pass.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Pass.h index 1cba71ae7e..ee7f850d27 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Pass.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Pass.h @@ -80,7 +80,7 @@ namespace AZ //! ending with 'Internal' to define the behavior of your passes. These virtual are recursively //! called in Preorder order throughout the pass tree. Only FramePrepare and FrameEnd are //! guaranteed to be called per frame. The other override-able functions are called as needed - //! when scheduled with the PassSystem. See QueueForBuildAttachments and QueueForRemoval. + //! when scheduled with the PassSystem. See QueueForBuild and QueueForRemoval. //! //! Passes are created by the PassFactory. They can be created using either Pass Name, //! a PassTemplate, or a PassRequest. To register your pass class with the PassFactory, @@ -153,11 +153,14 @@ namespace AZ // --- Utility functions --- - //! Queues the pass to have BuildAttachments() called by the PassSystem on frame update - void QueueForBuildAttachments(); + //! Queues the pass to have Build() called by the PassSystem on frame update + void QueueForBuild(); //! Queues the pass to have RemoveFromParent() called by the PassSystem on frame update - void QueueForRemoval(bool needsDeletion = false); + void QueueForRemoval(); + + //! Queues the pass to have Initialize() called by the PassSystem on frame update + void QueueForInitialization(); //! Adds an attachment binding to the list of this Pass' attachment bindings void AddAttachmentBinding(PassAttachmentBinding attachmentBinding); @@ -173,8 +176,8 @@ namespace AZ //! Attach an external buffer resource as attachment to specified slot //! The buffer will be added as a pass attachment then attach to the pass slot - //! Note: the pass attachment and binding will be removed after the general BuildAttachments call. - //! you can add this call in pass' BuildAttachmentsInternal so it will be added whenever attachments get rebuilt + //! Note: the pass attachment and binding will be removed after the general Build call. + //! you can add this call in pass' BuildInternal so it will be added whenever attachments get rebuilt void AttachBufferToSlot(AZStd::string_view slot, Data::Instance buffer); void AttachBufferToSlot(const Name& slot, Data::Instance buffer); void AttachImageToSlot(const Name& slot, Data::Instance image); @@ -256,6 +259,8 @@ namespace AZ //! Returns pointer to the parent pass ParentPass* GetParent() const; + PassState GetPassState() const; + protected: explicit Pass(const PassDescriptor& descriptor); @@ -309,18 +314,23 @@ namespace AZ // customize it's behavior, hence why these functions are called the pass behavior functions. // Resets everything in the pass (like Attachments). - // Called from PassSystem when pass is QueueForBuildAttachments. + // Called from PassSystem when pass is QueueForBuild. void Reset(); virtual void ResetInternal() { } // Builds and sets up any attachments and input/output connections the pass needs. - // Called from PassSystem when pass is QueueForBuildAttachments. - void BuildAttachments(); - virtual void BuildAttachmentsInternal() { } + // Called from PassSystem when pass is QueueForBuild. + void Build(); + virtual void BuildInternal() { } // Called after the pass build phase has finished. Allows passes to reset build flags. - void OnBuildAttachmentsFinished(); - virtual void OnBuildAttachmentsFinishedInternal() { }; + void OnBuildFinished(); + virtual void OnBuildFinishedInternal() { }; + + // Allows for additional pass initialization between building and rendering + // Can be queued independently of Build so as to only invoke Initialize without Build + void Initialize(); + virtual void InitializeInternal() { }; // The Pass's 'Render' function. Called every frame, here the pass sets up it's rendering logic with // the FrameGraphBuilder. This is where your derived pass needs to call ImportScopeProducer on @@ -379,20 +389,16 @@ namespace AZ struct { uint64_t m_createdByPassRequest : 1; - uint64_t m_initialized : 1; uint64_t m_enabled : 1; uint64_t m_parentEnabled : 1; - uint64_t m_alreadyCreated : 1; - uint64_t m_alreadyReset : 1; - uint64_t m_alreadyPrepared : 1; + + uint64_t m_initialized : 1; + uint64_t m_partOfHierarchy : 1; uint64_t m_hasDrawListTag : 1; uint64_t m_hasPipelineViewTag : 1; - uint64_t m_queuedForBuildAttachment : 1; uint64_t m_timestampQueryEnabled : 1; uint64_t m_pipelineStatisticsQueryEnabled : 1; - uint64_t m_isBuildingAttachments : 1; - uint64_t m_isRendering : 1; }; uint64_t m_allFlags = 0; }; @@ -510,6 +516,12 @@ namespace AZ // Depth of the tree hierarchy this pass is at. // Example: Root would be depth 0, Root.Ssao.Downsample depth 2 uint32_t m_treeDepth = 0; + + // Used to track what phase of build/execution the pass is in + PassState m_state = PassState::Uninitialized; + + // Used to track what phases of build/initialization the pass is queued for + PassQueueState m_queueState = PassQueueState::NoQueue; }; //! Struct used to return results from Pass hierarchy validation diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/PassDefines.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/PassDefines.h index d536104768..7c55944603 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/PassDefines.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/PassDefines.h @@ -21,3 +21,28 @@ // Set this to 1 locally on your machine to facilitate pass debugging and get extra information // about passes in the output window. DO NOT SUBMIT with value set to 1 #define AZ_RPI_ENABLE_PASS_DEBUGGING 0 + +namespace AZ +{ + namespace RPI + { + enum class PassState : u8 + { + Uninitialized, + Queued, + Resetting, + Building, + Initializing, + Initialized, + Rendering + }; + + enum class PassQueueState : u8 + { + NoQueue, + QueuedForRemoval, + QueuedForBuild, + QueuedForInitialization, + }; + } +} diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/PassSystem.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/PassSystem.h index fd30f4f406..534bf211dd 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/PassSystem.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/PassSystem.h @@ -73,12 +73,12 @@ namespace AZ bool LoadPassTemplateMappings(const AZStd::string& templateMappingPath) override; void WriteTemplateToFile(const PassTemplate& passTemplate, AZStd::string_view assetFilePath) override; void DebugPrintPassHierarchy() override; - bool IsBuilding() const override; bool IsHotReloading() const override; void SetHotReloading(bool hotReloading) override; void SetTargetedPassDebuggingName(const AZ::Name& targetPassName) override; const AZ::Name& GetTargetedPassDebuggingName() const override; void ConnectEvent(OnReadyLoadTemplatesEvent::Handler& handler) override; + PassSystemState GetState() const override; // PassSystemInterface factory related functions... void AddPassCreator(Name className, PassCreator createFunction) override; @@ -103,8 +103,11 @@ namespace AZ // Returns the root of the pass tree hierarchy const Ptr& GetRootPass() override; - // Calls BuildAttachments() on passes queued in m_buildAttachmentsList - void BuildPassAttachments(); + // Calls Build() on passes queued in m_buildPassList + void BuildPasses(); + + // Calls Initialize() on passes queued in m_initializePassList + void InitializePasses(); // Validates Pass Hierarchy after building void Validate(); @@ -113,13 +116,15 @@ namespace AZ void RemovePasses(); // Functions for queuing passes in the lists below - void QueueForBuildAttachments(Pass* pass) override; + void QueueForBuild(Pass* pass) override; void QueueForRemoval(Pass* pass) override; + void QueueForInitialization(Pass* pass) override; // Lists for queuing passes for various function calls // Name of the list reflects the pass function it will call - AZStd::vector< Ptr > m_buildAttachmentsList; + AZStd::vector< Ptr > m_buildPassList; AZStd::vector< Ptr > m_removePassList; + AZStd::vector< Ptr > m_initializePassList; // Library of pass descriptors that can be instantiated through data driven pass requests PassLibrary m_passLibrary; @@ -133,9 +138,6 @@ namespace AZ // Whether the Pass Hierarchy changed bool m_passHierarchyChanged = true; - // Whether the Pass System is currently in it's building phase - bool m_isBuilding = false; - // Whether the Pass System is currently hot reloading passes bool m_isHotReloading = false; @@ -147,6 +149,9 @@ namespace AZ // Events OnReadyLoadTemplatesEvent m_loadTemplatesEvent; + + // Used to track what phase of execution the pass system is in + PassSystemState m_state = PassSystemState::Unitialized; }; } // namespace RPI } // namespace AZ diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/PassSystemInterface.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/PassSystemInterface.h index 1224bf9545..788d00c8eb 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/PassSystemInterface.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/PassSystemInterface.h @@ -40,6 +40,18 @@ namespace AZ using PassCreator = AZStd::function(const PassDescriptor& descriptor)>; + enum class PassSystemState : u32 + { + Unitialized, + Idle, + RemovingPasses, + Building, + Initializing, + Validating, + Rendering, + FrameEnd, + }; + class PassSystemInterface { friend class Pass; @@ -77,9 +89,6 @@ namespace AZ //! Prints the entire pass hierarchy from the root virtual void DebugPrintPassHierarchy() = 0; - //! Returns whether the Pass System is currently in it's build phase - virtual bool IsBuilding() const = 0; - //! Returns whether the Pass System is currently hot reloading virtual bool IsHotReloading() const = 0; @@ -157,15 +166,20 @@ namespace AZ //! The handler can add new pass templates or load pass template mappings from assets virtual void ConnectEvent(OnReadyLoadTemplatesEvent::Handler& handler) = 0; + virtual PassSystemState GetState() const = 0; + private: // These functions are only meant to be used by the Pass class - // Schedules a pass to have it's BuildAttachments() function called during frame update - virtual void QueueForBuildAttachments(Pass* pass) = 0; + // Schedules a pass to have it's Build() function called during frame update + virtual void QueueForBuild(Pass* pass) = 0; // Schedules a pass to be deleted during frame update virtual void QueueForRemoval(Pass* pass) = 0; + // Schedules a pass to be initialized during frame update + virtual void QueueForInitialization(Pass* pass) = 0; + //! Registers the pass with the pass library. Called in the Pass constructor. virtual void RegisterPass(Pass* pass) = 0; diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/RenderPass.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/RenderPass.h index 5cd917e841..5f222d8bba 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/RenderPass.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/RenderPass.h @@ -96,7 +96,7 @@ namespace AZ void BindPassSrg(const RHI::FrameGraphCompileContext& context, Data::Instance& shaderResourceGroup); // Pass behavior overrides... - void OnBuildAttachmentsFinishedInternal() override; + void OnBuildFinishedInternal() override; void FrameBeginInternal(FramePrepareParams params) override; void FrameEndInternal() override; diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Specific/DownsampleMipChainPass.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Specific/DownsampleMipChainPass.h index 71c1fe4c49..eb4c4ed0aa 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Specific/DownsampleMipChainPass.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Specific/DownsampleMipChainPass.h @@ -46,7 +46,7 @@ namespace AZ // Pass Behaviour Overrides... void ResetInternal() override; - void BuildAttachmentsInternal() override; + void BuildInternal() override; void FrameBeginInternal(FramePrepareParams params) override; private: diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Specific/EnvironmentCubeMapPass.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Specific/EnvironmentCubeMapPass.h index 293a750f38..235871df83 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Specific/EnvironmentCubeMapPass.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Specific/EnvironmentCubeMapPass.h @@ -61,7 +61,7 @@ namespace AZ // Pass overrides void CreateChildPassesInternal() override; - void BuildAttachmentsInternal() override; + void BuildInternal() override; void FrameBeginInternal(FramePrepareParams params) override; void FrameEndInternal() override; diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Specific/RenderToTexturePass.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Specific/RenderToTexturePass.h index c8daab8ef8..c86203b79b 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Specific/RenderToTexturePass.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Specific/RenderToTexturePass.h @@ -47,7 +47,7 @@ namespace AZ protected: // Pass behavior overrides - void BuildAttachmentsInternal() override; + void BuildInternal() override; void FrameBeginInternal(FramePrepareParams params) override; // Function to be called when output size changed diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Specific/SelectorPass.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Specific/SelectorPass.h index fe0ce231eb..2d876c6040 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Specific/SelectorPass.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Specific/SelectorPass.h @@ -49,7 +49,7 @@ namespace AZ SelectorPass(const PassDescriptor& descriptor); // Pass behavior overrides - void BuildAttachmentsInternal() final; + void BuildInternal() final; // the input slot index each output slot connect to AZStd::vector m_connections; diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Specific/SwapChainPass.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Specific/SwapChainPass.h index 9aa00c99c2..7eac0d366d 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Specific/SwapChainPass.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Specific/SwapChainPass.h @@ -64,7 +64,7 @@ namespace AZ protected: // Pass behavior overrides void CreateChildPassesInternal() override final; - void BuildAttachmentsInternal() override final; + void BuildInternal() override final; void FrameBeginInternal(FramePrepareParams params) override final; // WindowNotificationBus::Handler overrides ... diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/CopyPass.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/CopyPass.cpp index 4a6c883584..9648a47fd6 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/CopyPass.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/CopyPass.cpp @@ -74,7 +74,7 @@ namespace AZ // --- Pass behavior overrides --- - void CopyPass::BuildAttachmentsInternal() + void CopyPass::BuildInternal() { AZ_Assert(GetInputCount() == 1 && GetOutputCount() == 1, "CopyPass has %d inputs and %d outputs. It should have exactly one of each.", diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/MSAAResolvePass.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/MSAAResolvePass.cpp index c889f367b7..e457cb4992 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/MSAAResolvePass.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/MSAAResolvePass.cpp @@ -38,7 +38,7 @@ namespace AZ { } - void MSAAResolvePass::BuildAttachmentsInternal() + void MSAAResolvePass::BuildInternal() { AZ_Assert(GetOutputCount() != 0, "MSAAResolvePass %s has no outputs to render to.", GetPathName().GetCStr()); } diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/ParentPass.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/ParentPass.cpp index 106ef82bf1..7244510fbd 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/ParentPass.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/ParentPass.cpp @@ -59,7 +59,7 @@ namespace AZ child->m_parent = this; child->OnHierarchyChange(); - QueueForBuildAttachments(); + QueueForBuild(); // Notify pipeline if (m_pipeline) @@ -248,13 +248,6 @@ namespace AZ void ParentPass::CreateChildPasses() { - // Flag prevents the function from executing multiple times a frame. Can happen - // as pass system has a list of passes for which it needs to call this function. - if (m_flags.m_alreadyCreated) - { - return; - } - m_flags.m_alreadyCreated = true; RemoveChildren(); CreatePassesFromTemplate(); CreateChildPassesInternal(); @@ -277,19 +270,27 @@ namespace AZ } } - void ParentPass::BuildAttachmentsInternal() + void ParentPass::BuildInternal() { for (const Ptr& child : m_children) { - child->BuildAttachments(); + child->Build(); } } - void ParentPass::OnBuildAttachmentsFinishedInternal() + void ParentPass::OnBuildFinishedInternal() { for (const Ptr& child : m_children) { - child->OnBuildAttachmentsFinished(); + child->OnBuildFinished(); + } + } + + void ParentPass::InitializeInternal() + { + for (const Ptr& child : m_children) + { + child->Initialize(); } } diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Pass.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Pass.cpp index 8d613eb2bb..da9022b655 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Pass.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Pass.cpp @@ -71,7 +71,7 @@ namespace AZ } PassSystemInterface::Get()->RegisterPass(this); - QueueForBuildAttachments(); + QueueForBuild(); } Pass::~Pass() @@ -162,6 +162,11 @@ namespace AZ // --- Getters & Setters --- + PassState Pass::GetPassState() const + { + return m_state; + } + ParentPass* Pass::GetParent() const { return m_parent; @@ -350,28 +355,49 @@ namespace AZ // --- Queuing functions with PassSystem --- - void Pass::QueueForBuildAttachments() + void Pass::QueueForBuild() { // Don't queue if we're in building phase - if (!PassSystemInterface::Get()->IsBuilding()) + if (PassSystemInterface::Get()->GetState() != PassSystemState::Building && + (m_queueState == PassQueueState::NoQueue || m_queueState == PassQueueState::QueuedForInitialization)) { - // m_queuedForBuildAttachment makes sure the pass only be queue for once - if (!m_flags.m_queuedForBuildAttachment) - { - PassSystemInterface::Get()->QueueForBuildAttachments(this); - m_flags.m_queuedForBuildAttachment = true; + PassSystemInterface::Get()->QueueForBuild(this); + m_queueState = PassQueueState::QueuedForBuild; - // Set these two flags to false since when queue build attachments request, they should all be already be false except one use - // case that the pass system processed all queued requests when active a scene. - m_flags.m_alreadyPrepared = false; - m_flags.m_alreadyReset = false; + if (m_state != PassState::Rendering) + { + m_state = PassState::Queued; } } } - void Pass::QueueForRemoval([[maybe_unused]] bool needsDeletion) + void Pass::QueueForInitialization() { - PassSystemInterface::Get()->QueueForRemoval(this); + // Don't queue if we're in initialization phase + if (PassSystemInterface::Get()->GetState() != PassSystemState::Initializing && m_queueState == PassQueueState::NoQueue) + { + PassSystemInterface::Get()->QueueForInitialization(this); + m_queueState = PassQueueState::QueuedForInitialization; + + if(m_state != PassState::Rendering) + { + m_state = PassState::Queued; + } + } + } + + void Pass::QueueForRemoval() + { + if (m_queueState != PassQueueState::QueuedForRemoval) + { + PassSystemInterface::Get()->QueueForRemoval(this); + m_queueState = PassQueueState::QueuedForRemoval; + + if (m_state != PassState::Rendering) + { + m_state = PassState::Queued; + } + } } // --- PassTemplate related functions --- @@ -990,7 +1016,7 @@ namespace AZ { Ptr targetAttachment = nullptr; - if (!m_flags.m_isBuildingAttachments && !IsEnabled() && binding.m_slotType == PassSlotType::Output && binding.m_fallbackBinding) + if (m_state != PassState::Building && !IsEnabled() && binding.m_slotType == PassSlotType::Output && binding.m_fallbackBinding) { targetAttachment = binding.m_fallbackBinding->m_attachment; } @@ -1037,13 +1063,11 @@ namespace AZ void Pass::Reset() { - // Flag prevents the function from executing multiple times a frame. Can happen - // as pass system has a list of passes for which it needs to call this function. - if (m_flags.m_alreadyReset) + if (m_queueState != PassQueueState::QueuedForBuild || m_state != PassState::Queued) { return; } - m_flags.m_alreadyReset = true; + m_state = PassState::Resetting; // Store references to imported attachments to underlying images and buffers aren't deleted during attachment building StoreImportedAttachmentReferences(); @@ -1060,18 +1084,13 @@ namespace AZ ResetInternal(); } - void Pass::BuildAttachments() + void Pass::Build() { - m_flags.m_queuedForBuildAttachment = false; - - // Flag prevents the function from executing multiple times a frame. Can happen - // as pass system has a list of passes for which it needs to call this function. - if (m_flags.m_alreadyPrepared) + if (m_queueState != PassQueueState::QueuedForBuild || m_state != PassState::Resetting) { return; } - m_flags.m_alreadyPrepared = true; - m_flags.m_isBuildingAttachments = true; + m_state = PassState::Building; AZ_RPI_BREAK_ON_TARGET_PASS; @@ -1084,7 +1103,7 @@ namespace AZ SetupInputsFromTemplate(); // Custom pass behavior - BuildAttachmentsInternal(); + BuildInternal(); // Outputs SetupOutputsFromTemplate(); @@ -1095,21 +1114,29 @@ namespace AZ UpdateOwnedAttachments(); UpdateAttachmentUsageIndices(); - m_flags.m_isBuildingAttachments = false; + // Queue for Initialization + m_queueState = PassQueueState::NoQueue; + QueueForInitialization(); } - void Pass::OnBuildAttachmentsFinished() + void Pass::OnBuildFinished() { AZ_RPI_BREAK_ON_TARGET_PASS; - // These flags are to prevent a pass from being built multiple times. - // We reset them after each build phase. - m_flags.m_alreadyCreated = false; - m_flags.m_alreadyPrepared = false; - m_flags.m_alreadyReset = false; - m_flags.m_queuedForBuildAttachment = false; m_importedAttachmentStore.clear(); - OnBuildAttachmentsFinishedInternal(); + OnBuildFinishedInternal(); + } + + void Pass::Initialize() + { + if (m_queueState != PassQueueState::QueuedForInitialization || m_state != PassState::Queued) + { + return; + } + + m_state = PassState::Initializing; + InitializeInternal(); + m_state = PassState::Initialized; } void Pass::Validate(PassValidationResults& validationResults) @@ -1165,7 +1192,7 @@ namespace AZ UpdateConnectedBindings(); return; } - m_flags.m_isRendering = true; + m_state = PassState::Rendering; UpdateConnectedBindings(); UpdateOwnedAttachments(); @@ -1180,10 +1207,10 @@ namespace AZ void Pass::FrameEnd() { - if (m_flags.m_isRendering) + if (m_state == PassState::Rendering) { FrameEndInternal(); - m_flags.m_isRendering = false; + m_state = (m_queueState == PassQueueState::NoQueue) ? PassState::Initialized : PassState::Queued; } } diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/PassSystem.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/PassSystem.cpp index 448c28f202..3dabd88fff 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/PassSystem.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/PassSystem.cpp @@ -93,11 +93,15 @@ namespace AZ void PassSystem::Init() { + m_state = PassSystemState::Initializing; + Interface::Register(this); m_passLibrary.Init(); m_passFactory.Init(&m_passLibrary); m_rootPass = CreatePass(Name{"Root"}); m_rootPass->m_flags.m_partOfHierarchy = true; + + m_state = PassSystemState::Idle; } void PassSystem::InitPassTemplates() @@ -118,10 +122,10 @@ namespace AZ JsonSerializationUtils::SaveObjectToFile(&passAsset, assetFilePath); } - void PassSystem::QueueForBuildAttachments(Pass* pass) + void PassSystem::QueueForBuild(Pass* pass) { - AZ_Assert(pass != nullptr, "Queuing nullptr pass in PassSystem::QueueForBuildAttachments"); - m_buildAttachmentsList.push_back(pass); + AZ_Assert(pass != nullptr, "Queuing nullptr pass in PassSystem::QueueForBuild"); + m_buildPassList.push_back(pass); } void PassSystem::QueueForRemoval(Pass* pass) @@ -130,6 +134,12 @@ namespace AZ m_removePassList.push_back(pass); } + void PassSystem::QueueForInitialization(Pass* pass) + { + AZ_Assert(pass != nullptr, "Queuing nullptr pass in PassSystem::QueueForInitialization"); + m_initializePassList.push_back(pass); + } + // Sort so passes with less depth (closer to the root) are first. Used when changes // in the parent passes can affect the child passes, like with attachment building. void SortPassListAscending(AZStd::vector< Ptr >& passList) @@ -155,6 +165,7 @@ namespace AZ void PassSystem::RemovePasses() { + m_state = PassSystemState::RemovingPasses; AZ_ATOM_PROFILE_FUNCTION("RPI", "PassSystem: RemovePasses"); if (!m_removePassList.empty()) @@ -168,24 +179,25 @@ namespace AZ m_removePassList.clear(); } + + m_state = PassSystemState::Idle; } - void PassSystem::BuildPassAttachments() + void PassSystem::BuildPasses() { + m_state = PassSystemState::Building; AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzRender); AZ_ATOM_PROFILE_FUNCTION("RPI", "PassSystem: BuildPassAttachments"); - m_isBuilding = true; + m_passHierarchyChanged = !m_buildPassList.empty(); - m_passHierarchyChanged = !m_buildAttachmentsList.empty(); - - // While loop is for the event in which passes being built add more pass to m_buildAttachmentsList - while(!m_buildAttachmentsList.empty()) + // While loop is for the event in which passes being built add more pass to m_buildPassList + while(!m_buildPassList.empty()) { AZ_Assert(m_removePassList.empty(), "Passes shouldn't be queued removal during build attachment process"); - AZStd::vector< Ptr > buildListCopy = m_buildAttachmentsList; - m_buildAttachmentsList.clear(); + AZStd::vector< Ptr > buildListCopy = m_buildPassList; + m_buildPassList.clear(); // Erase passes which were removed from pass tree already (which parent is empty) auto unused = AZStd::remove_if(buildListCopy.begin(), buildListCopy.end(), @@ -203,15 +215,15 @@ namespace AZ } for (const Ptr& pass : buildListCopy) { - pass->BuildAttachments(); + pass->Build(); } - - // Signal all passes that we have finished building - m_rootPass->OnBuildAttachmentsFinished(); } if (m_passHierarchyChanged) { + // Signal all passes that we have finished building + m_rootPass->OnBuildFinished(); + #if AZ_RPI_ENABLE_PASS_DEBUGGING if (!m_isHotReloading) { @@ -221,11 +233,39 @@ namespace AZ #endif } - m_isBuilding = false; + m_state = PassSystemState::Idle; + } + + void PassSystem::InitializePasses() + { + m_state = PassSystemState::Initializing; + AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzRender); + AZ_ATOM_PROFILE_FUNCTION("RPI", "PassSystem: BuildPassAttachments"); + + if(!m_initializePassList.empty()) + { + // Erase passes which were removed from pass tree already (which parent is empty) + auto unused = AZStd::remove_if(m_initializePassList.begin(), m_initializePassList.end(), + [](const RHI::Ptr& currentPass) + { + return !currentPass->m_flags.m_partOfHierarchy; + }); + m_initializePassList.erase(unused, m_initializePassList.end()); + + SortPassListAscending(m_initializePassList); + + for (const Ptr& pass : m_initializePassList) + { + pass->Initialize(); + } + } + + m_state = PassSystemState::Idle; } void PassSystem::Validate() { + m_state = PassSystemState::Validating; AZ_ATOM_PROFILE_FUNCTION("RPI", "PassSystem: Validate"); if (PassValidation::IsEnabled()) @@ -241,12 +281,15 @@ namespace AZ m_rootPass->Validate(validationResults); validationResults.PrintValidationIfError(); } + + m_state = PassSystemState::Idle; } void PassSystem::ProcessQueuedChanges() { RemovePasses(); - BuildPassAttachments(); + BuildPasses(); + InitializePasses(); Validate(); } @@ -256,6 +299,8 @@ namespace AZ AZ_ATOM_PROFILE_FUNCTION("RPI", "PassSystem: FrameUpdate"); ProcessQueuedChanges(); + + m_state = PassSystemState::Rendering; Pass::FramePrepareParams params{ &frameGraphBuilder }; m_rootPass->FrameBegin(params); } @@ -264,6 +309,8 @@ namespace AZ { AZ_ATOM_PROFILE_FUNCTION("RHI", "PassSystem: FrameEnd"); + m_state = PassSystemState::FrameEnd; + m_rootPass->FrameEnd(); // remove any pipelines that are marked as ExecuteOnce @@ -278,12 +325,14 @@ namespace AZ } m_passHierarchyChanged = false; + + m_state = PassSystemState::Idle; } void PassSystem::Shutdown() { RemovePasses(); - m_buildAttachmentsList.clear(); + m_buildPassList.clear(); m_rootPass = nullptr; m_passFactory.Shutdown(); m_passLibrary.Shutdown(); @@ -296,9 +345,9 @@ namespace AZ return m_rootPass; } - bool PassSystem::IsBuilding() const + PassSystemState PassSystem::GetState() const { - return m_isBuilding; + return m_state; } bool PassSystem::IsHotReloading() const diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/RenderPass.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/RenderPass.cpp index 3a2a556429..12989fb873 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/RenderPass.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/RenderPass.cpp @@ -128,7 +128,7 @@ namespace AZ } - void RenderPass::OnBuildAttachmentsFinishedInternal() + void RenderPass::OnBuildFinishedInternal() { if (m_shaderResourceGroup != nullptr) { diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/DownsampleMipChainPass.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/DownsampleMipChainPass.cpp index 0e0ebf445e..329247d4eb 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/DownsampleMipChainPass.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/DownsampleMipChainPass.cpp @@ -181,12 +181,12 @@ namespace AZ // Pass behavior functions... - void DownsampleMipChainPass::BuildAttachmentsInternal() + void DownsampleMipChainPass::BuildInternal() { GetInputInfo(); BuildChildPasses(); UpdateChildren(); - ParentPass::BuildAttachmentsInternal(); + ParentPass::BuildInternal(); } void DownsampleMipChainPass::FrameBeginInternal(FramePrepareParams params) diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/EnvironmentCubeMapPass.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/EnvironmentCubeMapPass.cpp index c72712bce5..672e5509ee 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/EnvironmentCubeMapPass.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/EnvironmentCubeMapPass.cpp @@ -37,8 +37,6 @@ namespace AZ EnvironmentCubeMapPass::EnvironmentCubeMapPass(const PassDescriptor& passDescriptor) : ParentPass(passDescriptor) { - m_flags.m_alreadyCreated = false; - // load pass data const EnvironmentCubeMapPassData* passData = PassUtils::GetPassData(passDescriptor); if (passData == nullptr) @@ -113,7 +111,7 @@ namespace AZ AddChild(m_childPass); } - void EnvironmentCubeMapPass::BuildAttachmentsInternal() + void EnvironmentCubeMapPass::BuildInternal() { // create output image descriptor m_outputImageDesc = RHI::ImageDescriptor::Create2D(RHI::ImageBindFlags::Color | RHI::ImageBindFlags::CopyRead, CubeMapFaceSize, CubeMapFaceSize, RHI::Format::R16G16B16A16_FLOAT); @@ -135,7 +133,7 @@ namespace AZ m_attachmentBindings.push_back(outputAttachment); - ParentPass::BuildAttachmentsInternal(); + ParentPass::BuildInternal(); } void EnvironmentCubeMapPass::FrameBeginInternal(FramePrepareParams params) diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/RenderToTexturePass.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/RenderToTexturePass.cpp index 4356a56622..c0a4785365 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/RenderToTexturePass.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/RenderToTexturePass.cpp @@ -50,7 +50,7 @@ namespace AZ { } - void RenderToTexturePass::BuildAttachmentsInternal() + void RenderToTexturePass::BuildInternal() { m_outputAttachment = aznew PassAttachment(); m_outputAttachment->m_name = "RenderTarget"; @@ -73,7 +73,7 @@ namespace AZ m_attachmentBindings.push_back(outputBinding); - Base::BuildAttachmentsInternal(); + Base::BuildInternal(); } void RenderToTexturePass::FrameBeginInternal(FramePrepareParams params) @@ -100,7 +100,7 @@ namespace AZ m_passData.m_width = width; m_passData.m_height = height; OnUpdateOutputSize(); - QueueForBuildAttachments(); + QueueForBuild(); } void RenderToTexturePass::OnUpdateOutputSize() diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/SelectorPass.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/SelectorPass.cpp index 8e8c67393d..90390b78d7 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/SelectorPass.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/SelectorPass.cpp @@ -44,7 +44,7 @@ namespace AZ } } - void SelectorPass::BuildAttachmentsInternal() + void SelectorPass::BuildInternal() { // Update output connections based on m_connections // This need to be done after BuildAttachment is finished @@ -72,7 +72,7 @@ namespace AZ m_connections[outputSlotIndex] = inputSlotIndex; // Queue to rebuild attachment connections - QueueForBuildAttachments(); + QueueForBuild(); } void SelectorPass::Connect(const AZ::Name& inputSlot, const AZ::Name& outputSlot) @@ -113,7 +113,7 @@ namespace AZ m_connections[outputIdx] = inputIdx; // Queue to rebuild attachment connections - QueueForBuildAttachments(); + QueueForBuild(); } } // namespace RPI diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/SwapChainPass.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/SwapChainPass.cpp index 5bcec87df0..e6f65e997c 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/SwapChainPass.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/SwapChainPass.cpp @@ -26,8 +26,6 @@ namespace AZ , m_windowContext(windowContext) , m_childTemplateName(childTemplateName) { - m_flags.m_alreadyCreated = false; - PassSystemInterface* passSystem = PassSystemInterface::Get(); // Create child pass @@ -112,7 +110,7 @@ namespace AZ AddChild(m_childPass); } - void SwapChainPass::BuildAttachmentsInternal() + void SwapChainPass::BuildInternal() { if (m_windowContext->GetSwapChain() == nullptr) { @@ -124,7 +122,7 @@ namespace AZ SetupSwapChainAttachment(); - ParentPass::BuildAttachmentsInternal(); + ParentPass::BuildInternal(); } void SwapChainPass::FrameBeginInternal(FramePrepareParams params) @@ -154,7 +152,7 @@ namespace AZ void SwapChainPass::OnWindowResized([[maybe_unused]] uint32_t width, [[maybe_unused]] uint32_t height) { - QueueForBuildAttachments(); + QueueForBuild(); } void SwapChainPass::ReadbackSwapChain(AZStd::shared_ptr readback) diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/RenderPipeline.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/RenderPipeline.cpp index cc0cefd082..86d76287bb 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/RenderPipeline.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/RenderPipeline.cpp @@ -329,9 +329,8 @@ namespace AZ if (validation.IsValid()) { // Remove old pass - bool deletePass = true; m_rootPass->SetRenderPipeline(nullptr); - m_rootPass->QueueForRemoval(deletePass); + m_rootPass->QueueForRemoval(); // Set new root m_rootPass = newRoot; diff --git a/Gems/Atom/RPI/Code/Tests/Pass/PassTests.cpp b/Gems/Atom/RPI/Code/Tests/Pass/PassTests.cpp index 96a21f8c9b..f9a2bc4493 100644 --- a/Gems/Atom/RPI/Code/Tests/Pass/PassTests.cpp +++ b/Gems/Atom/RPI/Code/Tests/Pass/PassTests.cpp @@ -329,7 +329,7 @@ namespace UnitTest Ptr parentPass = m_passSystem->CreatePassFromTemplate(Name("ParentPass"), Name("ParentPass")); parentPass->Reset(); - parentPass->BuildAttachments(); + parentPass->Build(); PassValidationResults validationResults; parentPass->Validate(validationResults); @@ -351,7 +351,7 @@ namespace UnitTest Ptr parentPass = m_passSystem->CreatePassFromTemplate(Name("ParentPass"), Name("ParentPass")); parentPass->Reset(); - parentPass->BuildAttachments(); + parentPass->Build(); PassValidationResults validationResults; parentPass->Validate(validationResults); @@ -373,7 +373,7 @@ namespace UnitTest Ptr parentPass = m_passSystem->CreatePassFromTemplate(Name("ParentPass"), Name("ParentPass")); parentPass->Reset(); - parentPass->BuildAttachments(); + parentPass->Build(); PassValidationResults validationResults; parentPass->Validate(validationResults); @@ -397,7 +397,7 @@ namespace UnitTest parentPass->m_flags.m_partOfHierarchy = true; parentPass->OnHierarchyChange(); parentPass->Reset(); - parentPass->BuildAttachments(); + parentPass->Build(); PassValidationResults validationResults; parentPass->Validate(validationResults); @@ -421,7 +421,7 @@ namespace UnitTest parentPass->m_flags.m_partOfHierarchy = true; parentPass->OnHierarchyChange(); parentPass->Reset(); - parentPass->BuildAttachments(); + parentPass->Build(); PassValidationResults validationResults; parentPass->Validate(validationResults); @@ -445,7 +445,7 @@ namespace UnitTest parentPass->m_flags.m_partOfHierarchy = true; parentPass->OnHierarchyChange(); parentPass->Reset(); - parentPass->BuildAttachments(); + parentPass->Build(); PassValidationResults validationResults; parentPass->Validate(validationResults); @@ -469,7 +469,7 @@ namespace UnitTest parentPass->m_flags.m_partOfHierarchy = true; parentPass->OnHierarchyChange(); parentPass->Reset(); - parentPass->BuildAttachments(); + parentPass->Build(); PassValidationResults validationResults; parentPass->Validate(validationResults);