FoveatedImagePass.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 <Atom/RPI.Public/Pass/Pass.h>
  10. #include <Atom/RHI/XRRenderingInterface.h>
  11. namespace XR
  12. {
  13. static constexpr const char* const FoveatedImagePassClassName = "FoveatedImagePass";
  14. static constexpr const char* const FoveatedImagePassTemplateName = "FoveatedImagePassTemplate";
  15. static constexpr const char* const FoveatedImageSlotName = "FoveatedImageOutput";
  16. //! Custom data for the FoveatedImagePass Pass.
  17. struct FoveatedImagePassData
  18. : public AZ::RPI::PassData
  19. {
  20. AZ_RTTI(FoveatedImagePassData, "{DA97DB6D-6B41-4285-9266-8A7903887910}", AZ::RPI::PassData);
  21. AZ_CLASS_ALLOCATOR(FoveatedImagePassData, AZ::SystemAllocator);
  22. FoveatedImagePassData() = default;
  23. virtual ~FoveatedImagePassData() = default;
  24. //! Foveated level for the shading rate image
  25. AZ::RHI::XRFoveatedLevel m_foveatedLevel = AZ::RHI::XRFoveatedLevel::None;
  26. };
  27. //! This pass handles the initialization of the content of the shading rate image used
  28. //! for foveted rendering. This pass doesn't render or compute anything. It just creates the
  29. //! shading rate image (based on the pipeline output size and device capabilities) and fills it
  30. //! with the proper values depending on the foveated level. It also handles resizes of the
  31. //! pipeline output.
  32. class FoveatedImagePass : public AZ::RPI::Pass
  33. {
  34. using Base = AZ::RPI::Pass;
  35. AZ_RPI_PASS(FoveatedImagePass);
  36. public:
  37. AZ_RTTI(FoveatedImagePass, "{C4C33582-21E9-42CE-801B-BE3A1C468A72}", Base);
  38. AZ_CLASS_ALLOCATOR(FoveatedImagePass, AZ::SystemAllocator);
  39. virtual ~FoveatedImagePass() = default;
  40. /// Creates a FoveatedImagePass
  41. static AZ::RPI::Ptr<FoveatedImagePass> Create(const AZ::RPI::PassDescriptor& descriptor);
  42. private:
  43. FoveatedImagePass(const AZ::RPI::PassDescriptor& descriptor);
  44. // Pass behavior overrides...
  45. void ResetInternal() override;
  46. void BuildInternal() override;
  47. AZ::RPI::Ptr<AZ::RPI::PassAttachment> m_foveatedAttachment;
  48. AZ::Data::Instance<AZ::RPI::AttachmentImage> m_foveatedImage;
  49. AZ::RHI::XRFoveatedLevel m_foveatedLevel = AZ::RHI::XRFoveatedLevel::None;
  50. };
  51. } // namespace XR