Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
check for overflow vertex indices, fixes issue 6135
thx @ JMC47 for identifying the reversion, creating a useful bug report with fifo log :-)
  • Loading branch information
degasus committed Mar 22, 2013
1 parent 59b3600 commit 470c9ff
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
7 changes: 7 additions & 0 deletions Source/Core/VideoCommon/Src/IndexGenerator.cpp
Expand Up @@ -166,3 +166,10 @@ void IndexGenerator::AddPoints(u32 numVerts)
++numP;
}
}


u32 IndexGenerator::GetRemainingIndices()
{
u32 max_index = 65535;
return max_index - index;
}
2 changes: 2 additions & 0 deletions Source/Core/VideoCommon/Src/IndexGenerator.h
Expand Up @@ -41,6 +41,8 @@ class IndexGenerator
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
{
Expand Down
10 changes: 6 additions & 4 deletions Source/Core/VideoCommon/Src/VertexManagerBase.cpp
Expand Up @@ -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.");
}
}

Expand Down

0 comments on commit 470c9ff

Please sign in to comment.