From 6388277cd12c5019f48ee75cdb734a827545bf27 Mon Sep 17 00:00:00 2001 From: antonmic Date: Fri, 21 May 2021 21:20:08 -0700 Subject: [PATCH] Fixed ImGui Pass as well as how exposure pass enables itself --- .../Assets/Passes/LightAdaptationParent.pass | 2 +- .../ExposureControlSettings.cpp | 25 ---------- .../ExposureControl/ExposureControlSettings.h | 1 - .../PostProcessing/EyeAdaptationPass.cpp | 50 ++++++------------- .../Source/PostProcessing/EyeAdaptationPass.h | 6 +-- .../Include/Atom/RPI.Public/Pass/RenderPass.h | 2 +- .../RPI/Code/Source/RPI.Public/Pass/Pass.cpp | 2 +- .../Source/RPI.Public/Pass/RenderPass.cpp | 2 +- 8 files changed, 21 insertions(+), 69 deletions(-) diff --git a/Gems/Atom/Feature/Common/Assets/Passes/LightAdaptationParent.pass b/Gems/Atom/Feature/Common/Assets/Passes/LightAdaptationParent.pass index 3e804d23e2..ff55ebc200 100644 --- a/Gems/Atom/Feature/Common/Assets/Passes/LightAdaptationParent.pass +++ b/Gems/Atom/Feature/Common/Assets/Passes/LightAdaptationParent.pass @@ -80,7 +80,7 @@ { "Name": "EyeAdaptationPass", "TemplateName": "EyeAdaptationTemplate", - "Enabled": false, + "Enabled": true, "Connections": [ { "LocalSlot": "SceneLuminanceInput", diff --git a/Gems/Atom/Feature/Common/Code/Source/PostProcess/ExposureControl/ExposureControlSettings.cpp b/Gems/Atom/Feature/Common/Code/Source/PostProcess/ExposureControl/ExposureControlSettings.cpp index b22f4b5861..056f7b7da4 100644 --- a/Gems/Atom/Feature/Common/Code/Source/PostProcess/ExposureControl/ExposureControlSettings.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/PostProcess/ExposureControl/ExposureControlSettings.cpp @@ -69,7 +69,6 @@ namespace AZ if (m_shouldUpdatePassParameters) { - UpdateEyeAdaptationPass(); UpdateLuminanceHeatmap(); m_shouldUpdatePassParameters = false; @@ -198,30 +197,6 @@ namespace AZ } } - void ExposureControlSettings::UpdateEyeAdaptationPass() - { - auto* passSystem = AZ::RPI::PassSystemInterface::Get(); - - // [GFX-TODO][ATOM-13224] Remove UpdateLuminanceHeatmap and UpdateEyeAdaptationPass - auto passTemplateName = m_eyeAdaptationPassTemplateNameId; - - if (passSystem->HasPassesForTemplateName(passTemplateName)) - { - const AZStd::vector& eyeAdaptationPasses = passSystem->GetPassesForTemplateName(passTemplateName); - for (RPI::Pass* pass : eyeAdaptationPasses) - { - auto* eyeAdaptationPass = azrtti_cast(pass); - auto* renderPipeline = eyeAdaptationPass->GetRenderPipeline(); - - if (renderPipeline && renderPipeline->GetScene() == GetParentScene()) - { - // update eye adaptation pass's enable state - eyeAdaptationPass->UpdateEnable(); - } - } - } - } - void ExposureControlSettings::UpdateLuminanceHeatmap() { auto* passSystem = AZ::RPI::PassSystemInterface::Get(); diff --git a/Gems/Atom/Feature/Common/Code/Source/PostProcess/ExposureControl/ExposureControlSettings.h b/Gems/Atom/Feature/Common/Code/Source/PostProcess/ExposureControl/ExposureControlSettings.h index 566f60dd28..8344d6aa09 100644 --- a/Gems/Atom/Feature/Common/Code/Source/PostProcess/ExposureControl/ExposureControlSettings.h +++ b/Gems/Atom/Feature/Common/Code/Source/PostProcess/ExposureControl/ExposureControlSettings.h @@ -85,7 +85,6 @@ namespace AZ void UpdateExposureControlRelatedPassParameters(); void UpdateLuminanceHeatmap(); - void UpdateEyeAdaptationPass(); PostProcessSettings* m_parentSettings = nullptr; bool m_shouldUpdatePassParameters = true; diff --git a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/EyeAdaptationPass.cpp b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/EyeAdaptationPass.cpp index 97c11a9d89..e7d4c47f02 100644 --- a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/EyeAdaptationPass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/EyeAdaptationPass.cpp @@ -62,17 +62,24 @@ namespace AZ m_buffer = RPI::BufferSystemInterface::Get()->CreateBufferFromCommonPool(desc); } - void EyeAdaptationPass::UpdateEnable() + void EyeAdaptationPass::BuildAttachmentsInternal() { - if (m_pipeline == nullptr) + if (!m_buffer) { - SetEnabled(false); - return; + InitBuffer(); } - AZ_Assert(m_pipeline->GetScene(), "Scene shouldn't nullptr"); + AttachBufferToSlot(EyeAdaptationDataInputOutputSlotName, m_buffer); + } - UpdateInputBufferIndices(); + bool EyeAdaptationPass::IsEnabled() const + { + if (!ComputePass::IsEnabled() || m_pipeline == nullptr) + { + return false; + } + + AZ_Assert(m_pipeline->GetScene(), "EyeAdaptationPass's Pipeline does not have a valid scene pointer"); AZ::RPI::Scene* scene = GetScene(); bool enabled = false; @@ -95,38 +102,9 @@ namespace AZ } } - const bool lastEnabled = IsEnabled(); - SetEnabled(enabled); - - if (IsEnabled() && !lastEnabled) - { - // Need rebuilt this pass's attachment as any connections. So queue parent pass. - GetParent()->QueueForBuildAttachments(); - } + return enabled; } - void EyeAdaptationPass::UpdateInputBufferIndices() - { - if (m_exposureControlBufferInputIndex.IsNull()) - { - m_exposureControlBufferInputIndex = GetView()->GetShaderResourceGroup()->FindShaderInputBufferIndex(Name("m_exposureControl")); - } - } - - void EyeAdaptationPass::BuildAttachmentsInternal() - { - if (m_pipeline == nullptr) - { - return; - } - - if (!m_buffer) - { - InitBuffer(); - } - - AttachBufferToSlot(EyeAdaptationDataInputOutputSlotName, m_buffer); - } void EyeAdaptationPass::FrameBeginInternal(FramePrepareParams params) { diff --git a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/EyeAdaptationPass.h b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/EyeAdaptationPass.h index b87d9db86f..cef168a122 100644 --- a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/EyeAdaptationPass.h +++ b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/EyeAdaptationPass.h @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -45,12 +46,11 @@ namespace AZ static RPI::Ptr Create(const RPI::PassDescriptor& descriptor); // Check if we should enable of disable this pass - void UpdateEnable(); + bool IsEnabled() const override; protected: EyeAdaptationPass(const RPI::PassDescriptor& descriptor); void InitBuffer(); - void UpdateInputBufferIndices(); // A StructuredBuffer for exposure calculation on the GPU. struct ExposureCalculationData @@ -65,7 +65,7 @@ namespace AZ AZ::Data::Instance m_buffer; // SRG binding indices... - AZ::RHI::ShaderInputBufferIndex m_exposureControlBufferInputIndex; + AZ::RHI::ShaderInputNameIndex m_exposureControlBufferInputIndex = "m_exposureControl"; }; } // namespace Render } // namespace AZ 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 84ccb57e06..5cd917e841 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 @@ -72,7 +72,7 @@ namespace AZ //! Return the View if this pass is associated with a pipeline view via PipelineViewTag. //! It may return nullptr if this pass is independent with any views. - ViewPtr GetView(); + ViewPtr GetView() const; protected: explicit RenderPass(const PassDescriptor& descriptor); 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 6ed8ac018c..8d613eb2bb 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Pass.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Pass.cpp @@ -98,7 +98,7 @@ namespace AZ bool Pass::IsEnabled() const { - return m_flags.m_enabled && (m_flags.m_parentEnabled || m_parent == nullptr); + return m_flags.m_enabled; } // --- Error Logging --- 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 3f5c16678c..9c6a95e582 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/RenderPass.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/RenderPass.cpp @@ -342,7 +342,7 @@ namespace AZ } } - ViewPtr RenderPass::GetView() + ViewPtr RenderPass::GetView() const { if (m_flags.m_hasPipelineViewTag && m_pipeline) {