OpenGL2: Bit of multidraw optimization.

This commit is contained in:
SmileTheory 2014-10-16 00:32:20 -07:00
parent 03ac9649ea
commit 4f5ebf8349
3 changed files with 3 additions and 9 deletions

View File

@ -2005,7 +2005,7 @@ typedef struct stageVars
vec2_t texcoords[NUM_TEXTURE_BUNDLES][SHADER_MAX_VERTEXES];
} stageVars_t;
#define MAX_MULTIDRAW_PRIMITIVES 16384
#define MAX_MULTIDRAW_PRIMITIVES 256
typedef struct shaderCommands_s
{
@ -2045,7 +2045,6 @@ typedef struct shaderCommands_s
int multiDrawPrimitives;
GLsizei multiDrawNumIndexes[MAX_MULTIDRAW_PRIMITIVES];
glIndex_t *multiDrawFirstIndex[MAX_MULTIDRAW_PRIMITIVES];
glIndex_t *multiDrawLastIndex[MAX_MULTIDRAW_PRIMITIVES];
glIndex_t multiDrawMinIndex[MAX_MULTIDRAW_PRIMITIVES];
glIndex_t multiDrawMaxIndex[MAX_MULTIDRAW_PRIMITIVES];

View File

@ -54,7 +54,7 @@ void R_DrawElementsVao( int numIndexes, glIndex_t firstIndex, glIndex_t minIndex
static void R_DrawMultiElementsVao( int multiDrawPrimitives, glIndex_t *multiDrawMinIndex, glIndex_t *multiDrawMaxIndex,
GLsizei *multiDrawNumIndexes, glIndex_t **multiDrawFirstIndex)
{
if (glRefConfig.multiDrawArrays)
if (glRefConfig.multiDrawArrays && multiDrawPrimitives > 1)
{
qglMultiDrawElementsEXT(GL_TRIANGLES, multiDrawNumIndexes, GL_INDEX_TYPE, (const GLvoid **)multiDrawFirstIndex, multiDrawPrimitives);
}

View File

@ -441,7 +441,7 @@ static qboolean RB_SurfaceVao(vao_t *vao, int numVerts, int numIndexes, int firs
for (; i < tess.multiDrawPrimitives; i++)
{
if (tess.multiDrawLastIndex[i] == firstIndexOffset)
if (firstIndexOffset == tess.multiDrawFirstIndex[i] + tess.multiDrawNumIndexes[i])
{
mergeBack = i;
@ -462,7 +462,6 @@ static qboolean RB_SurfaceVao(vao_t *vao, int numVerts, int numIndexes, int firs
if (mergeBack != -1 && mergeForward == -1)
{
tess.multiDrawNumIndexes[mergeBack] += numIndexes;
tess.multiDrawLastIndex[mergeBack] = tess.multiDrawFirstIndex[mergeBack] + tess.multiDrawNumIndexes[mergeBack];
tess.multiDrawMinIndex[mergeBack] = MIN(tess.multiDrawMinIndex[mergeBack], minIndex);
tess.multiDrawMaxIndex[mergeBack] = MAX(tess.multiDrawMaxIndex[mergeBack], maxIndex);
backEnd.pc.c_multidrawsMerged++;
@ -471,7 +470,6 @@ static qboolean RB_SurfaceVao(vao_t *vao, int numVerts, int numIndexes, int firs
{
tess.multiDrawNumIndexes[mergeForward] += numIndexes;
tess.multiDrawFirstIndex[mergeForward] = firstIndexOffset;
tess.multiDrawLastIndex[mergeForward] = tess.multiDrawFirstIndex[mergeForward] + tess.multiDrawNumIndexes[mergeForward];
tess.multiDrawMinIndex[mergeForward] = MIN(tess.multiDrawMinIndex[mergeForward], minIndex);
tess.multiDrawMaxIndex[mergeForward] = MAX(tess.multiDrawMaxIndex[mergeForward], maxIndex);
backEnd.pc.c_multidrawsMerged++;
@ -479,7 +477,6 @@ 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[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--;
@ -488,7 +485,6 @@ 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];
}
@ -498,7 +494,6 @@ static qboolean RB_SurfaceVao(vao_t *vao, int numVerts, int numIndexes, int firs
{
tess.multiDrawNumIndexes[tess.multiDrawPrimitives] = numIndexes;
tess.multiDrawFirstIndex[tess.multiDrawPrimitives] = firstIndexOffset;
tess.multiDrawLastIndex[tess.multiDrawPrimitives] = lastIndexOffset;
tess.multiDrawMinIndex[tess.multiDrawPrimitives] = minIndex;
tess.multiDrawMaxIndex[tess.multiDrawPrimitives] = maxIndex;
tess.multiDrawPrimitives++;