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.

70 lines
1.4 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Real-Time Hierarchical Profiling
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef VTUNEINTERFACE_H
  8. #define VTUNEINTERFACE_H
  9. //#define VTUNE_ENABLED
  10. #ifdef VTUNE_ENABLED
  11. #include "platform.h"
  12. #include "..\thirdparty\vtune\include\ittnotify.h"
  13. class VTuneInterface
  14. {
  15. public:
  16. virtual void Init() = 0;
  17. virtual void StartFrame() = 0;
  18. virtual void EndFrame() = 0;
  19. virtual __itt_event CreateEvent( const char *name ) = 0;
  20. };
  21. // VTuneEvent implements user events. By default starts when created, stops
  22. // when out of scope. To change start behaviour set bStart = false in constructor
  23. // and call Start(). To change stop behaviour call Stop().
  24. class VTuneAutoEvent
  25. {
  26. public:
  27. VTuneAutoEvent( __itt_event vtuneEvent )
  28. {
  29. m_event = vtuneEvent;
  30. Start();
  31. }
  32. ~VTuneAutoEvent()
  33. {
  34. End();
  35. }
  36. PLATFORM_CLASS void Start();
  37. PLATFORM_CLASS void End();
  38. private:
  39. __itt_event m_event;
  40. };
  41. PLATFORM_INTERFACE VTuneInterface *g_pVTuneInterface;
  42. #define VTUNE_AUTO_EVENT( name ) \
  43. static __itt_event event_ ## name = 0; \
  44. if ( ! (event_ ## name) ) \
  45. { \
  46. event_ ## name = g_pVTuneInterface->CreateEvent( #name ); \
  47. } \
  48. VTuneAutoEvent autoEvent_ ## name ( event_ ## name );
  49. #endif
  50. #endif // VTUNEINTERFACE_H