include/mgba/internal/ds/gx/software.h (view raw)
1/* Copyright (c) 2013-2017 Jeffrey Pfau
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6#ifndef DS_GX_SOFTWARE_H
7#define DS_GX_SOFTWARE_H
8
9#include <mgba-util/common.h>
10
11CXX_GUARD_START
12
13#include <mgba/internal/ds/gx.h>
14#include <mgba/internal/ds/video.h>
15#include <mgba-util/table.h>
16#include <mgba-util/vector.h>
17
18struct DSGXSoftwarePolygon {
19 struct DSGXPolygon* poly;
20 unsigned polyId;
21 uint16_t* texBase;
22 uint16_t* palBase;
23 int texFormat;
24 int blendFormat;
25 int texW;
26 int texH;
27 int minY;
28 int maxY;
29};
30
31struct DSGXSoftwareEdge {
32 unsigned polyId;
33 int32_t y0; // 20.12
34 int32_t x0; // 20.12
35 int32_t z0; // 20.12
36 int32_t w0; // 20.12
37 uint8_t cr0;
38 uint8_t cg0;
39 uint8_t cb0;
40 int16_t s0;
41 int16_t t0;
42
43 int32_t y1; // 20.12
44 int32_t x1; // 20.12
45 int32_t z1; // 20.12
46 int32_t w1; // 20.12
47 uint8_t cr1;
48 uint8_t cg1;
49 uint8_t cb1;
50 int16_t s1;
51 int16_t t1;
52};
53
54struct DSGXSoftwareEndpoint {
55 int32_t coord[4]; // 20.12
56 int64_t wRecip;
57 uint8_t cr;
58 uint8_t cg;
59 uint8_t cb;
60 int16_t s;
61 int16_t t;
62
63 int64_t stepZ;
64 int64_t stepW;
65 int64_t stepR;
66 int64_t stepG;
67 int64_t stepB;
68 int64_t stepS;
69 int64_t stepT;
70};
71
72struct DSGXSoftwareSpan {
73 struct DSGXSoftwarePolygon* poly;
74 int polyId;
75 struct DSGXSoftwareEndpoint ep[2];
76 struct DSGXSoftwareEndpoint step;
77};
78
79DECLARE_VECTOR(DSGXSoftwarePolygonList, struct DSGXSoftwarePolygon);
80DECLARE_VECTOR(DSGXSoftwareEdgeList, struct DSGXSoftwareEdge);
81
82struct DSGXSoftwareRenderer {
83 struct DSGXRenderer d;
84
85 struct DSGXSoftwarePolygonList activePolys;
86 struct DSGXSoftwareEdgeList activeEdges;
87
88 int32_t* depthBuffer;
89 uint8_t* stencilBuffer;
90 color_t* scanlineCache;
91 int sort;
92
93 struct DSGXVertex* verts;
94};
95
96void DSGXSoftwareRendererCreate(struct DSGXSoftwareRenderer* renderer);
97
98CXX_GUARD_END
99
100#endif