summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon
diff options
context:
space:
mode:
authordegasus <wickmarkus@web.de>2013-03-23 00:18:35 +0100
committerdegasus <wickmarkus@web.de>2013-03-23 00:18:35 +0100
commit470c9ff08a79514f70666b0077ef5d2bedab8b3c (patch)
treefd99dffbe327ccb9e8ff0ae95dec44b862bdf247 /Source/Core/VideoCommon
parent59b360028404050b5e31de2c9618cb855917cad9 (diff)
check for overflow vertex indices, fixes issue 6135
thx @ JMC47 for identifying the reversion, creating a useful bug report with fifo log :-)
Diffstat (limited to 'Source/Core/VideoCommon')
-rw-r--r--Source/Core/VideoCommon/Src/IndexGenerator.cpp7
-rw-r--r--Source/Core/VideoCommon/Src/IndexGenerator.h2
-rw-r--r--Source/Core/VideoCommon/Src/VertexManagerBase.cpp10
3 files changed, 15 insertions, 4 deletions
diff --git a/Source/Core/VideoCommon/Src/IndexGenerator.cpp b/Source/Core/VideoCommon/Src/IndexGenerator.cpp
index 4e44fd8997..aa1a971687 100644
--- a/Source/Core/VideoCommon/Src/IndexGenerator.cpp
+++ b/Source/Core/VideoCommon/Src/IndexGenerator.cpp
@@ -166,3 +166,10 @@ void IndexGenerator::AddPoints(u32 numVerts)
++numP;
}
}
+
+
+u32 IndexGenerator::GetRemainingIndices()
+{
+ u32 max_index = 65535;
+ return max_index - index;
+}
diff --git a/Source/Core/VideoCommon/Src/IndexGenerator.h b/Source/Core/VideoCommon/Src/IndexGenerator.h
index b889d7ca23..f14d3ae026 100644
--- a/Source/Core/VideoCommon/Src/IndexGenerator.h
+++ b/Source/Core/VideoCommon/Src/IndexGenerator.h
@@ -41,6 +41,8 @@ public:
static u32 GetTriangleindexLen() {return (u32)(Tptr - BASETptr);}
static u32 GetLineindexLen() {return (u32)(Lptr - BASELptr);}
static u32 GetPointindexLen() {return (u32)(Pptr - BASEPptr);}
+
+ static u32 GetRemainingIndices();
/*
enum IndexPrimitiveType
{
diff --git a/Source/Core/VideoCommon/Src/VertexManagerBase.cpp b/Source/Core/VideoCommon/Src/VertexManagerBase.cpp
index 9cfc3aa3f4..87856b5aeb 100644
--- a/Source/Core/VideoCommon/Src/VertexManagerBase.cpp
+++ b/Source/Core/VideoCommon/Src/VertexManagerBase.cpp
@@ -52,16 +52,18 @@ void VertexManager::PrepareForAdditionalData(int primitive, u32 count, u32 strid
{
u32 const needed_vertex_bytes = count * stride;
- if (needed_vertex_bytes > GetRemainingSize() || count > GetRemainingIndices(primitive))
+ if (count > IndexGenerator::GetRemainingIndices() || count > GetRemainingIndices(primitive) || needed_vertex_bytes > GetRemainingSize())
{
Flush();
- if (needed_vertex_bytes > GetRemainingSize())
- ERROR_LOG(VIDEO, "VertexManager: Buffer not large enough for all vertices! "
- "Increase MAXVBUFFERSIZE or we need primitive breaking afterall.");
+ if(count > IndexGenerator::GetRemainingIndices())
+ ERROR_LOG(VIDEO, "Too less index values. Use 32bit or reset them on flush.");
if (count > GetRemainingIndices(primitive))
ERROR_LOG(VIDEO, "VertexManager: Buffer not large enough for all indices! "
"Increase MAXIBUFFERSIZE or we need primitive breaking afterall.");
+ if (needed_vertex_bytes > GetRemainingSize())
+ ERROR_LOG(VIDEO, "VertexManager: Buffer not large enough for all vertices! "
+ "Increase MAXVBUFFERSIZE or we need primitive breaking afterall.");
}
}