RPISystemComponent.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. /**
  9. * @file RPISystemComponent.h
  10. * @brief Contains the definition of the RPISystemComponent that will actually have ownership of
  11. * most RPI constructs and will be responsible for propagation to them as necessary
  12. */
  13. #pragma once
  14. #include <AzCore/Component/Component.h>
  15. #include <AzCore/Debug/PerformanceCollector.h>
  16. #include <Atom/RHI/RHISystemInterface.h>
  17. #include <Atom/RPI.Public/RPISystem.h>
  18. #include <Atom/RPI.Public/GpuQuery/GpuPassProfiler.h>
  19. #include <Atom/RPI.Public/XR/XRRenderingInterface.h>
  20. #include "PerformanceCVarManager.h"
  21. namespace AZ
  22. {
  23. namespace RPI
  24. {
  25. class MaterialFunctorSourceDataRegistration;
  26. /**
  27. * @brief The system level component of managing the RPI systems
  28. * @detail This class is mainly in charge of wrapping the RPISystem and
  29. * providing access to other objects that live a the same execution level.
  30. * This is the main entry point for adding GPU work to the RPI and for
  31. * controlling RPI execution.
  32. */
  33. class RPISystemComponent final
  34. : public AZ::Component
  35. , public AZ::SystemTickBus::Handler
  36. , public AZ::RHI::RHISystemNotificationBus::Handler
  37. , public XRRegisterInterface::Registrar
  38. , public PerformanceCollectorOwner::Registrar
  39. {
  40. public:
  41. AZ_COMPONENT(RPISystemComponent, "{83E301F3-7A0C-4099-B530-9342B91B1BC0}");
  42. static void Reflect(AZ::ReflectContext* context);
  43. static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
  44. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
  45. static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
  46. RPISystemComponent();
  47. ~RPISystemComponent() override;
  48. void Activate() override;
  49. void Deactivate() override;
  50. ///////////////////////////////////////////////////////////////////
  51. // IXRRegisterInterface overrides
  52. void RegisterXRInterface(XRRenderingInterface* xrSystemInterface) override;
  53. void UnRegisterXRInterface() override;
  54. ///////////////////////////////////////////////////////////////////
  55. private:
  56. RPISystemComponent(const RPISystemComponent&) = delete;
  57. // SystemTickBus overrides...
  58. void OnSystemTick() override;
  59. // RHISystemNotificationBus::Handler
  60. void OnDeviceRemoved(RHI::Device* device) override;
  61. ///////////////////////////////////////////////////////////////////
  62. // IPerformanceCollectorOwner overrides
  63. AZ::Debug::PerformanceCollector* GetPerformanceCollector() override { return m_performanceCollector.get(); }
  64. GpuPassProfiler* GetGpuPassProfiler() override { return m_gpuPassProfiler.get(); }
  65. ///////////////////////////////////////////////////////////////////
  66. ///////////////////////////////////////////////////////////////////
  67. // Performance Collection
  68. //! Returns "Graphics-<OS>-<RHI>" string, which will be part of the output filename.
  69. //! It will make it easy to keep vulkan and dx12 results side by side.
  70. AZStd::string GetLogCategory();
  71. void InitializePerformanceCollector();
  72. static constexpr AZStd::string_view PerformanceLogCategory = "Graphics";
  73. static constexpr AZStd::string_view PerformanceSpecGraphicsSimulationTime = "Graphics Simulation Time";
  74. static constexpr AZStd::string_view PerformanceSpecGraphicsRenderTime = "Graphics Render Time";
  75. static constexpr AZStd::string_view PerformanceSpecEngineCpuTime = "Engine Cpu Time";
  76. static constexpr AZStd::string_view PerformanceSpecGpuTime = "Frame Gpu Time";
  77. AZStd::unique_ptr<AZ::Debug::PerformanceCollector> m_performanceCollector;
  78. AZStd::unique_ptr<GpuPassProfiler> m_gpuPassProfiler; // Used to measure "Render Pipeline Gpu Time".
  79. ///////////////////////////////////////////////////////////////////
  80. RPISystem m_rpiSystem;
  81. RPISystemDescriptor m_rpiDescriptor;
  82. MaterialFunctorSourceDataRegistration* m_materialFunctorRegistration = nullptr;
  83. };
  84. } // namespace RPI
  85. } // namespace AZ