RenderDocSystemComponent.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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/Component/Component.h>
  10. #include <AzCore/Module/DynamicModuleHandle.h>
  11. #include <AzCore/std/smart_ptr/unique_ptr.h>
  12. #include <Atom/RHI.Profiler/GraphicsProfilerBus.h>
  13. #include <renderdoc_app.h>
  14. namespace AZ::RHI
  15. {
  16. //! System component in charge of loading the RenderDoc library or
  17. //! connecting to it if it's already loaded. If RenderDoc is present and
  18. //! available, it registers to the GraphicsProfilerBus to provide GPU
  19. //! capture functionality using RenderDoc.
  20. class RenderDocSystemComponent final
  21. : public AZ::Component
  22. , public GraphicsProfilerBus::Handler
  23. {
  24. public:
  25. AZ_COMPONENT(RenderDocSystemComponent, "{32718E24-774B-49AD-BD1F-2079D257F3C4}");
  26. static void Reflect(AZ::ReflectContext* context);
  27. RenderDocSystemComponent() = default;
  28. ~RenderDocSystemComponent() override = default;
  29. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
  30. // AZ::Component overrides ...
  31. void Activate() override;
  32. void Deactivate() override;
  33. // GraphicsProfilerBus overrides ...
  34. void StartCapture(const AzFramework::NativeWindowHandle window) override;
  35. bool EndCapture(const AzFramework::NativeWindowHandle window) override;
  36. void TriggerCapture() override;
  37. private:
  38. RenderDocSystemComponent(const RenderDocSystemComponent&) = delete;
  39. // Function pointer for accessing the renderdoc functionality.
  40. RENDERDOC_API_1_1_2* m_renderDocApi = nullptr;
  41. AZStd::unique_ptr<AZ::DynamicModuleHandle> m_dynamicModule;
  42. };
  43. } // namespace AZ::RHI