From 4b2503c850ecc09c01569abed2f910ab4c08ea04 Mon Sep 17 00:00:00 2001 From: SmileTheory Date: Wed, 15 Oct 2014 20:00:54 -0700 Subject: OpenGL2: Fix missing surfaces with r_mergeMultidraws 2. --- src/renderergl2/tr_surface.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'src') 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; -- cgit