DS GX: Start work on multi-parameter FIFO entries

This commit is contained in:
Vicki Pfau 2017-02-27 18:16:26 -08:00
parent 338d29f5ad
commit 2ab7289a05
2 changed files with 28 additions and 10 deletions

View File

@ -121,7 +121,7 @@ struct DSGX {
uint8_t outstandingCommand[4];
int activeParams;
int activeEntries[32];
struct DSGXEntry activeEntries[32];
bool swapBuffers;
int bufferIndex;

View File

@ -140,8 +140,13 @@ static void _fifoRun(struct mTiming* timing, void* context, uint32_t cyclesLate)
struct DSGX* gx = context;
uint32_t cycles;
bool first = true;
while (true) {
if (gx->swapBuffers) {
while (!gx->swapBuffers) {
if (CircleBufferSize(&gx->pipe) <= 2 * sizeof(struct DSGXEntry)) {
_pullPipe(gx);
}
if (!CircleBufferSize(&gx->pipe)) {
cycles = 0;
break;
}
@ -149,10 +154,6 @@ static void _fifoRun(struct mTiming* timing, void* context, uint32_t cyclesLate)
int pvMatrixPointer = DSRegGXSTATGetPVMatrixStackLevel(gxstat);
int projMatrixPointer = DSRegGXSTATGetProjMatrixStackLevel(gxstat);
if (CircleBufferSize(&gx->pipe) <= 2 * sizeof(struct DSGXEntry)) {
_pullPipe(gx);
}
struct DSGXEntry entry = { 0 };
CircleBufferDump(&gx->pipe, (int8_t*) &entry.command, 1);
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[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) {
case DS_GX_CMD_MTX_MODE:
if (entry.params[0] < 4) {
@ -249,9 +268,7 @@ static void _fifoRun(struct mTiming* timing, void* context, uint32_t cyclesLate)
if (cyclesLate >= cycles) {
cyclesLate -= cycles;
}
if (!CircleBufferSize(&gx->pipe)) {
cycles = 0;
} else {
break;
}
}
@ -298,6 +315,7 @@ void DSGXReset(struct DSGX* gx) {
memset(gx->outstandingParams, 0, sizeof(gx->outstandingParams));
memset(gx->outstandingCommand, 0, sizeof(gx->outstandingCommand));
gx->activeParams = 0;
}
void DSGXAssociateRenderer(struct DSGX* gx, struct DSGXRenderer* renderer) {