3
0

ProfilerSystemComponent.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 <CpuProfiler.h>
  10. #include <AzCore/Component/Component.h>
  11. #include <AzCore/Debug/ProfilerBus.h>
  12. #include <AzCore/std/parallel/thread.h>
  13. namespace Profiler
  14. {
  15. class ProfilerSystemComponent
  16. : public AZ::Component
  17. , protected AZ::Debug::ProfilerRequests
  18. {
  19. public:
  20. AZ_COMPONENT(ProfilerSystemComponent, "{3f52c1d7-d920-4781-8ed7-88077ec4f305}");
  21. static void Reflect(AZ::ReflectContext* context);
  22. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
  23. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
  24. static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
  25. static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
  26. ProfilerSystemComponent();
  27. ~ProfilerSystemComponent();
  28. protected:
  29. // AZ::Component interface implementation
  30. void Activate() override;
  31. void Deactivate() override;
  32. // ProfilerRequests interface implementation
  33. bool IsActive() const override;
  34. void SetActive(bool active) override;
  35. bool CaptureFrame(const AZStd::string& outputFilePath) override;
  36. bool StartCapture(AZStd::string outputFilePath) override;
  37. bool EndCapture() override;
  38. bool IsCaptureInProgress() const override;
  39. AZStd::thread m_cpuDataSerializationThread;
  40. AZStd::atomic_bool m_cpuDataSerializationInProgress{ false };
  41. AZStd::atomic_bool m_cpuCaptureInProgress{ false };
  42. CpuProfiler m_cpuProfiler;
  43. AZStd::string m_captureFile;
  44. };
  45. } // namespace Profiler