From b2fa9e4bd739db0d0a1c6d3166e51ce59db7e256 Mon Sep 17 00:00:00 2001
From: Eidolon <furyhunter600@gmail.com>
Date: Sat, 20 Aug 2022 14:50:06 -0500
Subject: [PATCH] Don't sleep w/ fpscap 0 and vsync enabled

---
 src/d_main.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/d_main.c b/src/d_main.c
index 91a42ff140..3566e7f3d2 100644
--- a/src/d_main.c
+++ b/src/d_main.c
@@ -895,7 +895,11 @@ void D_SRB2Loop(void)
 		if (!singletics)
 		{
 			INT64 elapsed = (INT64)(finishprecise - enterprecise);
-			if (elapsed > 0 && (INT64)capbudget > elapsed)
+
+			// in the case of "match refresh rate" + vsync, don't sleep at all
+			const boolean vsync_with_match_refresh = cv_vidwait.value && cv_fpscap.value == 0;
+
+			if (elapsed > 0 && (INT64)capbudget > elapsed && !vsync_with_match_refresh)
 			{
 				I_SleepDuration(capbudget - (finishprecise - enterprecise));
 			}
-- 
GitLab