summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrank Richter <[email protected]>2017-08-14 16:05:22 +0200
committerEmil Velikov <[email protected]>2017-08-19 01:46:08 +0100
commite452ed26ff2272d12e1b8c435cb4fc24949627ff (patch)
tree8cff78b091871e5e5efcabdd32e970f45c4d2ef6
parentc7c6ba44ca50a2ff7a6cbb0bdf48c03fab323eaf (diff)
st/wgl: check for negative delta in wait_swap_interval()
This can happen because of rollover. See bug report for details. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=102241 Cc: [email protected] Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Jose Fonseca <[email protected]> (cherry picked from commit d90e05ad487e9fe7e17c293814ac8549d9d686d8)
-rw-r--r--src/gallium/state_trackers/wgl/stw_framebuffer.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/gallium/state_trackers/wgl/stw_framebuffer.c b/src/gallium/state_trackers/wgl/stw_framebuffer.c
index 321fbb6ea77..06b5c8da3c2 100644
--- a/src/gallium/state_trackers/wgl/stw_framebuffer.c
+++ b/src/gallium/state_trackers/wgl/stw_framebuffer.c
@@ -601,8 +601,11 @@ wait_swap_interval(struct stw_framebuffer *fb)
int64_t min_swap_period =
1.0e6 / stw_dev->refresh_rate * stw_dev->swap_interval;
- /* if time since last swap is less than wait period, wait */
- if (delta < min_swap_period) {
+ /* If time since last swap is less than wait period, wait.
+ * Note that it's possible for the delta to be negative because of
+ * rollover. See https://bugs.freedesktop.org/show_bug.cgi?id=102241
+ */
+ if ((delta >= 0) && (delta < min_swap_period)) {
float fudge = 1.75f; /* emperical fudge factor */
int64_t wait = (min_swap_period - delta) * fudge;
os_time_sleep(wait);