Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
1.7 KiB

  1. //===== Copyright 1996-2005, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose: Real-Time Hierarchical Profiling
  4. //
  5. // $NoKeywords: $
  6. //===========================================================================//
  7. #include "pch_tier0.h"
  8. #include "tier0/memalloc.h"
  9. #include "tier0/valve_off.h"
  10. #include "tier0/threadtools.h"
  11. #include "vtuneinterface.h"
  12. // memdbgon must be the last include file in a .cpp file!!!
  13. #include "tier0/memdbgon.h"
  14. #ifdef VTUNE_ENABLED
  15. class VTuneInterfaceImpl : public VTuneInterface
  16. {
  17. public:
  18. VTuneInterfaceImpl()
  19. {
  20. m_pFrameDomain = NULL;
  21. }
  22. virtual void Init();
  23. virtual void StartFrame();
  24. virtual void EndFrame();
  25. virtual __itt_event CreateEvent( const char *name );
  26. private:
  27. __itt_domain* m_pFrameDomain;
  28. CThreadFastMutex m_eventCreateMutex;
  29. };
  30. VTuneInterfaceImpl g_VTuneInterface;
  31. VTuneInterface *g_pVTuneInterface = &g_VTuneInterface;
  32. /*******************************************************************************
  33. *
  34. * VTuneInterfaceImpl
  35. *
  36. *******************************************************************************/
  37. void VTuneInterfaceImpl::Init()
  38. {
  39. if ( !m_pFrameDomain )
  40. {
  41. m_pFrameDomain = __itt_domain_create( "Main" );
  42. m_pFrameDomain->flags = 1;
  43. }
  44. }
  45. void VTuneInterfaceImpl::StartFrame()
  46. {
  47. if ( m_pFrameDomain == NULL )
  48. {
  49. Init();
  50. }
  51. __itt_frame_begin_v3( m_pFrameDomain, NULL);
  52. }
  53. void VTuneInterfaceImpl::EndFrame()
  54. {
  55. __itt_frame_end_v3( m_pFrameDomain, NULL);
  56. }
  57. __itt_event VTuneInterfaceImpl::CreateEvent( const char *name )
  58. {
  59. AUTO_LOCK_FM( m_eventCreateMutex );
  60. return __itt_event_create( name, strlen( name ) );
  61. }
  62. void VTuneAutoEvent::Start()
  63. {
  64. __itt_event_start( m_event );
  65. }
  66. void VTuneAutoEvent::End()
  67. {
  68. __itt_event_end( m_event );
  69. }
  70. #endif // VTUNE_ENABLED