fix: add opengl drift correction for gpu zones#1394
Conversation
488c519 to
17afcee
Compare
|
|
Thank you, good catch. I suppose there's two options:
|
|
I don't think you would find any. Making this opt-in should be ok. |
We could switch this over to a glQueryCounter maybe? the drift fix wouldn't be perfect (since it would be delayed at worst to a couple frames?) but could still be better than default? I'll try it out and report back. Otherwise, happy to put the synchronous version behind a opt-in config. You know better than I, would that be best as a compiler flag or is there a better way to handle this config? |
|
Compiler flag, like the other existing config options. |
17afcee to
9bb3f10
Compare
|
For anyone else reading this in the future: So yea, I'll go with synchronous but behind a compiler flag. |
9bb3f10 to
e2ac8f7
Compare
| \subparagraph{Calibrated context} | ||
|
|
||
| By default, the OpenGL context is uncalibrated: the CPU and GPU clocks are aligned only once, when the context is created, so over long captures the two time domains may drift apart (section~\ref{options} describes correcting this drift manually). Defining \texttt{TRACY\_OPENGL\_AUTO\_CALIBRATION} before including \texttt{TracyOpenGL.hpp} enables periodic recalibration instead: roughly once per second Tracy samples the GPU and CPU clocks together and emits a calibration event, allowing the profiler to track and remove the drift automatically. | ||
|
|
||
| This is opt-in because OpenGL exposes no atomic CPU+GPU timestamp query (unlike Vulkan's \texttt{VK\_EXT\_calibrated\_timestamps} or Direct3D~12, whose contexts are always calibrated). Recalibration therefore reads the GPU clock with \texttt{glGetInteger64v(GL\_TIMESTAMP)}, which forces a CPU/GPU synchronization (a pipeline stall) each time it runs. Enable it only when the improved long-capture alignment is worth the periodic stall. | ||
|
|
There was a problem hiding this comment.
feel free to edit the position/content of this to match y'alls standards - not sure if worth mentioning vulkan here for example.
|
Please also add a line in |

Fixes #1393
Description
Implements opengl drift correction using the existing api (similar to vulkan and d3d12).
Screenshots
Before
(no clock drift correction applied):


Later:
After:
Later:

AI Disclosure
Implemented via Claude Code, tested by me.