Move TLS accesses close together.

This commit is contained in:
Bartosz Taudul 2019-06-24 19:38:44 +02:00
parent c4f0965851
commit 06a41708a7
6 changed files with 55 additions and 33 deletions

View File

@ -180,13 +180,14 @@ static tracy_force_inline void SendLuaCallstack( lua_State* L, uint32_t depth )
assert( dst - ptr == spaceNeeded + 4 ); assert( dst - ptr == spaceNeeded + 4 );
Magic magic; Magic magic;
const auto thread = GetThreadHandle();
auto token = GetToken(); auto token = GetToken();
auto& tail = token->get_tail_index(); auto& tail = token->get_tail_index();
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic ); auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
MemWrite( &item->hdr.type, QueueType::CallstackAlloc ); MemWrite( &item->hdr.type, QueueType::CallstackAlloc );
MemWrite( &item->callstackAlloc.ptr, (uint64_t)ptr ); MemWrite( &item->callstackAlloc.ptr, (uint64_t)ptr );
MemWrite( &item->callstackAlloc.nativePtr, (uint64_t)Callstack( depth ) ); MemWrite( &item->callstackAlloc.nativePtr, (uint64_t)Callstack( depth ) );
MemWrite( &item->callstackAlloc.thread, GetThreadHandle() ); MemWrite( &item->callstackAlloc.thread, thread );
tail.store( magic + 1, std::memory_order_release ); tail.store( magic + 1, std::memory_order_release );
} }
@ -227,6 +228,7 @@ static inline int LuaZoneBeginS( lua_State* L )
memcpy( ptr + 12 + fsz + 1, dbg.source, ssz + 1 ); memcpy( ptr + 12 + fsz + 1, dbg.source, ssz + 1 );
Magic magic; Magic magic;
const auto thread = GetThreadHandle();
auto token = GetToken(); auto token = GetToken();
auto& tail = token->get_tail_index(); auto& tail = token->get_tail_index();
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic ); auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
@ -238,7 +240,7 @@ static inline int LuaZoneBeginS( lua_State* L )
MemWrite( &item->zoneBegin.time, Profiler::GetTime( cpu ) ); MemWrite( &item->zoneBegin.time, Profiler::GetTime( cpu ) );
MemWrite( &item->zoneBegin.cpu, cpu ); MemWrite( &item->zoneBegin.cpu, cpu );
#endif #endif
MemWrite( &item->zoneBegin.thread, GetThreadHandle() ); MemWrite( &item->zoneBegin.thread, thread );
MemWrite( &item->zoneBegin.srcloc, (uint64_t)ptr ); MemWrite( &item->zoneBegin.srcloc, (uint64_t)ptr );
tail.store( magic + 1, std::memory_order_release ); tail.store( magic + 1, std::memory_order_release );
@ -293,6 +295,7 @@ static inline int LuaZoneBeginNS( lua_State* L )
memcpy( ptr + 12 + fsz + 1 + ssz + 1, name, nsz ); memcpy( ptr + 12 + fsz + 1 + ssz + 1, name, nsz );
Magic magic; Magic magic;
const auto thread = GetThreadHandle();
auto token = GetToken(); auto token = GetToken();
auto& tail = token->get_tail_index(); auto& tail = token->get_tail_index();
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic ); auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
@ -304,7 +307,7 @@ static inline int LuaZoneBeginNS( lua_State* L )
MemWrite( &item->zoneBegin.time, Profiler::GetTime( cpu ) ); MemWrite( &item->zoneBegin.time, Profiler::GetTime( cpu ) );
MemWrite( &item->zoneBegin.cpu, cpu ); MemWrite( &item->zoneBegin.cpu, cpu );
#endif #endif
MemWrite( &item->zoneBegin.thread, GetThreadHandle() ); MemWrite( &item->zoneBegin.thread, thread );
MemWrite( &item->zoneBegin.srcloc, (uint64_t)ptr ); MemWrite( &item->zoneBegin.srcloc, (uint64_t)ptr );
tail.store( magic + 1, std::memory_order_release ); tail.store( magic + 1, std::memory_order_release );
@ -359,6 +362,7 @@ static inline int LuaZoneBegin( lua_State* L )
memcpy( ptr + 12 + fsz + 1, dbg.source, ssz + 1 ); memcpy( ptr + 12 + fsz + 1, dbg.source, ssz + 1 );
Magic magic; Magic magic;
const auto thread = GetThreadHandle();
auto token = GetToken(); auto token = GetToken();
auto& tail = token->get_tail_index(); auto& tail = token->get_tail_index();
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic ); auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
@ -370,7 +374,7 @@ static inline int LuaZoneBegin( lua_State* L )
MemWrite( &item->zoneBegin.time, Profiler::GetTime( cpu ) ); MemWrite( &item->zoneBegin.time, Profiler::GetTime( cpu ) );
MemWrite( &item->zoneBegin.cpu, cpu ); MemWrite( &item->zoneBegin.cpu, cpu );
#endif #endif
MemWrite( &item->zoneBegin.thread, GetThreadHandle() ); MemWrite( &item->zoneBegin.thread, thread );
MemWrite( &item->zoneBegin.srcloc, (uint64_t)ptr ); MemWrite( &item->zoneBegin.srcloc, (uint64_t)ptr );
tail.store( magic + 1, std::memory_order_release ); tail.store( magic + 1, std::memory_order_release );
return 0; return 0;
@ -421,6 +425,7 @@ static inline int LuaZoneBeginN( lua_State* L )
memcpy( ptr + 12 + fsz + 1 + ssz + 1, name, nsz ); memcpy( ptr + 12 + fsz + 1 + ssz + 1, name, nsz );
Magic magic; Magic magic;
const auto thread = GetThreadHandle();
auto token = GetToken(); auto token = GetToken();
auto& tail = token->get_tail_index(); auto& tail = token->get_tail_index();
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic ); auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
@ -432,7 +437,7 @@ static inline int LuaZoneBeginN( lua_State* L )
MemWrite( &item->zoneBegin.time, Profiler::GetTime( cpu ) ); MemWrite( &item->zoneBegin.time, Profiler::GetTime( cpu ) );
MemWrite( &item->zoneBegin.cpu, cpu ); MemWrite( &item->zoneBegin.cpu, cpu );
#endif #endif
MemWrite( &item->zoneBegin.thread, GetThreadHandle() ); MemWrite( &item->zoneBegin.thread, thread );
MemWrite( &item->zoneBegin.srcloc, (uint64_t)ptr ); MemWrite( &item->zoneBegin.srcloc, (uint64_t)ptr );
tail.store( magic + 1, std::memory_order_release ); tail.store( magic + 1, std::memory_order_release );
return 0; return 0;
@ -453,6 +458,7 @@ static inline int LuaZoneEnd( lua_State* L )
#endif #endif
Magic magic; Magic magic;
const auto thread = GetThreadHandle();
auto token = GetToken(); auto token = GetToken();
auto& tail = token->get_tail_index(); auto& tail = token->get_tail_index();
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic ); auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
@ -464,7 +470,7 @@ static inline int LuaZoneEnd( lua_State* L )
MemWrite( &item->zoneEnd.time, Profiler::GetTime( cpu ) ); MemWrite( &item->zoneEnd.time, Profiler::GetTime( cpu ) );
MemWrite( &item->zoneEnd.cpu, cpu ); MemWrite( &item->zoneEnd.cpu, cpu );
#endif #endif
MemWrite( &item->zoneEnd.thread, GetThreadHandle() ); MemWrite( &item->zoneEnd.thread, thread );
tail.store( magic + 1, std::memory_order_release ); tail.store( magic + 1, std::memory_order_release );
return 0; return 0;
} }
@ -484,6 +490,7 @@ static inline int LuaZoneText( lua_State* L )
const auto size = strlen( txt ); const auto size = strlen( txt );
Magic magic; Magic magic;
const auto thread = GetThreadHandle();
auto token = GetToken(); auto token = GetToken();
auto ptr = (char*)tracy_malloc( size+1 ); auto ptr = (char*)tracy_malloc( size+1 );
memcpy( ptr, txt, size ); memcpy( ptr, txt, size );
@ -491,7 +498,7 @@ static inline int LuaZoneText( lua_State* L )
auto& tail = token->get_tail_index(); auto& tail = token->get_tail_index();
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic ); auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
MemWrite( &item->hdr.type, QueueType::ZoneText ); MemWrite( &item->hdr.type, QueueType::ZoneText );
MemWrite( &item->zoneText.thread, GetThreadHandle() ); MemWrite( &item->zoneText.thread, thread );
MemWrite( &item->zoneText.text, (uint64_t)ptr ); MemWrite( &item->zoneText.text, (uint64_t)ptr );
tail.store( magic + 1, std::memory_order_release ); tail.store( magic + 1, std::memory_order_release );
return 0; return 0;
@ -512,6 +519,7 @@ static inline int LuaZoneName( lua_State* L )
const auto size = strlen( txt ); const auto size = strlen( txt );
Magic magic; Magic magic;
const auto thread = GetThreadHandle();
auto token = GetToken(); auto token = GetToken();
auto ptr = (char*)tracy_malloc( size+1 ); auto ptr = (char*)tracy_malloc( size+1 );
memcpy( ptr, txt, size ); memcpy( ptr, txt, size );
@ -519,7 +527,7 @@ static inline int LuaZoneName( lua_State* L )
auto& tail = token->get_tail_index(); auto& tail = token->get_tail_index();
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic ); auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
MemWrite( &item->hdr.type, QueueType::ZoneName ); MemWrite( &item->hdr.type, QueueType::ZoneName );
MemWrite( &item->zoneText.thread, GetThreadHandle() ); MemWrite( &item->zoneText.thread, thread );
MemWrite( &item->zoneText.text, (uint64_t)ptr ); MemWrite( &item->zoneText.text, (uint64_t)ptr );
tail.store( magic + 1, std::memory_order_release ); tail.store( magic + 1, std::memory_order_release );
return 0; return 0;
@ -535,6 +543,7 @@ static inline int LuaMessage( lua_State* L )
const auto size = strlen( txt ); const auto size = strlen( txt );
Magic magic; Magic magic;
const auto thread = GetThreadHandle();
auto token = GetToken(); auto token = GetToken();
auto ptr = (char*)tracy_malloc( size+1 ); auto ptr = (char*)tracy_malloc( size+1 );
memcpy( ptr, txt, size ); memcpy( ptr, txt, size );
@ -543,7 +552,7 @@ static inline int LuaMessage( lua_State* L )
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic ); auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
MemWrite( &item->hdr.type, QueueType::Message ); MemWrite( &item->hdr.type, QueueType::Message );
MemWrite( &item->message.time, Profiler::GetTime() ); MemWrite( &item->message.time, Profiler::GetTime() );
MemWrite( &item->message.thread, GetThreadHandle() ); MemWrite( &item->message.thread, thread );
MemWrite( &item->message.text, (uint64_t)ptr ); MemWrite( &item->message.text, (uint64_t)ptr );
tail.store( magic + 1, std::memory_order_release ); tail.store( magic + 1, std::memory_order_release );
return 0; return 0;

View File

@ -102,13 +102,14 @@ public:
const float period = 1.f; const float period = 1.f;
Magic magic; Magic magic;
const auto thread = GetThreadHandle();
auto token = GetToken(); auto token = GetToken();
auto& tail = token->get_tail_index(); auto& tail = token->get_tail_index();
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic ); auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
MemWrite( &item->hdr.type, QueueType::GpuNewContext ); MemWrite( &item->hdr.type, QueueType::GpuNewContext );
MemWrite( &item->gpuNewContext.cpuTime, tcpu ); MemWrite( &item->gpuNewContext.cpuTime, tcpu );
MemWrite( &item->gpuNewContext.gpuTime, tgpu ); MemWrite( &item->gpuNewContext.gpuTime, tgpu );
MemWrite( &item->gpuNewContext.thread, GetThreadHandle() ); MemWrite( &item->gpuNewContext.thread, thread );
MemWrite( &item->gpuNewContext.period, period ); MemWrite( &item->gpuNewContext.period, period );
MemWrite( &item->gpuNewContext.context, m_context ); MemWrite( &item->gpuNewContext.context, m_context );
MemWrite( &item->gpuNewContext.accuracyBits, (uint8_t)bits ); MemWrite( &item->gpuNewContext.accuracyBits, (uint8_t)bits );
@ -238,9 +239,8 @@ public:
const auto queryId = GetGpuCtx().ptr->NextQueryId(); const auto queryId = GetGpuCtx().ptr->NextQueryId();
glQueryCounter( GetGpuCtx().ptr->TranslateOpenGlQueryId( queryId ), GL_TIMESTAMP ); glQueryCounter( GetGpuCtx().ptr->TranslateOpenGlQueryId( queryId ), GL_TIMESTAMP );
const auto thread = GetThreadHandle();
Magic magic; Magic magic;
const auto thread = GetThreadHandle();
auto token = GetToken(); auto token = GetToken();
auto& tail = token->get_tail_index(); auto& tail = token->get_tail_index();
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic ); auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );

View File

@ -211,13 +211,14 @@ public:
vkCmdWriteTimestamp( cmdbuf, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, ctx->m_query, queryId ); vkCmdWriteTimestamp( cmdbuf, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, ctx->m_query, queryId );
Magic magic; Magic magic;
const auto thread = GetThreadHandle();
auto token = GetToken(); auto token = GetToken();
auto& tail = token->get_tail_index(); auto& tail = token->get_tail_index();
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic ); auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
MemWrite( &item->hdr.type, QueueType::GpuZoneBegin ); MemWrite( &item->hdr.type, QueueType::GpuZoneBegin );
MemWrite( &item->gpuZoneBegin.cpuTime, Profiler::GetTime() ); MemWrite( &item->gpuZoneBegin.cpuTime, Profiler::GetTime() );
MemWrite( &item->gpuZoneBegin.srcloc, (uint64_t)srcloc ); MemWrite( &item->gpuZoneBegin.srcloc, (uint64_t)srcloc );
MemWrite( &item->gpuZoneBegin.thread, GetThreadHandle() ); MemWrite( &item->gpuZoneBegin.thread, thread );
MemWrite( &item->gpuZoneBegin.queryId, uint16_t( queryId ) ); MemWrite( &item->gpuZoneBegin.queryId, uint16_t( queryId ) );
MemWrite( &item->gpuZoneBegin.context, ctx->GetId() ); MemWrite( &item->gpuZoneBegin.context, ctx->GetId() );
tail.store( magic + 1, std::memory_order_release ); tail.store( magic + 1, std::memory_order_release );
@ -233,12 +234,12 @@ public:
#ifdef TRACY_ON_DEMAND #ifdef TRACY_ON_DEMAND
if( !m_active ) return; if( !m_active ) return;
#endif #endif
const auto thread = GetThreadHandle();
const auto queryId = ctx->NextQueryId(); const auto queryId = ctx->NextQueryId();
vkCmdWriteTimestamp( cmdbuf, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, ctx->m_query, queryId ); vkCmdWriteTimestamp( cmdbuf, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, ctx->m_query, queryId );
Magic magic; Magic magic;
const auto thread = GetThreadHandle();
auto token = GetToken(); auto token = GetToken();
auto& tail = token->get_tail_index(); auto& tail = token->get_tail_index();
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic ); auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );

View File

@ -124,12 +124,13 @@ public:
#endif #endif
Magic magic; Magic magic;
const auto thread = GetThreadHandle();
auto token = GetToken(); auto token = GetToken();
auto& tail = token->get_tail_index(); auto& tail = token->get_tail_index();
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic ); auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
MemWrite( &item->hdr.type, QueueType::LockRelease ); MemWrite( &item->hdr.type, QueueType::LockRelease );
MemWrite( &item->lockRelease.id, m_id ); MemWrite( &item->lockRelease.id, m_id );
MemWrite( &item->lockRelease.thread, GetThreadHandle() ); MemWrite( &item->lockRelease.thread, thread );
MemWrite( &item->lockRelease.time, Profiler::GetTime() ); MemWrite( &item->lockRelease.time, Profiler::GetTime() );
tail.store( magic + 1, std::memory_order_release ); tail.store( magic + 1, std::memory_order_release );
} }
@ -156,12 +157,13 @@ public:
if( ret ) if( ret )
{ {
Magic magic; Magic magic;
const auto thread = GetThreadHandle();
auto token = GetToken(); auto token = GetToken();
auto& tail = token->get_tail_index(); auto& tail = token->get_tail_index();
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic ); auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
MemWrite( &item->hdr.type, QueueType::LockObtain ); MemWrite( &item->hdr.type, QueueType::LockObtain );
MemWrite( &item->lockObtain.id, m_id ); MemWrite( &item->lockObtain.id, m_id );
MemWrite( &item->lockObtain.thread, GetThreadHandle() ); MemWrite( &item->lockObtain.thread, thread );
MemWrite( &item->lockObtain.time, Profiler::GetTime() ); MemWrite( &item->lockObtain.time, Profiler::GetTime() );
tail.store( magic + 1, std::memory_order_release ); tail.store( magic + 1, std::memory_order_release );
} }
@ -183,12 +185,13 @@ public:
#endif #endif
Magic magic; Magic magic;
const auto thread = GetThreadHandle();
auto token = GetToken(); auto token = GetToken();
auto& tail = token->get_tail_index(); auto& tail = token->get_tail_index();
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic ); auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
MemWrite( &item->hdr.type, QueueType::LockMark ); MemWrite( &item->hdr.type, QueueType::LockMark );
MemWrite( &item->lockMark.id, m_id ); MemWrite( &item->lockMark.id, m_id );
MemWrite( &item->lockMark.thread, GetThreadHandle() ); MemWrite( &item->lockMark.thread, thread );
MemWrite( &item->lockMark.srcloc, (uint64_t)srcloc ); MemWrite( &item->lockMark.srcloc, (uint64_t)srcloc );
tail.store( magic + 1, std::memory_order_release ); tail.store( magic + 1, std::memory_order_release );
} }
@ -317,12 +320,13 @@ public:
#endif #endif
Magic magic; Magic magic;
const auto thread = GetThreadHandle();
auto token = GetToken(); auto token = GetToken();
auto& tail = token->get_tail_index(); auto& tail = token->get_tail_index();
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic ); auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
MemWrite( &item->hdr.type, QueueType::LockRelease ); MemWrite( &item->hdr.type, QueueType::LockRelease );
MemWrite( &item->lockRelease.id, m_id ); MemWrite( &item->lockRelease.id, m_id );
MemWrite( &item->lockRelease.thread, GetThreadHandle() ); MemWrite( &item->lockRelease.thread, thread );
MemWrite( &item->lockRelease.time, Profiler::GetTime() ); MemWrite( &item->lockRelease.time, Profiler::GetTime() );
tail.store( magic + 1, std::memory_order_release ); tail.store( magic + 1, std::memory_order_release );
} }
@ -349,12 +353,13 @@ public:
if( ret ) if( ret )
{ {
Magic magic; Magic magic;
const auto thread = GetThreadHandle();
auto token = GetToken(); auto token = GetToken();
auto& tail = token->get_tail_index(); auto& tail = token->get_tail_index();
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic ); auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
MemWrite( &item->hdr.type, QueueType::LockObtain ); MemWrite( &item->hdr.type, QueueType::LockObtain );
MemWrite( &item->lockObtain.id, m_id ); MemWrite( &item->lockObtain.id, m_id );
MemWrite( &item->lockObtain.thread, GetThreadHandle() ); MemWrite( &item->lockObtain.thread, thread );
MemWrite( &item->lockObtain.time, Profiler::GetTime() ); MemWrite( &item->lockObtain.time, Profiler::GetTime() );
tail.store( magic + 1, std::memory_order_release ); tail.store( magic + 1, std::memory_order_release );
} }
@ -424,12 +429,13 @@ public:
#endif #endif
Magic magic; Magic magic;
const auto thread = GetThreadHandle();
auto token = GetToken(); auto token = GetToken();
auto& tail = token->get_tail_index(); auto& tail = token->get_tail_index();
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic ); auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
MemWrite( &item->hdr.type, QueueType::LockSharedRelease ); MemWrite( &item->hdr.type, QueueType::LockSharedRelease );
MemWrite( &item->lockRelease.id, m_id ); MemWrite( &item->lockRelease.id, m_id );
MemWrite( &item->lockRelease.thread, GetThreadHandle() ); MemWrite( &item->lockRelease.thread, thread );
MemWrite( &item->lockRelease.time, Profiler::GetTime() ); MemWrite( &item->lockRelease.time, Profiler::GetTime() );
tail.store( magic + 1, std::memory_order_release ); tail.store( magic + 1, std::memory_order_release );
} }
@ -456,12 +462,13 @@ public:
if( ret ) if( ret )
{ {
Magic magic; Magic magic;
const auto thread = GetThreadHandle();
auto token = GetToken(); auto token = GetToken();
auto& tail = token->get_tail_index(); auto& tail = token->get_tail_index();
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic ); auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
MemWrite( &item->hdr.type, QueueType::LockSharedObtain ); MemWrite( &item->hdr.type, QueueType::LockSharedObtain );
MemWrite( &item->lockObtain.id, m_id ); MemWrite( &item->lockObtain.id, m_id );
MemWrite( &item->lockObtain.thread, GetThreadHandle() ); MemWrite( &item->lockObtain.thread, thread );
MemWrite( &item->lockObtain.time, Profiler::GetTime() ); MemWrite( &item->lockObtain.time, Profiler::GetTime() );
tail.store( magic + 1, std::memory_order_release ); tail.store( magic + 1, std::memory_order_release );
} }
@ -483,12 +490,13 @@ public:
#endif #endif
Magic magic; Magic magic;
const auto thread = GetThreadHandle();
auto token = GetToken(); auto token = GetToken();
auto& tail = token->get_tail_index(); auto& tail = token->get_tail_index();
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic ); auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
MemWrite( &item->hdr.type, QueueType::LockMark ); MemWrite( &item->hdr.type, QueueType::LockMark );
MemWrite( &item->lockMark.id, m_id ); MemWrite( &item->lockMark.id, m_id );
MemWrite( &item->lockMark.thread, GetThreadHandle() ); MemWrite( &item->lockMark.thread, thread );
MemWrite( &item->lockMark.srcloc, (uint64_t)srcloc ); MemWrite( &item->lockMark.srcloc, (uint64_t)srcloc );
tail.store( magic + 1, std::memory_order_release ); tail.store( magic + 1, std::memory_order_release );
} }

View File

@ -492,8 +492,8 @@ LONG WINAPI CrashFilter( PEXCEPTION_POINTERS pExp )
} }
{ {
const auto thread = GetThreadHandle();
Magic magic; Magic magic;
const auto thread = GetThreadHandle();
auto token = GetToken(); auto token = GetToken();
auto& tail = token->get_tail_index(); auto& tail = token->get_tail_index();
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic ); auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
@ -730,8 +730,8 @@ static void CrashHandler( int signal, siginfo_t* info, void* /*ucontext*/ )
} }
{ {
const auto thread = GetThreadHandle();
Magic magic; Magic magic;
const auto thread = GetThreadHandle();
auto token = GetToken(); auto token = GetToken();
auto& tail = token->get_tail_index(); auto& tail = token->get_tail_index();
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic ); auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
@ -2065,11 +2065,11 @@ TracyCZoneCtx ___tracy_emit_zone_begin( const struct ___tracy_source_location_da
ctx.active = active; ctx.active = active;
#endif #endif
if( !ctx.active ) return ctx; if( !ctx.active ) return ctx;
const auto thread = tracy::GetThreadHandle();
const auto id = tracy::GetProfiler().GetNextZoneId(); const auto id = tracy::GetProfiler().GetNextZoneId();
ctx.id = id; ctx.id = id;
tracy::Magic magic; tracy::Magic magic;
const auto thread = tracy::GetThreadHandle();
auto token = tracy::GetToken(); auto token = tracy::GetToken();
auto& tail = token->get_tail_index(); auto& tail = token->get_tail_index();
#ifndef TRACY_NO_VERIFY #ifndef TRACY_NO_VERIFY
@ -2107,11 +2107,11 @@ TracyCZoneCtx ___tracy_emit_zone_begin_callstack( const struct ___tracy_source_l
ctx.active = active; ctx.active = active;
#endif #endif
if( !ctx.active ) return ctx; if( !ctx.active ) return ctx;
const auto thread = tracy::GetThreadHandle();
const auto id = tracy::GetProfiler().GetNextZoneId(); const auto id = tracy::GetProfiler().GetNextZoneId();
ctx.id = id; ctx.id = id;
tracy::Magic magic; tracy::Magic magic;
const auto thread = tracy::GetThreadHandle();
auto token = tracy::GetToken(); auto token = tracy::GetToken();
auto& tail = token->get_tail_index(); auto& tail = token->get_tail_index();
#ifndef TRACY_NO_VERIFY #ifndef TRACY_NO_VERIFY
@ -2145,8 +2145,8 @@ TracyCZoneCtx ___tracy_emit_zone_begin_callstack( const struct ___tracy_source_l
void ___tracy_emit_zone_end( TracyCZoneCtx ctx ) void ___tracy_emit_zone_end( TracyCZoneCtx ctx )
{ {
if( !ctx.active ) return; if( !ctx.active ) return;
const auto thread = tracy::GetThreadHandle();
tracy::Magic magic; tracy::Magic magic;
const auto thread = tracy::GetThreadHandle();
auto token = tracy::GetToken(); auto token = tracy::GetToken();
auto& tail = token->get_tail_index(); auto& tail = token->get_tail_index();
#ifndef TRACY_NO_VERIFY #ifndef TRACY_NO_VERIFY
@ -2176,8 +2176,8 @@ void ___tracy_emit_zone_end( TracyCZoneCtx ctx )
void ___tracy_emit_zone_text( TracyCZoneCtx ctx, const char* txt, size_t size ) void ___tracy_emit_zone_text( TracyCZoneCtx ctx, const char* txt, size_t size )
{ {
if( !ctx.active ) return; if( !ctx.active ) return;
const auto thread = tracy::GetThreadHandle();
tracy::Magic magic; tracy::Magic magic;
const auto thread = tracy::GetThreadHandle();
auto token = tracy::GetToken(); auto token = tracy::GetToken();
auto ptr = (char*)tracy::tracy_malloc( size+1 ); auto ptr = (char*)tracy::tracy_malloc( size+1 );
memcpy( ptr, txt, size ); memcpy( ptr, txt, size );
@ -2204,8 +2204,8 @@ void ___tracy_emit_zone_text( TracyCZoneCtx ctx, const char* txt, size_t size )
void ___tracy_emit_zone_name( TracyCZoneCtx ctx, const char* txt, size_t size ) void ___tracy_emit_zone_name( TracyCZoneCtx ctx, const char* txt, size_t size )
{ {
if( !ctx.active ) return; if( !ctx.active ) return;
const auto thread = tracy::GetThreadHandle();
tracy::Magic magic; tracy::Magic magic;
const auto thread = tracy::GetThreadHandle();
auto token = tracy::GetToken(); auto token = tracy::GetToken();
auto ptr = (char*)tracy::tracy_malloc( size+1 ); auto ptr = (char*)tracy::tracy_malloc( size+1 );
memcpy( ptr, txt, size ); memcpy( ptr, txt, size );

View File

@ -251,6 +251,7 @@ public:
if( !GetProfiler().IsConnected() ) return; if( !GetProfiler().IsConnected() ) return;
#endif #endif
Magic magic; Magic magic;
const auto thread = GetThreadHandle();
auto token = GetToken(); auto token = GetToken();
auto ptr = (char*)tracy_malloc( size+1 ); auto ptr = (char*)tracy_malloc( size+1 );
memcpy( ptr, txt, size ); memcpy( ptr, txt, size );
@ -259,7 +260,7 @@ public:
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic ); auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
MemWrite( &item->hdr.type, QueueType::Message ); MemWrite( &item->hdr.type, QueueType::Message );
MemWrite( &item->message.time, GetTime() ); MemWrite( &item->message.time, GetTime() );
MemWrite( &item->message.thread, GetThreadHandle() ); MemWrite( &item->message.thread, thread );
MemWrite( &item->message.text, (uint64_t)ptr ); MemWrite( &item->message.text, (uint64_t)ptr );
tail.store( magic + 1, std::memory_order_release ); tail.store( magic + 1, std::memory_order_release );
} }
@ -270,12 +271,13 @@ public:
if( !GetProfiler().IsConnected() ) return; if( !GetProfiler().IsConnected() ) return;
#endif #endif
Magic magic; Magic magic;
const auto thread = GetThreadHandle();
auto token = GetToken(); auto token = GetToken();
auto& tail = token->get_tail_index(); auto& tail = token->get_tail_index();
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic ); auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
MemWrite( &item->hdr.type, QueueType::MessageLiteral ); MemWrite( &item->hdr.type, QueueType::MessageLiteral );
MemWrite( &item->message.time, GetTime() ); MemWrite( &item->message.time, GetTime() );
MemWrite( &item->message.thread, GetThreadHandle() ); MemWrite( &item->message.thread, thread );
MemWrite( &item->message.text, (uint64_t)txt ); MemWrite( &item->message.text, (uint64_t)txt );
tail.store( magic + 1, std::memory_order_release ); tail.store( magic + 1, std::memory_order_release );
} }
@ -286,6 +288,7 @@ public:
if( !GetProfiler().IsConnected() ) return; if( !GetProfiler().IsConnected() ) return;
#endif #endif
Magic magic; Magic magic;
const auto thread = GetThreadHandle();
auto token = GetToken(); auto token = GetToken();
auto ptr = (char*)tracy_malloc( size+1 ); auto ptr = (char*)tracy_malloc( size+1 );
memcpy( ptr, txt, size ); memcpy( ptr, txt, size );
@ -294,7 +297,7 @@ public:
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic ); auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
MemWrite( &item->hdr.type, QueueType::MessageColor ); MemWrite( &item->hdr.type, QueueType::MessageColor );
MemWrite( &item->messageColor.time, GetTime() ); MemWrite( &item->messageColor.time, GetTime() );
MemWrite( &item->messageColor.thread, GetThreadHandle() ); MemWrite( &item->messageColor.thread, thread );
MemWrite( &item->messageColor.text, (uint64_t)ptr ); MemWrite( &item->messageColor.text, (uint64_t)ptr );
MemWrite( &item->messageColor.r, uint8_t( ( color ) & 0xFF ) ); MemWrite( &item->messageColor.r, uint8_t( ( color ) & 0xFF ) );
MemWrite( &item->messageColor.g, uint8_t( ( color >> 8 ) & 0xFF ) ); MemWrite( &item->messageColor.g, uint8_t( ( color >> 8 ) & 0xFF ) );
@ -308,12 +311,13 @@ public:
if( !GetProfiler().IsConnected() ) return; if( !GetProfiler().IsConnected() ) return;
#endif #endif
Magic magic; Magic magic;
const auto thread = GetThreadHandle();
auto token = GetToken(); auto token = GetToken();
auto& tail = token->get_tail_index(); auto& tail = token->get_tail_index();
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic ); auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
MemWrite( &item->hdr.type, QueueType::MessageLiteralColor ); MemWrite( &item->hdr.type, QueueType::MessageLiteralColor );
MemWrite( &item->messageColor.time, GetTime() ); MemWrite( &item->messageColor.time, GetTime() );
MemWrite( &item->messageColor.thread, GetThreadHandle() ); MemWrite( &item->messageColor.thread, thread );
MemWrite( &item->messageColor.text, (uint64_t)txt ); MemWrite( &item->messageColor.text, (uint64_t)txt );
MemWrite( &item->messageColor.r, uint8_t( ( color ) & 0xFF ) ); MemWrite( &item->messageColor.r, uint8_t( ( color ) & 0xFF ) );
MemWrite( &item->messageColor.g, uint8_t( ( color >> 8 ) & 0xFF ) ); MemWrite( &item->messageColor.g, uint8_t( ( color >> 8 ) & 0xFF ) );