Attempt to fix the CMDFIFO hole count feature based on the code from voodoo.h.txt.

The Voodoo2 works fine with it. With the Banshee model only the 16 bpp mode is
not usable yet. This issue needs to be investigated.
This commit is contained in:
Volker Ruppert 2017-11-30 17:24:02 +00:00
parent 01067cb4b9
commit 5698c69744
2 changed files with 38 additions and 19 deletions

View File

@ -1822,11 +1822,12 @@ void bx_voodoo_c::banshee_agp_reg_write(Bit8u reg, Bit32u value)
} else { } else {
v->fbi.cmdfifo[1].end = v->fbi.cmdfifo[1].base + (((value & 0xff) + 1) << 12); v->fbi.cmdfifo[1].end = v->fbi.cmdfifo[1].base + (((value & 0xff) + 1) << 12);
} }
v->fbi.cmdfifo[fifo_idx].enabled = ((value >> 8) & 1); v->fbi.cmdfifo[fifo_idx].count_holes = (((value >> 10) & 1) == 0);
if (((value >> 10) & 1) == 0) { if (v->fbi.cmdfifo[fifo_idx].enabled != ((value >> 8) & 1)) {
BX_ERROR(("CMDFIFO hole count feature not supported yet")); v->fbi.cmdfifo[fifo_idx].enabled = ((value >> 8) & 1);
BX_INFO(("CMDFIFO #%d now %sabled", fifo_idx + 1,
v->fbi.cmdfifo[fifo_idx].enabled ? "en" : "dis"));
} }
// v->fbi.cmdfifo[fifo_idx].count_holes = (((value >> 10) & 1) == 0);
BX_UNLOCK(cmdfifo_mutex); BX_UNLOCK(cmdfifo_mutex);
break; break;
case cmdBump0: case cmdBump0:

View File

@ -2444,14 +2444,32 @@ void cmdfifo_w(cmdfifo_info *f, Bit32u fbi_offset, Bit32u data)
{ {
BX_LOCK(cmdfifo_mutex); BX_LOCK(cmdfifo_mutex);
*(Bit32u*)(&v->fbi.ram[fbi_offset]) = data; *(Bit32u*)(&v->fbi.ram[fbi_offset]) = data;
/* count holes? */
if (f->count_holes) { if (f->count_holes) {
if (fbi_offset == (f->amin + 4)) { if ((f->holes == 0) && (fbi_offset == (f->amin + 4))) {
f->amin = fbi_offset; /* in-order, no holes */
f->amin = f->amax = fbi_offset;
f->depth++; f->depth++;
} else if (fbi_offset < f->amin) {
/* out-of-order, below the minimum */
if (f->holes != 0) {
BX_ERROR(("Unexpected CMDFIFO: AMin=0x%08x AMax=0x%08x Holes=%d WroteTo:0x%08x RdPtr:0x%08x",
f->amin, f->amax, f->holes, fbi_offset, f->rdptr));
}
f->amin = f->amax = fbi_offset;
f->depth++;
} else if (fbi_offset < f->amax) {
/* out-of-order, but within the min-max range */
f->holes--;
if (f->holes == 0) {
f->depth += (f->amax - f->amin) / 4;
f->amin = f->amax;
}
} else {
/* out-of-order, bumping max */
f->holes += (fbi_offset - f->amax) / 4 - 1;
f->amax = fbi_offset;
} }
f->amax = fbi_offset;
} else {
f->depth++;
} }
if (f->depth_needed == BX_MAX_BIT32U) { if (f->depth_needed == BX_MAX_BIT32U) {
f->depth_needed = cmdfifo_calc_depth_needed(f); f->depth_needed = cmdfifo_calc_depth_needed(f);
@ -2475,11 +2493,7 @@ Bit32u cmdfifo_r(cmdfifo_info *f)
BX_INFO(("CMDFIFO RdPtr rollover")); BX_INFO(("CMDFIFO RdPtr rollover"));
f->rdptr = f->base; f->rdptr = f->base;
} }
if (f->count_holes) { f->depth--;
f->depth = (f->amin - f->rdptr) / 4;
} else {
f->depth--;
}
return data; return data;
} }
@ -2890,12 +2904,10 @@ void register_w_common(Bit32u offset, Bit32u data)
if (v->type == VOODOO_2 && (chips & 1) && INITEN_ENABLE_HW_INIT(v->pci.init_enable)) if (v->type == VOODOO_2 && (chips & 1) && INITEN_ENABLE_HW_INIT(v->pci.init_enable))
{ {
v->fbi.cmdfifo[0].count_holes = !FBIINIT7_DISABLE_CMDFIFO_HOLES(data);
if (v->fbi.cmdfifo[0].enabled != FBIINIT7_CMDFIFO_ENABLE(data)) { if (v->fbi.cmdfifo[0].enabled != FBIINIT7_CMDFIFO_ENABLE(data)) {
v->fbi.cmdfifo[0].enabled = FBIINIT7_CMDFIFO_ENABLE(data); v->fbi.cmdfifo[0].enabled = FBIINIT7_CMDFIFO_ENABLE(data);
BX_INFO(("CMDFIFO now %sabled", v->fbi.cmdfifo[0].enabled ? "en" : "dis")); BX_INFO(("CMDFIFO now %sabled", v->fbi.cmdfifo[0].enabled ? "en" : "dis"));
if (!FBIINIT7_DISABLE_CMDFIFO_HOLES(data)) {
BX_ERROR(("CMDFIFO hole count feature not supported yet"));
}
} }
v->reg[regnum].u = data; v->reg[regnum].u = data;
} else if (v->type >= VOODOO_BANSHEE) { } else if (v->type >= VOODOO_BANSHEE) {
@ -2918,16 +2930,20 @@ void register_w_common(Bit32u offset, Bit32u data)
case cmdFifoAMin: case cmdFifoAMin:
/* case colBufferAddr: -- Banshee */ /* case colBufferAddr: -- Banshee */
if (v->type == VOODOO_2 && (chips & 1)) if (v->type == VOODOO_2 && (chips & 1)) {
BX_LOCK(cmdfifo_mutex);
v->fbi.cmdfifo[0].amin = data; v->fbi.cmdfifo[0].amin = data;
else if (v->type >= VOODOO_BANSHEE && (chips & 1)) BX_UNLOCK(cmdfifo_mutex);
} else if (v->type >= VOODOO_BANSHEE && (chips & 1))
v->fbi.rgboffs[1] = data & v->fbi.mask & ~0x0f; v->fbi.rgboffs[1] = data & v->fbi.mask & ~0x0f;
break; break;
case cmdFifoAMax: case cmdFifoAMax:
/* case colBufferStride: -- Banshee */ /* case colBufferStride: -- Banshee */
if (v->type == VOODOO_2 && (chips & 1)) { if (v->type == VOODOO_2 && (chips & 1)) {
BX_LOCK(cmdfifo_mutex);
v->fbi.cmdfifo[0].amax = data; v->fbi.cmdfifo[0].amax = data;
BX_UNLOCK(cmdfifo_mutex);
} else if (v->type >= VOODOO_BANSHEE && (chips & 1)) { } else if (v->type >= VOODOO_BANSHEE && (chips & 1)) {
if (data & 0x8000) if (data & 0x8000)
v->fbi.rowpixels = (data & 0x7f) << 6; v->fbi.rowpixels = (data & 0x7f) << 6;
@ -2951,7 +2967,9 @@ void register_w_common(Bit32u offset, Bit32u data)
case cmdFifoHoles: case cmdFifoHoles:
/* case auxBufferStride: -- Banshee */ /* case auxBufferStride: -- Banshee */
if (v->type == VOODOO_2 && (chips & 1)) { if (v->type == VOODOO_2 && (chips & 1)) {
BX_LOCK(cmdfifo_mutex);
v->fbi.cmdfifo[0].holes = data; v->fbi.cmdfifo[0].holes = data;
BX_UNLOCK(cmdfifo_mutex);
} else if (v->type >= VOODOO_BANSHEE && (chips & 1)) { } else if (v->type >= VOODOO_BANSHEE && (chips & 1)) {
Bit32u rowpixels; Bit32u rowpixels;