mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-10-08 03:13:25 +00:00
Fix spiky polygon glitches with vertex cache in Dissidia and maybe more.
This commit is contained in:
parent
54310c312a
commit
4773f20fad
@ -116,126 +116,6 @@ void IndexGenerator::AddFan(int numVerts)
|
||||
seenPrims_ |= 1 << GE_PRIM_TRIANGLE_FAN;
|
||||
}
|
||||
|
||||
void IndexGenerator::TranslatePoints(int numVerts, const u8 *inds, int offset)
|
||||
{
|
||||
for (int i = 0; i < numVerts; i++)
|
||||
{
|
||||
*inds_++ = index_ + offset + inds[i];
|
||||
}
|
||||
index_ += numVerts;
|
||||
count_ += numVerts;
|
||||
prim_ = GE_PRIM_POINTS;
|
||||
seenPrims_ |= (1 << GE_PRIM_POINTS) | SEEN_INDEX8;
|
||||
}
|
||||
|
||||
void IndexGenerator::TranslatePoints(int numVerts, const u16 *inds, int offset)
|
||||
{
|
||||
for (int i = 0; i < numVerts; i++)
|
||||
{
|
||||
*inds_++ = index_ + offset + inds[i];
|
||||
}
|
||||
index_ += numVerts;
|
||||
count_ += numVerts;
|
||||
prim_ = GE_PRIM_POINTS;
|
||||
seenPrims_ |= (1 << GE_PRIM_POINTS) | SEEN_INDEX16;
|
||||
}
|
||||
|
||||
void IndexGenerator::TranslateList(int numVerts, const u8 *inds, int offset)
|
||||
{
|
||||
int numTris = numVerts / 3;
|
||||
for (int i = 0; i < numTris; i++)
|
||||
{
|
||||
*inds_++ = index_ + offset + inds[i*3];
|
||||
*inds_++ = index_ + offset + inds[i*3 + 1];
|
||||
*inds_++ = index_ + offset + inds[i*3 + 2];
|
||||
}
|
||||
index_ += numVerts;
|
||||
count_ += numTris * 3;
|
||||
prim_ = GE_PRIM_TRIANGLES;
|
||||
seenPrims_ |= (1 << GE_PRIM_TRIANGLES) | SEEN_INDEX8;
|
||||
}
|
||||
|
||||
void IndexGenerator::TranslateStrip(int numVerts, const u8 *inds, int offset)
|
||||
{
|
||||
bool wind = false;
|
||||
int numTris = numVerts - 2;
|
||||
for (int i = 0; i < numTris; i++)
|
||||
{
|
||||
*inds_++ = index_ + offset + inds[i];
|
||||
*inds_++ = index_ + offset + inds[i + (wind?2:1)];
|
||||
*inds_++ = index_ + offset + inds[i + (wind?1:2)];
|
||||
wind = !wind;
|
||||
}
|
||||
index_ += numVerts;
|
||||
count_ += numTris * 3;
|
||||
prim_ = GE_PRIM_TRIANGLES;
|
||||
seenPrims_ |= (1 << GE_PRIM_TRIANGLE_STRIP) | SEEN_INDEX8;
|
||||
}
|
||||
|
||||
void IndexGenerator::TranslateFan(int numVerts, const u8 *inds, int offset)
|
||||
{
|
||||
if (numVerts <= 0) return;
|
||||
int numTris = numVerts - 2;
|
||||
for (int i = 0; i < numTris; i++)
|
||||
{
|
||||
*inds_++ = index_ + offset + inds[0];
|
||||
*inds_++ = index_ + offset + inds[i + 1];
|
||||
*inds_++ = index_ + offset + inds[i + 2];
|
||||
}
|
||||
index_ += numVerts;
|
||||
count_ += numTris * 3;
|
||||
prim_ = GE_PRIM_TRIANGLES;
|
||||
seenPrims_ |= (1 << GE_PRIM_TRIANGLE_FAN) | SEEN_INDEX8;
|
||||
}
|
||||
|
||||
void IndexGenerator::TranslateList(int numVerts, const u16 *inds, int offset)
|
||||
{
|
||||
int numTris = numVerts / 3;
|
||||
for (int i = 0; i < numTris; i++)
|
||||
{
|
||||
*inds_++ = index_ + offset + inds[i*3];
|
||||
*inds_++ = index_ + offset + inds[i*3 + 1];
|
||||
*inds_++ = index_ + offset + inds[i*3 + 2];
|
||||
}
|
||||
index_ += numVerts;
|
||||
count_ += numTris * 3;
|
||||
prim_ = GE_PRIM_TRIANGLES;
|
||||
seenPrims_ |= (1 << GE_PRIM_TRIANGLES) | SEEN_INDEX16;
|
||||
}
|
||||
|
||||
void IndexGenerator::TranslateStrip(int numVerts, const u16 *inds, int offset)
|
||||
{
|
||||
bool wind = false;
|
||||
int numTris = numVerts - 2;
|
||||
for (int i = 0; i < numTris; i++)
|
||||
{
|
||||
*inds_++ = index_ + offset + inds[i];
|
||||
*inds_++ = index_ + offset + inds[i + (wind?2:1)];
|
||||
*inds_++ = index_ + offset + inds[i + (wind?1:2)];
|
||||
wind = !wind;
|
||||
}
|
||||
index_ += numVerts;
|
||||
count_ += numTris * 3;
|
||||
prim_ = GE_PRIM_TRIANGLES;
|
||||
seenPrims_ |= (1 << GE_PRIM_TRIANGLE_STRIP) | SEEN_INDEX16;
|
||||
}
|
||||
|
||||
void IndexGenerator::TranslateFan(int numVerts, const u16 *inds, int offset)
|
||||
{
|
||||
if (numVerts <= 0) return;
|
||||
int numTris = numVerts - 2;
|
||||
for (int i = 0; i < numTris; i++)
|
||||
{
|
||||
*inds_++ = index_ + offset + inds[0];
|
||||
*inds_++ = index_ + offset + inds[i + 1];
|
||||
*inds_++ = index_ + offset + inds[i + 2];
|
||||
}
|
||||
index_ += numVerts;
|
||||
count_ += numTris * 3;
|
||||
prim_ = GE_PRIM_TRIANGLES;
|
||||
seenPrims_ |= (1 << GE_PRIM_TRIANGLE_FAN) | SEEN_INDEX16;
|
||||
}
|
||||
|
||||
//Lines
|
||||
void IndexGenerator::AddLineList(int numVerts)
|
||||
{
|
||||
@ -279,13 +159,142 @@ void IndexGenerator::AddRectangles(int numVerts)
|
||||
seenPrims_ |= 1 << GE_PRIM_RECTANGLES;
|
||||
}
|
||||
|
||||
void IndexGenerator::TranslateLineList(int numVerts, const u8 *inds, int offset)
|
||||
void IndexGenerator::TranslatePoints(int numInds, const u8 *inds, int indexLowerBound, int indexUpperBound)
|
||||
{
|
||||
int numLines = numVerts / 2;
|
||||
int numVerts = indexUpperBound - indexLowerBound + 1;
|
||||
for (int i = 0; i < numInds; i++)
|
||||
{
|
||||
*inds_++ = index_ - indexLowerBound + inds[i];
|
||||
}
|
||||
index_ += numVerts;
|
||||
count_ += numInds;
|
||||
prim_ = GE_PRIM_POINTS;
|
||||
seenPrims_ |= (1 << GE_PRIM_POINTS) | SEEN_INDEX8;
|
||||
}
|
||||
|
||||
void IndexGenerator::TranslatePoints(int numInds, const u16 *inds, int indexLowerBound, int indexUpperBound)
|
||||
{
|
||||
int numVerts = indexUpperBound - indexLowerBound + 1;
|
||||
for (int i = 0; i < numInds; i++)
|
||||
{
|
||||
*inds_++ = index_ - indexLowerBound + inds[i];
|
||||
}
|
||||
index_ += numVerts;
|
||||
count_ += numInds;
|
||||
prim_ = GE_PRIM_POINTS;
|
||||
seenPrims_ |= (1 << GE_PRIM_POINTS) | SEEN_INDEX16;
|
||||
}
|
||||
|
||||
void IndexGenerator::TranslateList(int numInds, const u8 *inds, int indexLowerBound, int indexUpperBound)
|
||||
{
|
||||
int numVerts = indexUpperBound - indexLowerBound + 1;
|
||||
int numTris = numInds / 3;
|
||||
for (int i = 0; i < numTris; i++)
|
||||
{
|
||||
*inds_++ = index_ - indexLowerBound + inds[i*3];
|
||||
*inds_++ = index_ - indexLowerBound + inds[i*3 + 1];
|
||||
*inds_++ = index_ - indexLowerBound + inds[i*3 + 2];
|
||||
}
|
||||
index_ += numVerts;
|
||||
count_ += numTris * 3;
|
||||
prim_ = GE_PRIM_TRIANGLES;
|
||||
seenPrims_ |= (1 << GE_PRIM_TRIANGLES) | SEEN_INDEX8;
|
||||
}
|
||||
|
||||
void IndexGenerator::TranslateStrip(int numInds, const u8 *inds, int indexLowerBound, int indexUpperBound)
|
||||
{
|
||||
int numVerts = indexUpperBound - indexLowerBound + 1;
|
||||
bool wind = false;
|
||||
int numTris = numInds - 2;
|
||||
for (int i = 0; i < numTris; i++)
|
||||
{
|
||||
*inds_++ = index_ - indexLowerBound + inds[i];
|
||||
*inds_++ = index_ - indexLowerBound + inds[i + (wind?2:1)];
|
||||
*inds_++ = index_ - indexLowerBound + inds[i + (wind?1:2)];
|
||||
wind = !wind;
|
||||
}
|
||||
index_ += numVerts;
|
||||
count_ += numTris * 3;
|
||||
prim_ = GE_PRIM_TRIANGLES;
|
||||
seenPrims_ |= (1 << GE_PRIM_TRIANGLE_STRIP) | SEEN_INDEX8;
|
||||
}
|
||||
|
||||
void IndexGenerator::TranslateFan(int numInds, const u8 *inds, int indexLowerBound, int indexUpperBound)
|
||||
{
|
||||
int numVerts = indexUpperBound - indexLowerBound + 1;
|
||||
if (numInds <= 0) return;
|
||||
int numTris = numInds - 2;
|
||||
for (int i = 0; i < numTris; i++)
|
||||
{
|
||||
*inds_++ = index_ - indexLowerBound + inds[0];
|
||||
*inds_++ = index_ - indexLowerBound + inds[i + 1];
|
||||
*inds_++ = index_ - indexLowerBound + inds[i + 2];
|
||||
}
|
||||
index_ += numVerts;
|
||||
count_ += numTris * 3;
|
||||
prim_ = GE_PRIM_TRIANGLES;
|
||||
seenPrims_ |= (1 << GE_PRIM_TRIANGLE_FAN) | SEEN_INDEX8;
|
||||
}
|
||||
|
||||
void IndexGenerator::TranslateList(int numInds, const u16 *inds, int indexLowerBound, int indexUpperBound)
|
||||
{
|
||||
int numVerts = indexUpperBound - indexLowerBound + 1;
|
||||
int numTris = numInds / 3;
|
||||
for (int i = 0; i < numTris; i++)
|
||||
{
|
||||
*inds_++ = index_ - indexLowerBound + inds[i*3];
|
||||
*inds_++ = index_ - indexLowerBound + inds[i*3 + 1];
|
||||
*inds_++ = index_ - indexLowerBound + inds[i*3 + 2];
|
||||
}
|
||||
index_ += numVerts;
|
||||
count_ += numTris * 3;
|
||||
prim_ = GE_PRIM_TRIANGLES;
|
||||
seenPrims_ |= (1 << GE_PRIM_TRIANGLES) | SEEN_INDEX16;
|
||||
}
|
||||
|
||||
void IndexGenerator::TranslateStrip(int numInds, const u16 *inds, int indexLowerBound, int indexUpperBound)
|
||||
{
|
||||
int numVerts = indexUpperBound - indexLowerBound + 1;
|
||||
bool wind = false;
|
||||
int numTris = numInds - 2;
|
||||
for (int i = 0; i < numTris; i++)
|
||||
{
|
||||
*inds_++ = index_ - indexLowerBound + inds[i];
|
||||
*inds_++ = index_ - indexLowerBound + inds[i + (wind?2:1)];
|
||||
*inds_++ = index_ - indexLowerBound + inds[i + (wind?1:2)];
|
||||
wind = !wind;
|
||||
}
|
||||
index_ += numVerts;
|
||||
count_ += numTris * 3;
|
||||
prim_ = GE_PRIM_TRIANGLES;
|
||||
seenPrims_ |= (1 << GE_PRIM_TRIANGLE_STRIP) | SEEN_INDEX16;
|
||||
}
|
||||
|
||||
void IndexGenerator::TranslateFan(int numInds, const u16 *inds, int indexLowerBound, int indexUpperBound)
|
||||
{
|
||||
int numVerts = indexUpperBound - indexLowerBound + 1;
|
||||
if (numInds <= 0) return;
|
||||
int numTris = numInds - 2;
|
||||
for (int i = 0; i < numTris; i++)
|
||||
{
|
||||
*inds_++ = index_ - indexLowerBound + inds[0];
|
||||
*inds_++ = index_ - indexLowerBound + inds[i + 1];
|
||||
*inds_++ = index_ - indexLowerBound + inds[i + 2];
|
||||
}
|
||||
index_ += numVerts;
|
||||
count_ += numTris * 3;
|
||||
prim_ = GE_PRIM_TRIANGLES;
|
||||
seenPrims_ |= (1 << GE_PRIM_TRIANGLE_FAN) | SEEN_INDEX16;
|
||||
}
|
||||
|
||||
void IndexGenerator::TranslateLineList(int numInds, const u8 *inds, int indexLowerBound, int indexUpperBound)
|
||||
{
|
||||
int numVerts = indexUpperBound - indexLowerBound + 1;
|
||||
int numLines = numInds / 2;
|
||||
for (int i = 0; i < numLines; i++)
|
||||
{
|
||||
*inds_++ = index_ + offset + inds[i*2];
|
||||
*inds_++ = index_ + offset + inds[i*2+1];
|
||||
*inds_++ = index_ - indexLowerBound + inds[i*2];
|
||||
*inds_++ = index_ - indexLowerBound + inds[i*2+1];
|
||||
}
|
||||
index_ += numVerts;
|
||||
count_ += numLines * 2;
|
||||
@ -293,13 +302,14 @@ void IndexGenerator::TranslateLineList(int numVerts, const u8 *inds, int offset)
|
||||
seenPrims_ |= (1 << GE_PRIM_LINES) | SEEN_INDEX8;
|
||||
}
|
||||
|
||||
void IndexGenerator::TranslateLineStrip(int numVerts, const u8 *inds, int offset)
|
||||
void IndexGenerator::TranslateLineStrip(int numInds, const u8 *inds, int indexLowerBound, int indexUpperBound)
|
||||
{
|
||||
int numLines = numVerts - 1;
|
||||
int numVerts = indexUpperBound - indexLowerBound + 1;
|
||||
int numLines = numInds - 1;
|
||||
for (int i = 0; i < numLines; i++)
|
||||
{
|
||||
*inds_++ = index_ + offset + inds[i];
|
||||
*inds_++ = index_ + offset + inds[i + 1];
|
||||
*inds_++ = index_ - indexLowerBound + inds[i];
|
||||
*inds_++ = index_ - indexLowerBound + inds[i + 1];
|
||||
}
|
||||
index_ += numVerts;
|
||||
count_ += numLines * 2;
|
||||
@ -307,13 +317,14 @@ void IndexGenerator::TranslateLineStrip(int numVerts, const u8 *inds, int offset
|
||||
seenPrims_ |= (1 << GE_PRIM_LINE_STRIP) | SEEN_INDEX8;
|
||||
}
|
||||
|
||||
void IndexGenerator::TranslateLineList(int numVerts, const u16 *inds, int offset)
|
||||
void IndexGenerator::TranslateLineList(int numInds, const u16 *inds, int indexLowerBound, int indexUpperBound)
|
||||
{
|
||||
int numLines = numVerts / 2;
|
||||
int numVerts = indexUpperBound - indexLowerBound + 1;
|
||||
int numLines = numInds / 2;
|
||||
for (int i = 0; i < numLines; i++)
|
||||
{
|
||||
*inds_++ = index_ + offset + inds[i*2];
|
||||
*inds_++ = index_ + offset + inds[i*2+1];
|
||||
*inds_++ = index_ - indexLowerBound + inds[i*2];
|
||||
*inds_++ = index_ - indexLowerBound + inds[i*2+1];
|
||||
}
|
||||
index_ += numVerts;
|
||||
count_ += numLines * 2;
|
||||
@ -321,13 +332,14 @@ void IndexGenerator::TranslateLineList(int numVerts, const u16 *inds, int offset
|
||||
seenPrims_ |= (1 << GE_PRIM_LINES) | SEEN_INDEX16;
|
||||
}
|
||||
|
||||
void IndexGenerator::TranslateLineStrip(int numVerts, const u16 *inds, int offset)
|
||||
void IndexGenerator::TranslateLineStrip(int numInds, const u16 *inds, int indexLowerBound, int indexUpperBound)
|
||||
{
|
||||
int numLines = numVerts - 1;
|
||||
int numVerts = indexUpperBound - indexLowerBound + 1;
|
||||
int numLines = numInds - 1;
|
||||
for (int i = 0; i < numLines; i++)
|
||||
{
|
||||
*inds_++ = index_ + offset + inds[i];
|
||||
*inds_++ = index_ + offset + inds[i + 1];
|
||||
*inds_++ = index_ - indexLowerBound + inds[i];
|
||||
*inds_++ = index_ - indexLowerBound + inds[i + 1];
|
||||
}
|
||||
index_ += numVerts;
|
||||
count_ += numLines * 2;
|
||||
@ -335,13 +347,14 @@ void IndexGenerator::TranslateLineStrip(int numVerts, const u16 *inds, int offse
|
||||
seenPrims_ |= (1 << GE_PRIM_LINE_STRIP) | SEEN_INDEX16;
|
||||
}
|
||||
|
||||
void IndexGenerator::TranslateRectangles(int numVerts, const u8 *inds, int offset)
|
||||
void IndexGenerator::TranslateRectangles(int numInds, const u8 *inds, int indexLowerBound, int indexUpperBound)
|
||||
{
|
||||
int numRects = numVerts / 2;
|
||||
int numVerts = indexUpperBound - indexLowerBound + 1;
|
||||
int numRects = numInds / 2;
|
||||
for (int i = 0; i < numRects; i++)
|
||||
{
|
||||
*inds_++ = index_ + offset + inds[i*2];
|
||||
*inds_++ = index_ + offset + inds[i*2+1];
|
||||
*inds_++ = index_ - indexLowerBound + inds[i*2];
|
||||
*inds_++ = index_ - indexLowerBound + inds[i*2+1];
|
||||
}
|
||||
index_ += numVerts;
|
||||
count_ += numRects * 2;
|
||||
@ -349,13 +362,14 @@ void IndexGenerator::TranslateRectangles(int numVerts, const u8 *inds, int offse
|
||||
seenPrims_ |= (1 << GE_PRIM_RECTANGLES) | SEEN_INDEX8;
|
||||
}
|
||||
|
||||
void IndexGenerator::TranslateRectangles(int numVerts, const u16 *inds, int offset)
|
||||
void IndexGenerator::TranslateRectangles(int numInds, const u16 *inds, int indexLowerBound, int indexUpperBound)
|
||||
{
|
||||
int numRects = numVerts / 2;
|
||||
int numVerts = indexUpperBound - indexLowerBound + 1;
|
||||
int numRects = numInds / 2;
|
||||
for (int i = 0; i < numRects; i++)
|
||||
{
|
||||
*inds_++ = index_ + offset + inds[i*2];
|
||||
*inds_++ = index_ + offset + inds[i*2+1];
|
||||
*inds_++ = index_ - indexLowerBound + inds[i*2];
|
||||
*inds_++ = index_ - indexLowerBound + inds[i*2+1];
|
||||
}
|
||||
index_ += numVerts;
|
||||
count_ += numRects * 2;
|
||||
|
@ -18,8 +18,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <algorithm>
|
||||
#include "CommonTypes.h"
|
||||
#include "../ge_constants.h"
|
||||
#undef max
|
||||
|
||||
class IndexGenerator
|
||||
{
|
||||
@ -42,28 +44,28 @@ public:
|
||||
// Rectangles
|
||||
void AddRectangles(int numVerts);
|
||||
|
||||
void TranslatePoints(int numVerts, const u8 *inds, int offset);
|
||||
void TranslatePoints(int numVerts, const u16 *inds, int offset);
|
||||
void TranslatePoints(int numVerts, const u8 *inds, int indexLowerBound, int indexUpperBound);
|
||||
void TranslatePoints(int numVerts, const u16 *inds, int indexLowerBound, int indexUpperBound);
|
||||
// Translates already indexed lists
|
||||
void TranslateLineList(int numVerts, const u8 *inds, int offset);
|
||||
void TranslateLineList(int numVerts, const u16 *inds, int offset);
|
||||
void TranslateLineStrip(int numVerts, const u8 *inds, int offset);
|
||||
void TranslateLineStrip(int numVerts, const u16 *inds, int offset);
|
||||
void TranslateLineList(int numVerts, const u8 *inds, int indexLowerBound, int indexUpperBound);
|
||||
void TranslateLineList(int numVerts, const u16 *inds, int indexLowerBound, int indexUpperBound);
|
||||
void TranslateLineStrip(int numVerts, const u8 *inds, int indexLowerBound, int indexUpperBound);
|
||||
void TranslateLineStrip(int numVerts, const u16 *inds, int indexLowerBound, int indexUpperBound);
|
||||
|
||||
void TranslateRectangles(int numVerts, const u8 *inds, int offset);
|
||||
void TranslateRectangles(int numVerts, const u16 *inds, int offset);
|
||||
void TranslateRectangles(int numVerts, const u8 *inds, int indexLowerBound, int indexUpperBound);
|
||||
void TranslateRectangles(int numVerts, const u16 *inds, int indexLowerBound, int indexUpperBound);
|
||||
|
||||
void TranslateList(int numVerts, const u8 *inds, int offset);
|
||||
void TranslateStrip(int numVerts, const u8 *inds, int offset);
|
||||
void TranslateFan(int numVerts, const u8 *inds, int offset);
|
||||
void TranslateList(int numVerts, const u16 *inds, int offset);
|
||||
void TranslateStrip(int numVerts, const u16 *inds, int offset);
|
||||
void TranslateFan(int numVerts, const u16 *inds, int offset);
|
||||
void TranslateList(int numVerts, const u8 *inds, int indexLowerBound, int indexUpperBound);
|
||||
void TranslateList(int numVerts, const u16 *inds, int indexLowerBound, int indexUpperBound);
|
||||
void TranslateStrip(int numVerts, const u8 *inds, int indexLowerBound, int indexUpperBound);
|
||||
void TranslateStrip(int numVerts, const u16 *inds, int indexLowerBound, int indexUpperBound);
|
||||
void TranslateFan(int numVerts, const u8 *inds, int indexLowerBound, int indexUpperBound);
|
||||
void TranslateFan(int numVerts, const u16 *inds, int indexLowerBound, int indexUpperBound);
|
||||
|
||||
int MaxIndex() { return index_; }
|
||||
int VertexCount() { return count_; }
|
||||
int MaxIndex() const { return index_; }
|
||||
int VertexCount() const { return count_; }
|
||||
|
||||
bool Empty() { return index_ == 0; }
|
||||
bool Empty() const { return index_ == 0; }
|
||||
|
||||
void SetIndex(int ind) { index_ = ind; }
|
||||
int SeenPrims() const { return seenPrims_; }
|
||||
|
@ -675,7 +675,6 @@ void TransformDrawEngine::SubmitPrim(void *verts, void *inds, int prim, int vert
|
||||
|
||||
if (!indexGen.PrimCompatible(prevPrim_, prim) || numDrawCalls >= MAX_DEFERRED_DRAW_CALLS)
|
||||
Flush();
|
||||
|
||||
prevPrim_ = prim;
|
||||
// If vtype has changed, setup the vertex decoder.
|
||||
// TODO: Simply cache the setup decoders instead.
|
||||
@ -738,25 +737,25 @@ void TransformDrawEngine::DecodeVerts() {
|
||||
|
||||
case GE_VTYPE_IDX_8BIT >> GE_VTYPE_IDX_SHIFT:
|
||||
switch (dc.prim) {
|
||||
case GE_PRIM_POINTS: indexGen.TranslatePoints(vertexCount, (const u8 *)inds, -indexLowerBound); break;
|
||||
case GE_PRIM_LINES: indexGen.TranslateLineList(vertexCount, (const u8 *)inds, -indexLowerBound); break;
|
||||
case GE_PRIM_LINE_STRIP: indexGen.TranslateLineStrip(vertexCount, (const u8 *)inds, -indexLowerBound); break;
|
||||
case GE_PRIM_TRIANGLES: indexGen.TranslateList(vertexCount, (const u8 *)inds, -indexLowerBound); break;
|
||||
case GE_PRIM_TRIANGLE_STRIP: indexGen.TranslateStrip(vertexCount, (const u8 *)inds, -indexLowerBound); break;
|
||||
case GE_PRIM_TRIANGLE_FAN: indexGen.TranslateFan(vertexCount, (const u8 *)inds, -indexLowerBound); break;
|
||||
case GE_PRIM_RECTANGLES: indexGen.TranslateRectangles(vertexCount, (const u8 *)inds, -indexLowerBound); break; // Same
|
||||
case GE_PRIM_POINTS: indexGen.TranslatePoints(vertexCount, (const u8 *)inds, indexLowerBound, indexUpperBound); break;
|
||||
case GE_PRIM_LINES: indexGen.TranslateLineList(vertexCount, (const u8 *)inds, indexLowerBound, indexUpperBound); break;
|
||||
case GE_PRIM_LINE_STRIP: indexGen.TranslateLineStrip(vertexCount, (const u8 *)inds, indexLowerBound, indexUpperBound); break;
|
||||
case GE_PRIM_TRIANGLES: indexGen.TranslateList(vertexCount, (const u8 *)inds, indexLowerBound, indexUpperBound); break;
|
||||
case GE_PRIM_TRIANGLE_STRIP: indexGen.TranslateStrip(vertexCount, (const u8 *)inds, indexLowerBound, indexUpperBound); break;
|
||||
case GE_PRIM_TRIANGLE_FAN: indexGen.TranslateFan(vertexCount, (const u8 *)inds, indexLowerBound, indexUpperBound); break;
|
||||
case GE_PRIM_RECTANGLES: indexGen.TranslateRectangles(vertexCount, (const u8 *)inds, indexLowerBound, indexUpperBound); break; // Same
|
||||
}
|
||||
break;
|
||||
|
||||
case GE_VTYPE_IDX_16BIT >> GE_VTYPE_IDX_SHIFT:
|
||||
switch (dc.prim) {
|
||||
case GE_PRIM_POINTS: indexGen.TranslatePoints(vertexCount, (const u16 *)inds, -indexLowerBound); break;
|
||||
case GE_PRIM_LINES: indexGen.TranslateLineList(vertexCount, (const u16 *)inds, -indexLowerBound); break;
|
||||
case GE_PRIM_LINE_STRIP: indexGen.TranslateLineStrip(vertexCount, (const u16 *)inds, -indexLowerBound); break;
|
||||
case GE_PRIM_TRIANGLES: indexGen.TranslateList(vertexCount, (const u16 *)inds, -indexLowerBound); break;
|
||||
case GE_PRIM_TRIANGLE_STRIP: indexGen.TranslateStrip(vertexCount, (const u16 *)inds, -indexLowerBound); break;
|
||||
case GE_PRIM_TRIANGLE_FAN: indexGen.TranslateFan(vertexCount, (const u16 *)inds, -indexLowerBound); break;
|
||||
case GE_PRIM_RECTANGLES: indexGen.TranslateRectangles(vertexCount, (const u16 *)inds, -indexLowerBound); break; // Same
|
||||
case GE_PRIM_POINTS: indexGen.TranslatePoints(vertexCount, (const u16 *)inds, indexLowerBound, indexUpperBound); break;
|
||||
case GE_PRIM_LINES: indexGen.TranslateLineList(vertexCount, (const u16 *)inds, indexLowerBound, indexUpperBound); break;
|
||||
case GE_PRIM_LINE_STRIP: indexGen.TranslateLineStrip(vertexCount, (const u16 *)inds, indexLowerBound, indexUpperBound); break;
|
||||
case GE_PRIM_TRIANGLES: indexGen.TranslateList(vertexCount, (const u16 *)inds, indexLowerBound, indexUpperBound); break;
|
||||
case GE_PRIM_TRIANGLE_STRIP: indexGen.TranslateStrip(vertexCount, (const u16 *)inds, indexLowerBound, indexUpperBound); break;
|
||||
case GE_PRIM_TRIANGLE_FAN: indexGen.TranslateFan(vertexCount, (const u16 *)inds, indexLowerBound, indexUpperBound); break;
|
||||
case GE_PRIM_RECTANGLES: indexGen.TranslateRectangles(vertexCount, (const u16 *)inds, indexLowerBound, indexUpperBound); break; // Same
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -909,6 +908,12 @@ void TransformDrawEngine::Flush() {
|
||||
// there is no need for the index buffer we built. We can then use glDrawArrays instead
|
||||
// for a very minor speed boost.
|
||||
if (useElements) {
|
||||
// Sanity Check
|
||||
for (int i = 0; i < indexGen.VertexCount(); i++) {
|
||||
if (decIndex[i] >= indexGen.MaxIndex()) {
|
||||
ERROR_LOG(G3D, "WTF? %i %i", indexGen.VertexCount(), indexGen.MaxIndex());
|
||||
}
|
||||
}
|
||||
glGenBuffers(1, &vai->ebo);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vai->ebo);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(short) * indexGen.VertexCount(), (GLvoid *)decIndex, GL_STATIC_DRAW);
|
||||
@ -958,6 +963,7 @@ void TransformDrawEngine::Flush() {
|
||||
rotateVBO:
|
||||
gpuStats.numUncachedVertsDrawn += indexGen.VertexCount();
|
||||
useElements = !indexGen.SeenOnlyPurePrims();
|
||||
vertexCount = indexGen.VertexCount();
|
||||
if (g_Config.bUseVBO) {
|
||||
// Just rotate VBO.
|
||||
vbo = vbo_[curVbo_];
|
||||
@ -969,13 +975,12 @@ rotateVBO:
|
||||
glBufferData(GL_ARRAY_BUFFER, dec.GetDecVtxFmt().stride * indexGen.MaxIndex(), decoded, GL_STREAM_DRAW);
|
||||
if (useElements) {
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ebo);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(short) * indexGen.VertexCount(), (GLvoid *)decIndex, GL_STREAM_DRAW);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(short) * vertexCount, (GLvoid *)decIndex, GL_STREAM_DRAW);
|
||||
}
|
||||
} else {
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
}
|
||||
vertexCount = indexGen.VertexCount();
|
||||
prim = indexGen.Prim();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user