all repos — mgba @ 13bc1125cecc29da586e225487069094a006cbcf

mGBA Game Boy Advance Emulator

DS GX: Minor optimizations
Vicki Pfau vi@endrift.com
Tue, 21 Mar 2017 16:36:15 -0700
commit

13bc1125cecc29da586e225487069094a006cbcf

parent

2b6ed2661e880a41bbd9d064794a59b9e44ef353

1 files changed, 13 insertions(+), 14 deletions(-)

jump to
M src/ds/gx/software.csrc/ds/gx/software.c

@@ -667,6 +667,10 @@ int32_t x = span->ep[0].coord[0] >> 12;

if (x < 0) { x = 0; } + unsigned stencilValue = span->polyId; + if (span->poly->blendFormat == 3) { + stencilValue |= 0x40; + } for (; x < (span->ep[1].coord[0] >> 12) && x < DS_VIDEO_HORIZONTAL_PIXELS; ++x) { color_t color = _lookupColor(softwareRenderer, &span->ep[0], span->poly); _stepEndpoint(span);

@@ -674,16 +678,13 @@ unsigned a = color >> 27;

unsigned current = scanline[x]; unsigned b = current >> 27; unsigned ab = a; - unsigned s = span->polyId; + unsigned s = stencilValue; if (b > ab) { ab = b; } - if (span->poly->blendFormat == 3) { - s |= 0x40; - } if (a == 0x1F) { if (span->ep[0].coord[softwareRenderer->sort] < softwareRenderer->depthBuffer[x]) { - if (s != 0x40 && !(softwareRenderer->stencilBuffer[x] & 0x40)) { + if (!(s == 0x40 || (softwareRenderer->stencilBuffer[x] & 0x40))) { softwareRenderer->depthBuffer[x] = span->ep[0].coord[softwareRenderer->sort]; scanline[x] = color; s &= ~0x40;

@@ -696,17 +697,15 @@ if (b) {

color = _mix32(a, color, 0x1F - a, current); color |= ab << 27; } - if (softwareRenderer->stencilBuffer[x] != s) { - if (span->ep[0].coord[softwareRenderer->sort] < softwareRenderer->depthBuffer[x]) { - if (s != 0x40 && !(softwareRenderer->stencilBuffer[x] & 0x40)) { - if (DSGXPolygonAttrsIsUpdateDepth(span->poly->poly->polyParams)) { - softwareRenderer->depthBuffer[x] = span->ep[0].coord[softwareRenderer->sort]; - } - scanline[x] = color; - s &= ~0x40; + if (softwareRenderer->stencilBuffer[x] != s && span->ep[0].coord[softwareRenderer->sort] < softwareRenderer->depthBuffer[x]) { + if (!(s == 0x40 || (softwareRenderer->stencilBuffer[x] & 0x40))) { + if (DSGXPolygonAttrsIsUpdateDepth(span->poly->poly->polyParams)) { + softwareRenderer->depthBuffer[x] = span->ep[0].coord[softwareRenderer->sort]; } - softwareRenderer->stencilBuffer[x] = s; + scanline[x] = color; + s &= ~0x40; } + softwareRenderer->stencilBuffer[x] = s; } } }