mirror of
https://github.com/wolfpld/tracy.git
synced 2026-08-24 20:18:21 +00:00
Show counter name in GUI
This commit is contained in:
@@ -1581,7 +1581,12 @@ void View::DrawGpuInfoWindow()
|
||||
|
||||
TextFocused( "Query ID:", RealToString(ev.query_id) );
|
||||
for (int i = 0; i < ev.note_count; i++ ) {
|
||||
TextFocused( RealToString(ev.note_ids[i]), RealToString(ev.note_vals[i]) );
|
||||
auto id = ev.note_ids[i];
|
||||
if (ctx->notes.count(id)) {
|
||||
TextFocused( m_worker.GetString( ctx->notes.at(id) ), RealToString(ev.note_vals[i]) );
|
||||
} else {
|
||||
TextFocused( RealToString(ev.note_ids[i]), RealToString(ev.note_vals[i]) );
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
@@ -2053,7 +2058,12 @@ void View::ZoneTooltip( const GpuEvent& ev )
|
||||
|
||||
TextFocused( "Query ID:", RealToString(ev.query_id) );
|
||||
for (int i = 0; i < ev.note_count; i++ ) {
|
||||
TextFocused( RealToString(ev.note_ids[i]), RealToString(ev.note_vals[i]) );
|
||||
auto id = ev.note_ids[i];
|
||||
if (ctx->notes.count(id)) {
|
||||
TextFocused( m_worker.GetString( ctx->notes.at(id) ), RealToString(ev.note_vals[i]) );
|
||||
} else {
|
||||
TextFocused( RealToString(ev.note_ids[i]), RealToString(ev.note_vals[i]) );
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::EndTooltip();
|
||||
|
||||
@@ -2358,6 +2358,10 @@ static void FreeAssociatedMemory( const QueueItem& item )
|
||||
tracy_free( (void*)ptr );
|
||||
break;
|
||||
#endif
|
||||
case QueueType::GpuAnnotationName:
|
||||
ptr = MemRead<uint64_t>( &item.gpuAnnotationNameFat.ptr );
|
||||
tracy_free( (void*)ptr );
|
||||
break;
|
||||
#ifdef TRACY_ON_DEMAND
|
||||
case QueueType::MessageAppInfo:
|
||||
case QueueType::GpuContextName:
|
||||
@@ -2573,6 +2577,12 @@ Profiler::DequeueStatus Profiler::Dequeue( moodycamel::ConsumerToken& token )
|
||||
tracy_free_fast( (void*)ptr );
|
||||
#endif
|
||||
break;
|
||||
case QueueType::GpuAnnotationName:
|
||||
ptr = MemRead<uint64_t>( &item->gpuAnnotationNameFat.ptr );
|
||||
size = MemRead<uint16_t>( &item->gpuAnnotationNameFat.size );
|
||||
SendSingleString( (const char*)ptr, size );
|
||||
tracy_free_fast( (void*)ptr );
|
||||
break;
|
||||
case QueueType::PlotDataInt:
|
||||
case QueueType::PlotDataFloat:
|
||||
case QueueType::PlotDataDouble:
|
||||
@@ -2931,6 +2941,14 @@ Profiler::DequeueStatus Profiler::DequeueSerial()
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
case QueueType::GpuAnnotationName:
|
||||
{
|
||||
ptr = MemRead<uint64_t>( &item->gpuAnnotationNameFat.ptr );
|
||||
uint16_t size = MemRead<uint16_t>( &item->gpuAnnotationNameFat.size );
|
||||
SendSingleString( (const char*)ptr, size );
|
||||
tracy_free_fast( (void*)ptr );
|
||||
break;
|
||||
}
|
||||
#ifdef TRACY_FIBERS
|
||||
case QueueType::ZoneBegin:
|
||||
case QueueType::ZoneBeginCallstack:
|
||||
|
||||
@@ -263,7 +263,6 @@ record_callback(rocprofiler_dispatch_counting_service_data_t dispatch_data,
|
||||
ROCPROFILER_CALL(rocprofiler_query_record_counter_id(record_data[0].id, &_counter_id),
|
||||
"query record counter id");
|
||||
tracy::MemWrite(&item->zoneAnnotation.noteId, _counter_id.handle);
|
||||
fprintf(stderr, "note %lu\n", _counter_id.handle);
|
||||
tracy::MemWrite(&item->zoneAnnotation.queryId, query_id);
|
||||
tracy::MemWrite(&item->zoneAnnotation.value, sum);
|
||||
tracy::MemWrite(&item->zoneAnnotation.context, data->context_id);
|
||||
@@ -351,6 +350,19 @@ dispatch_callback(rocprofiler_dispatch_counting_service_data_t dispatch_data,
|
||||
{
|
||||
std::clog << "Counter: " << counter.handle << " " << info.name << "\n";
|
||||
collect_counters.push_back(counter);
|
||||
|
||||
size_t name_length = strlen(info.name);
|
||||
char* cloned_name = (char*)tracy::tracy_malloc(name_length);
|
||||
memcpy(cloned_name, info.name, name_length);
|
||||
{
|
||||
auto* item = tracy::Profiler::QueueSerial();
|
||||
tracy::MemWrite(&item->hdr.type, tracy::QueueType::GpuAnnotationName);
|
||||
tracy::MemWrite(&item->gpuAnnotationNameFat.context, data->context_id);
|
||||
tracy::MemWrite(&item->gpuAnnotationNameFat.noteId, counter.handle);
|
||||
tracy::MemWrite(&item->gpuAnnotationNameFat.ptr, (uint64_t)cloned_name);
|
||||
tracy::MemWrite(&item->gpuAnnotationNameFat.size, name_length);
|
||||
tracy::Profiler::QueueSerialFinish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -61,6 +61,7 @@ enum class QueueType : uint8_t
|
||||
ThreadWakeup,
|
||||
GpuTime,
|
||||
GpuContextName,
|
||||
GpuAnnotationName,
|
||||
CallstackFrameSize,
|
||||
SymbolInformation,
|
||||
ExternalNameMetadata,
|
||||
@@ -488,6 +489,18 @@ struct QueueGpuContextNameFat : public QueueGpuContextName
|
||||
uint16_t size;
|
||||
};
|
||||
|
||||
struct QueueGpuAnnotationName
|
||||
{
|
||||
int64_t noteId;
|
||||
uint8_t context;
|
||||
};
|
||||
|
||||
struct QueueGpuAnnotationNameFat : public QueueGpuAnnotationName
|
||||
{
|
||||
uint64_t ptr;
|
||||
uint16_t size;
|
||||
};
|
||||
|
||||
struct QueueMemNamePayload
|
||||
{
|
||||
uint64_t name;
|
||||
@@ -765,6 +778,8 @@ struct QueueItem
|
||||
QueueGpuTimeSync gpuTimeSync;
|
||||
QueueGpuContextName gpuContextName;
|
||||
QueueGpuContextNameFat gpuContextNameFat;
|
||||
QueueGpuAnnotationName gpuAnnotationName;
|
||||
QueueGpuAnnotationNameFat gpuAnnotationNameFat;
|
||||
QueueMemAlloc memAlloc;
|
||||
QueueMemFree memFree;
|
||||
QueueMemDiscard memDiscard;
|
||||
@@ -859,6 +874,7 @@ static constexpr size_t QueueDataSize[] = {
|
||||
sizeof( QueueHeader ) + sizeof( QueueThreadWakeup ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueGpuTime ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueGpuContextName ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueGpuAnnotationName ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueCallstackFrameSize ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueSymbolInformation ),
|
||||
sizeof( QueueHeader ), // ExternalNameMetadata - not for wire transfer
|
||||
|
||||
@@ -778,6 +778,7 @@ struct GpuCtxData
|
||||
uint32_t overflowMul;
|
||||
StringIdx name;
|
||||
unordered_flat_map<uint64_t, GpuCtxThreadData> threadData;
|
||||
unordered_flat_map<int64_t, StringIdx> notes;
|
||||
short_ptr<GpuEvent> query[64*1024];
|
||||
};
|
||||
|
||||
|
||||
@@ -1105,6 +1105,15 @@ Worker::Worker( FileRead& f, EventType::Type eventMask, bool bgTasks, bool allow
|
||||
auto ctx = m_slab.AllocInit<GpuCtxData>();
|
||||
uint8_t calibration;
|
||||
f.Read7( ctx->thread, calibration, ctx->count, ctx->period, ctx->type, ctx->name, ctx->overflow );
|
||||
uint64_t notesz;
|
||||
f.Read( notesz );
|
||||
for ( uint64_t i=0; i<notesz; i++ )
|
||||
{
|
||||
decltype(ctx->notes)::key_type key;
|
||||
decltype(ctx->notes)::mapped_type value;
|
||||
f.Read2( key, value );
|
||||
ctx->notes[key] = value;
|
||||
}
|
||||
ctx->hasCalibration = calibration;
|
||||
ctx->hasPeriod = ctx->period != 1.f;
|
||||
m_data.gpuCnt += ctx->count;
|
||||
@@ -4622,6 +4631,9 @@ bool Worker::Process( const QueueItem& ev )
|
||||
case QueueType::GpuContextName:
|
||||
ProcessGpuContextName( ev.gpuContextName );
|
||||
break;
|
||||
case QueueType::GpuAnnotationName:
|
||||
ProcessGpuAnnotationName( ev.gpuAnnotationName );
|
||||
break;
|
||||
case QueueType::GpuZoneAnnotation:
|
||||
ProcessGpuZoneAnnotation( ev.zoneAnnotation );
|
||||
break;
|
||||
@@ -6017,6 +6029,14 @@ void Worker::ProcessGpuContextName( const QueueGpuContextName& ev )
|
||||
ctx->name = StringIdx( idx );
|
||||
}
|
||||
|
||||
void Worker::ProcessGpuAnnotationName( const QueueGpuAnnotationName& ev )
|
||||
{
|
||||
auto ctx = m_gpuCtxMap[ev.context];
|
||||
assert( ctx );
|
||||
const auto idx = GetSingleStringIdx();
|
||||
ctx->notes[ev.noteId] = StringIdx( idx );
|
||||
}
|
||||
|
||||
void Worker::ProcessGpuZoneAnnotation( const QueueGpuZoneAnnotation& ev )
|
||||
{
|
||||
auto ctx = m_gpuCtxMap[ev.context];
|
||||
@@ -6031,6 +6051,9 @@ void Worker::ProcessGpuZoneAnnotation( const QueueGpuZoneAnnotation& ev )
|
||||
zone->note_ids[zone->note_count] = ev.noteId;
|
||||
zone->note_vals[zone->note_count] = ev.value;
|
||||
zone->note_count++;
|
||||
|
||||
if (ctx->notes.contains(ev.noteId))
|
||||
fprintf(stderr, "%s: %f\n", GetString(ctx->notes[ev.noteId]), ev.value);
|
||||
}
|
||||
|
||||
MemEvent* Worker::ProcessMemAllocImpl( MemData& memdata, const QueueMemAlloc& ev )
|
||||
@@ -8149,6 +8172,13 @@ void Worker::Write( FileWrite& f, bool fiDict )
|
||||
f.Write( &ctx->type, sizeof( ctx->type ) );
|
||||
f.Write( &ctx->name, sizeof( ctx->name ) );
|
||||
f.Write( &ctx->overflow, sizeof( ctx->overflow ) );
|
||||
sz = ctx->notes.size();
|
||||
f.Write( &sz, sizeof( sz ) );
|
||||
for( auto& p : ctx->notes )
|
||||
{
|
||||
f.Write( &p.first, sizeof( p.first ) );
|
||||
f.Write( &p.second, sizeof( p.second ) );
|
||||
}
|
||||
sz = ctx->threadData.size();
|
||||
f.Write( &sz, sizeof( sz ) );
|
||||
for( auto& td : ctx->threadData )
|
||||
|
||||
@@ -740,6 +740,7 @@ private:
|
||||
tracy_force_inline void ProcessGpuCalibration( const QueueGpuCalibration& ev );
|
||||
tracy_force_inline void ProcessGpuTimeSync( const QueueGpuTimeSync& ev );
|
||||
tracy_force_inline void ProcessGpuContextName( const QueueGpuContextName& ev );
|
||||
tracy_force_inline void ProcessGpuAnnotationName( const QueueGpuAnnotationName& ev );
|
||||
tracy_force_inline void ProcessGpuZoneAnnotation( const QueueGpuZoneAnnotation& ev );
|
||||
tracy_force_inline MemEvent* ProcessMemAlloc( const QueueMemAlloc& ev );
|
||||
tracy_force_inline MemEvent* ProcessMemAllocNamed( const QueueMemAlloc& ev );
|
||||
|
||||
Reference in New Issue
Block a user