1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-04 16:24:29 +01:00

[util] Be more robust against timing weirdness when computing vblank count

This commit is contained in:
Philip Rebohle 2023-06-16 15:55:31 +02:00
parent d1e39be7e7
commit d7fa39c4eb

View File

@ -36,6 +36,9 @@ namespace dxvk {
*/
template<typename TimePoint, typename Duration>
uint64_t computeRefreshCount(TimePoint t0, TimePoint t1, Duration refreshPeriod) {
if (t1 < t0)
return 0;
auto duration = std::chrono::duration_cast<Duration>(t1 - t0);
return duration.count() / refreshPeriod.count();
}