DepthOfFieldWriteFocusDepthFromGpuPass.cpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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/RHI/CommandList.h>
  9. #include <PostProcessing/DepthOfFieldWriteFocusDepthFromGpuPass.h>
  10. namespace AZ
  11. {
  12. namespace Render
  13. {
  14. RPI::Ptr<DepthOfFieldWriteFocusDepthFromGpuPass> DepthOfFieldWriteFocusDepthFromGpuPass::Create(const RPI::PassDescriptor& descriptor)
  15. {
  16. RPI::Ptr<DepthOfFieldWriteFocusDepthFromGpuPass> pass = aznew DepthOfFieldWriteFocusDepthFromGpuPass(descriptor);
  17. return pass;
  18. }
  19. DepthOfFieldWriteFocusDepthFromGpuPass::DepthOfFieldWriteFocusDepthFromGpuPass(const RPI::PassDescriptor& descriptor)
  20. : RPI::ComputePass(descriptor)
  21. {
  22. }
  23. void DepthOfFieldWriteFocusDepthFromGpuPass::CompileResources(const RHI::FrameGraphCompileContext& context)
  24. {
  25. AZ_Assert(m_shaderResourceGroup != nullptr, "%s has a null shader resource group when calling Compile.", GetPathName().GetCStr());
  26. m_shaderResourceGroup->SetConstant(m_autoFocusScreenPositionIndex, m_autoFocusScreenPosition);
  27. m_shaderResourceGroup->SetBufferView(
  28. m_autoFocusDataBufferIndex, m_bufferRef->GetBufferView());
  29. BindPassSrg(context, m_shaderResourceGroup);
  30. m_shaderResourceGroup->Compile();
  31. }
  32. void DepthOfFieldWriteFocusDepthFromGpuPass::SetScreenPosition(const AZ::Vector2& screenPosition)
  33. {
  34. m_autoFocusScreenPosition = screenPosition;
  35. }
  36. void DepthOfFieldWriteFocusDepthFromGpuPass::SetBufferRef(RPI::Ptr<RPI::Buffer> bufferRef)
  37. {
  38. m_bufferRef = bufferRef;
  39. }
  40. void DepthOfFieldWriteFocusDepthFromGpuPass::BuildInternal()
  41. {
  42. AZ_Assert(m_bufferRef != nullptr, "%s has a null buffer when calling BuildInternal.", GetPathName().GetCStr());
  43. AttachBufferToSlot(Name("DofDepthInputOutput"), m_bufferRef);
  44. }
  45. } // namespace Render
  46. } // namespace AZ