#1486

OpenGL ES: GPU timeline is misaligned when the GL_TIMESTAMP getter returns zero on Adreno 640

Openalasramopened 15d ago

With Tracy 0.14.1, we observed GPU zones shifted approximately 250.17 seconds ahead of their corresponding CPU submissions on an Android device. Individual GPU durations were positive and plausible, and the offset stayed nearly constant across 37,537 completed top-level GPU zones.

  • Android 11, arm64, OpenGL ES 3.2.
  • GPU: Adreno (TM) 640.
  • GL_EXT_disjoint_timer_query advertised; timestamp precision reported as 40 bits.
  • Tracy client and profiler 0.14.1; TRACY_ON_DEMAND enabled; automatic OpenGL calibration disabled.
  1. Create a GLES context with a small EGL pbuffer and make it current.
  2. Read glGetInteger64v(GL_TIMESTAMP_EXT, ...) before and after completed timestamp queries.
  3. Issue queries using glQueryCounterEXT and retrieve their results with glGetQueryObjectui64vEXT(..., GL_QUERY_RESULT_EXT, ...).
  4. Check GL errors and GL_GPU_DISJOINT_EXT throughout.

In a five-second probe, all 102 synchronous getter reads returned zero with GL_NO_ERROR. Query timestamps advanced monotonically from 813020217836 to 818016881846 ns. All disjoint checks returned zero. glGetInteger64vEXT was unavailable on this driver.

Tracy uses the synchronous getter to establish the CPU/GPU clock anchor. Accepting zero as that anchor shifts subsequent valid query timestamps into the wrong place on the CPU timeline. The observed 250-second offset depends on the timer value at initialization; it is not a universal offset. This is distinct from accumulating clock drift.

Expected behavior and proposed fix

Support a query-based clock anchor when the synchronous getter returns zero. Our downstream fallback takes eight completed query samples, brackets each submission/result pair with CPU timestamps, and selects the shortest bracket's midpoint. It reuses the next free slot in Tracy's existing query pool without advancing the ring indices. The nonzero getter path is preserved, and the same helper serves optional periodic calibration.

The probe's eight samples took 10.25 ms total; the selected bracket was 292.40 microseconds wide. All 51 subsequent mapped query timestamps over five seconds fell within their CPU submission/result brackets. The patched application also showed aligned CPU/GPU zones in the profiler. These results validate the initial alignment; they do not establish long-term drift or disjoint-event recovery.

Activity

0

No activity yet.