SMAABasePass.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. #pragma once
  9. #include <AzCore/RTTI/RTTI.h>
  10. #include <AzCore/Memory/SystemAllocator.h>
  11. #include <Atom/RHI/CommandList.h>
  12. #include <Atom/RHI/DeviceDrawItem.h>
  13. #include <Atom/RHI/ScopeProducer.h>
  14. #include <Atom/RPI.Reflect/Pass/PassName.h>
  15. #include <Atom/RPI.Public/Pass/FullscreenTrianglePass.h>
  16. #include <Atom/RPI.Public/Shader/Shader.h>
  17. #include <Atom/RPI.Public/Shader/ShaderResourceGroup.h>
  18. namespace AZ
  19. {
  20. namespace Render
  21. {
  22. //! SMAABasePass
  23. //! This pass contains data structure and method commonly used by SMAA passes implementation.
  24. class SMAABasePass
  25. : public AZ::RPI::FullscreenTrianglePass
  26. {
  27. public:
  28. AZ_RTTI(SMAABasePass, "{D879B4E8-DEDC-422D-950A-8B5341A8FD48}", AZ::RPI::FullscreenTrianglePass);
  29. AZ_CLASS_ALLOCATOR(SMAABasePass, SystemAllocator);
  30. virtual ~SMAABasePass();
  31. protected:
  32. SMAABasePass(const RPI::PassDescriptor& descriptor);
  33. // Pass behavior overrides...
  34. void InitializeInternal() override;
  35. // An interface to update pass srg.
  36. virtual void UpdateSRG() = 0;
  37. // An interface to get current shader variation option.
  38. virtual void GetCurrentShaderOption(AZ::RPI::ShaderOptionGroup& shaderOption) const = 0;
  39. void InvalidateShaderVariant();
  40. void InvalidateSRG();
  41. AZ::Vector4 CalculateRenderTargetMetrics(const RPI::PassAttachment* attachment);
  42. AZ::Vector4 m_renderTargetMetrics = AZ::Vector4(0.0f, 0.0f, 0.0f, 0.0f);
  43. private:
  44. void UpdateCurrentShaderVariant();
  45. // Scope producer functions...
  46. void CompileResources(const RHI::FrameGraphCompileContext& context) override;
  47. bool m_needToUpdateShaderVariant = false;
  48. bool m_needToUpdateSRG = true;
  49. };
  50. } // namespace Render
  51. } // namespace AZ