Tracking render time with multi-gpu transfers
I found good solutions for this while typing this up; still creating the issue so that I don't forget to actually implement it.
With multi gpu transfers, we currently track the render time by doing two render time queries:
- one for compositing on the primary GPU:
primary gpu end time - compositing start time
- one for copying the result to the secondary gpu:
secondary gpu end time - copy start time
However, copy start time
is almost always in between compositing start time
and primary gpu end time
, and more towards the start than towards the end. This can result in big overestimation of the actual time until rendering is complete, which negatively affects latency.
Directly just doing the desired secondary gpu end time - compositing start time
calculation is also not trivially possible, as the clocks are not compatible. As potential solutions, we could
- do a more complex render time tracking thing where we track the fence of the last render job on the CPU side. This would be renderer agnostic (working for Vulkan too), but doing it accurately would require yet another thread
- record
GL_TIME_ELAPSED
for the second job, instead of timestamps; adding that toprimary gpu end time
should effectively always yield correct results - convert all the timestamps into a common time base,
CLOCK_MONOTONIC
. This shouldn't be too complicated afaict