mirror of https://github.com/mgba-emu/mgba.git
DS GX: Render polygons in an opaque and a translucent pass
This commit is contained in:
parent
a79ff0964b
commit
d7ce8f9f06
|
@ -442,19 +442,9 @@ static void DSGXSoftwareRendererInvalidateTex(struct DSGXRenderer* renderer, int
|
||||||
// TODO
|
// 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;
|
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);
|
struct DSGXSoftwareEdge* edge = DSGXSoftwareEdgeListAppend(&softwareRenderer->activeEdges);
|
||||||
poly->poly = &polys[i];
|
|
||||||
poly->texFormat = DSGXTexParamsGetFormat(poly->poly->texParams);
|
poly->texFormat = DSGXTexParamsGetFormat(poly->poly->texParams);
|
||||||
poly->blendFormat = DSGXPolygonAttrsGetMode(poly->poly->polyParams);
|
poly->blendFormat = DSGXPolygonAttrsGetMode(poly->poly->polyParams);
|
||||||
poly->texW = 8 << DSGXTexParamsGetSSize(poly->poly->texParams);
|
poly->texW = 8 << DSGXTexParamsGetSSize(poly->poly->texParams);
|
||||||
|
@ -479,7 +469,7 @@ static void DSGXSoftwareRendererSetRAM(struct DSGXRenderer* renderer, struct DSG
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
edge->polyId = i;
|
edge->polyId = polyId;
|
||||||
|
|
||||||
struct DSGXVertex* v0 = &verts[poly->poly->vertIds[0]];
|
struct DSGXVertex* v0 = &verts[poly->poly->vertIds[0]];
|
||||||
struct DSGXVertex* v1;
|
struct DSGXVertex* v1;
|
||||||
|
@ -528,7 +518,7 @@ static void DSGXSoftwareRendererSetRAM(struct DSGXRenderer* renderer, struct DSG
|
||||||
}
|
}
|
||||||
|
|
||||||
edge = DSGXSoftwareEdgeListAppend(&softwareRenderer->activeEdges);
|
edge = DSGXSoftwareEdgeListAppend(&softwareRenderer->activeEdges);
|
||||||
edge->polyId = i;
|
edge->polyId = polyId;
|
||||||
v0 = v1;
|
v0 = v1;
|
||||||
v0x = v1x;
|
v0x = v1x;
|
||||||
v0y = v1y;
|
v0y = v1y;
|
||||||
|
@ -572,6 +562,54 @@ static void DSGXSoftwareRendererSetRAM(struct DSGXRenderer* renderer, struct DSG
|
||||||
edge->t1 = v0->vt;
|
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) {
|
static void DSGXSoftwareRendererDrawScanline(struct DSGXRenderer* renderer, int y) {
|
||||||
|
|
Loading…
Reference in New Issue