Added ClearPass and automatic instantiation from ParentPass for slots specifying a clear action
Signed-off-by: antonmic <56370189+antonmic@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"Type": "JsonSerialization",
|
||||
"Version": 1,
|
||||
"ClassName": "PassAsset",
|
||||
"ClassData": {
|
||||
"PassTemplate": {
|
||||
"Name": "ClearPassTemplate",
|
||||
"PassClass": "ClearPass",
|
||||
"Slots": [
|
||||
{
|
||||
"Name": "ClearInputOutput",
|
||||
"SlotType": "InputOutput",
|
||||
"ScopeAttachmentUsage": "RenderTarget",
|
||||
"LoadStoreAction": {
|
||||
"ClearValue": {
|
||||
"Value": [
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0
|
||||
]
|
||||
},
|
||||
"LoadAction": "Clear",
|
||||
"LoadActionStencil": "Clear"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -64,6 +64,10 @@
|
||||
"Name": "CascadedShadowmapsTemplate",
|
||||
"Path": "Passes/CascadedShadowmaps.pass"
|
||||
},
|
||||
{
|
||||
"Name": "ClearPassTemplate",
|
||||
"Path": "Passes/Clear.pass"
|
||||
},
|
||||
{
|
||||
"Name": "FullscreenCopyTemplate",
|
||||
"Path": "Passes/FullscreenCopy.pass"
|
||||
|
||||
@@ -25,10 +25,7 @@
|
||||
{
|
||||
"Name": "OutputColor",
|
||||
"SlotType": "Output",
|
||||
"ScopeAttachmentUsage": "RenderTarget",
|
||||
"LoadStoreAction": {
|
||||
"LoadAction": "DontCare"
|
||||
}
|
||||
"ScopeAttachmentUsage": "RenderTarget"
|
||||
}
|
||||
],
|
||||
"Connections": [
|
||||
|
||||
@@ -25,10 +25,7 @@
|
||||
{
|
||||
"Name": "OutputColor",
|
||||
"SlotType": "Output",
|
||||
"ScopeAttachmentUsage": "RenderTarget",
|
||||
"LoadStoreAction": {
|
||||
"LoadAction": "DontCare"
|
||||
}
|
||||
"ScopeAttachmentUsage": "RenderTarget"
|
||||
}
|
||||
],
|
||||
"Connections": [
|
||||
|
||||
@@ -53,6 +53,7 @@ set(FILES
|
||||
Materials/Types/StandardPBR_LowEndForward.azsl
|
||||
Materials/Types/StandardPBR_LowEndForward.shader
|
||||
Materials/Types/StandardPBR_LowEndForward_EDS.shader
|
||||
Materials/Types/StandardPBR_Metallic.lua
|
||||
Materials/Types/StandardPBR_ParallaxState.lua
|
||||
Materials/Types/StandardPBR_Roughness.lua
|
||||
Materials/Types/StandardPBR_ShaderEnable.lua
|
||||
@@ -85,6 +86,7 @@ set(FILES
|
||||
Passes/CascadedShadowmaps.pass
|
||||
Passes/CheckerboardResolveColor.pass
|
||||
Passes/CheckerboardResolveDepth.pass
|
||||
Passes/Clear.pass
|
||||
Passes/ContrastAdaptiveSharpening.pass
|
||||
Passes/ConvertToAcescg.pass
|
||||
Passes/DebugOverlayParent.pass
|
||||
@@ -129,6 +131,7 @@ set(FILES
|
||||
Passes/DownsampleMipChain.pass
|
||||
Passes/EnvironmentCubeMapDepthMSAA.pass
|
||||
Passes/EnvironmentCubeMapForwardMSAA.pass
|
||||
Passes/EnvironmentCubeMapForwardSubsurfaceMSAA.pass
|
||||
Passes/EnvironmentCubeMapPipeline.pass
|
||||
Passes/EnvironmentCubeMapSkyBox.pass
|
||||
Passes/EsmShadowmaps.pass
|
||||
@@ -303,6 +306,7 @@ set(FILES
|
||||
ShaderLib/Atom/Features/ScreenSpace/ScreenSpaceUtil.azsli
|
||||
ShaderLib/Atom/Features/Shadow/BicubicPcfFilters.azsli
|
||||
ShaderLib/Atom/Features/Shadow/DirectionalLightShadow.azsli
|
||||
ShaderLib/Atom/Features/Shadow/ESM.azsli
|
||||
ShaderLib/Atom/Features/Shadow/NormalOffsetShadows.azsli
|
||||
ShaderLib/Atom/Features/Shadow/ProjectedShadow.azsli
|
||||
ShaderLib/Atom/Features/Shadow/ReceiverPlaneDepthBias.azsli
|
||||
|
||||
@@ -73,8 +73,6 @@ namespace AZ
|
||||
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;
|
||||
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
|
||||
#include <Atom/RHI/CommandList.h>
|
||||
#include <Atom/RHI/DrawItem.h>
|
||||
#include <Atom/RHI/ScopeProducer.h>
|
||||
|
||||
#include <Atom/RPI.Public/Pass/RenderPass.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace RPI
|
||||
{
|
||||
//! A simple pass to clear a render target
|
||||
class ClearPass
|
||||
: public RenderPass
|
||||
{
|
||||
AZ_RPI_PASS(ClearPass);
|
||||
|
||||
public:
|
||||
AZ_RTTI(ClearPass, "{31CBAD6C-108F-4F3F-B498-ED968DFCFCE2}", RenderPass);
|
||||
AZ_CLASS_ALLOCATOR(ClearPass, SystemAllocator, 0);
|
||||
virtual ~ClearPass() = default;
|
||||
|
||||
//! Creates a ClearPass
|
||||
static Ptr<ClearPass> Create(const PassDescriptor& descriptor);
|
||||
|
||||
protected:
|
||||
ClearPass(const PassDescriptor& descriptor);
|
||||
void InitializeInternal() override;
|
||||
|
||||
private:
|
||||
|
||||
RHI::ClearValue m_clearValue;
|
||||
};
|
||||
} // namespace RPI
|
||||
} // namespace AZ
|
||||
@@ -131,6 +131,10 @@ namespace AZ
|
||||
|
||||
// Generates child passes from source PassTemplate
|
||||
void CreatePassesFromTemplate();
|
||||
|
||||
// Generates child clear passes to clear input and input/output attachments
|
||||
void CreateClearPassFromBinding(PassAttachmentBinding& binding, PassRequest& clearRequest);
|
||||
void CreateClearPassesFromBindings();
|
||||
};
|
||||
|
||||
template<typename PassType>
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <Atom/RHI.Reflect/ClearValue.h>
|
||||
|
||||
#include <Atom/RPI.Reflect/Pass/RenderPassData.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace RPI
|
||||
{
|
||||
//! Custom data for the ClearPass. Should be specified in the PassRequest.
|
||||
struct ClearPassData
|
||||
: public RenderPassData
|
||||
{
|
||||
AZ_RTTI(ClearPassData, "{5F2C24A4-62D0-4E60-91EC-C207C10D15C6}", RenderPassData);
|
||||
AZ_CLASS_ALLOCATOR(ClearPassData, SystemAllocator, 0);
|
||||
|
||||
ClearPassData() = default;
|
||||
virtual ~ClearPassData() = default;
|
||||
|
||||
static void Reflect(ReflectContext* context)
|
||||
{
|
||||
if (auto* serializeContext = azrtti_cast<SerializeContext*>(context))
|
||||
{
|
||||
serializeContext->Class<ClearPassData, RenderPassData>()
|
||||
->Version(0)
|
||||
->Field("ClearValue", &ClearPassData::m_clearValue)
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
RHI::ClearValue m_clearValue;
|
||||
};
|
||||
} // namespace RPI
|
||||
} // namespace AZ
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include <Atom/RPI.Public/Pass/ClearPass.h>
|
||||
#include <Atom/RPI.Public/Pass/PassUtils.h>
|
||||
#include <Atom/RPI.Public/RPIUtils.h>
|
||||
#include <Atom/RPI.Public/Shader/ShaderReloadDebugTracker.h>
|
||||
|
||||
#include <Atom/RPI.Reflect/Pass/ClearPassData.h>
|
||||
#include <Atom/RPI.Reflect/Pass/PassTemplate.h>
|
||||
#include <Atom/RPI.Reflect/Shader/ShaderAsset.h>
|
||||
|
||||
#include <Atom/RHI/Factory.h>
|
||||
#include <Atom/RHI/FrameScheduler.h>
|
||||
#include <Atom/RHI/PipelineState.h>
|
||||
|
||||
#include <AzCore/Asset/AssetCommon.h>
|
||||
#include <AzCore/Asset/AssetManagerBus.h>
|
||||
#include <AzCore/std/algorithm.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace RPI
|
||||
{
|
||||
Ptr<ClearPass> ClearPass::Create(const PassDescriptor& descriptor)
|
||||
{
|
||||
Ptr<ClearPass> pass = aznew ClearPass(descriptor);
|
||||
return pass;
|
||||
}
|
||||
|
||||
ClearPass::ClearPass(const PassDescriptor& descriptor)
|
||||
: RenderPass(descriptor)
|
||||
{
|
||||
const ClearPassData* passData = PassUtils::GetPassData<ClearPassData>(descriptor);
|
||||
if (passData != nullptr)
|
||||
{
|
||||
m_clearValue = passData->m_clearValue;
|
||||
}
|
||||
}
|
||||
|
||||
void ClearPass::InitializeInternal()
|
||||
{
|
||||
RenderPass::InitializeInternal();
|
||||
|
||||
// Set clear value
|
||||
AZ_Assert(GetInputOutputCount() > 0, "ClearPass: Missing InputOutput binding!");
|
||||
RPI::PassAttachmentBinding& binding = GetInputOutputBinding(0);
|
||||
binding.m_unifiedScopeDesc.m_loadStoreAction.m_clearValue = m_clearValue;
|
||||
}
|
||||
|
||||
} // namespace RPI
|
||||
} // namespace AZ
|
||||
@@ -9,11 +9,15 @@
|
||||
#include <AtomCore/Instance/InstanceDatabase.h>
|
||||
#include <AtomCore/std/containers/vector_set.h>
|
||||
|
||||
#include <Atom/RPI.Public/Pass/ClearPass.h>
|
||||
#include <Atom/RPI.Public/Pass/ParentPass.h>
|
||||
#include <Atom/RPI.Public/Pass/PassAttachment.h>
|
||||
#include <Atom/RPI.Public/Pass/PassDefines.h>
|
||||
#include <Atom/RPI.Public/Pass/PassSystemInterface.h>
|
||||
#include <Atom/RPI.Public/RenderPipeline.h>
|
||||
|
||||
#include <Atom/RPI.Reflect/Pass/ClearPassData.h>
|
||||
#include <Atom/RPI.Reflect/Pass/PassName.h>
|
||||
#include <Atom/RPI.Reflect/Pass/PassRequest.h>
|
||||
|
||||
namespace AZ
|
||||
@@ -196,7 +200,7 @@ namespace AZ
|
||||
}
|
||||
}
|
||||
|
||||
// --- PassTemplate related functions ---
|
||||
// --- Child creation ---
|
||||
|
||||
void ParentPass::CreatePassesFromTemplate()
|
||||
{
|
||||
@@ -217,6 +221,49 @@ namespace AZ
|
||||
}
|
||||
}
|
||||
|
||||
void ParentPass::CreateClearPassFromBinding(PassAttachmentBinding& binding, PassRequest& clearRequest)
|
||||
{
|
||||
if (binding.m_unifiedScopeDesc.m_loadStoreAction.m_loadAction == RHI::AttachmentLoadAction::Clear ||
|
||||
binding.m_unifiedScopeDesc.m_loadStoreAction.m_loadActionStencil == RHI::AttachmentLoadAction::Clear)
|
||||
{
|
||||
// Set the name of the child clear pass as well as the binding it's connected to
|
||||
clearRequest.m_passName = ConcatPassName(Name("Clear"), binding.m_name);
|
||||
clearRequest.m_connections[0].m_attachmentRef.m_attachment = binding.m_name;
|
||||
|
||||
// Set the pass clear value to the clear value of the attachment binding
|
||||
ClearPassData* clearData = static_cast<ClearPassData*>(clearRequest.m_passData.get());
|
||||
clearData->m_clearValue = binding.m_unifiedScopeDesc.m_loadStoreAction.m_clearValue;
|
||||
|
||||
// Create and add the pass
|
||||
Ptr<Pass> clearPass = PassSystemInterface::Get()->CreatePassFromRequest(&clearRequest);
|
||||
if (clearPass)
|
||||
{
|
||||
AddChild(clearPass);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ParentPass::CreateClearPassesFromBindings()
|
||||
{
|
||||
PassRequest clearRequest;
|
||||
clearRequest.m_templateName = Name("ClearPassTemplate");
|
||||
clearRequest.m_passData = AZStd::make_shared<ClearPassData>();
|
||||
clearRequest.m_connections.push_back();
|
||||
clearRequest.m_connections[0].m_localSlot = Name("ClearInputOutput");
|
||||
clearRequest.m_connections[0].m_attachmentRef.m_pass = Name("Parent");
|
||||
|
||||
for (uint32_t idx = 0; idx < GetInputCount(); ++idx)
|
||||
{
|
||||
CreateClearPassFromBinding(GetInputBinding(idx), clearRequest);
|
||||
}
|
||||
|
||||
for (uint32_t idx = 0; idx < GetInputOutputCount(); ++idx)
|
||||
{
|
||||
CreateClearPassFromBinding(GetInputOutputBinding(idx), clearRequest);
|
||||
}
|
||||
}
|
||||
|
||||
// --- Pass behavior functions ---
|
||||
|
||||
void ParentPass::CreateChildPasses()
|
||||
@@ -229,6 +276,7 @@ namespace AZ
|
||||
m_flags.m_alreadyCreatedChildren = true;
|
||||
|
||||
RemoveChildren();
|
||||
CreateClearPassesFromBindings();
|
||||
CreatePassesFromTemplate();
|
||||
CreateChildPassesInternal();
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include <AzCore/Interface/Interface.h>
|
||||
|
||||
#include <Atom/RPI.Public/Pass/ClearPass.h>
|
||||
#include <Atom/RPI.Public/Pass/ComputePass.h>
|
||||
#include <Atom/RPI.Public/Pass/CopyPass.h>
|
||||
#include <Atom/RPI.Public/Pass/FullscreenTrianglePass.h>
|
||||
@@ -60,6 +61,7 @@ namespace AZ
|
||||
{
|
||||
AddPassCreator(Name("ParentPass"), &ParentPass::Create);
|
||||
AddPassCreator(Name("RasterPass"), &RasterPass::Create);
|
||||
AddPassCreator(Name("ClearPass"), &ClearPass::Create);
|
||||
AddPassCreator(Name("CopyPass"), &CopyPass::Create);
|
||||
AddPassCreator(Name("FullScreenTriangle"), &FullscreenTrianglePass::Create);
|
||||
AddPassCreator(Name("ComputePass"), &ComputePass::Create);
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <Atom/RPI.Public/Pass/Specific/SwapChainPass.h>
|
||||
#include <Atom/RPI.Public/RenderPipeline.h>
|
||||
|
||||
#include <Atom/RPI.Reflect/Pass/ClearPassData.h>
|
||||
#include <Atom/RPI.Reflect/Pass/ComputePassData.h>
|
||||
#include <Atom/RPI.Reflect/Pass/CopyPassData.h>
|
||||
#include <Atom/RPI.Reflect/Pass/DownsampleMipChainPassData.h>
|
||||
@@ -67,6 +68,7 @@ namespace AZ
|
||||
PassSlot::Reflect(context);
|
||||
|
||||
PassData::Reflect(context);
|
||||
ClearPassData::Reflect(context);
|
||||
CopyPassData::Reflect(context);
|
||||
RenderPassData::Reflect(context);
|
||||
ComputePassData::Reflect(context);
|
||||
|
||||
@@ -57,6 +57,7 @@ set(FILES
|
||||
Include/Atom/RPI.Public/Model/ModelSystem.h
|
||||
Include/Atom/RPI.Public/Model/UvStreamTangentBitmask.h
|
||||
Include/Atom/RPI.Public/Pass/AttachmentReadback.h
|
||||
Include/Atom/RPI.Public/Pass/ClearPass.h
|
||||
Include/Atom/RPI.Public/Pass/ComputePass.h
|
||||
Include/Atom/RPI.Public/Pass/CopyPass.h
|
||||
Include/Atom/RPI.Public/Pass/FullscreenTrianglePass.h
|
||||
@@ -135,6 +136,7 @@ set(FILES
|
||||
Source/RPI.Public/Model/ModelSystem.cpp
|
||||
Source/RPI.Public/Model/UvStreamTangentBitmask.cpp
|
||||
Source/RPI.Public/Pass/AttachmentReadback.cpp
|
||||
Source/RPI.Public/Pass/ClearPass.cpp
|
||||
Source/RPI.Public/Pass/ComputePass.cpp
|
||||
Source/RPI.Public/Pass/CopyPass.cpp
|
||||
Source/RPI.Public/Pass/FullscreenTrianglePass.cpp
|
||||
|
||||
@@ -62,6 +62,7 @@ set(FILES
|
||||
Include/Atom/RPI.Reflect/Material/ShaderCollection.h
|
||||
Include/Atom/RPI.Reflect/Material/MaterialFunctor.h
|
||||
Include/Atom/RPI.Reflect/Material/MaterialVersionUpdate.h
|
||||
Include/Atom/RPI.Reflect/Pass/ClearPassData.h
|
||||
Include/Atom/RPI.Reflect/Pass/ComputePassData.h
|
||||
Include/Atom/RPI.Reflect/Pass/CopyPassData.h
|
||||
Include/Atom/RPI.Reflect/Pass/DownsampleMipChainPassData.h
|
||||
|
||||
Reference in New Issue
Block a user