1
0
mirror of https://github.com/wolfpld/tracy.git synced 2025-03-20 07:40:02 +08:00

Add support for QPC timer.

This commit is contained in:
Bartosz Taudul
2020-04-07 22:01:31 +02:00
parent 34b512d04b
commit b69aaf04e9
3 changed files with 24 additions and 1 deletions
+12 -1
View File
@@ -220,6 +220,7 @@ static void InitFailure( const char* msg )
static int64_t SetupHwTimer()
{
#ifndef TRACY_TIMER_QPC
uint32_t regs[4];
CpuId( regs, 0x80000001 );
if( !( regs[3] & ( 1 << 27 ) ) ) InitFailure( "CPU doesn't support RDTSCP instruction." );
@@ -229,9 +230,10 @@ static int64_t SetupHwTimer()
const char* noCheck = getenv( "TRACY_NO_INVARIANT_CHECK" );
if( !noCheck || noCheck[0] != '1' )
{
InitFailure( "CPU doesn't support invariant TSC.\nDefine TRACY_NO_INVARIANT_CHECK=1 to ignore this error, *if you know what you are doing*." );
InitFailure( "CPU doesn't support invariant TSC.\nDefine TRACY_NO_INVARIANT_CHECK=1 to ignore this error, *if you know what you are doing*.\nAlternatively you may rebuild the application with the TRACY_TIMER_QPC define to use lower resolution timer." );
}
}
#endif
return Profiler::GetTime();
}
@@ -2786,6 +2788,15 @@ void Profiler::SendCodeLocation( uint64_t ptr )
#endif
}
#if ( defined _WIN32 || defined __CYGWIN__ ) && defined TRACY_TIMER_QPC
int64_t Profiler::GetTimeQpc()
{
LARGE_INTEGER t;
QueryPerformanceCounter( &t );
return t.QuadPart;
}
#endif
}
#ifdef __cplusplus