From 41a1ac203b5fc54bb96bbbaa2c76a3b4cc370132 Mon Sep 17 00:00:00 2001 From: Pilzschaf Date: Fri, 9 Sep 2022 18:40:17 +0200 Subject: [PATCH 1/2] Added gpu calibration to the C API --- public/client/TracyProfiler.cpp | 21 +++++++++++++++++++++ public/tracy/TracyC.h | 8 ++++++++ 2 files changed, 29 insertions(+) diff --git a/public/client/TracyProfiler.cpp b/public/client/TracyProfiler.cpp index e0783825..55b92d3b 100644 --- a/public/client/TracyProfiler.cpp +++ b/public/client/TracyProfiler.cpp @@ -4219,6 +4219,16 @@ TRACY_API void ___tracy_emit_gpu_context_name( const struct ___tracy_gpu_context TracyLfqCommitC; } +TRACY_API void ___tracy_emit_gpu_calibration( const struct ___tracy_gpu_calibration_data data ) +{ + TracyLfqPrepareC( tracy::QueueType::GpuCalibration ); + tracy::MemWrite( &item->gpuCalibration.cpuTime, tracy::Profiler::GetTime() ); + tracy::MemWrite( &item->gpuCalibration.gpuTime, data.gpuTime ); + tracy::MemWrite( &item->gpuCalibration.cpuDelta, data.cpuDelta ); + tracy::MemWrite( &item->gpuCalibration.context, data.context ); + TracyLfqCommitC; +} + TRACY_API void ___tracy_emit_gpu_zone_begin_alloc_serial( const struct ___tracy_gpu_zone_begin_data data ) { auto item = tracy::Profiler::QueueSerial(); @@ -4279,6 +4289,17 @@ TRACY_API void ___tracy_emit_gpu_context_name_serial( const struct ___tracy_gpu_ tracy::Profiler::QueueSerialFinish(); } +TRACY_API void ___tracy_emit_gpu_calibration_serial( const struct ___tracy_gpu_calibration_data data ) +{ + auto item = tracy::Profiler::QueueSerial(); + tracy::MemWrite( &item->hdr.type, tracy::QueueType::GpuCalibration ); + tracy::MemWrite( &item->gpuCalibration.cpuTime, tracy::Profiler::GetTime() ); + tracy::MemWrite( &item->gpuCalibration.gpuTime, data.gpuTime ); + tracy::MemWrite( &item->gpuCalibration.cpuDelta, data.cpuDelta ); + tracy::MemWrite( &item->gpuCalibration.context, data.context ); + tracy::Profiler::QueueSerialFinish(); +} + TRACY_API int ___tracy_connected( void ) { return tracy::GetProfiler().IsConnected(); diff --git a/public/tracy/TracyC.h b/public/tracy/TracyC.h index ffcca5a1..2500bbb4 100644 --- a/public/tracy/TracyC.h +++ b/public/tracy/TracyC.h @@ -136,6 +136,12 @@ struct ___tracy_gpu_context_name_data { uint16_t len; }; +struct ___tracy_gpu_calibration_data { + int64_t gpuTime; + int64_t cpuDelta; + uint8_t context; +}; + // Some containers don't support storing const types. // This struct, as visible to user, is immutable, so treat it as if const was declared here. typedef /*const*/ struct ___tracy_c_zone_context TracyCZoneCtx; @@ -164,12 +170,14 @@ TRACY_API void ___tracy_emit_gpu_zone_end( const struct ___tracy_gpu_zone_end_da TRACY_API void ___tracy_emit_gpu_time( const struct ___tracy_gpu_time_data ); TRACY_API void ___tracy_emit_gpu_new_context( const struct ___tracy_gpu_new_context_data ); TRACY_API void ___tracy_emit_gpu_context_name( const struct ___tracy_gpu_context_name_data ); +TRACY_API void ___tracy_emit_gpu_calibration( const struct ___tracy_gpu_calibration_data ); TRACY_API void ___tracy_emit_gpu_zone_begin_alloc_serial( const struct ___tracy_gpu_zone_begin_data ); TRACY_API void ___tracy_emit_gpu_zone_end_serial( const struct ___tracy_gpu_zone_end_data data ); TRACY_API void ___tracy_emit_gpu_time_serial( const struct ___tracy_gpu_time_data ); TRACY_API void ___tracy_emit_gpu_new_context_serial( const struct ___tracy_gpu_new_context_data ); TRACY_API void ___tracy_emit_gpu_context_name_serial( const struct ___tracy_gpu_context_name_data ); +TRACY_API void ___tracy_emit_gpu_calibration_serial(const struct ___tracy_gpu_calibration_data ); TRACY_API int ___tracy_connected(void); From 823519a1dec7c3f8e7dc1aee1f53c5ff8b7a752b Mon Sep 17 00:00:00 2001 From: Pilzschaf Date: Fri, 9 Sep 2022 18:45:54 +0200 Subject: [PATCH 2/2] Fix indentation --- public/tracy/TracyC.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/tracy/TracyC.h b/public/tracy/TracyC.h index 2500bbb4..e78521c6 100644 --- a/public/tracy/TracyC.h +++ b/public/tracy/TracyC.h @@ -177,7 +177,7 @@ TRACY_API void ___tracy_emit_gpu_zone_end_serial( const struct ___tracy_gpu_zone TRACY_API void ___tracy_emit_gpu_time_serial( const struct ___tracy_gpu_time_data ); TRACY_API void ___tracy_emit_gpu_new_context_serial( const struct ___tracy_gpu_new_context_data ); TRACY_API void ___tracy_emit_gpu_context_name_serial( const struct ___tracy_gpu_context_name_data ); -TRACY_API void ___tracy_emit_gpu_calibration_serial(const struct ___tracy_gpu_calibration_data ); +TRACY_API void ___tracy_emit_gpu_calibration_serial( const struct ___tracy_gpu_calibration_data ); TRACY_API int ___tracy_connected(void);