From f09aa788d79d36688bcfdd3b49b92367590c5f16 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Tue, 2 Apr 2013 10:01:21 +0100 Subject: DRI2GetMSC: Do not send a bogus ust for when the drawable is not displayed According to the opengl glx_sync_control spec, the Unadjusted System Time (or UST) is a 64-bit monotonically increasing counter that is available throughout the system: http://www.opengl.org/registry/specs/OML/glx_sync_control.txt Therefore, sending 0, even in this corner case, is out of spec. However, we cannot just return FALSE here as that triggers a BadDrawable error to be sent, and as is often the case mishandled, to the client. This results in a certain compositor terminating, for example. As an alternative we can use the monotonic system timestamp which in theory should also be monotonic with the previous and subsequent vblank times. Based on a patch by Daniel Kurtz. Reported-by: Daniel Kurtz Signed-off-by: Chris Wilson --- src/intel_dri.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/intel_dri.c') diff --git a/src/intel_dri.c b/src/intel_dri.c index f3512034..8f279216 100644 --- a/src/intel_dri.c +++ b/src/intel_dri.c @@ -1326,6 +1326,16 @@ blit_fallback: return TRUE; } +static uint64_t gettime_us(void) +{ + struct timespec tv; + + if (clock_gettime(CLOCK_MONOTONIC, &tv)) + return 0; + + return (uint64_t)tv.tv_sec * 1000000 + tv.tv_nsec / 1000; +} + /* * Get current frame count and frame count timestamp, based on drawable's * crtc. @@ -1339,9 +1349,9 @@ I830DRI2GetMSC(DrawablePtr draw, CARD64 *ust, CARD64 *msc) drmVBlank vbl; int ret, pipe = I830DRI2DrawablePipe(draw); - /* Drawable not displayed, make up a value */ + /* Drawable not displayed, make up a *monotonic* value */ if (pipe == -1) { - *ust = 0; + *ust = gettime_us(); *msc = 0; return TRUE; } -- cgit v1.2.3