summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon
diff options
context:
space:
mode:
authordegasus <wickmarkus@web.de>2013-06-23 14:38:25 +0200
committerdegasus <wickmarkus@web.de>2013-06-23 14:38:25 +0200
commita2e132dd4b53d636641ecc4e74fdab7444f4b68e (patch)
tree25f9f9e88cdaf2d2f41be29bc617be80584c8ef4 /Source/Core/VideoCommon
parentb9953f5d6a1f54b53198bf1bd2b59bac1a90425b (diff)
small index generator optimiztions
- rewrite loops to not use divisions and multiplications - remove warnings as the current implementations seems to be correct (ignore additional vertices)
Diffstat (limited to 'Source/Core/VideoCommon')
-rw-r--r--Source/Core/VideoCommon/Src/IndexGenerator.cpp41
1 files changed, 14 insertions, 27 deletions
diff --git a/Source/Core/VideoCommon/Src/IndexGenerator.cpp b/Source/Core/VideoCommon/Src/IndexGenerator.cpp
index 3970d8c82f..25597862e0 100644
--- a/Source/Core/VideoCommon/Src/IndexGenerator.cpp
+++ b/Source/Core/VideoCommon/Src/IndexGenerator.cpp
@@ -80,14 +80,10 @@ template <bool pr> __forceinline void IndexGenerator::WriteTriangle(u32 index1,
template <bool pr> void IndexGenerator::AddList(u32 const numVerts)
{
- auto const numTris = numVerts / 3;
- for (u32 i = 0; i != numTris; ++i)
+ for (u32 i = 2; i < numVerts; i+=3)
{
- WriteTriangle<pr>(index + i * 3, index + i * 3 + 1, index + i * 3 + 2);
+ WriteTriangle<pr>(index + i - 2, index + i - 1, index + i);
}
- u32 remainingVerts = numVerts - numTris*3;
- if(remainingVerts)
- ERROR_LOG(VIDEO, "AddList: unknown count of vertices found");
}
template <bool pr> void IndexGenerator::AddStrip(u32 const numVerts)
@@ -189,50 +185,41 @@ template <bool pr> void IndexGenerator::AddFan(u32 numVerts)
*/
template <bool pr> void IndexGenerator::AddQuads(u32 numVerts)
{
- auto const numQuads = numVerts / 4;
- for (u32 i = 0; i != numQuads; ++i)
+ u32 i = 3;
+ for (; i < numVerts; i+=4)
{
if(pr)
{
- *Tptr++ = index + i * 4 + 1;
- *Tptr++ = index + i * 4 + 2;
- *Tptr++ = index + i * 4 + 0;
- *Tptr++ = index + i * 4 + 3;
+ *Tptr++ = index + i - 2;
+ *Tptr++ = index + i - 1;
+ *Tptr++ = index + i - 3;
+ *Tptr++ = index + i - 0;
*Tptr++ = s_primitive_restart;
numT += 2;
}
else
{
- WriteTriangle<pr>(index + i * 4, index + i * 4 + 1, index + i * 4 + 2);
- WriteTriangle<pr>(index + i * 4, index + i * 4 + 2, index + i * 4 + 3);
+ WriteTriangle<pr>(index + i - 3, index + i - 2, index + i - 1);
+ WriteTriangle<pr>(index + i - 3, index + i - 1, index + i - 0);
}
}
// three vertices remaining, so render a triangle
- u32 remainingVerts = numVerts - numQuads*4;
- if(remainingVerts == 3)
+ if(i == numVerts)
{
WriteTriangle<pr>(index+numVerts-3, index+numVerts-2, index+numVerts-1);
}
- else if(remainingVerts)
- {
- ERROR_LOG(VIDEO, "AddQuads: unknown count of vertices found");
- }
}
// Lines
void IndexGenerator::AddLineList(u32 numVerts)
{
- auto const numLines = numVerts / 2;
- for (u32 i = 0; i != numLines; ++i)
+ for (u32 i = 1; i < numVerts; i+=2)
{
- *Lptr++ = index + i * 2;
- *Lptr++ = index + i * 2 + 1;
+ *Lptr++ = index + i - 1;
+ *Lptr++ = index + i;
++numL;
}
- u32 remainingVerts = numVerts - numLines*2;
- if(remainingVerts)
- ERROR_LOG(VIDEO, "AddLineList: unknown count of vertices found");
}