Add mutex to protect Voodoo swap count and pending. Should fix hangs

sometimes changing video mode on Voodoo 3.
This commit is contained in:
SarahW 2020-11-03 21:17:29 +00:00
commit 193645a426
6 changed files with 37 additions and 6 deletions

View file

@ -531,6 +531,7 @@ skip_draw:
{
voodoo_t *voodoo_1 = voodoo->set->voodoos[1];
thread_lock_mutex(voodoo->swap_mutex);
/*Only swap if both Voodoos are waiting for buffer swap*/
if (voodoo->swap_pending && (voodoo->retrace_count > voodoo->swap_interval) &&
voodoo_1->swap_pending && (voodoo_1->retrace_count > voodoo_1->swap_interval))
@ -548,6 +549,7 @@ skip_draw:
if (voodoo_1->swap_count > 0)
voodoo_1->swap_count--;
voodoo_1->swap_pending = 0;
thread_unlock_mutex(voodoo->swap_mutex);
thread_set_event(voodoo->wake_fifo_thread);
thread_set_event(voodoo_1->wake_fifo_thread);
@ -555,21 +557,28 @@ skip_draw:
voodoo->frame_count++;
voodoo_1->frame_count++;
}
else
thread_unlock_mutex(voodoo->swap_mutex);
}
}
else
{
thread_lock_mutex(voodoo->swap_mutex);
if (voodoo->swap_pending && (voodoo->retrace_count > voodoo->swap_interval))
{
memset(voodoo->dirty_line, 1, 1024);
voodoo->retrace_count = 0;
voodoo->front_offset = voodoo->swap_offset;
if (voodoo->swap_count > 0)
voodoo->swap_count--;
voodoo->swap_pending = 0;
thread_unlock_mutex(voodoo->swap_mutex);
memset(voodoo->dirty_line, 1, 1024);
voodoo->retrace_count = 0;
thread_set_event(voodoo->wake_fifo_thread);
voodoo->frame_count++;
}
else
thread_unlock_mutex(voodoo->swap_mutex);
}
voodoo->v_retrace = 1;
}