Skip to content

Metal (TracyMetal.hmm): GPU zones are heavily time-shifted after replacing gputime withProfiler::GetTime() (GPU no longer aligns with CPU) #1247

@Hanflipped

Description

@Hanflipped

Hi Tracy team,

I modified Tracy’s Metal integration (TracyMetal.hmm) and now GPU zone timestamps are badly misaligned with CPU zones.

I changed the Collect() logic in TracyMetal.hmm to use MTLCommandBuffer::addCompletedHandler to measure the GPU execution duration of a frame. The completion handler provides timing in CFTimeInterval

Because of that change, I replaced the original gputime timestamp source with Profiler::GetTime() (so both CPU zones and the GPU context would use the same clock). which is MemWrite(&item->gpuNewContext.gpuTime, Profiler::GetTime())

After replacing gputime with Profiler::GetTime(), GPU zones appear far earlier (many seconds, ~20s+) than they should, and they no longer line up with CPU zones, even though both are now using Profiler::GetTime()

Image

Are there recommended debugging/visualization techniques inside Tracy to diagnose CPU/GPU misalignment,I ’ve already tried many different alignment/conversion changes, but none of them had any effect
Any help or guidance would be greatly appreciated—thank you for your time

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions