3
0

CheckerboardPass.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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/RHI.Reflect/Size.h>
  10. #include <Atom/RPI.Public/Pass/RasterPass.h>
  11. namespace AZ
  12. {
  13. namespace Render
  14. {
  15. //! Checkerboard pass renders scene to a multi-sample target with checkerboard pattern
  16. //! The checkerboard will be shifted one pixel between odd and even frames
  17. //! In this customized pass, it creates two imported attachment images to save last frame's color and depth buffer
  18. //! And it also shifts the viewport for the checkerboard pattern
  19. class CheckerboardPass final
  20. : public RPI::RasterPass
  21. {
  22. using Base = RPI::RasterPass;
  23. AZ_RPI_PASS(CheckerboardPass);
  24. public:
  25. AZ_RTTI(CheckerboardPass, "{C78A4C90-3915-4D8C-80BE-3698CF72C2C1}", Base);
  26. AZ_CLASS_ALLOCATOR(CheckerboardPass, SystemAllocator);
  27. ~CheckerboardPass() = default;
  28. static RPI::Ptr<CheckerboardPass> Create(const RPI::PassDescriptor& descriptor);
  29. Data::Instance<RPI::AttachmentImage> GetAttachmentImage(Name attachmentName, uint8_t frameOffset);
  30. protected:
  31. // Pass overrides...
  32. void FrameBeginInternal(FramePrepareParams params) override;
  33. void BuildInternal() override;
  34. void FrameEndInternal() override;
  35. private:
  36. CheckerboardPass() = delete;
  37. explicit CheckerboardPass(const RPI::PassDescriptor& descriptor);
  38. // PassAttachment name to AttachmentImages mapping
  39. // Each pass output image attachment has two AttachmentImage.
  40. // One for last frame and one for current frame. They will be used in checkerboard resolve
  41. AZStd::unordered_map<Name, AZStd::array<Data::Instance<RPI::AttachmentImage>, 2>> m_imageAttachments;
  42. uint8_t m_frameOffset = 0;
  43. };
  44. } // namespace Render
  45. } // namespace AZ