all repos — mgba @ 8f58343e2b3ff091f51254983c54e581581b118e

mGBA Game Boy Advance Emulator

DS GX: Move rendering until first scanline is requested
Vicki Pfau vi@endrift.com
Thu, 23 Mar 2017 21:23:47 -0700
commit

8f58343e2b3ff091f51254983c54e581581b118e

parent

69f21e1fb401078ebdd2a27a6575339ef6f60f1f

2 files changed, 12 insertions(+), 7 deletions(-)

jump to
M include/mgba/internal/ds/gx/software.hinclude/mgba/internal/ds/gx/software.h

@@ -93,6 +93,7 @@ int32_t* depthBuffer;

uint8_t* stencilBuffer; color_t* scanlineCache; int sort; + bool flushPending; struct DSGXVertex* verts; };
M src/ds/gx/software.csrc/ds/gx/software.c

@@ -697,18 +697,27 @@ softwareRenderer->depthBuffer[i + 1] = INT32_MAX;

softwareRenderer->depthBuffer[i + 2] = INT32_MAX; softwareRenderer->depthBuffer[i + 3] = INT32_MAX; } + softwareRenderer->flushPending = true; +} + +static void DSGXSoftwareRendererDrawScanline(struct DSGXRenderer* renderer, int y) { + struct DSGXSoftwareRenderer* softwareRenderer = (struct DSGXSoftwareRenderer*) renderer; + if (!softwareRenderer->flushPending || y) { + return; + } size_t p; for (p = 0; p < DSGXSoftwarePolygonListSize(&softwareRenderer->activePolys); ++p) { struct DSGXSoftwarePolygon* poly = DSGXSoftwarePolygonListGetPointer(&softwareRenderer->activePolys, p); DSGXSoftwareEdgeListClear(&softwareRenderer->activeEdges); - _preparePoly(renderer, verts, poly); + _preparePoly(renderer, softwareRenderer->verts, poly); int y; for (y = poly->minY; y <= poly->maxY; ++y) { struct DSGXSoftwareSpan span = { .poly = poly, .polyId = DSGXPolygonAttrsGetId(poly->polyParams), }; + size_t i; for (i = 0; i < DSGXSoftwareEdgeListSize(&softwareRenderer->activeEdges); ++i) { struct DSGXSoftwareEdge* edge = DSGXSoftwareEdgeListGetPointer(&softwareRenderer->activeEdges, i); if (edge->y1 < (y << 12)) {

@@ -729,12 +738,7 @@ }

} } } -} - -static void DSGXSoftwareRendererDrawScanline(struct DSGXRenderer* renderer, int y) { - struct DSGXSoftwareRenderer* softwareRenderer = (struct DSGXSoftwareRenderer*) renderer; - UNUSED(softwareRenderer); - UNUSED(y); + softwareRenderer->flushPending = false; } static void DSGXSoftwareRendererGetScanline(struct DSGXRenderer* renderer, int y, const color_t** output) {