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 int8_t cr0;
31 int8_t cg0;
32 int8_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 int8_t cr1;
40 int8_t cg1;
41 int8_t cb1;
42 int16_t s1;
43 int16_t t1;
44};
45
46struct DSGXSoftwareSpan {
47 int32_t x0; // 20.12
48 int32_t w0; // 20.12
49 int8_t cr0;
50 int8_t cg0;
51 int8_t cb0;
52 int16_t s0;
53 int16_t t0;
54
55 int32_t x1; // 20.12
56 int32_t w1; // 20.12
57 int8_t cr1;
58 int8_t cg1;
59 int8_t cb1;
60 int16_t s1;
61 int16_t t1;
62};
63
64DECLARE_VECTOR(DSGXSoftwarePolygonList, struct DSGXSoftwarePolygon);
65DECLARE_VECTOR(DSGXSoftwareEdgeList, struct DSGXSoftwareEdge);
66DECLARE_VECTOR(DSGXSoftwareSpanList, struct DSGXSoftwareSpan);
67
68struct DSGXSoftwareRenderer {
69 struct DSGXRenderer d;
70
71 struct DSGXSoftwarePolygonList activePolys;
72 struct DSGXSoftwareEdgeList activeEdges;
73 struct DSGXSoftwareSpanList activeSpans;
74 struct Table bucket;
75
76 uint16_t depthBuffer[DS_VIDEO_HORIZONTAL_PIXELS];
77 color_t* scanlineCache;
78
79 struct DSGXVertex* verts;
80};
81
82CXX_GUARD_END
83
84#endif