all repos — mgba @ fbece0e7933c59579f7ae6494980d4eda6783254

mGBA Game Boy Advance Emulator

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