diff --git a/Tracy.hpp b/Tracy.hpp index bcaab54c..1b75dcec 100644 --- a/Tracy.hpp +++ b/Tracy.hpp @@ -6,6 +6,11 @@ #ifndef TRACY_ENABLE +#define ZoneNamed(x) +#define ZoneNamedN(x,y) +#define ZoneNamedC(x,y) +#define ZoneNamedNC(x,y,z) + #define ZoneScoped #define ZoneScopedN(x) #define ZoneScopedC(x) @@ -32,6 +37,11 @@ #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) @@ -46,10 +56,15 @@ #include "client/TracyProfiler.hpp" #include "client/TracyScoped.hpp" -#define ZoneScoped static const tracy::SourceLocation __tracy_source_location##__LINE__ { nullptr, __FUNCTION__, __FILE__, (uint32_t)__LINE__, 0 }; tracy::ScopedZone ___tracy_scoped_zone( &__tracy_source_location##__LINE__ ); -#define ZoneScopedN( name ) static const tracy::SourceLocation __tracy_source_location##__LINE__ { name, __FUNCTION__, __FILE__, (uint32_t)__LINE__, 0 }; tracy::ScopedZone ___tracy_scoped_zone( &__tracy_source_location##__LINE__ ); -#define ZoneScopedC( color ) static const tracy::SourceLocation __tracy_source_location##__LINE__ { nullptr, __FUNCTION__, __FILE__, (uint32_t)__LINE__, color }; tracy::ScopedZone ___tracy_scoped_zone( &__tracy_source_location##__LINE__ ); -#define ZoneScopedNC( name, color ) static const tracy::SourceLocation __tracy_source_location##__LINE__ { name, __FUNCTION__, __FILE__, (uint32_t)__LINE__, color }; tracy::ScopedZone ___tracy_scoped_zone( &__tracy_source_location##__LINE__ ); +#define ZoneNamed( varname ) static const tracy::SourceLocation __tracy_source_location##__LINE__ { nullptr, __FUNCTION__, __FILE__, (uint32_t)__LINE__, 0 }; tracy::ScopedZone varname( &__tracy_source_location##__LINE__ ); +#define ZoneNamedN( varname, name ) static const tracy::SourceLocation __tracy_source_location##__LINE__ { name, __FUNCTION__, __FILE__, (uint32_t)__LINE__, 0 }; tracy::ScopedZone varname( &__tracy_source_location##__LINE__ ); +#define ZoneNamedC( varname, color ) static const tracy::SourceLocation __tracy_source_location##__LINE__ { nullptr, __FUNCTION__, __FILE__, (uint32_t)__LINE__, color }; tracy::ScopedZone varname( &__tracy_source_location##__LINE__ ); +#define ZoneNamedNC( varname, name, color ) static const tracy::SourceLocation __tracy_source_location##__LINE__ { name, __FUNCTION__, __FILE__, (uint32_t)__LINE__, color }; tracy::ScopedZone varname( &__tracy_source_location##__LINE__ ); + +#define ZoneScoped ZoneNamed( ___tracy_scoped_zone ) +#define ZoneScopedN( name ) ZoneNamedN( ___tracy_scoped_zone, name ) +#define ZoneScopedC( color ) ZoneNamedC( ___tracy_scoped_zone, color ) +#define ZoneScopedNC( name, color ) ZoneNamedNC( ___tracy_scoped_zone, name, color ) #define ZoneText( txt, size ) ___tracy_scoped_zone.Text( txt, size ); #define ZoneName( txt, size ) ___tracy_scoped_zone.Name( txt, size ); @@ -73,14 +88,24 @@ #define TracyFree( ptr ) tracy::Profiler::MemFree( ptr ); #ifdef TRACY_HAS_CALLSTACK -# define ZoneScopedS( depth ) static const tracy::SourceLocation __tracy_source_location##__LINE__ { nullptr, __FUNCTION__, __FILE__, (uint32_t)__LINE__, 0 }; tracy::ScopedZone ___tracy_scoped_zone( &__tracy_source_location##__LINE__, depth ); -# define ZoneScopedNS( name, depth ) static const tracy::SourceLocation __tracy_source_location##__LINE__ { name, __FUNCTION__, __FILE__, (uint32_t)__LINE__, 0 }; tracy::ScopedZone ___tracy_scoped_zone( &__tracy_source_location##__LINE__, depth ); -# define ZoneScopedCS( varname, color, depth ) static const tracy::SourceLocation __tracy_source_location##__LINE__ { nullptr, __FUNCTION__, __FILE__, (uint32_t)__LINE__, color }; tracy::ScopedZone ___tracy_scoped_zone( &__tracy_source_location##__LINE__, depth ); -# define ZoneScopedNCS( name, color, depth ) static const tracy::SourceLocation __tracy_source_location##__LINE__ { name, __FUNCTION__, __FILE__, (uint32_t)__LINE__, color }; tracy::ScopedZone ___tracy_scoped_zone( &__tracy_source_location##__LINE__, depth ); +# define ZoneNamedS( varname, depth ) static const tracy::SourceLocation __tracy_source_location##__LINE__ { nullptr, __FUNCTION__, __FILE__, (uint32_t)__LINE__, 0 }; tracy::ScopedZone varname( &__tracy_source_location##__LINE__, depth ); +# define ZoneNamedNS( varname, name, depth ) static const tracy::SourceLocation __tracy_source_location##__LINE__ { name, __FUNCTION__, __FILE__, (uint32_t)__LINE__, 0 }; tracy::ScopedZone varname( &__tracy_source_location##__LINE__, depth ); +# define ZoneNamedCS( varname, color, depth ) static const tracy::SourceLocation __tracy_source_location##__LINE__ { nullptr, __FUNCTION__, __FILE__, (uint32_t)__LINE__, color }; tracy::ScopedZone varname( &__tracy_source_location##__LINE__, depth ); +# define ZoneNamedNCS( varname, name, color, depth ) static const tracy::SourceLocation __tracy_source_location##__LINE__ { name, __FUNCTION__, __FILE__, (uint32_t)__LINE__, color }; tracy::ScopedZone varname( &__tracy_source_location##__LINE__, depth ); + +# define ZoneScopedS( depth ) ZoneNamedS( ___tracy_scoped_zone, depth ) +# define ZoneScopedNS( name, depth ) ZoneNamedNS( ___tracy_scoped_zone, name, depth ) +# define ZoneScopedCS( color, depth ) ZoneNamedCS( ___tracy_scoped_zone, color, depth ) +# define ZoneScopedNCS( name, color, depth ) ZoneNamedNCS( ___tracy_scoped_zone, name, color depth ) # 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 ) ZoneNamed( varname ) +# define ZoneNamedNS( varname, name, depth ) ZoneNamedN( varname, name ) +# define ZoneNamedCS( varname, color, depth ) ZoneNamedC( varname, color ) +# define ZoneNamedNCS( varname, name, color, depth ) ZoneNamedNC( varname, name, color ) + # define ZoneScopedS( depth ) ZoneScoped # define ZoneScopedNS( name, depth ) ZoneScopedN( name ) # define ZoneScopedCS( color, depth ) ZoneScopedC( color )