DS GX: Render polygons in an opaque and a translucent pass

This commit is contained in:
Vicki Pfau 2017-03-21 15:01:23 -07:00
parent a79ff0964b
commit d7ce8f9f06
1 changed files with 124 additions and 86 deletions

View File

@ -442,19 +442,9 @@ static void DSGXSoftwareRendererInvalidateTex(struct DSGXRenderer* renderer, int
// TODO
}
static void DSGXSoftwareRendererSetRAM(struct DSGXRenderer* renderer, struct DSGXVertex* verts, struct DSGXPolygon* polys, unsigned polyCount, bool wSort) {
static void _preparePoly(struct DSGXRenderer* renderer, struct DSGXVertex* verts, struct DSGXSoftwarePolygon* poly, int polyId) {
struct DSGXSoftwareRenderer* softwareRenderer = (struct DSGXSoftwareRenderer*) renderer;
softwareRenderer->flushPending = true;
softwareRenderer->wSort = wSort;
softwareRenderer->verts = verts;
DSGXSoftwarePolygonListClear(&softwareRenderer->activePolys);
DSGXSoftwareEdgeListClear(&softwareRenderer->activeEdges);
unsigned i;
for (i = 0; i < polyCount; ++i) {
struct DSGXSoftwarePolygon* poly = DSGXSoftwarePolygonListAppend(&softwareRenderer->activePolys);
struct DSGXSoftwareEdge* edge = DSGXSoftwareEdgeListAppend(&softwareRenderer->activeEdges);
poly->poly = &polys[i];
poly->texFormat = DSGXTexParamsGetFormat(poly->poly->texParams);
poly->blendFormat = DSGXPolygonAttrsGetMode(poly->poly->polyParams);
poly->texW = 8 << DSGXTexParamsGetSSize(poly->poly->texParams);
@ -479,7 +469,7 @@ static void DSGXSoftwareRendererSetRAM(struct DSGXRenderer* renderer, struct DSG
break;
}
}
edge->polyId = i;
edge->polyId = polyId;
struct DSGXVertex* v0 = &verts[poly->poly->vertIds[0]];
struct DSGXVertex* v1;
@ -528,7 +518,7 @@ static void DSGXSoftwareRendererSetRAM(struct DSGXRenderer* renderer, struct DSG
}
edge = DSGXSoftwareEdgeListAppend(&softwareRenderer->activeEdges);
edge->polyId = i;
edge->polyId = polyId;
v0 = v1;
v0x = v1x;
v0y = v1y;
@ -572,6 +562,54 @@ static void DSGXSoftwareRendererSetRAM(struct DSGXRenderer* renderer, struct DSG
edge->t1 = v0->vt;
}
}
static void DSGXSoftwareRendererSetRAM(struct DSGXRenderer* renderer, struct DSGXVertex* verts, struct DSGXPolygon* polys, unsigned polyCount, bool wSort) {
struct DSGXSoftwareRenderer* softwareRenderer = (struct DSGXSoftwareRenderer*) renderer;
softwareRenderer->flushPending = true;
softwareRenderer->wSort = wSort;
softwareRenderer->verts = verts;
DSGXSoftwarePolygonListClear(&softwareRenderer->activePolys);
DSGXSoftwareEdgeListClear(&softwareRenderer->activeEdges);
unsigned i;
// Pass 1: Opaque
for (i = 0; i < polyCount; ++i) {
struct DSGXSoftwarePolygon* poly = NULL;
switch (DSGXTexParamsGetFormat(polys[i].texParams)) {
default:
if (DSGXPolygonAttrsGetAlpha(polys[i].polyParams) == 0x1F) {
poly = DSGXSoftwarePolygonListAppend(&softwareRenderer->activePolys);
break;
}
case 1:
case 6:
break;
}
if (!poly) {
continue;
}
poly->poly = &polys[i];
_preparePoly(renderer, verts, poly, DSGXSoftwarePolygonListSize(&softwareRenderer->activePolys) - 1);
}
// Pass 2: Translucent
for (i = 0; i < polyCount; ++i) {
struct DSGXSoftwarePolygon* poly = NULL;
switch (DSGXTexParamsGetFormat(polys[i].texParams)) {
default:
if (DSGXPolygonAttrsGetAlpha(polys[i].polyParams) == 0x1F) {
break;
}
case 1:
case 6:
poly = DSGXSoftwarePolygonListAppend(&softwareRenderer->activePolys);
break;
}
if (!poly) {
continue;
}
poly->poly = &polys[i];
_preparePoly(renderer, verts, poly, DSGXSoftwarePolygonListSize(&softwareRenderer->activePolys) - 1);
}
}
static void DSGXSoftwareRendererDrawScanline(struct DSGXRenderer* renderer, int y) {