summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon
diff options
context:
space:
mode:
authordegasus <wickmarkus@web.de>2013-03-29 14:27:33 +0100
committerdegasus <wickmarkus@web.de>2013-03-29 14:27:33 +0100
commitca8554e7d1d7c77b3c2a9ed8a7fb12de7096c67b (patch)
treed4ffebafd1430f53c99bf0dc34b8dd80d319b4b4 /Source/Core/VideoCommon
parentc743e75d928f3367214d0ac87f80f3946c73e818 (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')
-rw-r--r--Source/Core/VideoCommon/Src/IndexGenerator.cpp46
-rw-r--r--Source/Core/VideoCommon/Src/VertexLoader.cpp4
-rw-r--r--Source/Core/VideoCommon/Src/VertexManagerBase.cpp70
-rw-r--r--Source/Core/VideoCommon/Src/VideoConfig.h1
4 files changed, 87 insertions, 34 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);
+ }
}
}
diff --git a/Source/Core/VideoCommon/Src/VertexLoader.cpp b/Source/Core/VideoCommon/Src/VertexLoader.cpp
index 5df495a44c..74c1bd9705 100644
--- a/Source/Core/VideoCommon/Src/VertexLoader.cpp
+++ b/Source/Core/VideoCommon/Src/VertexLoader.cpp
@@ -659,6 +659,10 @@ void VertexLoader::SetVAT(u32 _group0, u32 _group1, u32 _group2)
m_VtxAttr.texCoord[7].Elements = vat.g2.Tex7CoordElements;
m_VtxAttr.texCoord[7].Format = vat.g2.Tex7CoordFormat;
m_VtxAttr.texCoord[7].Frac = vat.g2.Tex7Frac;
+
+ if(!m_VtxAttr.ByteDequant) {
+ ERROR_LOG(VIDEO, "ByteDequant is set to zero");
+ }
};
void VertexLoader::AppendToString(std::string *dest) const
diff --git a/Source/Core/VideoCommon/Src/VertexManagerBase.cpp b/Source/Core/VideoCommon/Src/VertexManagerBase.cpp
index 87856b5aeb..076c45e4eb 100644
--- a/Source/Core/VideoCommon/Src/VertexManagerBase.cpp
+++ b/Source/Core/VideoCommon/Src/VertexManagerBase.cpp
@@ -74,28 +74,54 @@ bool VertexManager::IsFlushed() const
u32 VertexManager::GetRemainingIndices(int primitive)
{
- switch (primitive)
- {
- case GX_DRAW_QUADS:
- return (MAXIBUFFERSIZE - IndexGenerator::GetTriangleindexLen()) / 6 * 4;
- case GX_DRAW_TRIANGLES:
- return (MAXIBUFFERSIZE - IndexGenerator::GetTriangleindexLen());
- case GX_DRAW_TRIANGLE_STRIP:
- return (MAXIBUFFERSIZE - IndexGenerator::GetTriangleindexLen()) / 3 + 2;
- case GX_DRAW_TRIANGLE_FAN:
- return (MAXIBUFFERSIZE - IndexGenerator::GetTriangleindexLen()) / 3 + 2;
-
- case GX_DRAW_LINES:
- return (MAXIBUFFERSIZE - IndexGenerator::GetLineindexLen());
- case GX_DRAW_LINE_STRIP:
- return (MAXIBUFFERSIZE - IndexGenerator::GetLineindexLen()) / 2 + 1;
-
- case GX_DRAW_POINTS:
- return (MAXIBUFFERSIZE - IndexGenerator::GetPointindexLen());
-
- default:
- return 0;
- }
+
+ if(g_Config.backend_info.bSupportsPrimitiveRestart) {
+ switch (primitive)
+ {
+ case GX_DRAW_QUADS:
+ return (MAXIBUFFERSIZE - IndexGenerator::GetTriangleindexLen()) / 5 * 4;
+ case GX_DRAW_TRIANGLES:
+ return (MAXIBUFFERSIZE - IndexGenerator::GetTriangleindexLen()) / 4 * 3;
+ case GX_DRAW_TRIANGLE_STRIP:
+ return (MAXIBUFFERSIZE - IndexGenerator::GetTriangleindexLen()) / 1 - 1;
+ case GX_DRAW_TRIANGLE_FAN:
+ return (MAXIBUFFERSIZE - IndexGenerator::GetTriangleindexLen()) / 4 + 2;
+
+ case GX_DRAW_LINES:
+ return (MAXIBUFFERSIZE - IndexGenerator::GetLineindexLen());
+ case GX_DRAW_LINE_STRIP:
+ return (MAXIBUFFERSIZE - IndexGenerator::GetLineindexLen()) / 2 + 1;
+
+ case GX_DRAW_POINTS:
+ return (MAXIBUFFERSIZE - IndexGenerator::GetPointindexLen());
+
+ default:
+ return 0;
+ }
+ } else {
+ switch (primitive)
+ {
+ case GX_DRAW_QUADS:
+ return (MAXIBUFFERSIZE - IndexGenerator::GetTriangleindexLen()) / 6 * 4;
+ case GX_DRAW_TRIANGLES:
+ return (MAXIBUFFERSIZE - IndexGenerator::GetTriangleindexLen());
+ case GX_DRAW_TRIANGLE_STRIP:
+ return (MAXIBUFFERSIZE - IndexGenerator::GetTriangleindexLen()) / 3 + 2;
+ case GX_DRAW_TRIANGLE_FAN:
+ return (MAXIBUFFERSIZE - IndexGenerator::GetTriangleindexLen()) / 3 + 2;
+
+ case GX_DRAW_LINES:
+ return (MAXIBUFFERSIZE - IndexGenerator::GetLineindexLen());
+ case GX_DRAW_LINE_STRIP:
+ return (MAXIBUFFERSIZE - IndexGenerator::GetLineindexLen()) / 2 + 1;
+
+ case GX_DRAW_POINTS:
+ return (MAXIBUFFERSIZE - IndexGenerator::GetPointindexLen());
+
+ default:
+ return 0;
+ }
+ }
}
void VertexManager::AddVertices(int primitive, u32 numVertices)
diff --git a/Source/Core/VideoCommon/Src/VideoConfig.h b/Source/Core/VideoCommon/Src/VideoConfig.h
index 442e95f9bf..88326346f2 100644
--- a/Source/Core/VideoCommon/Src/VideoConfig.h
+++ b/Source/Core/VideoCommon/Src/VideoConfig.h
@@ -153,6 +153,7 @@ struct VideoConfig
bool bSupportsDualSourceBlend; // only supported by D3D11 and OpenGL
bool bSupportsFormatReinterpretation;
bool bSupportsPixelLighting;
+ bool bSupportsPrimitiveRestart;
bool bSupportsGLSLUBO; // needed by pixelShaderGen, so must stay in videoCommon
} backend_info;