Skip to content

Commit

Permalink
vblank: be more defensive against NVIDIA
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
yshui committed Oct 17, 2024
1 parent daaefc0 commit 2fa4f2d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/vblank.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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,
Expand Down

0 comments on commit 2fa4f2d

Please sign in to comment.