MSAAResolvePass.cpp 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <Atom/RPI.Public/Pass/MSAAResolvePass.h>
  9. #include <Atom/RPI.Public/RenderPipeline.h>
  10. #include <Atom/RPI.Reflect/Pass/PassTemplate.h>
  11. #include <Atom/RPI.Reflect/Shader/ShaderAsset.h>
  12. #include <Atom/RHI/DrawItem.h>
  13. #include <Atom/RHI/Factory.h>
  14. #include <Atom/RHI/FrameScheduler.h>
  15. #include <Atom/RHI/PipelineState.h>
  16. #include <AzCore/Asset/AssetCommon.h>
  17. #include <AzCore/Asset/AssetManagerBus.h>
  18. namespace AZ
  19. {
  20. namespace RPI
  21. {
  22. Ptr<MSAAResolvePass> MSAAResolvePass::Create(const PassDescriptor& descriptor)
  23. {
  24. Ptr<MSAAResolvePass> pass = aznew MSAAResolvePass(descriptor);
  25. return pass;
  26. }
  27. MSAAResolvePass::MSAAResolvePass(const PassDescriptor& descriptor)
  28. : RenderPass(descriptor)
  29. {
  30. }
  31. void MSAAResolvePass::BuildInternal()
  32. {
  33. AZ_Assert(GetOutputCount() != 0, "MSAAResolvePass %s has no outputs to render to.", GetPathName().GetCStr());
  34. }
  35. void MSAAResolvePass::FrameBeginInternal(FramePrepareParams params)
  36. {
  37. RenderPass::FrameBeginInternal(params);
  38. }
  39. void MSAAResolvePass::SetupFrameGraphDependencies(RHI::FrameGraphInterface frameGraph)
  40. {
  41. // Manually declare attachments since the resolve attachment is not supported by RenderPass
  42. AZ_Assert(GetInputCount() == 1, "MSAAResolvePass only supports a single Input");
  43. AZ_Assert(GetOutputCount() == 1, "MSAAResolvePass only supports a single Output");
  44. const AZ::RPI::PassAttachmentBinding& copySource = GetInputBinding(0);
  45. const AZ::RPI::PassAttachmentBinding& copyDest = GetOutputBinding(0);
  46. frameGraph.UseColorAttachment(copySource.m_unifiedScopeDesc.GetAsImage());
  47. RHI::ResolveScopeAttachmentDescriptor descriptor;
  48. descriptor.m_attachmentId = copyDest.GetAttachment()->GetAttachmentId();
  49. descriptor.m_loadStoreAction.m_loadAction = RHI::AttachmentLoadAction::DontCare;
  50. descriptor.m_resolveAttachmentId = copySource.GetAttachment()->GetAttachmentId();
  51. frameGraph.UseResolveAttachment(descriptor);
  52. RenderPass::AddScopeQueryToFrameGraph(frameGraph);
  53. }
  54. void MSAAResolvePass::CompileResources([[maybe_unused]] const RHI::FrameGraphCompileContext& context)
  55. {
  56. }
  57. void MSAAResolvePass::BuildCommandListInternal([[maybe_unused]] const RHI::FrameGraphExecuteContext& context)
  58. {
  59. }
  60. bool MSAAResolvePass::IsEnabled() const
  61. {
  62. // check Pass base class first to see if the Pass is explicitly disabled
  63. if (!Pass::IsEnabled())
  64. {
  65. return false;
  66. }
  67. // check render pipeline MSAA sample count
  68. return (m_pipeline->GetRenderSettings().m_multisampleState.m_samples > 1);
  69. }
  70. } // namespace RPI
  71. } // namespace AZ