tracy/Tracy.hpp

142 lines
8.3 KiB
C++
Raw Normal View History

2017-09-10 18:10:20 +00:00
#ifndef __TRACY_HPP__
#define __TRACY_HPP__
#include "common/TracyColor.hpp"
2017-10-22 15:05:35 +00:00
#include "common/TracySystem.hpp"
#ifndef TRACY_ENABLE
#define ZoneNamed(x,y)
#define ZoneNamedN(x,y,z)
#define ZoneNamedC(x,y,z)
#define ZoneNamedNC(x,y,z,w)
#define ZoneScoped
#define ZoneScopedN(x)
2017-09-25 20:46:14 +00:00
#define ZoneScopedC(x)
#define ZoneScopedNC(x,y)
2017-09-25 20:46:14 +00:00
#define ZoneText(x,y)
2018-06-29 14:01:31 +00:00
#define ZoneName(x,y)
#define FrameMark
2018-08-04 13:04:18 +00:00
#define FrameMarkNamed(x)
2018-08-05 00:09:59 +00:00
#define FrameMarkStart(x)
#define FrameMarkEnd(x)
2017-10-04 13:41:02 +00:00
#define TracyLockable( type, varname ) type varname;
2017-10-12 18:00:53 +00:00
#define TracyLockableN( type, varname, desc ) type varname;
2017-12-10 20:49:45 +00:00
#define TracySharedLockable( type, varname ) type varname;
#define TracySharedLockableN( type, varname, desc ) type varname;
2017-10-04 13:41:02 +00:00
#define LockableBase( type ) type
2017-12-10 20:49:45 +00:00
#define SharedLockableBase( type ) type
#define LockMark(x) (void)x;
2017-10-04 13:41:02 +00:00
2017-10-13 00:07:03 +00:00
#define TracyPlot(x,y)
2017-10-15 11:06:20 +00:00
#define TracyMessage(x,y)
2017-10-15 11:06:49 +00:00
#define TracyMessageL(x)
2017-10-14 11:23:13 +00:00
#define TracyAlloc(x,y)
#define TracyFree(x)
#define ZoneNamedS(x,y)
#define ZoneNamedNS(x,y,z)
#define ZoneNamedCS(x,y,z)
#define ZoneNamedNCS(x,y,z,w)
#define ZoneScopedS(x)
#define ZoneScopedNS(x,y)
#define ZoneScopedCS(x,y)
#define ZoneScopedNCS(x,y,z)
2018-06-19 17:36:28 +00:00
#define TracyAllocS(x,y,z)
#define TracyFreeS(x,y)
#else
2017-10-16 19:28:38 +00:00
#include "client/TracyLock.hpp"
#include "client/TracyProfiler.hpp"
#include "client/TracyScoped.hpp"
2017-09-10 18:10:20 +00:00
#define ZoneNamed( varname, active ) static const tracy::SourceLocationData TracyConcat(__tracy_source_location,__LINE__) { nullptr, __FUNCTION__, __FILE__, (uint32_t)__LINE__, 0 }; tracy::ScopedZone varname( &TracyConcat(__tracy_source_location,__LINE__), active );
#define ZoneNamedN( varname, name, active ) static const tracy::SourceLocationData TracyConcat(__tracy_source_location,__LINE__) { name, __FUNCTION__, __FILE__, (uint32_t)__LINE__, 0 }; tracy::ScopedZone varname( &TracyConcat(__tracy_source_location,__LINE__), active );
#define ZoneNamedC( varname, color, active ) static const tracy::SourceLocationData TracyConcat(__tracy_source_location,__LINE__) { nullptr, __FUNCTION__, __FILE__, (uint32_t)__LINE__, color }; tracy::ScopedZone varname( &TracyConcat(__tracy_source_location,__LINE__), active );
#define ZoneNamedNC( varname, name, color, active ) static const tracy::SourceLocationData TracyConcat(__tracy_source_location,__LINE__) { name, __FUNCTION__, __FILE__, (uint32_t)__LINE__, color }; tracy::ScopedZone varname( &TracyConcat(__tracy_source_location,__LINE__), active );
#define ZoneScoped ZoneNamed( ___tracy_scoped_zone, true )
#define ZoneScopedN( name ) ZoneNamedN( ___tracy_scoped_zone, name, true )
#define ZoneScopedC( color ) ZoneNamedC( ___tracy_scoped_zone, color, true )
#define ZoneScopedNC( name, color ) ZoneNamedNC( ___tracy_scoped_zone, name, color, true )
#define ZoneScopedA( active ) ZoneNamed( ___tracy_scoped_zone, active )
#define ZoneScopedNA( name, active ) ZoneNamedN( ___tracy_scoped_zone, name, active )
#define ZoneScopedCA( color, active ) ZoneNamedC( ___tracy_scoped_zone, color, active )
#define ZoneScopedNCA( name, color, active ) ZoneNamedNC( ___tracy_scoped_zone, name, color, active )
2017-09-25 20:46:14 +00:00
2017-09-27 00:18:17 +00:00
#define ZoneText( txt, size ) ___tracy_scoped_zone.Text( txt, size );
2018-06-29 14:01:31 +00:00
#define ZoneName( txt, size ) ___tracy_scoped_zone.Name( txt, size );
2017-09-27 00:18:17 +00:00
#define FrameMark tracy::Profiler::SendFrameMark();
2018-08-05 00:09:59 +00:00
#define FrameMarkNamed( name ) tracy::Profiler::SendFrameMark( name, tracy::QueueType::FrameMarkMsg );
#define FrameMarkStart( name ) tracy::Profiler::SendFrameMark( name, tracy::QueueType::FrameMarkMsgStart );
#define FrameMarkEnd( name ) tracy::Profiler::SendFrameMark( name, tracy::QueueType::FrameMarkMsgEnd );
2017-09-10 18:10:20 +00:00
#define TracyLockable( type, varname ) tracy::Lockable<type> varname { [] () -> const tracy::SourceLocationData* { static const tracy::SourceLocationData srcloc { nullptr, #type " " #varname, __FILE__, __LINE__, 0 }; return &srcloc; }() };
#define TracyLockableN( type, varname, desc ) tracy::Lockable<type> varname { [] () -> const tracy::SourceLocationData* { static const tracy::SourceLocationData srcloc { nullptr, desc, __FILE__, __LINE__, 0 }; return &srcloc; }() };
#define TracySharedLockable( type, varname ) tracy::SharedLockable<type> varname { [] () -> const tracy::SourceLocationData* { static const tracy::SourceLocationData srcloc { nullptr, #type " " #varname, __FILE__, __LINE__, 0 }; return &srcloc; }() };
#define TracySharedLockableN( type, varname, desc ) tracy::SharedLockable<type> varname { [] () -> const tracy::SourceLocationData* { static const tracy::SourceLocationData srcloc { nullptr, desc, __FILE__, __LINE__, 0 }; return &srcloc; }() };
2017-10-04 13:41:02 +00:00
#define LockableBase( type ) tracy::Lockable<type>
2017-12-10 20:49:45 +00:00
#define SharedLockableBase( type ) tracy::SharedLockable<type>
#define LockMark( varname ) static const tracy::SourceLocationData __tracy_lock_location_##varname { nullptr, __FUNCTION__, __FILE__, (uint32_t)__LINE__, 0 }; varname.Mark( &__tracy_lock_location_##varname );
2017-10-04 13:41:02 +00:00
2017-10-13 00:07:03 +00:00
#define TracyPlot( name, val ) tracy::Profiler::PlotData( name, val );
2017-10-14 11:23:13 +00:00
#define TracyMessage( txt, size ) tracy::Profiler::Message( txt, size );
2017-10-15 11:06:49 +00:00
#define TracyMessageL( txt ) tracy::Profiler::Message( txt );
2017-10-14 11:23:13 +00:00
2018-03-31 19:56:05 +00:00
#define TracyAlloc( ptr, size ) tracy::Profiler::MemAlloc( ptr, size );
#define TracyFree( ptr ) tracy::Profiler::MemFree( ptr );
#ifdef TRACY_HAS_CALLSTACK
# define ZoneNamedS( varname, depth, active ) static const tracy::SourceLocationData TracyConcat(__tracy_source_location,__LINE__) { nullptr, __FUNCTION__, __FILE__, (uint32_t)__LINE__, 0 }; tracy::ScopedZone varname( &TracyConcat(__tracy_source_location,__LINE__), depth, active );
# define ZoneNamedNS( varname, name, depth, active ) static const tracy::SourceLocationData TracyConcat(__tracy_source_location,__LINE__) { name, __FUNCTION__, __FILE__, (uint32_t)__LINE__, 0 }; tracy::ScopedZone varname( &TracyConcat(__tracy_source_location,__LINE__), depth, active );
# define ZoneNamedCS( varname, color, depth, active ) static const tracy::SourceLocationData TracyConcat(__tracy_source_location,__LINE__) { nullptr, __FUNCTION__, __FILE__, (uint32_t)__LINE__, color }; tracy::ScopedZone varname( &TracyConcat(__tracy_source_location,__LINE__), depth, active );
# define ZoneNamedNCS( varname, name, color, depth, active ) static const tracy::SourceLocationData TracyConcat(__tracy_source_location,__LINE__) { name, __FUNCTION__, __FILE__, (uint32_t)__LINE__, color }; tracy::ScopedZone varname( &TracyConcat(__tracy_source_location,__LINE__), depth, active );
# define ZoneScopedS( depth ) ZoneNamedS( ___tracy_scoped_zone, depth, true )
# define ZoneScopedNS( name, depth ) ZoneNamedNS( ___tracy_scoped_zone, name, depth, true )
# define ZoneScopedCS( color, depth ) ZoneNamedCS( ___tracy_scoped_zone, color, depth, true )
# define ZoneScopedNCS( name, color, depth ) ZoneNamedNCS( ___tracy_scoped_zone, name, color depth, true )
# define ZoneScopedSA( depth, active ) ZoneNamedS( ___tracy_scoped_zone, depth, active )
# define ZoneScopedNSA( name, depth, active ) ZoneNamedNS( ___tracy_scoped_zone, name, depth, active )
# define ZoneScopedCSA( color, depth, active ) ZoneNamedCS( ___tracy_scoped_zone, color, depth, active )
# define ZoneScopedNCSA( name, color, depth, active ) ZoneNamedNCS( ___tracy_scoped_zone, name, color depth, active )
2018-06-21 22:56:01 +00:00
# define TracyAllocS( ptr, size, depth ) tracy::Profiler::MemAllocCallstack( ptr, size, depth );
# define TracyFreeS( ptr, depth ) tracy::Profiler::MemFreeCallstack( ptr, depth );
#else
# define ZoneNamedS( varname, depth, active ) ZoneNamed( varname, active )
# define ZoneNamedNS( varname, name, depth, active ) ZoneNamedN( varname, name, active )
# define ZoneNamedCS( varname, color, depth, active ) ZoneNamedC( varname, color, active )
# define ZoneNamedNCS( varname, name, color, depth, active ) ZoneNamedNC( varname, name, color, active )
# define ZoneScopedS( depth ) ZoneScoped( depth, true )
# define ZoneScopedNS( name, depth ) ZoneScopedN( name, true )
# define ZoneScopedCS( color, depth ) ZoneScopedC( color, true )
# define ZoneScopedNCS( name, color, depth ) ZoneScopedNC( name, color, true )
# define ZoneScopedSA( depth, active ) ZoneScoped( depth, active )
# define ZoneScopedNSA( name, depth, active ) ZoneScopedN( name, active )
# define ZoneScopedCSA( color, depth, active ) ZoneScopedC( color, active )
# define ZoneScopedNCSA( name, color, depth, active ) ZoneScopedNC( name, color, active )
2018-06-21 22:56:01 +00:00
# define TracyAllocS( ptr, size, depth ) TracyAlloc( ptr, size )
# define TracyFreeS( ptr, depth ) TracyFree( ptr )
#endif
2018-03-31 19:56:05 +00:00
2017-09-10 18:10:20 +00:00
#endif
#endif