OpenGL2: Fix missing surfaces with r_mergeMultidraws 2.

This commit is contained in:
SmileTheory 2014-10-15 20:00:54 -07:00
parent 541d3a40c2
commit e34972b110

View file

@ -436,22 +436,26 @@ static qboolean RB_SurfaceVao(vao_t *vao, int numVerts, int numIndexes, int firs
if (r_mergeMultidraws->integer == 1)
{
// lazy merge, only check the last primitive
if (tess.multiDrawPrimitives)
{
// harmless if no multidraw primitives (i = -1 < 0)
i = tess.multiDrawPrimitives - 1;
}
}
for (; i < tess.multiDrawPrimitives; i++)
{
if (tess.multiDrawLastIndex[i] == firstIndexOffset)
{
mergeBack = i;
if (mergeForward != -1)
break;
}
if (lastIndexOffset == tess.multiDrawFirstIndex[i])
{
mergeForward = i;
if (mergeBack != -1)
break;
}
}
}
@ -476,7 +480,7 @@ static qboolean RB_SurfaceVao(vao_t *vao, int numVerts, int numIndexes, int firs
else if (mergeBack != -1 && mergeForward != -1)
{
tess.multiDrawNumIndexes[mergeBack] += numIndexes + tess.multiDrawNumIndexes[mergeForward];
tess.multiDrawLastIndex[mergeBack] = tess.multiDrawFirstIndex[mergeBack] + tess.multiDrawNumIndexes[mergeBack];
tess.multiDrawLastIndex[mergeBack] = tess.multiDrawFirstIndex[mergeForward] + tess.multiDrawNumIndexes[mergeForward];
tess.multiDrawMinIndex[mergeBack] = MIN(tess.multiDrawMinIndex[mergeBack], MIN(tess.multiDrawMinIndex[mergeForward], minIndex));
tess.multiDrawMaxIndex[mergeBack] = MAX(tess.multiDrawMaxIndex[mergeBack], MAX(tess.multiDrawMaxIndex[mergeForward], maxIndex));
tess.multiDrawPrimitives--;
@ -485,10 +489,13 @@ static qboolean RB_SurfaceVao(vao_t *vao, int numVerts, int numIndexes, int firs
{
tess.multiDrawNumIndexes[mergeForward] = tess.multiDrawNumIndexes[tess.multiDrawPrimitives];
tess.multiDrawFirstIndex[mergeForward] = tess.multiDrawFirstIndex[tess.multiDrawPrimitives];
tess.multiDrawLastIndex[mergeForward] = tess.multiDrawLastIndex[tess.multiDrawPrimitives];
tess.multiDrawMinIndex[mergeForward] = tess.multiDrawMinIndex[tess.multiDrawPrimitives];
tess.multiDrawMaxIndex[mergeForward] = tess.multiDrawMaxIndex[tess.multiDrawPrimitives];
}
backEnd.pc.c_multidrawsMerged += 2;
}
else if (mergeBack == -1 && mergeForward == -1)
else //if (mergeBack == -1 && mergeForward == -1)
{
tess.multiDrawNumIndexes[tess.multiDrawPrimitives] = numIndexes;
tess.multiDrawFirstIndex[tess.multiDrawPrimitives] = firstIndexOffset;