diff --git a/Gems/Atom/Feature/Common/Assets/Passes/MSAAResolveCustom.pass b/Gems/Atom/Feature/Common/Assets/Passes/MSAAResolveCustom.pass index b7e6040cec..5fee65640f 100644 --- a/Gems/Atom/Feature/Common/Assets/Passes/MSAAResolveCustom.pass +++ b/Gems/Atom/Feature/Common/Assets/Passes/MSAAResolveCustom.pass @@ -5,7 +5,7 @@ "ClassData": { "PassTemplate": { "Name": "MSAAResolveCustomTemplate", - "PassClass": "FullScreenTriangle", + "PassClass": "MSAAResolveFullScreenPass", "Slots": [ { "Name": "Input", diff --git a/Gems/Atom/Feature/Common/Assets/Passes/MSAAResolveDepth.pass b/Gems/Atom/Feature/Common/Assets/Passes/MSAAResolveDepth.pass index b335c5460e..9edcf17cf6 100644 --- a/Gems/Atom/Feature/Common/Assets/Passes/MSAAResolveDepth.pass +++ b/Gems/Atom/Feature/Common/Assets/Passes/MSAAResolveDepth.pass @@ -5,7 +5,7 @@ "ClassData": { "PassTemplate": { "Name": "MSAAResolveDepthTemplate", - "PassClass": "FullScreenTriangle", + "PassClass": "MSAAResolveFullScreenPass", "Slots": [ { "Name": "Input", diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/MSAAResolvePass.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/MSAAResolvePass.h index 71776982b3..d70bb6e134 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/MSAAResolvePass.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/MSAAResolvePass.h @@ -42,6 +42,7 @@ namespace AZ // Pass behavior overrides... void BuildInternal() override; void FrameBeginInternal(FramePrepareParams params) override; + bool IsEnabled() const override; private: diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Specific/MSAAResolveFullScreenPass.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Specific/MSAAResolveFullScreenPass.h new file mode 100644 index 0000000000..e9337962b1 --- /dev/null +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Specific/MSAAResolveFullScreenPass.h @@ -0,0 +1,41 @@ +/* +* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or +* its licensors. +* +* For complete copyright and license terms please see the LICENSE at the root of this +* distribution (the "License"). All use of this software is governed by the License, +* or, if provided, by the license below or the license accompanying this file. Do not +* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* +*/ +#pragma once + +#include +#include + +namespace AZ +{ + namespace RPI + { + //! This pass allows the use of a custom fullscreen MSAA resolve pass shader. + class MSAAResolveFullScreenPass + : public RPI::FullscreenTrianglePass + { + AZ_RPI_PASS(MSAAResolveFullScreenPass); + + public: + AZ_RTTI(RPI::MSAAResolveFullScreenPass, "{998FCF6D-5441-4C59-89EC-795CFB803912}", FullscreenTrianglePass); + AZ_CLASS_ALLOCATOR(RPI::MSAAResolveFullScreenPass, SystemAllocator, 0); + + //! Creates a new pass without a PassTemplate + static RPI::Ptr Create(const RPI::PassDescriptor& descriptor); + + private: + explicit MSAAResolveFullScreenPass(const RPI::PassDescriptor& descriptor); + + // Pass Overrides... + bool IsEnabled() const override; + }; + } // namespace RPI +} // namespace AZ diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/MSAAResolvePass.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/MSAAResolvePass.cpp index e457cb4992..03e5be4ee6 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/MSAAResolvePass.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/MSAAResolvePass.cpp @@ -11,6 +11,7 @@ */ #include +#include #include #include @@ -76,5 +77,17 @@ namespace AZ void MSAAResolvePass::BuildCommandListInternal([[maybe_unused]] const RHI::FrameGraphExecuteContext& context) { } + + bool MSAAResolvePass::IsEnabled() const + { + // check Pass base class first to see if the Pass is explicitly disabled + if (!Pass::IsEnabled()) + { + return false; + } + + // check render pipeline MSAA sample count + return (m_pipeline->GetRenderSettings().m_multisampleState.m_samples > 1); + } } // namespace RPI } // namespace AZ diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/PassFactory.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/PassFactory.cpp index 90df206a3d..e96ce25844 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/PassFactory.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/PassFactory.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -67,6 +68,7 @@ namespace AZ AddPassCreator(Name("FullScreenTriangle"), &FullscreenTrianglePass::Create); AddPassCreator(Name("ComputePass"), &ComputePass::Create); AddPassCreator(Name("MSAAResolvePass"), &MSAAResolvePass::Create); + AddPassCreator(Name("MSAAResolveFullScreenPass"), &MSAAResolveFullScreenPass::Create); AddPassCreator(Name("DownsampleMipChainPass"), &DownsampleMipChainPass::Create); AddPassCreator(Name("EnvironmentCubeMapPass"), &EnvironmentCubeMapPass::Create); AddPassCreator(Name("RenderToTexturePass"), &RenderToTexturePass::Create); diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/MSAAResolveFullScreenPass.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/MSAAResolveFullScreenPass.cpp new file mode 100644 index 0000000000..bb2d8d6a21 --- /dev/null +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/MSAAResolveFullScreenPass.cpp @@ -0,0 +1,44 @@ +/* +* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or +* its licensors. +* +* For complete copyright and license terms please see the LICENSE at the root of this +* distribution (the "License"). All use of this software is governed by the License, +* or, if provided, by the license below or the license accompanying this file. Do not +* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* +*/ + +#include +#include +#include + +namespace AZ +{ + namespace RPI + { + RPI::Ptr MSAAResolveFullScreenPass::Create(const RPI::PassDescriptor& descriptor) + { + RPI::Ptr pass = aznew MSAAResolveFullScreenPass(descriptor); + return AZStd::move(pass); + } + + MSAAResolveFullScreenPass::MSAAResolveFullScreenPass(const RPI::PassDescriptor& descriptor) + : RPI::FullscreenTrianglePass(descriptor) + { + } + + bool MSAAResolveFullScreenPass::IsEnabled() const + { + // check Pass base class first to see if the Pass is explicitly disabled + if (!Pass::IsEnabled()) + { + return false; + } + + // check render pipeline MSAA sample count + return (m_pipeline->GetRenderSettings().m_multisampleState.m_samples > 1); + } + } // namespace RPI +} // namespace AZ diff --git a/Gems/Atom/RPI/Code/atom_rpi_public_files.cmake b/Gems/Atom/RPI/Code/atom_rpi_public_files.cmake index 6461edd291..108b2c9caf 100644 --- a/Gems/Atom/RPI/Code/atom_rpi_public_files.cmake +++ b/Gems/Atom/RPI/Code/atom_rpi_public_files.cmake @@ -78,6 +78,7 @@ set(FILES Include/Atom/RPI.Public/Pass/Specific/DownsampleMipChainPass.h Include/Atom/RPI.Public/Pass/Specific/ImageAttachmentPreviewPass.h Include/Atom/RPI.Public/Pass/Specific/EnvironmentCubeMapPass.h + Include/Atom/RPI.Public/Pass/Specific/MSAAResolveFullScreenPass.h Include/Atom/RPI.Public/Pass/Specific/RenderToTexturePass.h Include/Atom/RPI.Public/Pass/Specific/SelectorPass.h Include/Atom/RPI.Public/Pass/Specific/SwapChainPass.h @@ -153,6 +154,7 @@ set(FILES Source/RPI.Public/Pass/Specific/DownsampleMipChainPass.cpp Source/RPI.Public/Pass/Specific/ImageAttachmentPreviewPass.cpp Source/RPI.Public/Pass/Specific/EnvironmentCubeMapPass.cpp + Source/RPI.Public/Pass/Specific/MSAAResolveFullScreenPass.cpp Source/RPI.Public/Pass/Specific/RenderToTexturePass.cpp Source/RPI.Public/Pass/Specific/SelectorPass.cpp Source/RPI.Public/Pass/Specific/SwapChainPass.cpp