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 int32_t topY;
21 int32_t bottomY;
22 int32_t topZ;
23};
24
25struct DSGXSoftwareEdge {
26 unsigned polyId;
27 int32_t y0; // 20.12
28 int32_t x0; // 20.12
29 int32_t w0; // 20.12
30 uint8_t cr0;
31 uint8_t cg0;
32 uint8_t cb0;
33 int16_t s0;
34 int16_t t0;
35
36 int32_t y1; // 20.12
37 int32_t x1; // 20.12
38 int32_t w1; // 20.12
39 uint8_t cr1;
40 uint8_t cg1;
41 uint8_t cb1;
42 int16_t s1;
43 int16_t t1;
44};
45
46struct DSGXSoftwareEndpoint {
47 int32_t x; // 20.12
48 int32_t w; // 20.12
49 uint8_t cr;
50 uint8_t cg;
51 uint8_t cb;
52 int16_t s;
53 int16_t t;
54};
55
56struct DSGXSoftwareSpan {
57 struct DSGXSoftwareEndpoint ep[2];
58};
59
60DECLARE_VECTOR(DSGXSoftwarePolygonList, struct DSGXSoftwarePolygon);
61DECLARE_VECTOR(DSGXSoftwareEdgeList, struct DSGXSoftwareEdge);
62DECLARE_VECTOR(DSGXSoftwareSpanList, struct DSGXSoftwareSpan);
63
64struct DSGXSoftwareRenderer {
65 struct DSGXRenderer d;
66
67 struct DSGXSoftwarePolygonList activePolys;
68 struct DSGXSoftwareEdgeList activeEdges;
69 struct DSGXSoftwareSpanList activeSpans;
70 struct DSGXSoftwareSpan** bucket;
71
72 uint16_t depthBuffer[DS_VIDEO_HORIZONTAL_PIXELS];
73 color_t* scanlineCache;
74
75 struct DSGXVertex* verts;
76};
77
78CXX_GUARD_END
79
80#endif