From d7fa39c4eb2ea8ebe9ec220deff08e7afa959332 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Fri, 16 Jun 2023 15:55:31 +0200 Subject: [PATCH] [util] Be more robust against timing weirdness when computing vblank count --- src/util/util_misc.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/util/util_misc.h b/src/util/util_misc.h index 105f0507..da56f644 100644 --- a/src/util/util_misc.h +++ b/src/util/util_misc.h @@ -36,6 +36,9 @@ namespace dxvk { */ template uint64_t computeRefreshCount(TimePoint t0, TimePoint t1, Duration refreshPeriod) { + if (t1 < t0) + return 0; + auto duration = std::chrono::duration_cast(t1 - t0); return duration.count() / refreshPeriod.count(); }