[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
1 changed files with 3 additions and 0 deletions

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();
}