SuperluminalProfilerEventForwarder.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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/TickBus.h>
  10. #include <AzCore/Debug/Profiler.h>
  11. #include <AzCore/Memory/SystemAllocator.h>
  12. #include <AzCore/Name/Name.h>
  13. #include <AzCore/RTTI/RTTI.h>
  14. #include <AzCore/std/parallel/mutex.h>
  15. #include <AzCore/std/parallel/shared_mutex.h>
  16. namespace SuperluminalProfiler
  17. {
  18. //! Listen to 03DE frame/profiling events and forward them to the Superluminal profiling library
  19. class SuperluminalProfilerEventForwarder final : public AZ::Debug::Profiler
  20. {
  21. public:
  22. AZ_RTTI(SuperluminalProfilerEventForwarder, "{A05E7DC4-AB00-41BC-A739-8E58908CB84F}", AZ::Debug::Profiler);
  23. AZ_CLASS_ALLOCATOR(SuperluminalProfilerEventForwarder, AZ::SystemAllocator);
  24. SuperluminalProfilerEventForwarder() = default;
  25. ~SuperluminalProfilerEventForwarder() = default;
  26. //! Registers/un-registers the AZ::Debug::Profiler instance to the interface
  27. void Init();
  28. void Shutdown();
  29. //! AZ::Debug::Profiler overrides...
  30. void BeginRegion(const AZ::Debug::Budget* budget, const char* eventName, ...) final override;
  31. void EndRegion(const AZ::Debug::Budget* budget) final override;
  32. //! Check to see if a programmatic capture is currently in progress, implies
  33. //! that the profiler is active if returns True.
  34. bool IsContinuousCaptureInProgress() const;
  35. private:
  36. // This lock will only be contested when the SuperluminalProfilerEventForwarder's Shutdown() method has been called
  37. AZStd::shared_mutex m_shutdownMutex;
  38. bool m_initialized = false;
  39. };
  40. } // namespace SuperluminalProfiler