From 01b6766519b129059d3de9dfcf92a732961272e4 Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Thu, 17 Oct 2024 16:47:41 +0100 Subject: [PATCH] vblank: be more defensive against NVIDIA There is a bug in the NVIDIA driver that it sometimes does not store msc into the pointer we passed to glXWaitVideoSyncSGI, leaving `last_msc` uninitialized. This change makes sure `last_msc` is always initialized regardless of this bug. Signed-off-by: Yuxuan Shui --- src/vblank.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/vblank.c b/src/vblank.c index 4f845222..0b1b3d0c 100644 --- a/src/vblank.c +++ b/src/vblank.c @@ -214,6 +214,8 @@ static void *sgi_video_sync_thread(void *data) { pthread_cond_signal(&args->start_cnd); pthread_mutex_unlock(&args->start_mtx); + unsigned int last_msc = 0; + pthread_mutex_lock(&self->vblank_requested_mtx); while (self->running) { if (!self->vblank_requested) { @@ -223,10 +225,9 @@ static void *sgi_video_sync_thread(void *data) { } pthread_mutex_unlock(&self->vblank_requested_mtx); - unsigned int last_msc; glXWaitVideoSyncSGI(1, 0, &last_msc); - struct timespec now; + struct timespec now = {}; clock_gettime(CLOCK_MONOTONIC, &now); atomic_store(&self->current_msc, last_msc); atomic_store(&self->current_ust,