I've been adding timestamp queries to my DX12 renderer and noticed something weird. This can get long to explain so I'll try to mention as little as possible (I'll just add further information if it's deemed necessary).
In short, I noticed that I can usually safely compare timestamp results between different command lists as well as inside them and they return sensible values. However, should I compare a timestamp from a previous command list with any timestamp that was queried inside a command list that eventually barriers the back buffer into the _PRESENT state, then there's a sudden jump in timestamp towards the VSYNC expected time.
A bit of pseudocode may help explain:
<commandlist0>
Draw()
EndQuery(TIMESTAMP, 0)
Draw()
EndQuery(TIMESTAMP, 1)
</commandlist0>
<commandlist1>
Draw()
EndQuery(TIMESTAMP, 2)
</commandlist1>
<commandlist2>
Draw()
EndQuery(TIMESTAMP, 3)
Draw()
EndQuery(TIMESTAMP, 4)
Barrier(backBuffer, PRESENT_STATE)
</commandlist2>
Present(1, 0)
Now, when running on a 60Hz monitor the results (in ms) of comparing 0 to 1, 1 to 2, 2 to 3 and 3 to 4 are something along the lines of:
0.1, 0.15, 16.6, 0.1
If I move the window to a 120Hz screen the previous becomes:
0.1, 0.15, 8.1, 0.1
However, if the Present function changes to Present(0, 0) I get something like this:
0.1, 0.15, 0.12, 0.1
Can someone shed some light into this? Thanks!