1
// Copyright (c) 2012- PPSSPP Project.
3
// This program is free software: you can redistribute it and/or modify
4
// it under the terms of the GNU General Public License as published by
5
// the Free Software Foundation, version 2.0 or later versions.
7
// This program is distributed in the hope that it will be useful,
8
// but WITHOUT ANY WARRANTY; without even the implied warranty of
9
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
// GNU General Public License 2.0 for more details.
12
// A copy of the GPL 2.0 should have been included with the program.
13
// If not, see http://www.gnu.org/licenses/
15
// Official git repository and contact information can be found at
16
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
22
#include "Common/CommonTypes.h"
23
#include "Common/Swap.h"
24
#include "GPU/ge_constants.h"
26
class IndexGenerator {
28
void Setup(u16 *indexptr);
30
static bool PrimCompatible(int prim1, int prim2);
31
bool PrimCompatible(int prim) const;
32
GEPrimitiveType Prim() const { return prim_; }
34
void AddPrim(int prim, int vertexCount);
35
void TranslatePrim(int prim, int numInds, const u8 *inds, int indexOffset);
36
void TranslatePrim(int prim, int numInds, const u16_le *inds, int indexOffset);
37
void TranslatePrim(int prim, int numInds, const u32_le *inds, int indexOffset);
39
void Advance(int numVerts) {
43
void SetIndex(int ind) { index_ = ind; }
44
int MaxIndex() const { return index_; }
45
int VertexCount() const { return count_; }
46
bool Empty() const { return index_ == 0; }
47
int SeenPrims() const { return seenPrims_; }
48
int PureCount() const { return pureCount_; }
49
bool SeenOnlyPurePrims() const {
50
return seenPrims_ == (1 << GE_PRIM_TRIANGLES) ||
51
seenPrims_ == (1 << GE_PRIM_LINES) ||
52
seenPrims_ == (1 << GE_PRIM_POINTS) ||
53
seenPrims_ == (1 << GE_PRIM_TRIANGLE_STRIP);
57
// Points (why index these? code simplicity)
58
void AddPoints(int numVerts);
60
void AddList(int numVerts);
61
void AddStrip(int numVerts);
62
void AddFan(int numVerts);
64
void AddLineList(int numVerts);
65
void AddLineStrip(int numVerts);
67
void AddRectangles(int numVerts);
69
// These translate already indexed lists
70
template <class ITypeLE, int flag>
71
void TranslatePoints(int numVerts, const ITypeLE *inds, int indexOffset);
72
template <class ITypeLE, int flag>
73
void TranslateList(int numVerts, const ITypeLE *inds, int indexOffset);
74
template <class ITypeLE, int flag>
75
inline void TranslateLineList(int numVerts, const ITypeLE *inds, int indexOffset);
76
template <class ITypeLE, int flag>
77
inline void TranslateLineStrip(int numVerts, const ITypeLE *inds, int indexOffset);
79
template <class ITypeLE, int flag>
80
void TranslateStrip(int numVerts, const ITypeLE *inds, int indexOffset);
81
template <class ITypeLE, int flag>
82
void TranslateFan(int numVerts, const ITypeLE *inds, int indexOffset);
84
template <class ITypeLE, int flag>
85
inline void TranslateRectangles(int numVerts, const ITypeLE *inds, int indexOffset);
88
SEEN_INDEX8 = 1 << 16,
89
SEEN_INDEX16 = 1 << 17,
90
SEEN_INDEX32 = 1 << 18,
98
GEPrimitiveType prim_;