mirror of
https://github.com/UberGames/ioef.git
synced 2024-11-30 16:01:46 +00:00
OpenGL2: Bit of multidraw optimization.
This commit is contained in:
parent
03ac9649ea
commit
4f5ebf8349
3 changed files with 3 additions and 9 deletions
|
@ -2005,7 +2005,7 @@ typedef struct stageVars
|
||||||
vec2_t texcoords[NUM_TEXTURE_BUNDLES][SHADER_MAX_VERTEXES];
|
vec2_t texcoords[NUM_TEXTURE_BUNDLES][SHADER_MAX_VERTEXES];
|
||||||
} stageVars_t;
|
} stageVars_t;
|
||||||
|
|
||||||
#define MAX_MULTIDRAW_PRIMITIVES 16384
|
#define MAX_MULTIDRAW_PRIMITIVES 256
|
||||||
|
|
||||||
typedef struct shaderCommands_s
|
typedef struct shaderCommands_s
|
||||||
{
|
{
|
||||||
|
@ -2045,7 +2045,6 @@ typedef struct shaderCommands_s
|
||||||
int multiDrawPrimitives;
|
int multiDrawPrimitives;
|
||||||
GLsizei multiDrawNumIndexes[MAX_MULTIDRAW_PRIMITIVES];
|
GLsizei multiDrawNumIndexes[MAX_MULTIDRAW_PRIMITIVES];
|
||||||
glIndex_t *multiDrawFirstIndex[MAX_MULTIDRAW_PRIMITIVES];
|
glIndex_t *multiDrawFirstIndex[MAX_MULTIDRAW_PRIMITIVES];
|
||||||
glIndex_t *multiDrawLastIndex[MAX_MULTIDRAW_PRIMITIVES];
|
|
||||||
glIndex_t multiDrawMinIndex[MAX_MULTIDRAW_PRIMITIVES];
|
glIndex_t multiDrawMinIndex[MAX_MULTIDRAW_PRIMITIVES];
|
||||||
glIndex_t multiDrawMaxIndex[MAX_MULTIDRAW_PRIMITIVES];
|
glIndex_t multiDrawMaxIndex[MAX_MULTIDRAW_PRIMITIVES];
|
||||||
|
|
||||||
|
|
|
@ -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,
|
static void R_DrawMultiElementsVao( int multiDrawPrimitives, glIndex_t *multiDrawMinIndex, glIndex_t *multiDrawMaxIndex,
|
||||||
GLsizei *multiDrawNumIndexes, glIndex_t **multiDrawFirstIndex)
|
GLsizei *multiDrawNumIndexes, glIndex_t **multiDrawFirstIndex)
|
||||||
{
|
{
|
||||||
if (glRefConfig.multiDrawArrays)
|
if (glRefConfig.multiDrawArrays && multiDrawPrimitives > 1)
|
||||||
{
|
{
|
||||||
qglMultiDrawElementsEXT(GL_TRIANGLES, multiDrawNumIndexes, GL_INDEX_TYPE, (const GLvoid **)multiDrawFirstIndex, multiDrawPrimitives);
|
qglMultiDrawElementsEXT(GL_TRIANGLES, multiDrawNumIndexes, GL_INDEX_TYPE, (const GLvoid **)multiDrawFirstIndex, multiDrawPrimitives);
|
||||||
}
|
}
|
||||||
|
|
|
@ -441,7 +441,7 @@ static qboolean RB_SurfaceVao(vao_t *vao, int numVerts, int numIndexes, int firs
|
||||||
|
|
||||||
for (; i < tess.multiDrawPrimitives; i++)
|
for (; i < tess.multiDrawPrimitives; i++)
|
||||||
{
|
{
|
||||||
if (tess.multiDrawLastIndex[i] == firstIndexOffset)
|
if (firstIndexOffset == tess.multiDrawFirstIndex[i] + tess.multiDrawNumIndexes[i])
|
||||||
{
|
{
|
||||||
mergeBack = 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)
|
if (mergeBack != -1 && mergeForward == -1)
|
||||||
{
|
{
|
||||||
tess.multiDrawNumIndexes[mergeBack] += numIndexes;
|
tess.multiDrawNumIndexes[mergeBack] += numIndexes;
|
||||||
tess.multiDrawLastIndex[mergeBack] = tess.multiDrawFirstIndex[mergeBack] + tess.multiDrawNumIndexes[mergeBack];
|
|
||||||
tess.multiDrawMinIndex[mergeBack] = MIN(tess.multiDrawMinIndex[mergeBack], minIndex);
|
tess.multiDrawMinIndex[mergeBack] = MIN(tess.multiDrawMinIndex[mergeBack], minIndex);
|
||||||
tess.multiDrawMaxIndex[mergeBack] = MAX(tess.multiDrawMaxIndex[mergeBack], maxIndex);
|
tess.multiDrawMaxIndex[mergeBack] = MAX(tess.multiDrawMaxIndex[mergeBack], maxIndex);
|
||||||
backEnd.pc.c_multidrawsMerged++;
|
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.multiDrawNumIndexes[mergeForward] += numIndexes;
|
||||||
tess.multiDrawFirstIndex[mergeForward] = firstIndexOffset;
|
tess.multiDrawFirstIndex[mergeForward] = firstIndexOffset;
|
||||||
tess.multiDrawLastIndex[mergeForward] = tess.multiDrawFirstIndex[mergeForward] + tess.multiDrawNumIndexes[mergeForward];
|
|
||||||
tess.multiDrawMinIndex[mergeForward] = MIN(tess.multiDrawMinIndex[mergeForward], minIndex);
|
tess.multiDrawMinIndex[mergeForward] = MIN(tess.multiDrawMinIndex[mergeForward], minIndex);
|
||||||
tess.multiDrawMaxIndex[mergeForward] = MAX(tess.multiDrawMaxIndex[mergeForward], maxIndex);
|
tess.multiDrawMaxIndex[mergeForward] = MAX(tess.multiDrawMaxIndex[mergeForward], maxIndex);
|
||||||
backEnd.pc.c_multidrawsMerged++;
|
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)
|
else if (mergeBack != -1 && mergeForward != -1)
|
||||||
{
|
{
|
||||||
tess.multiDrawNumIndexes[mergeBack] += numIndexes + tess.multiDrawNumIndexes[mergeForward];
|
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.multiDrawMinIndex[mergeBack] = MIN(tess.multiDrawMinIndex[mergeBack], MIN(tess.multiDrawMinIndex[mergeForward], minIndex));
|
||||||
tess.multiDrawMaxIndex[mergeBack] = MAX(tess.multiDrawMaxIndex[mergeBack], MAX(tess.multiDrawMaxIndex[mergeForward], maxIndex));
|
tess.multiDrawMaxIndex[mergeBack] = MAX(tess.multiDrawMaxIndex[mergeBack], MAX(tess.multiDrawMaxIndex[mergeForward], maxIndex));
|
||||||
tess.multiDrawPrimitives--;
|
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.multiDrawNumIndexes[mergeForward] = tess.multiDrawNumIndexes[tess.multiDrawPrimitives];
|
||||||
tess.multiDrawFirstIndex[mergeForward] = tess.multiDrawFirstIndex[tess.multiDrawPrimitives];
|
tess.multiDrawFirstIndex[mergeForward] = tess.multiDrawFirstIndex[tess.multiDrawPrimitives];
|
||||||
tess.multiDrawLastIndex[mergeForward] = tess.multiDrawLastIndex[tess.multiDrawPrimitives];
|
|
||||||
tess.multiDrawMinIndex[mergeForward] = tess.multiDrawMinIndex[tess.multiDrawPrimitives];
|
tess.multiDrawMinIndex[mergeForward] = tess.multiDrawMinIndex[tess.multiDrawPrimitives];
|
||||||
tess.multiDrawMaxIndex[mergeForward] = tess.multiDrawMaxIndex[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.multiDrawNumIndexes[tess.multiDrawPrimitives] = numIndexes;
|
||||||
tess.multiDrawFirstIndex[tess.multiDrawPrimitives] = firstIndexOffset;
|
tess.multiDrawFirstIndex[tess.multiDrawPrimitives] = firstIndexOffset;
|
||||||
tess.multiDrawLastIndex[tess.multiDrawPrimitives] = lastIndexOffset;
|
|
||||||
tess.multiDrawMinIndex[tess.multiDrawPrimitives] = minIndex;
|
tess.multiDrawMinIndex[tess.multiDrawPrimitives] = minIndex;
|
||||||
tess.multiDrawMaxIndex[tess.multiDrawPrimitives] = maxIndex;
|
tess.multiDrawMaxIndex[tess.multiDrawPrimitives] = maxIndex;
|
||||||
tess.multiDrawPrimitives++;
|
tess.multiDrawPrimitives++;
|
||||||
|
|
Loading…
Reference in a new issue