initial changes compiling

This commit is contained in:
antonmic
2021-06-04 09:38:28 -07:00
parent e56fce88c3
commit 0f90ccc0b4
80 changed files with 361 additions and 238 deletions
@@ -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);
@@ -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;
@@ -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:
@@ -46,7 +46,7 @@ namespace AZ
private:
void BuildAttachmentsInternal() override;
void BuildInternal() override;
void FrameBeginInternal(FramePrepareParams params) override;
void UpdataAttachment();
@@ -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.
@@ -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...
@@ -50,7 +50,7 @@ namespace AZ
Base::FrameBeginInternal(params);
}
void CheckerboardPass::BuildAttachmentsInternal()
void CheckerboardPass::BuildInternal()
{
Data::Instance<RPI::AttachmentImagePool> 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();
}
@@ -40,7 +40,7 @@ namespace AZ
protected:
// Pass overrides...
void FrameBeginInternal(FramePrepareParams params);
void BuildAttachmentsInternal() override;
void BuildInternal() override;
void FrameEndInternal() override;
private:
@@ -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);
}
}
@@ -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;
@@ -1106,7 +1106,7 @@ namespace AZ
{
for (EsmShadowmapsPass* pass : it.second)
{
pass->QueueForBuildAttachments();
pass->QueueForBuild();
}
}
}
@@ -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();
@@ -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<RPI::Buffer> m_lightList;
uint32_t m_tileDataIndex = -1;
@@ -108,7 +108,7 @@ namespace AZ
return -1;
}
void LightCullingRemap::BuildAttachmentsInternal()
void LightCullingRemap::BuildInternal()
{
m_tileDataIndex = FindInputOutputBinding(AZ::Name("TileLightData"));
m_tileDim = GetTileDataBufferResolution();
@@ -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;
@@ -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<AZ::RPI::ShaderAsset>&)
{
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
@@ -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";
@@ -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
@@ -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;
@@ -107,7 +107,7 @@ namespace AZ
m_scissorState = scissor;
}
void ShadowmapPass::BuildAttachmentsInternal()
void ShadowmapPass::BuildInternal()
{
RPI::Ptr<RPI::ParentPass> 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
@@ -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;
@@ -34,7 +34,7 @@ namespace AZ
{
}
void DisplayMapperFullScreenPass::BuildAttachmentsInternal()
void DisplayMapperFullScreenPass::BuildInternal()
{
RPI::PassConnection inConnection;
inConnection.m_localSlot = InputAttachmentName;
@@ -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)
@@ -519,13 +519,13 @@ namespace AZ
io.Fonts->TexID = reinterpret_cast<ImTextureID>(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)
@@ -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
@@ -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)
@@ -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)
@@ -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
@@ -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;
@@ -252,10 +252,10 @@ namespace AZ
}
}
void BloomBlurPass::BuildAttachmentsInternal()
void BloomBlurPass::BuildInternal()
{
BuildChildPasses();
ParentPass::BuildAttachmentsInternal();
ParentPass::BuildInternal();
}
void BloomBlurPass::FrameBeginInternal(FramePrepareParams params)
@@ -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();
@@ -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)
@@ -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();
@@ -74,10 +74,10 @@ namespace AZ
AddAttachmentBinding(outBinding);
}
ComputePass::BuildAttachmentsInternal();
ComputePass::BuildInternal();
}
void BloomDownsamplePass::BuildAttachmentsInternal()
void BloomDownsamplePass::BuildInternal()
{
BuildOutAttachmentBinding();
}
@@ -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();
@@ -52,7 +52,7 @@ namespace AZ
return depth;
}
void DepthOfFieldCopyFocusDepthToCpuPass::BuildAttachmentsInternal()
void DepthOfFieldCopyFocusDepthToCpuPass::BuildInternal()
{
SetScopeId(RHI::ScopeId(GetPathName()));
}
@@ -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<RPI::Buffer> m_bufferRef;
@@ -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);
}
@@ -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
@@ -62,7 +62,7 @@ namespace AZ
m_buffer = RPI::BufferSystemInterface::Get()->CreateBufferFromCommonPool(desc);
}
void EyeAdaptationPass::BuildAttachmentsInternal()
void EyeAdaptationPass::BuildInternal()
{
if (!m_buffer)
{
@@ -58,7 +58,7 @@ namespace AZ
float m_exposureValue = 1.0f;
};
void BuildAttachmentsInternal() override;
void BuildInternal() override;
void FrameBeginInternal(FramePrepareParams params) override;
@@ -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)
@@ -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;
@@ -86,7 +86,7 @@ namespace AZ
return colorBuffer->m_descriptor.m_image.m_size;
}
void LuminanceHistogramGeneratorPass::BuildAttachmentsInternal()
void LuminanceHistogramGeneratorPass::BuildInternal()
{
CreateHistogramBuffer();
AttachHistogramBuffer();
@@ -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();
@@ -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.");
@@ -36,7 +36,7 @@ namespace AZ
protected:
// Behavior functions override...
void OnBuildAttachmentsFinishedInternal() override;
void OnBuildFinishedInternal() override;
void FrameBeginInternal(FramePrepareParams params) override;
private:
@@ -42,7 +42,7 @@ namespace AZ
}
}
void RayTracingAccelerationStructurePass::BuildAttachmentsInternal()
void RayTracingAccelerationStructurePass::BuildInternal()
{
SetScopeId(RHI::ScopeId(GetPathName()));
}
@@ -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
@@ -30,7 +30,7 @@ namespace AZ
{
}
void ReflectionCopyFrameBufferPass::BuildAttachmentsInternal()
void ReflectionCopyFrameBufferPass::BuildInternal()
{
RPI::PassHierarchyFilter passFilter(AZ::Name("ReflectionScreenSpaceBlurPass"));
const AZStd::vector<RPI::Pass*>& 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
@@ -37,7 +37,7 @@ namespace AZ
explicit ReflectionCopyFrameBufferPass(const RPI::PassDescriptor& descriptor);
// Pass Overrides...
void BuildAttachmentsInternal() override;
void BuildInternal() override;
};
} // namespace RPI
} // namespace AZ
@@ -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;
@@ -44,7 +44,7 @@ namespace AZ
// Pass Overrides...
void ResetInternal() override;
void BuildAttachmentsInternal() override;
void BuildInternal() override;
AZStd::vector<RPI::Ptr<RPI::FullscreenTrianglePass>> m_verticalBlurChildPasses;
AZStd::vector<RPI::Ptr<RPI::FullscreenTrianglePass>> m_horizontalBlurChildPasses;
@@ -526,7 +526,7 @@ namespace AZ::Render
for (EsmShadowmapsPass* esmPass : m_esmShadowmapsPasses)
{
esmPass->QueueForBuildAttachments();
esmPass->QueueForBuild();
}
for (ProjectedShadowmapsPass* shadowPass : m_projectedShadowmapsPasses)
@@ -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;
@@ -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:
@@ -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;
@@ -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> buffer);
void AttachBufferToSlot(const Name& slot, Data::Instance<Buffer> buffer);
void AttachImageToSlot(const Name& slot, Data::Instance<AttachmentImage> 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
@@ -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,
};
}
}
@@ -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<ParentPass>& 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<Pass> > m_buildAttachmentsList;
AZStd::vector< Ptr<Pass> > m_buildPassList;
AZStd::vector< Ptr<Pass> > m_removePassList;
AZStd::vector< Ptr<Pass> > 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
@@ -40,6 +40,18 @@ namespace AZ
using PassCreator = AZStd::function<Ptr<Pass>(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;
@@ -96,7 +96,7 @@ namespace AZ
void BindPassSrg(const RHI::FrameGraphCompileContext& context, Data::Instance<ShaderResourceGroup>& shaderResourceGroup);
// Pass behavior overrides...
void OnBuildAttachmentsFinishedInternal() override;
void OnBuildFinishedInternal() override;
void FrameBeginInternal(FramePrepareParams params) override;
void FrameEndInternal() override;
@@ -46,7 +46,7 @@ namespace AZ
// Pass Behaviour Overrides...
void ResetInternal() override;
void BuildAttachmentsInternal() override;
void BuildInternal() override;
void FrameBeginInternal(FramePrepareParams params) override;
private:
@@ -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;
@@ -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
@@ -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<uint32_t> m_connections;
@@ -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 ...
@@ -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.",
@@ -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());
}
@@ -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<Pass>& child : m_children)
{
child->BuildAttachments();
child->Build();
}
}
void ParentPass::OnBuildAttachmentsFinishedInternal()
void ParentPass::OnBuildFinishedInternal()
{
for (const Ptr<Pass>& child : m_children)
{
child->OnBuildAttachmentsFinished();
child->OnBuildFinished();
}
}
void ParentPass::InitializeInternal()
{
for (const Ptr<Pass>& child : m_children)
{
child->Initialize();
}
}
@@ -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<PassAttachment> 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;
}
}
@@ -93,11 +93,15 @@ namespace AZ
void PassSystem::Init()
{
m_state = PassSystemState::Initializing;
Interface<PassSystemInterface>::Register(this);
m_passLibrary.Init();
m_passFactory.Init(&m_passLibrary);
m_rootPass = CreatePass<ParentPass>(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<Pass> >& 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<Pass> > buildListCopy = m_buildAttachmentsList;
m_buildAttachmentsList.clear();
AZStd::vector< Ptr<Pass> > 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>& 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<Pass>& currentPass)
{
return !currentPass->m_flags.m_partOfHierarchy;
});
m_initializePassList.erase(unused, m_initializePassList.end());
SortPassListAscending(m_initializePassList);
for (const Ptr<Pass>& 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
@@ -128,7 +128,7 @@ namespace AZ
}
void RenderPass::OnBuildAttachmentsFinishedInternal()
void RenderPass::OnBuildFinishedInternal()
{
if (m_shaderResourceGroup != nullptr)
{
@@ -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)
@@ -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<EnvironmentCubeMapPassData>(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)
@@ -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()
@@ -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
@@ -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<AttachmentReadback> readback)
@@ -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;
+7 -7
View File
@@ -329,7 +329,7 @@ namespace UnitTest
Ptr<Pass> 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<Pass> 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<Pass> 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);