Pass changes WIP: standardized usage of new pass initialization functions

This commit is contained in:
antonmic
2021-06-08 22:36:54 -07:00
parent 6973d9c7a3
commit 702356007c
40 changed files with 127 additions and 107 deletions
@@ -48,7 +48,9 @@ namespace AZ
void SetShaperParams(const ShaperParams& shaperParams);
private:
explicit AcesOutputTransformLutPass(const RPI::PassDescriptor& descriptor);
void Init() override;
// Pass behavior overrides...
void InitializeInternal() override;
// Scope producer functions...
void SetupFrameGraphDependencies(RHI::FrameGraphInterface frameGraph) override;
@@ -50,7 +50,9 @@ namespace AZ
private:
explicit AcesOutputTransformPass(const RPI::PassDescriptor& descriptor);
void Init() override;
// Pass behavior overrides
void InitializeInternal() override;
// Scope producer functions...
void CompileResources(const RHI::FrameGraphCompileContext& context) override;
@@ -45,7 +45,9 @@ namespace AZ
protected:
explicit ApplyShaperLookupTablePass(const RPI::PassDescriptor& descriptor);
void Init() override;
// Pass behavior overrides...
void InitializeInternal() override;
RHI::ShaderInputImageIndex m_shaderInputLutImageIndex;
@@ -57,15 +57,13 @@ namespace AZ
explicit BakeAcesOutputTransformLutPass(const RPI::PassDescriptor& descriptor);
// Pass behavior overrides...
void FrameBeginInternal(FramePrepareParams params) override;
void InitializeInternal() override;
// RHI::ScopeProducer overrides...
void SetupFrameGraphDependencies(RHI::FrameGraphInterface frameGraph) override;
void CompileResources(const RHI::FrameGraphCompileContext& context) override;
void BuildCommandListInternal(const RHI::FrameGraphExecuteContext& context) override;
void Init();
void AcquireLutImage();
void ReleaseLutImage();
@@ -41,14 +41,11 @@ namespace AZ
void SetInputReferencePassName(const Name& passName);
void SetInputReferenceAttachmentName(const Name& attachmentName);
// Pass behavior overrides
virtual void BuildInternal() override;
protected:
explicit DisplayMapperFullScreenPass(const RPI::PassDescriptor& descriptor);
// FullscreenTrianglePass behavior overrides
virtual void Init();
// Pass behavior overrides...
virtual void BuildInternal() override;
private:
Name m_inputReferencePassName = Name{ "Parent" };
@@ -77,6 +77,7 @@ namespace AZ
// Pass behavior overrides
void BuildInternal() final;
void InitializeInternal() final;
void FrameBeginInternal(FramePrepareParams params) final;
void FrameEndInternal() final;
void CreateChildPassesInternal() final;
@@ -49,7 +49,9 @@ namespace AZ
protected:
explicit OutputTransformPass(const RPI::PassDescriptor& descriptor);
void Init() override;
// Pass behavior overrides
void InitializeInternal() override;
private:
// Scope producer functions...
@@ -42,9 +42,9 @@ namespace AZ
ReleaseLutImage();
}
void AcesOutputTransformLutPass::Init()
void AcesOutputTransformLutPass::InitializeInternal()
{
DisplayMapperFullScreenPass::Init();
DisplayMapperFullScreenPass::InitializeInternal();
AZ_Assert(m_shaderResourceGroup != nullptr, "AcesOutputTransformLutPass %s has a null shader resource group when calling Init.", GetPathName().GetCStr());
@@ -44,9 +44,9 @@ namespace AZ
{
}
void AcesOutputTransformPass::Init()
void AcesOutputTransformPass::InitializeInternal()
{
DisplayMapperFullScreenPass::Init();
DisplayMapperFullScreenPass::InitializeInternal();
AZ_Assert(m_shaderResourceGroup != nullptr, "AcesOutputTransformPass %s has a null shader resource group when calling Init.", GetPathName().GetCStr());
@@ -38,9 +38,9 @@ namespace AZ
ReleaseLutImage();
}
void ApplyShaperLookupTablePass::Init()
void ApplyShaperLookupTablePass::InitializeInternal()
{
DisplayMapperFullScreenPass::Init();
DisplayMapperFullScreenPass::InitializeInternal();
AZ_Assert(m_shaderResourceGroup != nullptr, "ApplyShaperLookupTablePass %s has a null shader resource group when calling Init.", GetPathName().GetCStr());
@@ -38,17 +38,7 @@ namespace AZ
ReleaseLutImage();
}
void BakeAcesOutputTransformLutPass::FrameBeginInternal(FramePrepareParams params)
{
if (!m_flags.m_initialized)
{
Init();
}
ComputePass::FrameBeginInternal(params);
}
void BakeAcesOutputTransformLutPass::Init()
void BakeAcesOutputTransformLutPass::InitializeInternal()
{
AZ_Assert(m_shaderResourceGroup != nullptr, "BakeAcesOutputTransformLutPass %s has a null shader resource group when calling Init.", GetPathName().GetCStr());
@@ -67,7 +57,6 @@ namespace AZ
m_shaderInputShaperBiasIndex = m_shaderResourceGroup->FindShaderInputConstantIndex(Name{ "m_shaperBias" });
m_shaderInputShaperScaleIndex = m_shaderResourceGroup->FindShaderInputConstantIndex(Name{ "m_shaperScale" });
}
m_flags.m_initialized = true;
}
void BakeAcesOutputTransformLutPass::SetupFrameGraphDependencies(RHI::FrameGraphInterface frameGraph)
@@ -53,9 +53,5 @@ namespace AZ
m_inputReferenceAttachmentName = attachmentName;
}
void DisplayMapperFullScreenPass::Init()
{
FullscreenTrianglePass::Init();
}
} // namespace Render
} // namespace AZ
@@ -82,7 +82,7 @@ namespace AZ
const Name& passName = fullscreenTrianglePass->GetName();
if (passName.GetStringView() == "CopyToSwapChain")
{
fullscreenTrianglePass->Invalidate();
fullscreenTrianglePass->QueueForInitialization();
}
}
}
@@ -186,6 +186,18 @@ namespace AZ
ParentPass::BuildInternal();
}
void DisplayMapperPass::InitializeInternal()
{
// Force update on bindings because children of display mapper pass have their outputs connect
// to their parent's output, which is a non-conventional and non-standard workflow
for (const RPI::Ptr<Pass>& child : m_children)
{
child->UpdateConnectedBindings();
}
RPI::ParentPass::InitializeInternal();
}
void DisplayMapperPass::FrameBeginInternal(FramePrepareParams params)
{
ConfigureDisplayParameters();
@@ -39,9 +39,9 @@ namespace AZ
{
}
void OutputTransformPass::Init()
void OutputTransformPass::InitializeInternal()
{
DisplayMapperFullScreenPass::Init();
DisplayMapperFullScreenPass::InitializeInternal();
AZ_Assert(m_shaderResourceGroup != nullptr, "OutputTransformPass %s has a null shader resource group when calling Init.", GetPathName().GetCStr());
@@ -43,14 +43,9 @@ namespace AZ
ReleaseLutImage();
}
void BlendColorGradingLutsPass::FrameBeginInternal(FramePrepareParams params)
void BlendColorGradingLutsPass::InitializeInternal()
{
if (!m_flags.m_initialized)
{
Init();
}
ComputePass::FrameBeginInternal(params);
InitializeShaderVariant();
}
void BlendColorGradingLutsPass::InitializeShaderVariant()
@@ -106,12 +101,6 @@ namespace AZ
m_needToUpdateShaderVariant = false;
}
void BlendColorGradingLutsPass::Init()
{
InitializeShaderVariant();
m_flags.m_initialized = true;
}
void BlendColorGradingLutsPass::SetupFrameGraphDependencies(RHI::FrameGraphInterface frameGraph)
{
ComputePass::SetupFrameGraphDependencies(frameGraph);
@@ -56,7 +56,7 @@ namespace AZ
explicit BlendColorGradingLutsPass(const RPI::PassDescriptor& descriptor);
// Pass behavior overrides...
void FrameBeginInternal(FramePrepareParams params) override;
void InitializeInternal() override;
// Scope producer functions...
void SetupFrameGraphDependencies(RHI::FrameGraphInterface frameGraph) override;
@@ -66,8 +66,6 @@ namespace AZ
void InitializeShaderVariant();
void UpdateCurrentShaderVariant();
void Init();
void AcquireLutImage();
void ReleaseLutImage();
@@ -43,9 +43,9 @@ namespace AZ
{
}
void DepthOfFieldBokehBlurPass::Init()
void DepthOfFieldBokehBlurPass::InitializeInternal()
{
FullscreenTrianglePass::Init();
FullscreenTrianglePass::InitializeInternal();
m_sampleNumberIndex.Reset();
m_radiusMinIndex.Reset();
@@ -39,11 +39,11 @@ namespace AZ
protected:
// Behaviour functions override...
void InitializeInternal() override;
void FrameBeginInternal(FramePrepareParams params) override;
private:
DepthOfFieldBokehBlurPass(const RPI::PassDescriptor& descriptor);
void Init() override;
void InitializeShaderVariant();
void UpdateCurrentShaderVariant();
@@ -40,9 +40,9 @@ namespace AZ
{
}
void DepthOfFieldCompositePass::Init()
void DepthOfFieldCompositePass::InitializeInternal()
{
FullscreenTrianglePass::Init();
FullscreenTrianglePass::InitializeInternal();
m_backBlendFactorDivision2Index.Reset();
m_backBlendFactorDivision4Index.Reset();
@@ -37,11 +37,11 @@ namespace AZ
protected:
// Pass behavior overrides...
void InitializeInternal() override;
void FrameBeginInternal(FramePrepareParams params) override;
private:
DepthOfFieldCompositePass(const RPI::PassDescriptor& descriptor);
void Init() override;
void InitializeShaderVariant();
void UpdateCurrentShaderVariant();
@@ -33,9 +33,9 @@ namespace AZ
{
}
void DepthOfFieldMaskPass::Init()
void DepthOfFieldMaskPass::InitializeInternal()
{
FullscreenTrianglePass::Init();
FullscreenTrianglePass::InitializeInternal();
m_blendFactorIndex.Reset();
m_inputResolutionInverseIndex.Reset();
@@ -37,11 +37,11 @@ namespace AZ
protected:
// Pass behavior overrides...
void InitializeInternal() override;
void FrameBeginInternal(FramePrepareParams params) override;
private:
DepthOfFieldMaskPass(const RPI::PassDescriptor& descriptor);
virtual void Init() override;
// SRG binding indices...
RHI::ShaderInputNameIndex m_blendFactorIndex = "m_blendFactor";
@@ -48,9 +48,9 @@ namespace AZ
}
}
void LookModificationCompositePass::Init()
void LookModificationCompositePass::InitializeInternal()
{
FullscreenTrianglePass::Init();
FullscreenTrianglePass::InitializeInternal();
m_shaderColorGradingLutImageIndex.Reset();
m_shaderColorGradingShaperTypeIndex.Reset();
@@ -60,9 +60,9 @@ namespace AZ
protected:
LookModificationCompositePass(const RPI::PassDescriptor& descriptor);
void Init() override;
//! Pass behavior overrides
void InitializeInternal() override;
void FrameBeginInternal(FramePrepareParams params) final;
private:
@@ -43,9 +43,9 @@ namespace AZ
{
}
void SMAABasePass::Init()
void SMAABasePass::InitializeInternal()
{
FullscreenTrianglePass::Init();
FullscreenTrianglePass::InitializeInternal();
AZ_Assert(m_shaderResourceGroup != nullptr, "SMAABasePass %s has a null shader resource group when calling Init.", GetPathName().GetCStr());
@@ -41,9 +41,12 @@ namespace AZ
protected:
SMAABasePass(const RPI::PassDescriptor& descriptor);
void Init() override;
// Pass behavior overrides...
void InitializeInternal() override;
// An interface to update pass srg.
virtual void UpdateSRG() = 0;
// An interface to get current shader variation option.
virtual void GetCurrentShaderOption(AZ::RPI::ShaderOptionGroup& shaderOption) const = 0;
@@ -94,9 +94,9 @@ namespace AZ
}
}
void SMAABlendingWeightCalculationPass::Init()
void SMAABlendingWeightCalculationPass::InitializeInternal()
{
SMAABasePass::Init();
SMAABasePass::InitializeInternal();
AZ_Assert(m_shaderResourceGroup != nullptr, "SMAABlendingWeightCalculationPass %s has a null shader resource group when calling Init.", GetPathName().GetCStr());
@@ -43,7 +43,9 @@ namespace AZ
private:
SMAABlendingWeightCalculationPass(const RPI::PassDescriptor& descriptor);
void Init() override;
// Pass behavior overrides...
void InitializeInternal() override;
// SMAABasePass functions...
void UpdateSRG() override;
@@ -48,9 +48,9 @@ namespace AZ
{
}
void SMAAEdgeDetectionPass::Init()
void SMAAEdgeDetectionPass::InitializeInternal()
{
SMAABasePass::Init();
SMAABasePass::InitializeInternal();
m_renderTargetMetricsShaderInputIndex.Reset();
m_chromaThresholdShaderInputIndex.Reset();
@@ -45,7 +45,9 @@ namespace AZ
private:
SMAAEdgeDetectionPass(const RPI::PassDescriptor& descriptor);
void Init() override;
// Pass behavior overrides
void InitializeInternal() override;
// SMAABasePass functions...
void UpdateSRG() override;
@@ -47,9 +47,9 @@ namespace AZ
{
}
void SMAANeighborhoodBlendingPass::Init()
void SMAANeighborhoodBlendingPass::InitializeInternal()
{
SMAABasePass::Init();
SMAABasePass::InitializeInternal();
m_renderTargetMetricsShaderInputIndex.Reset();
}
@@ -37,7 +37,9 @@ namespace AZ
private:
SMAANeighborhoodBlendingPass(const RPI::PassDescriptor& descriptor);
void Init() override;
// Pass behavior overrides
void InitializeInternal() override;
// SMAABasePass functions...
void UpdateSRG() override;
@@ -46,9 +46,9 @@ namespace AZ
}
void DeferredFogPass::Init()
void DeferredFogPass::InitializeInternal()
{
FullscreenTrianglePass::Init();
FullscreenTrianglePass::InitializeInternal();
// The following will ensure that in the case of data driven pass, the settings will get
// updated by the pass enable state.
@@ -43,13 +43,11 @@ namespace AZ
{
AZ_RPI_PASS(DeferredFogPass);
public:
AZ_RTTI(DeferredFogPass, "{0406C8AB-E95D-43A7-AF53-BDEE22D36746}", RPI::FullscreenTrianglePass);
AZ_CLASS_ALLOCATOR(DeferredFogPass, SystemAllocator, 0);
~DeferredFogPass() = default;
void Init() override;
static RPI::Ptr<DeferredFogPass> Create(const RPI::PassDescriptor& descriptor);
@@ -57,12 +55,16 @@ namespace AZ
virtual bool IsEnabled() const override;
void SetupFrameGraphDependencies(RHI::FrameGraphInterface frameGraph) override;
void CompileResources(const RHI::FrameGraphCompileContext& context) override;
protected:
DeferredFogPass(const RPI::PassDescriptor& descriptor);
// Pass behavior overrides...
void InitializeInternal() override;
// Scope producer functions...
void SetupFrameGraphDependencies(RHI::FrameGraphInterface frameGraph) override;
void CompileResources(const RHI::FrameGraphCompileContext& context) override;
//! Set the binding indices of all members of the SRG
void SetSrgBindIndices();
@@ -44,14 +44,11 @@ namespace AZ
//! Creates a FullscreenTrianglePass
static Ptr<FullscreenTrianglePass> Create(const PassDescriptor& descriptor);
// Clears the initialized flag so that the next time PrepareFrameInternal is called, it will update the pipeline state
void Invalidate();
protected:
FullscreenTrianglePass(const PassDescriptor& descriptor);
virtual void Init();
// Pass behavior overrides...
void InitializeInternal() override;
void FrameBeginInternal(FramePrepareParams params) override;
RHI::Viewport m_viewportState;
@@ -262,6 +262,15 @@ namespace AZ
PassState GetPassState() const;
// Update all bindings on this pass that are connected to bindings on other passes
void UpdateConnectedBindings();
protected:
explicit Pass(const PassDescriptor& descriptor);
@@ -393,7 +402,6 @@ namespace AZ
uint64_t m_enabled : 1;
uint64_t m_parentEnabled : 1;
uint64_t m_initialized : 1;
uint64_t m_alreadyCreated : 1;
uint64_t m_createChildren : 1;
@@ -427,6 +435,12 @@ namespace AZ
// fully custom sort implementations by overriding the SortDrawList() function.
RHI::DrawListSortType m_drawListSortType = RHI::DrawListSortType::KeyThenDepth;
private:
// Return the Timestamp result of this pass
virtual TimestampResult GetTimestampResultInternal() const;
@@ -475,9 +489,6 @@ namespace AZ
// This sets the binding's attachment pointer to the connected binding's attachment
void UpdateConnectedBinding(PassAttachmentBinding& binding);
// Update all bindings on this pass that are connected to bindings on other passes
void UpdateConnectedBindings();
// Process a PassFallbackConnection to connect an output to an input to act as a short-circuit for when Pass is disabled
void ProcessFallbackConnection(const PassFallbackConnection& connection);
@@ -64,6 +64,8 @@ namespace AZ
void FullscreenTrianglePass::LoadShader()
{
AZ_Assert(GetPassState() != PassState::Rendering, "FullscreenTrianglePass - Reloading shader during Rendering phase!");
// Load FullscreenTrianglePassData
const FullscreenTrianglePassData* passData = PassUtils::GetPassData<FullscreenTrianglePassData>(m_passDescriptor);
if (passData == nullptr)
@@ -121,14 +123,16 @@ namespace AZ
// Store stencil reference value for the draw call
m_stencilRef = passData->m_stencilRef;
m_flags.m_initialized = false;
QueueForInitialization();
ShaderReloadNotificationBus::Handler::BusDisconnect();
ShaderReloadNotificationBus::Handler::BusConnect(shaderAsset.GetId());
}
void FullscreenTrianglePass::Init()
void FullscreenTrianglePass::InitializeInternal()
{
RenderPass::InitializeInternal();
// This draw item purposefully does not reference any geometry buffers.
// Instead it's expected that the extended class uses a vertex shader
// that generates a full-screen triangle completely from vertex ids.
@@ -155,17 +159,10 @@ namespace AZ
m_item.m_arguments = RHI::DrawArguments(draw);
m_item.m_pipelineState = m_shader->AcquirePipelineState(pipelineStateDescriptor);
m_item.m_stencilRef = m_stencilRef;
m_flags.m_initialized = true;
}
void FullscreenTrianglePass::FrameBeginInternal(FramePrepareParams params)
{
if (!m_flags.m_initialized)
{
Init();
}
const PassAttachment* outputAttachment = nullptr;
if (GetOutputCount() > 0)
@@ -225,11 +222,6 @@ namespace AZ
commandList->Submit(m_item);
}
void FullscreenTrianglePass::Invalidate()
{
m_flags.m_initialized = false;
}
} // namespace RPI
} // namespace AZ
@@ -1088,6 +1088,12 @@ namespace AZ
void Pass::QueueForInitialization()
{
// Pass::FrameBegin - Pass [Root.LowEndPipeline.LowEndPipelineTemplate.LightAdaptation.LookModificationTransformPass.LookModificationComposite] is attempting to render, but is not in the Idle state.
if (m_path == Name("Root.LowEndPipeline.LowEndPipelineTemplate.LightAdaptation.LookModificationTransformPass.LookModificationComposite"))
{
__nop();
}
// Only queue if the pass is not in any other queue
if (m_queueState == PassQueueState::NoQueue)
{
@@ -1119,6 +1125,11 @@ namespace AZ
void Pass::Reset()
{
if (m_path == Name("Root.LowEndPipeline.LowEndPipelineTemplate.LightAdaptation.LookModificationTransformPass.LookModificationComposite"))
{
__nop();
}
bool execute = (m_state == PassState::Idle);
execute = execute || (m_state == PassState::Queued && m_queueState == PassQueueState::QueuedForBuild);
execute = execute || (m_state == PassState::Queued && m_queueState == PassQueueState::QueuedForInitialization);
@@ -1158,6 +1169,11 @@ namespace AZ
void Pass::Build(bool calledFromPassSystem)
{
if (m_path == Name("Root.LowEndPipeline.LowEndPipelineTemplate.LightAdaptation.LookModificationTransformPass.LookModificationComposite"))
{
__nop();
}
AZ_RPI_BREAK_ON_TARGET_PASS;
bool execute = (m_state == PassState::Idle || m_state == PassState::Reset);
@@ -103,7 +103,7 @@ namespace AZ
m_rootPass = CreatePass<ParentPass>(Name{"Root"});
m_rootPass->m_flags.m_partOfHierarchy = true;
//m_targetedPassDebugName = "RPISamplePipeline";
//m_targetedPassDebugName = "AcesOutputTransform";
m_state = PassSystemState::Idle;
}
@@ -107,8 +107,13 @@ namespace AZ
pipeline->m_originalRenderSettings = desc.m_renderSettings;
pipeline->m_activeRenderSettings = desc.m_renderSettings;
pipeline->m_rootPass->SetRenderPipeline(pipeline);
// Manually create the pipeline so we can gather the view tags from it's passes
pipeline->m_rootPass->Reset();
pipeline->m_rootPass->Build();
pipeline->m_rootPass->Initialize();
pipeline->m_rootPass->OnInitializationFinished();
pipeline->BuildPipelineViews();
}