renderer-native: Fix page flip retry timeout calculation

It tried to add a (implicitly casted) float to a uint64_t, and due to
floating point precision issues resulted in timestamps intended to be
in the future to actually be in the past. Fix this by first casting the
delay to an uint64_t, then add it to the time stamp.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/506
This commit is contained in:
Jonas Ådahl 2019-03-22 18:54:20 +01:00
parent 4cae9b5b11
commit 40e7e5d356

View File

@ -1576,7 +1576,7 @@ retry_page_flips (gpointer user_data)
g_error_matches (error, G_IO_ERROR, G_IO_ERROR_BUSY)) g_error_matches (error, G_IO_ERROR, G_IO_ERROR_BUSY))
{ {
retry_page_flip_data->retry_time_us += retry_page_flip_data->retry_time_us +=
G_USEC_PER_SEC / crtc->current_mode->refresh_rate; (uint64_t) (G_USEC_PER_SEC / crtc->current_mode->refresh_rate);
l = l_next; l = l_next;
continue; continue;
} }
@ -1660,7 +1660,7 @@ schedule_retry_page_flip (MetaOnscreenNative *onscreen_native,
now_us = g_get_monotonic_time (); now_us = g_get_monotonic_time ();
retry_time_us = retry_time_us =
now_us + (G_USEC_PER_SEC / crtc->current_mode->refresh_rate); now_us + (uint64_t) (G_USEC_PER_SEC / crtc->current_mode->refresh_rate);
retry_page_flip_data = g_new0 (RetryPageFlipData, 1); retry_page_flip_data = g_new0 (RetryPageFlipData, 1);
retry_page_flip_data->crtc = crtc; retry_page_flip_data->crtc = crtc;