all repos — mgba @ 10ed2ed418542aa5bf06d7bdd39784a0ea43e121

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	int32_t z;
 54	int32_t w;
 55	int64_t wRecip;
 56	uint8_t cr;
 57	uint8_t cg;
 58	uint8_t cb;
 59	int16_t s;
 60	int16_t t;
 61
 62	int64_t stepZ;
 63	int64_t stepW;
 64	int64_t stepR;
 65	int64_t stepG;
 66	int64_t stepB;
 67	int64_t stepS;
 68	int64_t stepT;
 69};
 70
 71struct DSGXSoftwareSpan {
 72	struct DSGXSoftwarePolygon* poly;
 73	struct DSGXSoftwareEndpoint ep[2];
 74	struct DSGXSoftwareEndpoint step;
 75};
 76
 77DECLARE_VECTOR(DSGXSoftwarePolygonList, struct DSGXSoftwarePolygon);
 78DECLARE_VECTOR(DSGXSoftwareEdgeList, struct DSGXSoftwareEdge);
 79DECLARE_VECTOR(DSGXSoftwareSpanList, struct DSGXSoftwareSpan);
 80
 81struct DSGXSoftwareRenderer {
 82	struct DSGXRenderer d;
 83
 84	struct DSGXSoftwarePolygonList activePolys;
 85	struct DSGXSoftwareEdgeList activeEdges;
 86	struct DSGXSoftwareSpanList activeSpans;
 87	struct DSGXSoftwareSpan** bucket;
 88
 89	int32_t depthBuffer[DS_VIDEO_HORIZONTAL_PIXELS];
 90	color_t* scanlineCache;
 91	bool flushPending;
 92	bool wSort;
 93
 94	struct DSGXVertex* verts;
 95};
 96
 97void DSGXSoftwareRendererCreate(struct DSGXSoftwareRenderer* renderer);
 98
 99CXX_GUARD_END
100
101#endif