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 <yshuiv7@gmail.com>
  • Loading branch information
yshui committed Oct 17, 2024
1 parent e65ebd7 commit 01b6766
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

1 comment on commit 01b6766

@yshui
Copy link
Owner Author

@yshui yshui commented on 01b6766 Oct 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cubanismo hi, since you said in the past we can ping you, i am taking you up on that :)

so yeah, basically what the commit message says, glXWaitVideoSyncSGI sometimes does not store into count pointer, generally this happens when the monitor is turned off. could this be a nvidia driver bug?

would appreciate if you can have a look.

Please sign in to comment.