The Voodoos now correctly lock and unlock mutexes.

This commit is contained in:
OBattler
2020-11-18 16:15:01 +01:00
parent 9fb3a3ed56
commit 889c19c650
5 changed files with 26 additions and 0 deletions

View File

@@ -450,7 +450,9 @@ static void voodoo_writel(uint32_t addr, uint32_t val, void *p)
case SST_swapbufferCMD:
voodoo->cmd_written++;
thread_wait_mutex(voodoo->swap_mutex);
voodoo->swap_count++;
thread_release_mutex(voodoo->swap_mutex);
if (voodoo->fbiInit7 & FBIINIT7_CMDFIFO_ENABLE)
return;
voodoo_queue_command(voodoo, addr | FIFO_WRITEL_REG, val);
@@ -531,7 +533,9 @@ static void voodoo_writel(uint32_t addr, uint32_t val, void *p)
if ((voodoo->fbiInit1 & FBIINIT1_VIDEO_RESET) && !(val & FBIINIT1_VIDEO_RESET))
{
voodoo->line = 0;
thread_wait_mutex(voodoo->swap_mutex);
voodoo->swap_count = 0;
thread_release_mutex(voodoo->swap_mutex);
voodoo->retrace_count = 0;
}
voodoo->fbiInit1 = (val & ~5) | (voodoo->fbiInit1 & 5);

View File

@@ -1307,7 +1307,9 @@ static void banshee_reg_writel(uint32_t addr, uint32_t val, void *p)
break;
case SST_swapPending:
thread_wait_mutex(voodoo->swap_mutex);
voodoo->swap_count++;
thread_release_mutex(voodoo->swap_mutex);
// voodoo->cmd_written++;
break;
@@ -2246,11 +2248,13 @@ static void banshee_vsync_callback(svga_t *svga)
voodoo_t *voodoo = banshee->voodoo;
voodoo->retrace_count++;
thread_wait_mutex(voodoo->swap_mutex);
if (voodoo->swap_pending && (voodoo->retrace_count > voodoo->swap_interval))
{
if (voodoo->swap_count > 0)
voodoo->swap_count--;
voodoo->swap_pending = 0;
thread_release_mutex(voodoo->swap_mutex);
memset(voodoo->dirty_line, 1, sizeof(voodoo->dirty_line));
voodoo->retrace_count = 0;
@@ -2258,6 +2262,8 @@ static void banshee_vsync_callback(svga_t *svga)
thread_set_event(voodoo->wake_fifo_thread);
voodoo->frame_count++;
}
else
thread_release_mutex(voodoo->swap_mutex);
voodoo->overlay.src_y = 0;
banshee->desktop_addr = banshee->vidDesktopStartAddr;

View File

@@ -574,6 +574,7 @@ skip_draw:
{
voodoo_t *voodoo_1 = voodoo->set->voodoos[1];
thread_wait_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))
@@ -591,6 +592,7 @@ skip_draw:
if (voodoo_1->swap_count > 0)
voodoo_1->swap_count--;
voodoo_1->swap_pending = 0;
thread_release_mutex(voodoo->swap_mutex);
thread_set_event(voodoo->wake_fifo_thread);
thread_set_event(voodoo_1->wake_fifo_thread);
@@ -598,22 +600,28 @@ skip_draw:
voodoo->frame_count++;
voodoo_1->frame_count++;
}
else
thread_release_mutex(voodoo->swap_mutex);
}
}
else
{
thread_wait_mutex(voodoo->swap_mutex);
if (voodoo->swap_pending && (voodoo->retrace_count > voodoo->swap_interval))
{
voodoo->front_offset = voodoo->swap_offset;
if (voodoo->swap_count > 0)
voodoo->swap_count--;
voodoo->swap_pending = 0;
thread_release_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_release_mutex(voodoo->swap_mutex);
}
voodoo->v_retrace = 1;
}

View File

@@ -134,6 +134,7 @@ void voodoo_wait_for_swap_complete(voodoo_t *voodoo)
thread_wait_event(voodoo->wake_fifo_thread, -1);
thread_reset_event(voodoo->wake_fifo_thread);
thread_wait_mutex(voodoo->swap_mutex);
if ((voodoo->swap_pending && voodoo->flush) || FIFO_FULL)
{
/*Main thread is waiting for FIFO to empty, so skip vsync wait and just swap*/
@@ -142,8 +143,11 @@ void voodoo_wait_for_swap_complete(voodoo_t *voodoo)
if (voodoo->swap_count > 0)
voodoo->swap_count--;
voodoo->swap_pending = 0;
thread_release_mutex(voodoo->swap_mutex);;
break;
}
else
thread_release_mutex(voodoo->swap_mutex);;
}
}

View File

@@ -100,8 +100,10 @@ void voodoo_reg_writel(uint32_t addr, uint32_t val, void *p)
if (!(val & 1))
{
banshee_set_overlay_addr(voodoo->p, voodoo->leftOverlayBuf);
thread_wait_mutex(voodoo->swap_mutex);
if (voodoo->swap_count > 0)
voodoo->swap_count--;
thread_release_mutex(voodoo->swap_mutex);
voodoo->frame_count++;
}
else if (TRIPLE_BUFFER)
@@ -146,8 +148,10 @@ void voodoo_reg_writel(uint32_t addr, uint32_t val, void *p)
{
memset(voodoo->dirty_line, 1, sizeof(voodoo->dirty_line));
voodoo->front_offset = voodoo->params.front_offset;
thread_wait_mutex(voodoo->swap_mutex);
if (voodoo->swap_count > 0)
voodoo->swap_count--;
thread_release_mutex(voodoo->swap_mutex);
}
else if (TRIPLE_BUFFER)
{