DiffuseProbeGridBorderUpdatePass.h 2.9 KB

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