DiffuseProbeGridRayTracingPass.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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/ScopeProducer.h>
  10. #include <Atom/RPI.Public/Pass/RenderPass.h>
  11. #include <Atom/RPI.Public/Buffer/Buffer.h>
  12. #include <Atom/RHI/RayTracingBufferPools.h>
  13. #include <Atom/RHI/RayTracingPipelineState.h>
  14. #include <Atom/RHI/RayTracingShaderTable.h>
  15. #include <Atom/RPI.Public/RPIUtils.h>
  16. #include <Atom/RPI.Public/Shader/ShaderResourceGroup.h>
  17. #include <Render/DiffuseProbeGrid.h>
  18. namespace AZ
  19. {
  20. namespace Render
  21. {
  22. constexpr uint32_t MaxRecursionDepth = 16;
  23. //! Ray tracing shader that generates probe radiance values.
  24. class DiffuseProbeGridRayTracingPass final
  25. : public RPI::RenderPass
  26. {
  27. public:
  28. AZ_RPI_PASS(DiffuseProbeGridRayTracingPass);
  29. AZ_RTTI(DiffuseProbeGridRayTracingPass, "{CB0DF817-3D07-4AC7-8574-F5EE529B8DCA}", RPI::RenderPass);
  30. AZ_CLASS_ALLOCATOR(DiffuseProbeGridRayTracingPass, SystemAllocator);
  31. //! Creates a DiffuseProbeGridRayTracingPass
  32. static RPI::Ptr<DiffuseProbeGridRayTracingPass> Create(const RPI::PassDescriptor& descriptor);
  33. private:
  34. explicit DiffuseProbeGridRayTracingPass(const RPI::PassDescriptor& descriptor);
  35. void CreateRayTracingPipelineState();
  36. // Scope producer functions
  37. void SetupFrameGraphDependencies(RHI::FrameGraphInterface frameGraph) override;
  38. void CompileResources(const RHI::FrameGraphCompileContext& context) override;
  39. void BuildCommandListInternal(const RHI::FrameGraphExecuteContext& context) override;
  40. // Pass overrides
  41. bool IsEnabled() const override;
  42. void BuildInternal() override;
  43. void FrameBeginInternal(FramePrepareParams params) override;
  44. // revision number of the ray tracing TLAS when the shader table was built
  45. uint32_t m_rayTracingRevision = 0;
  46. // ray tracing shader and pipeline state
  47. Data::Instance<RPI::Shader> m_rayTracingShader;
  48. Data::Instance<RPI::Shader> m_closestHitShader;
  49. Data::Instance<RPI::Shader> m_missShader;
  50. RHI::Ptr<RHI::RayTracingPipelineState> m_rayTracingPipelineState;
  51. // ray tracing shader table
  52. RHI::Ptr<RHI::RayTracingShaderTable> m_rayTracingShaderTable;
  53. // ray tracing global shader resource group layout and pipeline state
  54. RHI::Ptr<RHI::ShaderResourceGroupLayout> m_globalSrgLayout;
  55. RHI::ConstPtr<RHI::PipelineState> m_globalPipelineState;
  56. RHI::ShaderInputNameIndex m_maxRecursionDepthNameIndex = "m_maxRecursionDepth";
  57. };
  58. } // namespace RPI
  59. } // namespace AZ