mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Cleanup IndexGenerator
This commit is contained in:
parent
7f727bb06f
commit
2351efc584
3 changed files with 35 additions and 35 deletions
|
@ -53,6 +53,18 @@ void IndexGenerator::Setup(u16 *inds) {
|
|||
Reset();
|
||||
}
|
||||
|
||||
void IndexGenerator::AddPrim(int prim, int vertexCount) {
|
||||
switch (prim) {
|
||||
case GE_PRIM_POINTS: AddPoints(vertexCount); break;
|
||||
case GE_PRIM_LINES: AddLineList(vertexCount); break;
|
||||
case GE_PRIM_LINE_STRIP: AddLineStrip(vertexCount); break;
|
||||
case GE_PRIM_TRIANGLES: AddList(vertexCount); break;
|
||||
case GE_PRIM_TRIANGLE_STRIP: AddStrip(vertexCount); break;
|
||||
case GE_PRIM_TRIANGLE_FAN: AddFan(vertexCount); break;
|
||||
case GE_PRIM_RECTANGLES: AddRectangles(vertexCount); break; // Same
|
||||
}
|
||||
}
|
||||
|
||||
void IndexGenerator::AddPoints(int numVerts) {
|
||||
for (int i = 0; i < numVerts; i++)
|
||||
*inds_++ = index_ + i;
|
||||
|
|
|
@ -32,6 +32,27 @@ public:
|
|||
bool PrimCompatible(int prim);
|
||||
int Prim() const { return prim_; }
|
||||
|
||||
void AddPrim(int prim, int vertexCount);
|
||||
void TranslatePrim(int prim, int numInds, const u8 *inds, int indexOffset);
|
||||
void TranslatePrim(int prim, int numInds, const u16 *inds, int indexOffset);
|
||||
|
||||
void Advance(int numVerts) {
|
||||
index_ += numVerts;
|
||||
}
|
||||
|
||||
void SetIndex(int ind) { index_ = ind; }
|
||||
int MaxIndex() const { return index_; }
|
||||
int VertexCount() const { return count_; }
|
||||
bool Empty() const { return index_ == 0; }
|
||||
int SeenPrims() const { return seenPrims_; }
|
||||
|
||||
bool SeenOnlyPurePrims() const {
|
||||
return seenPrims_ == (1 << GE_PRIM_TRIANGLES) ||
|
||||
seenPrims_ == (1 << GE_PRIM_LINES) ||
|
||||
seenPrims_ == (1 << GE_PRIM_POINTS);
|
||||
}
|
||||
|
||||
private:
|
||||
// Points (why index these? code simplicity)
|
||||
void AddPoints(int numVerts);
|
||||
// Triangles
|
||||
|
@ -44,9 +65,6 @@ public:
|
|||
// Rectangles
|
||||
void AddRectangles(int numVerts);
|
||||
|
||||
void TranslatePrim(int prim, int numInds, const u8 *inds, int indexOffset);
|
||||
void TranslatePrim(int prim, int numInds, const u16 *inds, int indexOffset);
|
||||
|
||||
void TranslatePoints(int numVerts, const u8 *inds, int indexOffset);
|
||||
void TranslatePoints(int numVerts, const u16 *inds, int indexOffset);
|
||||
// Translates already indexed lists
|
||||
|
@ -65,29 +83,6 @@ public:
|
|||
void TranslateFan(int numVerts, const u8 *inds, int indexOffset);
|
||||
void TranslateFan(int numVerts, const u16 *inds, int indexOffset);
|
||||
|
||||
void Advance(int numVerts) {
|
||||
index_ += numVerts;
|
||||
}
|
||||
|
||||
int MaxIndex() const { return index_; }
|
||||
int VertexCount() const { return count_; }
|
||||
|
||||
bool Empty() const { return index_ == 0; }
|
||||
|
||||
void SetIndex(int ind) { index_ = ind; }
|
||||
int SeenPrims() const { return seenPrims_; }
|
||||
|
||||
bool SeenOnlyPurePrims() const {
|
||||
return seenPrims_ == (1 << GE_PRIM_TRIANGLES) ||
|
||||
seenPrims_ == (1 << GE_PRIM_LINES) ||
|
||||
seenPrims_ == (1 << GE_PRIM_POINTS);
|
||||
}
|
||||
|
||||
bool SeenIndices() const {
|
||||
return (seenPrims_ & (SEEN_INDEX8 | SEEN_INDEX16)) != 0;
|
||||
}
|
||||
|
||||
private:
|
||||
enum {
|
||||
SEEN_INDEX8 = 1 << 16,
|
||||
SEEN_INDEX16 = 1 << 17
|
||||
|
|
|
@ -782,6 +782,7 @@ void TransformDrawEngine::SubmitPrim(void *verts, void *inds, int prim, int vert
|
|||
if (!indexGen.Empty()) {
|
||||
gpuStats.numJoins++;
|
||||
}
|
||||
|
||||
gpuStats.numDrawCalls++;
|
||||
gpuStats.numVertsSubmitted += vertexCount;
|
||||
|
||||
|
@ -814,15 +815,7 @@ void TransformDrawEngine::DecodeVerts() {
|
|||
dec.DecodeVerts(decoded + collectedVerts * (int)dec.GetDecVtxFmt().stride,
|
||||
dc.verts, indexLowerBound, indexUpperBound);
|
||||
collectedVerts += indexUpperBound - indexLowerBound + 1;
|
||||
switch (dc.prim) {
|
||||
case GE_PRIM_POINTS: indexGen.AddPoints(dc.vertexCount); break;
|
||||
case GE_PRIM_LINES: indexGen.AddLineList(dc.vertexCount); break;
|
||||
case GE_PRIM_LINE_STRIP: indexGen.AddLineStrip(dc.vertexCount); break;
|
||||
case GE_PRIM_TRIANGLES: indexGen.AddList(dc.vertexCount); break;
|
||||
case GE_PRIM_TRIANGLE_STRIP: indexGen.AddStrip(dc.vertexCount); break;
|
||||
case GE_PRIM_TRIANGLE_FAN: indexGen.AddFan(dc.vertexCount); break;
|
||||
case GE_PRIM_RECTANGLES: indexGen.AddRectangles(dc.vertexCount); break; // Same
|
||||
}
|
||||
indexGen.AddPrim(dc.prim, dc.vertexCount);
|
||||
} else {
|
||||
// It's fairly common that games issue long sequences of PRIM calls, with differing
|
||||
// inds pointer but the same base vertex pointer. We'd like to reuse vertices between
|
||||
|
|
Loading…
Add table
Reference in a new issue