Reverted BX_LOCK/BX_UNLOCK changes from previous commit (don't lock CMDFIFO

completely while running cmdfifo_process()). The donut demo is now a little bit
slower on Linux host, but other test cases are faster again.
This commit is contained in:
Volker Ruppert 2017-08-17 17:15:12 +00:00
parent fcb5f6d1d3
commit 6361386e8b
2 changed files with 10 additions and 2 deletions

View File

@ -166,19 +166,19 @@ BX_THREAD_FUNC(cmdfifo_thread, indata)
while (1) {
#ifdef WIN32
if (WaitForSingleObject(v->fbi.cmdfifo[0].event, 1) == WAIT_OBJECT_0) {
BX_LOCK(cmdfifo_mutex);
while (v->fbi.cmdfifo[0].enable && (v->fbi.cmdfifo[0].depth >= v->fbi.cmdfifo[0].depth_needed)) {
cmdfifo_process();
}
BX_LOCK(cmdfifo_mutex);
v->fbi.cmdfifo[0].cmd_ready = 0;
BX_UNLOCK(cmdfifo_mutex);
}
#else
while (!v->fbi.cmdfifo[0].event) BX_MSLEEP(1);
BX_LOCK(cmdfifo_mutex);
while (v->fbi.cmdfifo[0].enable && (v->fbi.cmdfifo[0].depth >= v->fbi.cmdfifo[0].depth_needed)) {
cmdfifo_process();
}
BX_LOCK(cmdfifo_mutex);
v->fbi.cmdfifo[0].cmd_ready = 0;
v->fbi.cmdfifo[0].event = 0;
BX_UNLOCK(cmdfifo_mutex);
@ -614,7 +614,9 @@ void bx_voodoo_c::vertical_timer_handler(void *this_ptr)
#ifdef WIN32
SetEvent(v->fbi.cmdfifo[0].event);
#else
BX_LOCK(cmdfifo_mutex);
v->fbi.cmdfifo[0].event = 1;
BX_UNLOCK(cmdfifo_mutex);
#endif
}

View File

@ -2406,7 +2406,9 @@ Bit32u cmdfifo_calc_depth_needed(void)
if (v->fbi.cmdfifo[0].depth == 0)
return needed;
BX_LOCK(cmdfifo_mutex);
command = *(Bit32u*)(&v->fbi.ram[v->fbi.cmdfifo[0].rdptr & v->fbi.mask]);
BX_UNLOCK(cmdfifo_mutex);
type = (Bit8u)(command & 0x07);
switch (type) {
case 0:
@ -2461,7 +2463,9 @@ void cmdfifo_w(Bit32u fbi_offset, Bit32u data)
*(Bit32u*)(&v->fbi.ram[fbi_offset]) = data;
v->fbi.cmdfifo[0].depth++;
if (v->fbi.cmdfifo[0].depth_needed == BX_MAX_BIT32U) {
BX_UNLOCK(cmdfifo_mutex);
v->fbi.cmdfifo[0].depth_needed = cmdfifo_calc_depth_needed();
BX_LOCK(cmdfifo_mutex);
}
if (v->fbi.cmdfifo[0].depth >= v->fbi.cmdfifo[0].depth_needed) {
v->fbi.cmdfifo[0].cmd_ready = 1;
@ -2473,9 +2477,11 @@ Bit32u cmdfifo_r(void)
{
Bit32u data;
BX_LOCK(cmdfifo_mutex);
data = *(Bit32u*)(&v->fbi.ram[v->fbi.cmdfifo[0].rdptr & v->fbi.mask]);
v->fbi.cmdfifo[0].rdptr += 4;
v->fbi.cmdfifo[0].depth--;
BX_UNLOCK(cmdfifo_mutex);
return data;
}