summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSmileTheory <SmileTheory@gmail.com>2014-10-15 20:00:54 -0700
committerTim Angus <tim@ngus.net>2015-03-17 11:38:54 +0000
commit4b2503c850ecc09c01569abed2f910ab4c08ea04 (patch)
tree3116090cc8a6d1ecadf83eed929a1b022486dd35
parent4db3b9ef897989f6b1bae8eae1b26f7b22e4adca (diff)
OpenGL2: Fix missing surfaces with r_mergeMultidraws 2.
-rw-r--r--src/renderergl2/tr_surface.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/renderergl2/tr_surface.c b/src/renderergl2/tr_surface.c
index ca804ee8..f4451eb8 100644
--- a/src/renderergl2/tr_surface.c
+++ b/src/renderergl2/tr_surface.c
@@ -437,10 +437,8 @@ 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)
- {
- i = tess.multiDrawPrimitives - 1;
- }
+ // harmless if no multidraw primitives (i = -1 < 0)
+ i = tess.multiDrawPrimitives - 1;
}
for (; i < tess.multiDrawPrimitives; i++)
@@ -448,11 +446,17 @@ static qboolean RB_SurfaceVao(vao_t *vao, int numVerts, int numIndexes, int firs
if (tess.multiDrawLastIndex[i] == firstIndexOffset)
{
mergeBack = i;
+
+ if (mergeForward != -1)
+ break;
}
if (lastIndexOffset == tess.multiDrawFirstIndex[i])
{
mergeForward = i;
+
+ if (mergeBack != -1)
+ break;
}
}
}
@@ -477,7 +481,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--;
@@ -486,10 +490,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;