diff options
-rw-r--r-- | src/renderergl2/tr_surface.c | 19 |
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; |