3
0

DiffuseProbeGridBorderUpdatePass.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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/Memory/SystemAllocator.h>
  10. #include <Atom/RHI/CommandList.h>
  11. #include <Atom/RHI/ScopeProducer.h>
  12. #include <Atom/RPI.Public/Pass/RenderPass.h>
  13. #include <Atom/RPI.Public/Shader/Shader.h>
  14. namespace AZ
  15. {
  16. namespace Render
  17. {
  18. //! Compute shader that updates probe distance and irradiance borders.
  19. class DiffuseProbeGridBorderUpdatePass final
  20. : public RPI::RenderPass
  21. {
  22. public:
  23. AZ_RPI_PASS(DiffuseProbeGridBorderUpdatePass);
  24. AZ_RTTI(AZ::Render::DiffuseProbeGridBorderUpdatePass, "{31A5CCD0-CE97-4138-88DA-7BDBD38C9DC8}", RPI::RenderPass);
  25. AZ_CLASS_ALLOCATOR(DiffuseProbeGridBorderUpdatePass, SystemAllocator);
  26. virtual ~DiffuseProbeGridBorderUpdatePass() = default;
  27. static RPI::Ptr<DiffuseProbeGridBorderUpdatePass> Create(const RPI::PassDescriptor& descriptor);
  28. private:
  29. DiffuseProbeGridBorderUpdatePass(const RPI::PassDescriptor& descriptor);
  30. void LoadShader(AZStd::string shaderFilePath,
  31. Data::Instance<RPI::Shader>& shader,
  32. const RHI::PipelineState*& pipelineState,
  33. RHI::Ptr<RHI::ShaderResourceGroupLayout>& srgLayout,
  34. RHI::DispatchDirect& dispatchArgs);
  35. // Pass overrides
  36. bool IsEnabled() const override;
  37. void SetupFrameGraphDependencies(RHI::FrameGraphInterface frameGraph) override;
  38. void CompileResources(const RHI::FrameGraphCompileContext& context) override;
  39. void BuildCommandListInternal(const RHI::FrameGraphExecuteContext& context) override;
  40. void FrameEndInternal() override;
  41. // the data for submits in this pass are pre-built to properly handle submitting on multiple threads
  42. struct SubmitItem
  43. {
  44. RHI::ShaderResourceGroup* m_shaderResourceGroup = nullptr;
  45. RHI::DispatchItem m_dispatchItem;
  46. };
  47. AZStd::vector<SubmitItem> m_submitItems;
  48. // shader
  49. Data::Instance<RPI::Shader> m_rowShader;
  50. Data::Instance<RPI::Shader> m_columnShader;
  51. const RHI::PipelineState* m_rowPipelineState = nullptr;
  52. const RHI::PipelineState* m_columnPipelineState = nullptr;
  53. RHI::Ptr<RHI::ShaderResourceGroupLayout> m_rowSrgLayout;
  54. RHI::Ptr<RHI::ShaderResourceGroupLayout> m_columnSrgLayout;
  55. RHI::DispatchDirect m_rowDispatchArgs;
  56. RHI::DispatchDirect m_columnDispatchArgs;
  57. };
  58. } // namespace Render
  59. } // namespace AZ