Pass changes WIP: moved child pass creation to Build phase
This commit is contained in:
@@ -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,
|
||||
@@ -61,8 +59,6 @@ namespace AZ
|
||||
{
|
||||
m_displayMapperConfigurationDescriptor = passData->m_config;
|
||||
}
|
||||
|
||||
m_needToRebuildChildren = true;
|
||||
}
|
||||
|
||||
DisplayMapperPass::~DisplayMapperPass()
|
||||
@@ -199,24 +195,14 @@ namespace AZ
|
||||
void DisplayMapperPass::FrameEndInternal()
|
||||
{
|
||||
GetDisplayMapperConfiguration();
|
||||
if (m_needToRebuildChildren)
|
||||
{
|
||||
ClearChildren();
|
||||
BuildGradingLutTemplate();
|
||||
CreateGradingAndAcesPasses();
|
||||
}
|
||||
ParentPass::FrameEndInternal();
|
||||
}
|
||||
|
||||
void DisplayMapperPass::CreateChildPassesInternal()
|
||||
{
|
||||
if (m_needToRebuildChildren)
|
||||
{
|
||||
ClearChildren();
|
||||
BuildGradingLutTemplate();
|
||||
CreateGradingAndAcesPasses();
|
||||
}
|
||||
ParentPass::CreateChildPassesInternal();
|
||||
ClearChildren();
|
||||
BuildGradingLutTemplate();
|
||||
CreateGradingAndAcesPasses();
|
||||
}
|
||||
|
||||
AZStd::shared_ptr<RPI::PassTemplate> CreatePassTemplateHelper(
|
||||
@@ -485,7 +471,6 @@ namespace AZ
|
||||
{
|
||||
AddChild(m_ldrGradingLookupTablePass);
|
||||
}
|
||||
m_needToRebuildChildren = false;
|
||||
}
|
||||
|
||||
void DisplayMapperPass::GetDisplayMapperConfiguration()
|
||||
@@ -513,7 +498,8 @@ namespace AZ
|
||||
desc.m_ldrColorGradingLut != m_displayMapperConfigurationDescriptor.m_ldrColorGradingLut ||
|
||||
desc.m_acesParameterOverrides.m_overrideDefaults != m_displayMapperConfigurationDescriptor.m_acesParameterOverrides.m_overrideDefaults)
|
||||
{
|
||||
m_needToRebuildChildren = true;
|
||||
m_flags.m_createChildren = true;
|
||||
QueueForBuild();
|
||||
}
|
||||
m_displayMapperConfigurationDescriptor = desc;
|
||||
}
|
||||
@@ -527,41 +513,15 @@ namespace AZ
|
||||
|
||||
void DisplayMapperPass::ClearChildren()
|
||||
{
|
||||
if (m_acesOutputTransformPass)
|
||||
{
|
||||
RemoveChild(m_acesOutputTransformPass);
|
||||
m_acesOutputTransformPass = nullptr;
|
||||
}
|
||||
if (m_bakeAcesOutputTransformLutPass)
|
||||
{
|
||||
RemoveChild(m_bakeAcesOutputTransformLutPass);
|
||||
m_bakeAcesOutputTransformLutPass = nullptr;
|
||||
}
|
||||
if (m_acesOutputTransformLutPass)
|
||||
{
|
||||
RemoveChild(m_acesOutputTransformLutPass);
|
||||
m_acesOutputTransformLutPass = nullptr;
|
||||
}
|
||||
if (m_displayMapperPassthroughPass)
|
||||
{
|
||||
RemoveChild(m_displayMapperPassthroughPass);
|
||||
m_displayMapperPassthroughPass = nullptr;
|
||||
}
|
||||
if (m_displayMapperOnlyGammaCorrectionPass)
|
||||
{
|
||||
RemoveChild(m_displayMapperOnlyGammaCorrectionPass);
|
||||
m_displayMapperOnlyGammaCorrectionPass = nullptr;
|
||||
}
|
||||
if (m_ldrGradingLookupTablePass)
|
||||
{
|
||||
RemoveChild(m_ldrGradingLookupTablePass);
|
||||
m_ldrGradingLookupTablePass = nullptr;
|
||||
}
|
||||
if (m_outputTransformPass)
|
||||
{
|
||||
RemoveChild(m_outputTransformPass);
|
||||
m_outputTransformPass = nullptr;
|
||||
}
|
||||
RemoveChildren();
|
||||
|
||||
m_acesOutputTransformPass = nullptr;
|
||||
m_bakeAcesOutputTransformLutPass = nullptr;
|
||||
m_acesOutputTransformLutPass = nullptr;
|
||||
m_displayMapperPassthroughPass = nullptr;
|
||||
m_displayMapperOnlyGammaCorrectionPass = nullptr;
|
||||
m_ldrGradingLookupTablePass = nullptr;
|
||||
m_outputTransformPass = nullptr;
|
||||
}
|
||||
} // namespace Render
|
||||
} // namespace AZ
|
||||
|
||||
@@ -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
|
||||
@@ -41,8 +39,6 @@ namespace AZ
|
||||
|
||||
// Create readback
|
||||
m_readback = AZStd::make_shared<AZ::RPI::AttachmentReadback>(AZ::RHI::ScopeId{ Uuid::CreateRandom().ToString<AZStd::string>() });
|
||||
|
||||
CreateChildPasses();
|
||||
}
|
||||
|
||||
LuxCoreTexturePass::~LuxCoreTexturePass()
|
||||
|
||||
+18
-15
@@ -34,18 +34,6 @@ namespace AZ
|
||||
DepthOfFieldReadBackFocusDepthPass::DepthOfFieldReadBackFocusDepthPass(const RPI::PassDescriptor& descriptor)
|
||||
: ParentPass(descriptor)
|
||||
{
|
||||
RPI::PassSystemInterface* passSystem = RPI::PassSystemInterface::Get();
|
||||
|
||||
// Create read back pass
|
||||
m_readbackPass = passSystem->CreatePass<DepthOfFieldCopyFocusDepthToCpuPass>(AZ::Name("DepthOfFieldReadBackPass"));
|
||||
AZ_Assert(m_readbackPass, "DepthOfFieldReadBackFocusDepthPass : read back pass is invalid");
|
||||
|
||||
AddChild(m_readbackPass);
|
||||
|
||||
// Find GetDepth pass on template
|
||||
auto pass = FindChildPass(Name("DepthOfFieldWriteFocusDepthFromGpu"));
|
||||
m_getDepthPass = static_cast<DepthOfFieldWriteFocusDepthFromGpuPass*>(pass.get());
|
||||
|
||||
// Create buffer for read back focus depth. We append static counter to avoid name conflicts.
|
||||
RPI::CommonBufferDescriptor desc;
|
||||
desc.m_bufferName = "DepthOfFieldReadBackAutoFocusDepthBuffer";
|
||||
@@ -55,9 +43,6 @@ namespace AZ
|
||||
desc.m_bufferData = nullptr;
|
||||
desc.m_elementFormat = RHI::Format::R32_FLOAT;
|
||||
m_buffer = RPI::BufferSystemInterface::Get()->CreateBufferFromCommonPool(desc);
|
||||
|
||||
m_getDepthPass->SetBufferRef(m_buffer);
|
||||
m_readbackPass->SetBufferRef(m_buffer);
|
||||
}
|
||||
|
||||
DepthOfFieldReadBackFocusDepthPass::~DepthOfFieldReadBackFocusDepthPass()
|
||||
@@ -85,6 +70,24 @@ namespace AZ
|
||||
}
|
||||
}
|
||||
|
||||
void DepthOfFieldReadBackFocusDepthPass::CreateChildPassesInternal()
|
||||
{
|
||||
RPI::PassSystemInterface* passSystem = RPI::PassSystemInterface::Get();
|
||||
|
||||
// Create read back pass
|
||||
m_readbackPass = passSystem->CreatePass<DepthOfFieldCopyFocusDepthToCpuPass>(AZ::Name("DepthOfFieldReadBackPass"));
|
||||
AZ_Assert(m_readbackPass, "DepthOfFieldReadBackFocusDepthPass : read back pass is invalid");
|
||||
|
||||
AddChild(m_readbackPass);
|
||||
|
||||
// Find GetDepth pass on template
|
||||
auto pass = FindChildPass(Name("DepthOfFieldWriteFocusDepthFromGpu"));
|
||||
m_getDepthPass = static_cast<DepthOfFieldWriteFocusDepthFromGpuPass*>(pass.get());
|
||||
|
||||
m_getDepthPass->SetBufferRef(m_buffer);
|
||||
m_readbackPass->SetBufferRef(m_buffer);
|
||||
}
|
||||
|
||||
void DepthOfFieldReadBackFocusDepthPass::FrameBeginInternal(FramePrepareParams params)
|
||||
{
|
||||
RPI::Scene* scene = GetScene();
|
||||
|
||||
+1
@@ -43,6 +43,7 @@ namespace AZ
|
||||
|
||||
protected:
|
||||
// Pass behavior overrides...
|
||||
void CreateChildPassesInternal() override;
|
||||
void FrameBeginInternal(FramePrepareParams params) override;
|
||||
|
||||
private:
|
||||
|
||||
+4
-4
@@ -47,7 +47,7 @@ namespace AZ
|
||||
RemoveChildren();
|
||||
}
|
||||
|
||||
void ReflectionScreenSpaceBlurPass::CreateChildPasses(uint32_t numBlurMips)
|
||||
void ReflectionScreenSpaceBlurPass::CreateChildPassesInternal()
|
||||
{
|
||||
RPI::PassSystemInterface* passSystem = RPI::PassSystemInterface::Get();
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace AZ
|
||||
horizontalBlurChildDesc.m_passTemplate = blurHorizontalPassTemplate;
|
||||
|
||||
// add child passes to perform the vertical and horizontal Gaussian blur for each roughness mip level
|
||||
for (uint32_t mip = 0; mip < numBlurMips; ++mip)
|
||||
for (uint32_t mip = 0; mip < m_numBlurMips; ++mip)
|
||||
{
|
||||
// create Vertical blur child passes
|
||||
{
|
||||
@@ -116,6 +116,7 @@ namespace AZ
|
||||
void ReflectionScreenSpaceBlurPass::BuildInternal()
|
||||
{
|
||||
RemoveChildren();
|
||||
m_flags.m_createChildren = true;
|
||||
|
||||
Data::Instance<RPI::AttachmentImagePool> pool = RPI::ImageSystemInterface::Get()->GetSystemAttachmentPool();
|
||||
|
||||
@@ -163,8 +164,7 @@ namespace AZ
|
||||
m_ownedAttachments.push_back(transientPassAttachment);
|
||||
}
|
||||
|
||||
// create child passes, one vertical and one horizontal blur per mip level
|
||||
CreateChildPasses(mipLevels - 1);
|
||||
m_numBlurMips = mipLevels - 1;
|
||||
|
||||
// call ParentPass::BuildInternal() first to configure the slots and auto-add the empty bindings,
|
||||
// then we will assign attachments to the bindings
|
||||
|
||||
+2
-1
@@ -40,7 +40,7 @@ namespace AZ
|
||||
private:
|
||||
explicit ReflectionScreenSpaceBlurPass(const RPI::PassDescriptor& descriptor);
|
||||
|
||||
void CreateChildPasses(uint32_t numBlurMips);
|
||||
void CreateChildPassesInternal() override;
|
||||
|
||||
// Pass Overrides...
|
||||
void ResetInternal() override;
|
||||
@@ -50,6 +50,7 @@ namespace AZ
|
||||
AZStd::vector<RPI::Ptr<RPI::FullscreenTrianglePass>> m_horizontalBlurChildPasses;
|
||||
|
||||
Data::Instance<RPI::AttachmentImage> m_frameBufferImageAttachment;
|
||||
uint32_t m_numBlurMips = 0;
|
||||
};
|
||||
} // namespace RPI
|
||||
} // namespace AZ
|
||||
|
||||
@@ -118,7 +118,7 @@ namespace AZ
|
||||
// Finds the pass in m_children and removes it
|
||||
void RemoveChild(Ptr<Pass> pass);
|
||||
|
||||
// Orphans all children from clearing m_children.
|
||||
// Orphans all children by clearing m_children.
|
||||
void RemoveChildren();
|
||||
|
||||
private:
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
friend class PassSystem; \
|
||||
friend class PassFactory; \
|
||||
friend class ParentPass; \
|
||||
friend class RenderPipeline; \
|
||||
friend class UnitTest::PassTests; \
|
||||
|
||||
namespace UnitTest
|
||||
@@ -394,6 +395,7 @@ namespace AZ
|
||||
|
||||
uint64_t m_initialized : 1;
|
||||
uint64_t m_alreadyCreated : 1;
|
||||
uint64_t m_createChildren : 1;
|
||||
|
||||
// OLD SCHOOL
|
||||
uint64_t m_alreadyPrepared : 1;
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace AZ
|
||||
ParentPass::ParentPass(const PassDescriptor& descriptor)
|
||||
: Pass(descriptor)
|
||||
{
|
||||
CreateChildPasses();
|
||||
m_flags.m_createChildren = true;
|
||||
}
|
||||
|
||||
ParentPass::~ParentPass()
|
||||
@@ -248,7 +248,7 @@ namespace AZ
|
||||
|
||||
void ParentPass::CreateChildPasses()
|
||||
{
|
||||
if (m_flags.m_alreadyCreated)
|
||||
if (!m_flags.m_createChildren || m_flags.m_alreadyCreated)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -258,14 +258,7 @@ namespace AZ
|
||||
CreatePassesFromTemplate();
|
||||
CreateChildPassesInternal();
|
||||
|
||||
for (Ptr<Pass>& child : m_children)
|
||||
{
|
||||
ParentPass* asParent = child->AsParent();
|
||||
if (asParent != nullptr)
|
||||
{
|
||||
asParent->CreateChildPasses();
|
||||
}
|
||||
}
|
||||
m_flags.m_createChildren = false;
|
||||
}
|
||||
|
||||
void ParentPass::ResetInternal()
|
||||
@@ -278,6 +271,8 @@ namespace AZ
|
||||
|
||||
void ParentPass::BuildInternal()
|
||||
{
|
||||
CreateChildPasses();
|
||||
|
||||
for (const Ptr<Pass>& child : m_children)
|
||||
{
|
||||
child->Build();
|
||||
|
||||
@@ -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)
|
||||
@@ -88,8 +86,6 @@ namespace AZ
|
||||
AZ::Matrix4x4 viewToClipMatrix;
|
||||
MakePerspectiveFovMatrixRH(viewToClipMatrix, AZ::Constants::HalfPi, 1.0f, 0.1f, 100.0f, true);
|
||||
m_view->SetViewToClipMatrix(viewToClipMatrix);
|
||||
|
||||
CreateChildPasses();
|
||||
}
|
||||
|
||||
EnvironmentCubeMapPass::~EnvironmentCubeMapPass()
|
||||
|
||||
@@ -26,8 +26,6 @@ namespace AZ
|
||||
, m_windowContext(windowContext)
|
||||
, m_childTemplateName(childTemplateName)
|
||||
{
|
||||
m_flags.m_alreadyCreated = false;
|
||||
|
||||
PassSystemInterface* passSystem = PassSystemInterface::Get();
|
||||
|
||||
// Create child pass
|
||||
@@ -44,8 +42,6 @@ namespace AZ
|
||||
|
||||
m_childPass = passSystem->CreatePassFromRequest(&childRequest);
|
||||
AZ_Assert(m_childPass, "SwapChain child pass is invalid: check your passs pipeline, run configuration and your AssetProcessor set project (project_path)");
|
||||
|
||||
CreateChildPasses();
|
||||
|
||||
AzFramework::WindowNotificationBus::Handler::BusConnect(m_windowContext->GetWindowHandle());
|
||||
}
|
||||
|
||||
@@ -107,6 +107,8 @@ namespace AZ
|
||||
pipeline->m_originalRenderSettings = desc.m_renderSettings;
|
||||
pipeline->m_activeRenderSettings = desc.m_renderSettings;
|
||||
pipeline->m_rootPass->SetRenderPipeline(pipeline);
|
||||
pipeline->m_rootPass->Build();
|
||||
pipeline->m_rootPass->Initialize();
|
||||
pipeline->BuildPipelineViews();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user