diff options
| author | degasus <wickmarkus@web.de> | 2013-03-29 14:27:33 +0100 |
|---|---|---|
| committer | degasus <wickmarkus@web.de> | 2013-03-29 14:27:33 +0100 |
| commit | ca8554e7d1d7c77b3c2a9ed8a7fb12de7096c67b (patch) | |
| tree | d4ffebafd1430f53c99bf0dc34b8dd80d319b4b4 /Source/Core/VideoCommon/Src/IndexGenerator.cpp | |
| parent | c743e75d928f3367214d0ac87f80f3946c73e818 (diff) | |
first try of primitive restart index generator
Convert all quads+triangles into trangle_strip and uses primitive restart to split them.
Speed up triangle_strip, but slows down all others primitive formats.
Only implemented in ogl.
Diffstat (limited to 'Source/Core/VideoCommon/Src/IndexGenerator.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/Src/IndexGenerator.cpp | 46 |
1 files changed, 34 insertions, 12 deletions
diff --git a/Source/Core/VideoCommon/Src/IndexGenerator.cpp b/Source/Core/VideoCommon/Src/IndexGenerator.cpp index aa1a971687..05097b7c9a 100644 --- a/Source/Core/VideoCommon/Src/IndexGenerator.cpp +++ b/Source/Core/VideoCommon/Src/IndexGenerator.cpp @@ -18,6 +18,7 @@ #include <cstddef> #include "Common.h" +#include "VideoConfig.h" #include "IndexGenerator.h" /* @@ -90,7 +91,9 @@ __forceinline void IndexGenerator::WriteTriangle(u32 index1, u32 index2, u32 ind *Tptr++ = index1; *Tptr++ = index2; *Tptr++ = index3; - + if(g_Config.backend_info.bSupportsPrimitiveRestart) + *Tptr++ = 65535; + ++numT; } @@ -105,15 +108,25 @@ void IndexGenerator::AddList(u32 const numVerts) void IndexGenerator::AddStrip(u32 const numVerts) { - bool wind = false; - for (u32 i = 2; i < numVerts; ++i) - { - WriteTriangle( - index + i - 2, - index + i - !wind, - index + i - wind); - - wind ^= true; + if(g_Config.backend_info.bSupportsPrimitiveRestart) { + for (u32 i = 0; i < numVerts; ++i) + { + *Tptr++ = index + i; + } + *Tptr++ = 65535; + numT += numVerts - 2; + + } else { + bool wind = false; + for (u32 i = 2; i < numVerts; ++i) + { + WriteTriangle( + index + i - 2, + index + i - !wind, + index + i - wind); + + wind ^= true; + } } } @@ -130,8 +143,17 @@ void IndexGenerator::AddQuads(u32 numVerts) auto const numQuads = numVerts / 4; for (u32 i = 0; i != numQuads; ++i) { - WriteTriangle(index + i * 4, index + i * 4 + 1, index + i * 4 + 2); - WriteTriangle(index + i * 4, index + i * 4 + 2, index + i * 4 + 3); + if(g_Config.backend_info.bSupportsPrimitiveRestart) { + *Tptr++ = index + i * 4 + 0; + *Tptr++ = index + i * 4 + 1; + *Tptr++ = index + i * 4 + 3; + *Tptr++ = index + i * 4 + 2; + *Tptr++ = 65535; + numT += 2; + } else { + WriteTriangle(index + i * 4, index + i * 4 + 1, index + i * 4 + 2); + WriteTriangle(index + i * 4, index + i * 4 + 2, index + i * 4 + 3); + } } } |
