mirror of https://github.com/mgba-emu/mgba.git
DS GX: Start work on multi-parameter FIFO entries
This commit is contained in:
parent
338d29f5ad
commit
2ab7289a05
|
@ -121,7 +121,7 @@ struct DSGX {
|
||||||
uint8_t outstandingCommand[4];
|
uint8_t outstandingCommand[4];
|
||||||
|
|
||||||
int activeParams;
|
int activeParams;
|
||||||
int activeEntries[32];
|
struct DSGXEntry activeEntries[32];
|
||||||
|
|
||||||
bool swapBuffers;
|
bool swapBuffers;
|
||||||
int bufferIndex;
|
int bufferIndex;
|
||||||
|
|
36
src/ds/gx.c
36
src/ds/gx.c
|
@ -140,8 +140,13 @@ static void _fifoRun(struct mTiming* timing, void* context, uint32_t cyclesLate)
|
||||||
struct DSGX* gx = context;
|
struct DSGX* gx = context;
|
||||||
uint32_t cycles;
|
uint32_t cycles;
|
||||||
bool first = true;
|
bool first = true;
|
||||||
while (true) {
|
while (!gx->swapBuffers) {
|
||||||
if (gx->swapBuffers) {
|
if (CircleBufferSize(&gx->pipe) <= 2 * sizeof(struct DSGXEntry)) {
|
||||||
|
_pullPipe(gx);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!CircleBufferSize(&gx->pipe)) {
|
||||||
|
cycles = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,10 +154,6 @@ static void _fifoRun(struct mTiming* timing, void* context, uint32_t cyclesLate)
|
||||||
int pvMatrixPointer = DSRegGXSTATGetPVMatrixStackLevel(gxstat);
|
int pvMatrixPointer = DSRegGXSTATGetPVMatrixStackLevel(gxstat);
|
||||||
int projMatrixPointer = DSRegGXSTATGetProjMatrixStackLevel(gxstat);
|
int projMatrixPointer = DSRegGXSTATGetProjMatrixStackLevel(gxstat);
|
||||||
|
|
||||||
if (CircleBufferSize(&gx->pipe) <= 2 * sizeof(struct DSGXEntry)) {
|
|
||||||
_pullPipe(gx);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct DSGXEntry entry = { 0 };
|
struct DSGXEntry entry = { 0 };
|
||||||
CircleBufferDump(&gx->pipe, (int8_t*) &entry.command, 1);
|
CircleBufferDump(&gx->pipe, (int8_t*) &entry.command, 1);
|
||||||
cycles = _gxCommandCycleBase[entry.command];
|
cycles = _gxCommandCycleBase[entry.command];
|
||||||
|
@ -168,6 +169,24 @@ static void _fifoRun(struct mTiming* timing, void* context, uint32_t cyclesLate)
|
||||||
CircleBufferRead8(&gx->pipe, (int8_t*) &entry.params[2]);
|
CircleBufferRead8(&gx->pipe, (int8_t*) &entry.params[2]);
|
||||||
CircleBufferRead8(&gx->pipe, (int8_t*) &entry.params[3]);
|
CircleBufferRead8(&gx->pipe, (int8_t*) &entry.params[3]);
|
||||||
|
|
||||||
|
if (gx->activeParams) {
|
||||||
|
int index = _gxCommandParams[entry.command] - gx->activeParams;
|
||||||
|
gx->activeEntries[index] = entry;
|
||||||
|
--gx->activeParams;
|
||||||
|
} else {
|
||||||
|
gx->activeParams = _gxCommandParams[entry.command];
|
||||||
|
if (gx->activeParams) {
|
||||||
|
--gx->activeParams;
|
||||||
|
}
|
||||||
|
if (gx->activeParams) {
|
||||||
|
gx->activeEntries[0] = entry;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gx->activeParams) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
switch (entry.command) {
|
switch (entry.command) {
|
||||||
case DS_GX_CMD_MTX_MODE:
|
case DS_GX_CMD_MTX_MODE:
|
||||||
if (entry.params[0] < 4) {
|
if (entry.params[0] < 4) {
|
||||||
|
@ -249,9 +268,7 @@ static void _fifoRun(struct mTiming* timing, void* context, uint32_t cyclesLate)
|
||||||
|
|
||||||
if (cyclesLate >= cycles) {
|
if (cyclesLate >= cycles) {
|
||||||
cyclesLate -= cycles;
|
cyclesLate -= cycles;
|
||||||
}
|
} else {
|
||||||
if (!CircleBufferSize(&gx->pipe)) {
|
|
||||||
cycles = 0;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -298,6 +315,7 @@ void DSGXReset(struct DSGX* gx) {
|
||||||
|
|
||||||
memset(gx->outstandingParams, 0, sizeof(gx->outstandingParams));
|
memset(gx->outstandingParams, 0, sizeof(gx->outstandingParams));
|
||||||
memset(gx->outstandingCommand, 0, sizeof(gx->outstandingCommand));
|
memset(gx->outstandingCommand, 0, sizeof(gx->outstandingCommand));
|
||||||
|
gx->activeParams = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DSGXAssociateRenderer(struct DSGX* gx, struct DSGXRenderer* renderer) {
|
void DSGXAssociateRenderer(struct DSGX* gx, struct DSGXRenderer* renderer) {
|
||||||
|
|
Loading…
Reference in New Issue