3
0

DepthOfFieldCopyFocusDepthToCpuPass.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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/CopyItem.h>
  10. #include <Atom/RHI/ScopeProducer.h>
  11. #include <Atom/RPI.Public/Pass/Pass.h>
  12. #include <Atom/RPI.Public/Buffer/Buffer.h>
  13. namespace AZ
  14. {
  15. namespace Render
  16. {
  17. //! This pass is used to read back the depth value written to the buffer.
  18. class DepthOfFieldCopyFocusDepthToCpuPass final
  19. : public RPI::Pass
  20. , public RHI::ScopeProducer
  21. {
  22. AZ_RPI_PASS(DepthOfFieldCopyFocusDepthToCpuPass);
  23. public:
  24. AZ_RTTI(DepthOfFieldCopyFocusDepthToCpuPass, "{EA00AD76-92FC-4223-AB7D-87F588AB5394}", Pass);
  25. AZ_CLASS_ALLOCATOR(DepthOfFieldCopyFocusDepthToCpuPass, SystemAllocator);
  26. //! Creates an DepthOfFieldCopyFocusDepthToCpuPass
  27. static RPI::Ptr<DepthOfFieldCopyFocusDepthToCpuPass> Create(const RPI::PassDescriptor& descriptor);
  28. ~DepthOfFieldCopyFocusDepthToCpuPass() = default;
  29. void SetBufferRef(RPI::Ptr<RPI::Buffer> bufferRef);
  30. float GetFocusDepth();
  31. private:
  32. explicit DepthOfFieldCopyFocusDepthToCpuPass(const RPI::PassDescriptor& descriptor);
  33. // Scope producer functions
  34. void SetupFrameGraphDependencies(RHI::FrameGraphInterface frameGraph) override;
  35. void CompileResources(const RHI::FrameGraphCompileContext& context) override;
  36. void BuildCommandList(const RHI::FrameGraphExecuteContext& context) override;
  37. // Pass overrides
  38. void BuildInternal() override;
  39. void FrameBeginInternal(FramePrepareParams params) override;
  40. RPI::Ptr<RPI::Buffer> m_bufferRef;
  41. Data::Instance<RPI::Buffer> m_readbackBuffer;
  42. RHI::CopyBufferDescriptor m_copyDescriptor;
  43. bool m_needsInitialize = true;
  44. };
  45. } // namespace RPI
  46. } // namespace AZ