mirror of
https://github.com/wolfpld/tracy
synced 2025-05-01 05:03:53 +00:00
collecting/resolving timestamps in pairs
This commit is contained in:
parent
6d04913b4a
commit
c6cc424991
@ -210,6 +210,7 @@ public:
|
|||||||
|
|
||||||
if (count >= MaxQueries)
|
if (count >= MaxQueries)
|
||||||
{
|
{
|
||||||
|
fprintf(stdout, "TracyMetal: Collect: FULL [%llu, %llu] (%d)\n", begin, latestCheckpoint, count);
|
||||||
TracyMetalPanic("Collect: too many pending timestamp queries.", return false;);
|
TracyMetalPanic("Collect: too many pending timestamp queries.", return false;);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,29 +223,54 @@ public:
|
|||||||
TracyMetalPanic("Collect: unable to resolve timestamps.", return false;);
|
TracyMetalPanic("Collect: unable to resolve timestamps.", return false;);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto i = 0; i < numResolvedTimestamps; ++i)
|
if (numResolvedTimestamps != count)
|
||||||
{
|
{
|
||||||
MTLTimestamp& timestamp = timestamps[i].timestamp;
|
fprintf(stdout, "TracyMetal: Collect: numResolvedTimestamps != count : %d != %d\n", numResolvedTimestamps, count);
|
||||||
if (timestamp == MTLCounterErrorValue)
|
}
|
||||||
|
|
||||||
|
for (auto i = 0; i < numResolvedTimestamps; i += 2)
|
||||||
|
{
|
||||||
|
static MTLTimestamp lastValidTimestamp = 0;
|
||||||
|
MTLTimestamp& t_start = timestamps[i+0].timestamp;
|
||||||
|
MTLTimestamp& t_end = timestamps[i+1].timestamp;
|
||||||
|
uint32_t k = RingIndex(begin + i);
|
||||||
|
fprintf(stdout, "TracyMetal: Collect: timestamp[%d] = %llu | timestamp[%d] = %llu | diff = %llu\n", k, t_start, k+1, t_end, (t_end - t_start));
|
||||||
|
if (t_start == MTLCounterErrorValue)
|
||||||
{
|
{
|
||||||
TracyMetalPanic("Collect: invalid timestamp: MTLCounterErrorValue (0xFF..FF).");
|
TracyMetalPanic("Collect: invalid timestamp: MTLCounterErrorValue (0xFF..FF).");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (timestamp == 0) // zero is apparently also considered "invalid"...
|
if (t_start == 0) // zero is apparently also considered "invalid"...
|
||||||
{
|
{
|
||||||
TracyMetalPanic("Collect: invalid timestamp: zero.");
|
static int HACK_retries = 0;
|
||||||
break;
|
if (++HACK_retries > 8) {
|
||||||
|
fprintf(stdout, "TracyMetal: Collect: giving up...\n", k, t_start, k+1, t_end);
|
||||||
|
t_start = t_end = lastValidTimestamp + 10;
|
||||||
|
HACK_retries = 0;
|
||||||
|
} else {
|
||||||
|
TracyMetalPanic("Collect: invalid timestamp: zero.");
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
m_previousCheckpoint += 1;
|
m_previousCheckpoint += 2;
|
||||||
uint32_t k = RingIndex(begin + i);
|
{
|
||||||
fprintf(stdout, "TracyMetal: timestamp[%d]: %llu\n", k, timestamp);
|
|
||||||
auto* item = Profiler::QueueSerial();
|
auto* item = Profiler::QueueSerial();
|
||||||
MemWrite(&item->hdr.type, QueueType::GpuTime);
|
MemWrite(&item->hdr.type, QueueType::GpuTime);
|
||||||
MemWrite(&item->gpuTime.gpuTime, static_cast<int64_t>(timestamp));
|
MemWrite(&item->gpuTime.gpuTime, static_cast<int64_t>(t_start));
|
||||||
MemWrite(&item->gpuTime.queryId, static_cast<uint16_t>(k));
|
MemWrite(&item->gpuTime.queryId, static_cast<uint16_t>(k));
|
||||||
MemWrite(&item->gpuTime.context, m_contextId);
|
MemWrite(&item->gpuTime.context, m_contextId);
|
||||||
Profiler::QueueSerialFinish();
|
Profiler::QueueSerialFinish();
|
||||||
timestamp = MTLCounterErrorValue; // "reset" timestamp
|
}
|
||||||
|
{
|
||||||
|
auto* item = Profiler::QueueSerial();
|
||||||
|
MemWrite(&item->hdr.type, QueueType::GpuTime);
|
||||||
|
MemWrite(&item->gpuTime.gpuTime, static_cast<int64_t>(t_end));
|
||||||
|
MemWrite(&item->gpuTime.queryId, static_cast<uint16_t>(k+1));
|
||||||
|
MemWrite(&item->gpuTime.context, m_contextId);
|
||||||
|
Profiler::QueueSerialFinish();
|
||||||
|
}
|
||||||
|
lastValidTimestamp = t_end;
|
||||||
|
t_start = t_end = MTLCounterErrorValue; // "reset" timestamps
|
||||||
}
|
}
|
||||||
|
|
||||||
//RecalibrateClocks(); // to account for drift
|
//RecalibrateClocks(); // to account for drift
|
||||||
|
Loading…
x
Reference in New Issue
Block a user