+ /* GPU time drifts due to being relative times, not absolute and can be
+ * affected by the gpu switch between processes.
+ *
+ * To attempt to compensate we resynchronise on frame end however there is
+ * still noticeable drift within a single frame which we do not account for.
+ */
+ if (retrace::profilingCpuTimes || retrace::profilingGpuTimes) {
+ int64_t cpuTime, gpuTime, error;
+
+ getCurrentTimes(cpuTime, gpuTime);
+ cpuTime = cpuTime - retrace::profiler.getBaseCpuTime();
+ gpuTime = gpuTime - retrace::profiler.getBaseGpuTime();
+ error = gpuTime - cpuTime;
+
+ retrace::profiler.setBaseGpuTime(retrace::profiler.getBaseGpuTime() + error);
+ }
+