When calling qglDrawRangeElementsEXT(), use proper start and end parameters.
This commit is contained in:
parent
8234225459
commit
86984eb536
7 changed files with 115 additions and 36 deletions
|
@ -974,6 +974,8 @@ void RE_StretchRaw (int x, int y, int w, int h, int cols, int rows, const byte *
|
||||||
tess.numIndexes = 0;
|
tess.numIndexes = 0;
|
||||||
tess.numVertexes = 0;
|
tess.numVertexes = 0;
|
||||||
tess.firstIndex = 0;
|
tess.firstIndex = 0;
|
||||||
|
tess.minIndex = 0;
|
||||||
|
tess.maxIndex = 0;
|
||||||
|
|
||||||
tess.xyz[tess.numVertexes][0] = x;
|
tess.xyz[tess.numVertexes][0] = x;
|
||||||
tess.xyz[tess.numVertexes][1] = y;
|
tess.xyz[tess.numVertexes][1] = y;
|
||||||
|
@ -1021,6 +1023,8 @@ void RE_StretchRaw (int x, int y, int w, int h, int cols, int rows, const byte *
|
||||||
tess.indexes[tess.numIndexes++] = 0;
|
tess.indexes[tess.numIndexes++] = 0;
|
||||||
tess.indexes[tess.numIndexes++] = 2;
|
tess.indexes[tess.numIndexes++] = 2;
|
||||||
tess.indexes[tess.numIndexes++] = 3;
|
tess.indexes[tess.numIndexes++] = 3;
|
||||||
|
tess.minIndex = 0;
|
||||||
|
tess.maxIndex = 3;
|
||||||
|
|
||||||
// FIXME: A lot of this can probably be removed for speed, and refactored into a more convenient function
|
// FIXME: A lot of this can probably be removed for speed, and refactored into a more convenient function
|
||||||
RB_UpdateVBOs(ATTR_POSITION | ATTR_TEXCOORD);
|
RB_UpdateVBOs(ATTR_POSITION | ATTR_TEXCOORD);
|
||||||
|
@ -1035,7 +1039,7 @@ void RE_StretchRaw (int x, int y, int w, int h, int cols, int rows, const byte *
|
||||||
VectorSet4(color, 1, 1, 1, 1);
|
VectorSet4(color, 1, 1, 1, 1);
|
||||||
GLSL_SetUniformVec4(sp, TEXTURECOLOR_UNIFORM_COLOR, color);
|
GLSL_SetUniformVec4(sp, TEXTURECOLOR_UNIFORM_COLOR, color);
|
||||||
|
|
||||||
R_DrawElementsVBO(tess.numIndexes, tess.firstIndex);
|
R_DrawElementsVBO(tess.numIndexes, tess.firstIndex, tess.minIndex, tess.maxIndex);
|
||||||
|
|
||||||
//R_BindNullVBO();
|
//R_BindNullVBO();
|
||||||
//R_BindNullIBO();
|
//R_BindNullIBO();
|
||||||
|
@ -1043,6 +1047,8 @@ void RE_StretchRaw (int x, int y, int w, int h, int cols, int rows, const byte *
|
||||||
tess.numIndexes = 0;
|
tess.numIndexes = 0;
|
||||||
tess.numVertexes = 0;
|
tess.numVertexes = 0;
|
||||||
tess.firstIndex = 0;
|
tess.firstIndex = 0;
|
||||||
|
tess.minIndex = 0;
|
||||||
|
tess.maxIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RE_UploadCinematic (int w, int h, int cols, int rows, const byte *data, int client, qboolean dirty) {
|
void RE_UploadCinematic (int w, int h, int cols, int rows, const byte *data, int client, qboolean dirty) {
|
||||||
|
|
|
@ -1939,11 +1939,16 @@ static void R_CreateWorldVBO(void)
|
||||||
{
|
{
|
||||||
srfTriangle_t *tri;
|
srfTriangle_t *tri;
|
||||||
|
|
||||||
|
srf->minIndex = numVerts + srf->triangles->indexes[0];
|
||||||
|
srf->maxIndex = numVerts + srf->triangles->indexes[0];
|
||||||
|
|
||||||
for(i = 0, tri = srf->triangles; i < srf->numTriangles; i++, tri++)
|
for(i = 0, tri = srf->triangles; i < srf->numTriangles; i++, tri++)
|
||||||
{
|
{
|
||||||
for(j = 0; j < 3; j++)
|
for(j = 0; j < 3; j++)
|
||||||
{
|
{
|
||||||
triangles[numTriangles + i].indexes[j] = numVerts + tri->indexes[j];
|
triangles[numTriangles + i].indexes[j] = numVerts + tri->indexes[j];
|
||||||
|
srf->minIndex = MIN(srf->minIndex, numVerts + tri->indexes[j]);
|
||||||
|
srf->maxIndex = MAX(srf->maxIndex, numVerts + tri->indexes[j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1963,11 +1968,16 @@ static void R_CreateWorldVBO(void)
|
||||||
{
|
{
|
||||||
srfTriangle_t *tri;
|
srfTriangle_t *tri;
|
||||||
|
|
||||||
|
srf->minIndex = numVerts + srf->triangles->indexes[0];
|
||||||
|
srf->maxIndex = numVerts + srf->triangles->indexes[0];
|
||||||
|
|
||||||
for(i = 0, tri = srf->triangles; i < srf->numTriangles; i++, tri++)
|
for(i = 0, tri = srf->triangles; i < srf->numTriangles; i++, tri++)
|
||||||
{
|
{
|
||||||
for(j = 0; j < 3; j++)
|
for(j = 0; j < 3; j++)
|
||||||
{
|
{
|
||||||
triangles[numTriangles + i].indexes[j] = numVerts + tri->indexes[j];
|
triangles[numTriangles + i].indexes[j] = numVerts + tri->indexes[j];
|
||||||
|
srf->minIndex = MIN(srf->minIndex, numVerts + tri->indexes[j]);
|
||||||
|
srf->maxIndex = MAX(srf->maxIndex, numVerts + tri->indexes[j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1987,11 +1997,16 @@ static void R_CreateWorldVBO(void)
|
||||||
{
|
{
|
||||||
srfTriangle_t *tri;
|
srfTriangle_t *tri;
|
||||||
|
|
||||||
|
srf->minIndex = numVerts + srf->triangles->indexes[0];
|
||||||
|
srf->maxIndex = numVerts + srf->triangles->indexes[0];
|
||||||
|
|
||||||
for(i = 0, tri = srf->triangles; i < srf->numTriangles; i++, tri++)
|
for(i = 0, tri = srf->triangles; i < srf->numTriangles; i++, tri++)
|
||||||
{
|
{
|
||||||
for(j = 0; j < 3; j++)
|
for(j = 0; j < 3; j++)
|
||||||
{
|
{
|
||||||
triangles[numTriangles + i].indexes[j] = numVerts + tri->indexes[j];
|
triangles[numTriangles + i].indexes[j] = numVerts + tri->indexes[j];
|
||||||
|
srf->minIndex = MIN(srf->minIndex, numVerts + tri->indexes[j]);
|
||||||
|
srf->maxIndex = MAX(srf->maxIndex, numVerts + tri->indexes[j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3101,6 +3116,15 @@ void R_MergeLeafSurfaces(void)
|
||||||
vboSurf->numVerts = numVerts;
|
vboSurf->numVerts = numVerts;
|
||||||
vboSurf->firstIndex = firstIndex;
|
vboSurf->firstIndex = firstIndex;
|
||||||
|
|
||||||
|
vboSurf->minIndex = *(iboIndexes + firstIndex);
|
||||||
|
vboSurf->maxIndex = *(iboIndexes + firstIndex);
|
||||||
|
|
||||||
|
for (j = 1; j < numTriangles * 3; j++)
|
||||||
|
{
|
||||||
|
vboSurf->minIndex = MIN(vboSurf->minIndex, *(iboIndexes + firstIndex + j));
|
||||||
|
vboSurf->maxIndex = MAX(vboSurf->maxIndex, *(iboIndexes + firstIndex + j));
|
||||||
|
}
|
||||||
|
|
||||||
vboSurf->shader = surf1->shader;
|
vboSurf->shader = surf1->shader;
|
||||||
vboSurf->fogIndex = surf1->fogIndex;
|
vboSurf->fogIndex = surf1->fogIndex;
|
||||||
|
|
||||||
|
|
|
@ -1151,6 +1151,8 @@ typedef struct srfGridMesh_s
|
||||||
// BSP VBO offsets
|
// BSP VBO offsets
|
||||||
int firstVert;
|
int firstVert;
|
||||||
int firstIndex;
|
int firstIndex;
|
||||||
|
glIndex_t minIndex;
|
||||||
|
glIndex_t maxIndex;
|
||||||
|
|
||||||
// static render data
|
// static render data
|
||||||
VBO_t *vbo; // points to bsp model VBO
|
VBO_t *vbo; // points to bsp model VBO
|
||||||
|
@ -1180,6 +1182,8 @@ typedef struct
|
||||||
// BSP VBO offsets
|
// BSP VBO offsets
|
||||||
int firstVert;
|
int firstVert;
|
||||||
int firstIndex;
|
int firstIndex;
|
||||||
|
glIndex_t minIndex;
|
||||||
|
glIndex_t maxIndex;
|
||||||
|
|
||||||
// static render data
|
// static render data
|
||||||
VBO_t *vbo; // points to bsp model VBO
|
VBO_t *vbo; // points to bsp model VBO
|
||||||
|
@ -1209,6 +1213,8 @@ typedef struct
|
||||||
// BSP VBO offsets
|
// BSP VBO offsets
|
||||||
int firstVert;
|
int firstVert;
|
||||||
int firstIndex;
|
int firstIndex;
|
||||||
|
glIndex_t minIndex;
|
||||||
|
glIndex_t maxIndex;
|
||||||
|
|
||||||
// static render data
|
// static render data
|
||||||
VBO_t *vbo; // points to bsp model VBO
|
VBO_t *vbo; // points to bsp model VBO
|
||||||
|
@ -1267,6 +1273,8 @@ typedef struct srfVBOMesh_s
|
||||||
int numIndexes;
|
int numIndexes;
|
||||||
int numVerts;
|
int numVerts;
|
||||||
int firstIndex;
|
int firstIndex;
|
||||||
|
glIndex_t minIndex;
|
||||||
|
glIndex_t maxIndex;
|
||||||
|
|
||||||
// static render data
|
// static render data
|
||||||
VBO_t *vbo;
|
VBO_t *vbo;
|
||||||
|
@ -1283,6 +1291,8 @@ typedef struct srfVBOMDVMesh_s
|
||||||
// backEnd stats
|
// backEnd stats
|
||||||
int numIndexes;
|
int numIndexes;
|
||||||
int numVerts;
|
int numVerts;
|
||||||
|
glIndex_t minIndex;
|
||||||
|
glIndex_t maxIndex;
|
||||||
|
|
||||||
// static render data
|
// static render data
|
||||||
VBO_t *vbo;
|
VBO_t *vbo;
|
||||||
|
@ -2363,11 +2373,15 @@ typedef struct shaderCommands_s
|
||||||
int firstIndex;
|
int firstIndex;
|
||||||
int numIndexes;
|
int numIndexes;
|
||||||
int numVertexes;
|
int numVertexes;
|
||||||
|
glIndex_t minIndex;
|
||||||
|
glIndex_t maxIndex;
|
||||||
|
|
||||||
int multiDrawPrimitives;
|
int multiDrawPrimitives;
|
||||||
GLsizei multiDrawNumIndexes[MAX_MULTIDRAW_PRIMITIVES];
|
GLsizei multiDrawNumIndexes[MAX_MULTIDRAW_PRIMITIVES];
|
||||||
GLvoid * multiDrawFirstIndex[MAX_MULTIDRAW_PRIMITIVES];
|
glIndex_t *multiDrawFirstIndex[MAX_MULTIDRAW_PRIMITIVES];
|
||||||
GLvoid * multiDrawLastIndex[MAX_MULTIDRAW_PRIMITIVES];
|
glIndex_t *multiDrawLastIndex[MAX_MULTIDRAW_PRIMITIVES];
|
||||||
|
glIndex_t multiDrawMinIndex[MAX_MULTIDRAW_PRIMITIVES];
|
||||||
|
glIndex_t multiDrawMaxIndex[MAX_MULTIDRAW_PRIMITIVES];
|
||||||
|
|
||||||
// info extracted from current shader
|
// info extracted from current shader
|
||||||
int numPasses;
|
int numPasses;
|
||||||
|
@ -2382,7 +2396,7 @@ void RB_EndSurface(void);
|
||||||
void RB_CheckOverflow( int verts, int indexes );
|
void RB_CheckOverflow( int verts, int indexes );
|
||||||
#define RB_CHECKOVERFLOW(v,i) if (tess.numVertexes + (v) >= SHADER_MAX_VERTEXES || tess.numIndexes + (i) >= SHADER_MAX_INDEXES ) {RB_CheckOverflow(v,i);}
|
#define RB_CHECKOVERFLOW(v,i) if (tess.numVertexes + (v) >= SHADER_MAX_VERTEXES || tess.numIndexes + (i) >= SHADER_MAX_INDEXES ) {RB_CheckOverflow(v,i);}
|
||||||
|
|
||||||
void R_DrawElementsVBO( int numIndexes, int firstIndex );
|
void R_DrawElementsVBO( int numIndexes, glIndex_t firstIndex, glIndex_t minIndex, glIndex_t maxIndex );
|
||||||
void RB_StageIteratorGeneric( void );
|
void RB_StageIteratorGeneric( void );
|
||||||
void RB_StageIteratorSky( void );
|
void RB_StageIteratorSky( void );
|
||||||
void RB_StageIteratorVertexLitTexture( void );
|
void RB_StageIteratorVertexLitTexture( void );
|
||||||
|
|
|
@ -762,6 +762,10 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, int bufferSize,
|
||||||
vboSurf->mdvSurface = surf;
|
vboSurf->mdvSurface = surf;
|
||||||
vboSurf->numIndexes = surf->numTriangles * 3;
|
vboSurf->numIndexes = surf->numTriangles * 3;
|
||||||
vboSurf->numVerts = surf->numVerts;
|
vboSurf->numVerts = surf->numVerts;
|
||||||
|
|
||||||
|
vboSurf->minIndex = 0;
|
||||||
|
vboSurf->maxIndex = surf->numVerts;
|
||||||
|
|
||||||
vboSurf->vbo = R_CreateVBO(va("staticMD3Mesh_VBO '%s'", surf->name), data, dataSize, VBO_USAGE_STATIC);
|
vboSurf->vbo = R_CreateVBO(va("staticMD3Mesh_VBO '%s'", surf->name), data, dataSize, VBO_USAGE_STATIC);
|
||||||
|
|
||||||
vboSurf->vbo->ofs_xyz = ofs_xyz;
|
vboSurf->vbo->ofs_xyz = ofs_xyz;
|
||||||
|
|
|
@ -41,21 +41,22 @@ R_DrawElements
|
||||||
==================
|
==================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void R_DrawElementsVBO( int numIndexes, int firstIndex )
|
void R_DrawElementsVBO( int numIndexes, glIndex_t firstIndex, glIndex_t minIndex, glIndex_t maxIndex )
|
||||||
{
|
{
|
||||||
if (glRefConfig.drawRangeElements)
|
if (glRefConfig.drawRangeElements)
|
||||||
qglDrawRangeElementsEXT(GL_TRIANGLES, 0, numIndexes, numIndexes, GL_INDEX_TYPE, BUFFER_OFFSET(firstIndex * sizeof(GL_INDEX_TYPE)));
|
qglDrawRangeElementsEXT(GL_TRIANGLES, minIndex, maxIndex, numIndexes, GL_INDEX_TYPE, BUFFER_OFFSET(firstIndex * sizeof(GL_INDEX_TYPE)));
|
||||||
else
|
else
|
||||||
qglDrawElements(GL_TRIANGLES, numIndexes, GL_INDEX_TYPE, BUFFER_OFFSET(firstIndex * sizeof(GL_INDEX_TYPE)));
|
qglDrawElements(GL_TRIANGLES, numIndexes, GL_INDEX_TYPE, BUFFER_OFFSET(firstIndex * sizeof(GL_INDEX_TYPE)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void R_DrawMultiElementsVBO( int multiDrawPrimitives, const GLvoid **multiDrawFirstIndex, GLsizei *multiDrawNumIndexes )
|
static void R_DrawMultiElementsVBO( int multiDrawPrimitives, glIndex_t *multiDrawMinIndex, glIndex_t *multiDrawMaxIndex,
|
||||||
|
GLsizei *multiDrawNumIndexes, glIndex_t **multiDrawFirstIndex)
|
||||||
{
|
{
|
||||||
if (glRefConfig.multiDrawArrays)
|
if (glRefConfig.multiDrawArrays)
|
||||||
{
|
{
|
||||||
qglMultiDrawElementsEXT(GL_TRIANGLES, multiDrawNumIndexes, GL_INDEX_TYPE, multiDrawFirstIndex, multiDrawPrimitives);
|
qglMultiDrawElementsEXT(GL_TRIANGLES, multiDrawNumIndexes, GL_INDEX_TYPE, (const GLvoid **)multiDrawFirstIndex, multiDrawPrimitives);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -65,7 +66,7 @@ static void R_DrawMultiElementsVBO( int multiDrawPrimitives, const GLvoid **mult
|
||||||
{
|
{
|
||||||
for (i = 0; i < multiDrawPrimitives; i++)
|
for (i = 0; i < multiDrawPrimitives; i++)
|
||||||
{
|
{
|
||||||
qglDrawRangeElementsEXT(GL_TRIANGLES, 0, multiDrawNumIndexes[i], multiDrawNumIndexes[i], GL_INDEX_TYPE, multiDrawFirstIndex[i]);
|
qglDrawRangeElementsEXT(GL_TRIANGLES, multiDrawMinIndex[i], multiDrawMaxIndex[i], multiDrawNumIndexes[i], GL_INDEX_TYPE, multiDrawFirstIndex[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -153,11 +154,11 @@ static void DrawTris (shaderCommands_t *input) {
|
||||||
|
|
||||||
if (input->multiDrawPrimitives)
|
if (input->multiDrawPrimitives)
|
||||||
{
|
{
|
||||||
R_DrawMultiElementsVBO(input->multiDrawPrimitives, (const GLvoid **)input->multiDrawFirstIndex, input->multiDrawNumIndexes);
|
R_DrawMultiElementsVBO(input->multiDrawPrimitives, input->multiDrawMinIndex, input->multiDrawMaxIndex, input->multiDrawNumIndexes, input->multiDrawFirstIndex);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
R_DrawElementsVBO(input->numIndexes, input->firstIndex);
|
R_DrawElementsVBO(input->numIndexes, input->firstIndex, input->minIndex, input->maxIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -404,11 +405,12 @@ static void ProjectDlightTexture( void ) {
|
||||||
|
|
||||||
if (tess.multiDrawPrimitives)
|
if (tess.multiDrawPrimitives)
|
||||||
{
|
{
|
||||||
R_DrawMultiElementsVBO(tess.multiDrawPrimitives, (const GLvoid **)tess.multiDrawFirstIndex, tess.multiDrawNumIndexes);
|
shaderCommands_t *input = &tess;
|
||||||
|
R_DrawMultiElementsVBO(input->multiDrawPrimitives, input->multiDrawMinIndex, input->multiDrawMaxIndex, input->multiDrawNumIndexes, input->multiDrawFirstIndex);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
R_DrawElementsVBO(tess.numIndexes, tess.firstIndex);
|
R_DrawElementsVBO(tess.numIndexes, tess.firstIndex, tess.minIndex, tess.maxIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
backEnd.pc.c_totalIndexes += tess.numIndexes;
|
backEnd.pc.c_totalIndexes += tess.numIndexes;
|
||||||
|
@ -856,11 +858,11 @@ static void ForwardDlight( void ) {
|
||||||
|
|
||||||
if (input->multiDrawPrimitives)
|
if (input->multiDrawPrimitives)
|
||||||
{
|
{
|
||||||
R_DrawMultiElementsVBO(input->multiDrawPrimitives, (const GLvoid **)input->multiDrawFirstIndex, input->multiDrawNumIndexes);
|
R_DrawMultiElementsVBO(input->multiDrawPrimitives, input->multiDrawMinIndex, input->multiDrawMaxIndex, input->multiDrawNumIndexes, input->multiDrawFirstIndex);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
R_DrawElementsVBO(input->numIndexes, input->firstIndex);
|
R_DrawElementsVBO(input->numIndexes, input->firstIndex, input->minIndex, input->maxIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
backEnd.pc.c_totalIndexes += tess.numIndexes;
|
backEnd.pc.c_totalIndexes += tess.numIndexes;
|
||||||
|
@ -1052,11 +1054,11 @@ static void ForwardSunlight( void ) {
|
||||||
|
|
||||||
if (input->multiDrawPrimitives)
|
if (input->multiDrawPrimitives)
|
||||||
{
|
{
|
||||||
R_DrawMultiElementsVBO(input->multiDrawPrimitives, (const GLvoid **)input->multiDrawFirstIndex, input->multiDrawNumIndexes);
|
R_DrawMultiElementsVBO(input->multiDrawPrimitives, input->multiDrawMinIndex, input->multiDrawMaxIndex, input->multiDrawNumIndexes, input->multiDrawFirstIndex);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
R_DrawElementsVBO(input->numIndexes, input->firstIndex);
|
R_DrawElementsVBO(input->numIndexes, input->firstIndex, input->minIndex, input->maxIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
backEnd.pc.c_totalIndexes += tess.numIndexes;
|
backEnd.pc.c_totalIndexes += tess.numIndexes;
|
||||||
|
@ -1127,11 +1129,11 @@ static void ProjectPshadowVBOGLSL( void ) {
|
||||||
|
|
||||||
if (input->multiDrawPrimitives)
|
if (input->multiDrawPrimitives)
|
||||||
{
|
{
|
||||||
R_DrawMultiElementsVBO(input->multiDrawPrimitives, (const GLvoid **)input->multiDrawFirstIndex, input->multiDrawNumIndexes);
|
R_DrawMultiElementsVBO(input->multiDrawPrimitives, input->multiDrawMinIndex, input->multiDrawMaxIndex, input->multiDrawNumIndexes, input->multiDrawFirstIndex);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
R_DrawElementsVBO(input->numIndexes, input->firstIndex);
|
R_DrawElementsVBO(input->numIndexes, input->firstIndex, input->minIndex, input->maxIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
backEnd.pc.c_totalIndexes += tess.numIndexes;
|
backEnd.pc.c_totalIndexes += tess.numIndexes;
|
||||||
|
@ -1197,11 +1199,12 @@ static void RB_FogPass( void ) {
|
||||||
|
|
||||||
if (tess.multiDrawPrimitives)
|
if (tess.multiDrawPrimitives)
|
||||||
{
|
{
|
||||||
R_DrawMultiElementsVBO(tess.multiDrawPrimitives, (const GLvoid **)tess.multiDrawFirstIndex, tess.multiDrawNumIndexes);
|
shaderCommands_t *input = &tess;
|
||||||
|
R_DrawMultiElementsVBO(input->multiDrawPrimitives, input->multiDrawMinIndex, input->multiDrawMaxIndex, input->multiDrawNumIndexes, input->multiDrawFirstIndex);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
R_DrawElementsVBO(tess.numIndexes, tess.firstIndex);
|
R_DrawElementsVBO(tess.numIndexes, tess.firstIndex, tess.minIndex, tess.maxIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1519,11 +1522,11 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input )
|
||||||
//
|
//
|
||||||
if (input->multiDrawPrimitives)
|
if (input->multiDrawPrimitives)
|
||||||
{
|
{
|
||||||
R_DrawMultiElementsVBO(input->multiDrawPrimitives, (const GLvoid **)input->multiDrawFirstIndex, input->multiDrawNumIndexes);
|
R_DrawMultiElementsVBO(input->multiDrawPrimitives, input->multiDrawMinIndex, input->multiDrawMaxIndex, input->multiDrawNumIndexes, input->multiDrawFirstIndex);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
R_DrawElementsVBO(input->numIndexes, input->firstIndex);
|
R_DrawElementsVBO(input->numIndexes, input->firstIndex, input->minIndex, input->maxIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
// allow skipping out to show just lightmaps during development
|
// allow skipping out to show just lightmaps during development
|
||||||
|
@ -1583,11 +1586,11 @@ static void RB_RenderShadowmap( shaderCommands_t *input )
|
||||||
|
|
||||||
if (input->multiDrawPrimitives)
|
if (input->multiDrawPrimitives)
|
||||||
{
|
{
|
||||||
R_DrawMultiElementsVBO(input->multiDrawPrimitives, (const GLvoid **)input->multiDrawFirstIndex, input->multiDrawNumIndexes);
|
R_DrawMultiElementsVBO(input->multiDrawPrimitives, input->multiDrawMinIndex, input->multiDrawMaxIndex, input->multiDrawNumIndexes, input->multiDrawFirstIndex);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
R_DrawElementsVBO(input->numIndexes, input->firstIndex);
|
R_DrawElementsVBO(input->numIndexes, input->firstIndex, input->minIndex, input->maxIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -366,6 +366,8 @@ static void DrawSkySide( struct image_s *image, const int mins[2], const int max
|
||||||
int s, t;
|
int s, t;
|
||||||
int firstVertex = tess.numVertexes;
|
int firstVertex = tess.numVertexes;
|
||||||
//int firstIndex = tess.numIndexes;
|
//int firstIndex = tess.numIndexes;
|
||||||
|
int minIndex = tess.minIndex;
|
||||||
|
int maxIndex = tess.maxIndex;
|
||||||
vec4_t color;
|
vec4_t color;
|
||||||
|
|
||||||
//tess.numVertexes = 0;
|
//tess.numVertexes = 0;
|
||||||
|
@ -415,6 +417,9 @@ static void DrawSkySide( struct image_s *image, const int mins[2], const int max
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tess.minIndex = firstVertex;
|
||||||
|
tess.maxIndex = tess.numVertexes;
|
||||||
|
|
||||||
// FIXME: A lot of this can probably be removed for speed, and refactored into a more convenient function
|
// FIXME: A lot of this can probably be removed for speed, and refactored into a more convenient function
|
||||||
RB_UpdateVBOs(ATTR_POSITION | ATTR_TEXCOORD);
|
RB_UpdateVBOs(ATTR_POSITION | ATTR_TEXCOORD);
|
||||||
/*
|
/*
|
||||||
|
@ -458,7 +463,7 @@ static void DrawSkySide( struct image_s *image, const int mins[2], const int max
|
||||||
GLSL_SetUniformMatrix16(sp, GENERIC_UNIFORM_DIFFUSETEXMATRIX, matrix);
|
GLSL_SetUniformMatrix16(sp, GENERIC_UNIFORM_DIFFUSETEXMATRIX, matrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
R_DrawElementsVBO(tess.numIndexes - tess.firstIndex, tess.firstIndex);
|
R_DrawElementsVBO(tess.numIndexes - tess.firstIndex, tess.firstIndex, tess.minIndex, tess.maxIndex);
|
||||||
|
|
||||||
//qglDrawElements(GL_TRIANGLES, tess.numIndexes - tess.firstIndex, GL_INDEX_TYPE, BUFFER_OFFSET(tess.firstIndex * sizeof(GL_INDEX_TYPE)));
|
//qglDrawElements(GL_TRIANGLES, tess.numIndexes - tess.firstIndex, GL_INDEX_TYPE, BUFFER_OFFSET(tess.firstIndex * sizeof(GL_INDEX_TYPE)));
|
||||||
|
|
||||||
|
@ -468,6 +473,8 @@ static void DrawSkySide( struct image_s *image, const int mins[2], const int max
|
||||||
tess.numIndexes = tess.firstIndex;
|
tess.numIndexes = tess.firstIndex;
|
||||||
tess.numVertexes = firstVertex;
|
tess.numVertexes = firstVertex;
|
||||||
tess.firstIndex = 0;
|
tess.firstIndex = 0;
|
||||||
|
tess.minIndex = minIndex;
|
||||||
|
tess.maxIndex = maxIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DrawSkyBox( shader_t *shader )
|
static void DrawSkyBox( shader_t *shader )
|
||||||
|
|
|
@ -214,16 +214,20 @@ void RB_InstantQuad2(vec4_t quadVerts[4], vec2_t texCoords[4])
|
||||||
tess.indexes[tess.numIndexes++] = 0;
|
tess.indexes[tess.numIndexes++] = 0;
|
||||||
tess.indexes[tess.numIndexes++] = 2;
|
tess.indexes[tess.numIndexes++] = 2;
|
||||||
tess.indexes[tess.numIndexes++] = 3;
|
tess.indexes[tess.numIndexes++] = 3;
|
||||||
|
tess.minIndex = 0;
|
||||||
|
tess.maxIndex = 3;
|
||||||
|
|
||||||
RB_UpdateVBOs(ATTR_POSITION | ATTR_TEXCOORD);
|
RB_UpdateVBOs(ATTR_POSITION | ATTR_TEXCOORD);
|
||||||
|
|
||||||
GLSL_VertexAttribsState(ATTR_POSITION | ATTR_TEXCOORD);
|
GLSL_VertexAttribsState(ATTR_POSITION | ATTR_TEXCOORD);
|
||||||
|
|
||||||
R_DrawElementsVBO(tess.numIndexes, tess.firstIndex);
|
R_DrawElementsVBO(tess.numIndexes, tess.firstIndex, tess.minIndex, tess.maxIndex);
|
||||||
|
|
||||||
tess.numIndexes = 0;
|
tess.numIndexes = 0;
|
||||||
tess.numVertexes = 0;
|
tess.numVertexes = 0;
|
||||||
tess.firstIndex = 0;
|
tess.firstIndex = 0;
|
||||||
|
tess.minIndex = 0;
|
||||||
|
tess.maxIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -461,7 +465,7 @@ static void RB_SurfaceHelper( int numVerts, srfVert_t *verts, int numTriangles,
|
||||||
tess.numVertexes += numVerts;
|
tess.numVertexes += numVerts;
|
||||||
}
|
}
|
||||||
|
|
||||||
static qboolean RB_SurfaceHelperVBO(VBO_t *vbo, IBO_t *ibo, int numVerts, int numIndexes, int firstIndex, int dlightBits, int pshadowBits, qboolean shaderCheck)
|
static qboolean RB_SurfaceHelperVBO(VBO_t *vbo, IBO_t *ibo, int numVerts, int numIndexes, int firstIndex, int minIndex, int maxIndex, int dlightBits, int pshadowBits, qboolean shaderCheck)
|
||||||
{
|
{
|
||||||
int i, mergeForward, mergeBack;
|
int i, mergeForward, mergeBack;
|
||||||
GLvoid *firstIndexOffset, *lastIndexOffset;
|
GLvoid *firstIndexOffset, *lastIndexOffset;
|
||||||
|
@ -517,20 +521,26 @@ static qboolean RB_SurfaceHelperVBO(VBO_t *vbo, IBO_t *ibo, int numVerts, int nu
|
||||||
if (mergeBack != -1 && mergeForward == -1)
|
if (mergeBack != -1 && mergeForward == -1)
|
||||||
{
|
{
|
||||||
tess.multiDrawNumIndexes[mergeBack] += numIndexes;
|
tess.multiDrawNumIndexes[mergeBack] += numIndexes;
|
||||||
tess.multiDrawLastIndex[mergeBack] = (byte *)tess.multiDrawFirstIndex[mergeBack] + tess.multiDrawNumIndexes[mergeBack] * sizeof(GL_INDEX_TYPE);
|
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++;
|
backEnd.pc.c_multidrawsMerged++;
|
||||||
}
|
}
|
||||||
else if (mergeBack == -1 && mergeForward != -1)
|
else if (mergeBack == -1 && mergeForward != -1)
|
||||||
{
|
{
|
||||||
tess.multiDrawNumIndexes[mergeForward] += numIndexes;
|
tess.multiDrawNumIndexes[mergeForward] += numIndexes;
|
||||||
tess.multiDrawFirstIndex[mergeForward] = firstIndexOffset;
|
tess.multiDrawFirstIndex[mergeForward] = firstIndexOffset;
|
||||||
tess.multiDrawLastIndex[mergeForward] = (byte *)tess.multiDrawFirstIndex[mergeForward] + tess.multiDrawNumIndexes[mergeForward] * sizeof(GL_INDEX_TYPE);
|
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++;
|
backEnd.pc.c_multidrawsMerged++;
|
||||||
}
|
}
|
||||||
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] = (byte *)tess.multiDrawFirstIndex[mergeBack] + tess.multiDrawNumIndexes[mergeBack] * sizeof(GL_INDEX_TYPE);
|
tess.multiDrawLastIndex[mergeBack] = tess.multiDrawFirstIndex[mergeBack] + tess.multiDrawNumIndexes[mergeBack];
|
||||||
|
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--;
|
tess.multiDrawPrimitives--;
|
||||||
|
|
||||||
if (mergeForward != tess.multiDrawPrimitives)
|
if (mergeForward != tess.multiDrawPrimitives)
|
||||||
|
@ -545,6 +555,8 @@ static qboolean RB_SurfaceHelperVBO(VBO_t *vbo, IBO_t *ibo, int numVerts, int nu
|
||||||
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.multiDrawLastIndex[tess.multiDrawPrimitives] = lastIndexOffset;
|
||||||
|
tess.multiDrawMinIndex[tess.multiDrawPrimitives] = minIndex;
|
||||||
|
tess.multiDrawMaxIndex[tess.multiDrawPrimitives] = maxIndex;
|
||||||
tess.multiDrawPrimitives++;
|
tess.multiDrawPrimitives++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -562,7 +574,7 @@ RB_SurfaceTriangles
|
||||||
=============
|
=============
|
||||||
*/
|
*/
|
||||||
static void RB_SurfaceTriangles( srfTriangles_t *srf ) {
|
static void RB_SurfaceTriangles( srfTriangles_t *srf ) {
|
||||||
if( RB_SurfaceHelperVBO (srf->vbo, srf->ibo, srf->numVerts, srf->numTriangles * 3, srf->firstIndex, srf->dlightBits[backEnd.smpFrame], srf->pshadowBits[backEnd.smpFrame], qtrue ) )
|
if( RB_SurfaceHelperVBO (srf->vbo, srf->ibo, srf->numVerts, srf->numTriangles * 3, srf->firstIndex, srf->minIndex, srf->maxIndex, srf->dlightBits[backEnd.smpFrame], srf->pshadowBits[backEnd.smpFrame], qtrue ) )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -623,6 +635,8 @@ static void RB_SurfaceBeam( void )
|
||||||
tess.numVertexes = 0;
|
tess.numVertexes = 0;
|
||||||
tess.numIndexes = 0;
|
tess.numIndexes = 0;
|
||||||
tess.firstIndex = 0;
|
tess.firstIndex = 0;
|
||||||
|
tess.minIndex = 0;
|
||||||
|
tess.maxIndex = 0;
|
||||||
|
|
||||||
for ( i = 0; i <= NUM_BEAM_SEGS; i++ ) {
|
for ( i = 0; i <= NUM_BEAM_SEGS; i++ ) {
|
||||||
VectorCopy(start_points[ i % NUM_BEAM_SEGS ], tess.xyz[tess.numVertexes++]);
|
VectorCopy(start_points[ i % NUM_BEAM_SEGS ], tess.xyz[tess.numVertexes++]);
|
||||||
|
@ -639,6 +653,9 @@ static void RB_SurfaceBeam( void )
|
||||||
tess.indexes[tess.numIndexes++] = 1 + (i + 1) * 2;
|
tess.indexes[tess.numIndexes++] = 1 + (i + 1) * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tess.minIndex = 0;
|
||||||
|
tess.maxIndex = tess.numVertexes;
|
||||||
|
|
||||||
// FIXME: A lot of this can probably be removed for speed, and refactored into a more convenient function
|
// FIXME: A lot of this can probably be removed for speed, and refactored into a more convenient function
|
||||||
RB_UpdateVBOs(ATTR_POSITION);
|
RB_UpdateVBOs(ATTR_POSITION);
|
||||||
|
|
||||||
|
@ -658,11 +675,13 @@ static void RB_SurfaceBeam( void )
|
||||||
GLSL_SetUniformVec4(sp, TEXTURECOLOR_UNIFORM_COLOR, color);
|
GLSL_SetUniformVec4(sp, TEXTURECOLOR_UNIFORM_COLOR, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
R_DrawElementsVBO(tess.numIndexes, tess.firstIndex);
|
R_DrawElementsVBO(tess.numIndexes, tess.firstIndex, tess.minIndex, tess.maxIndex);
|
||||||
|
|
||||||
tess.numIndexes = 0;
|
tess.numIndexes = 0;
|
||||||
tess.numVertexes = 0;
|
tess.numVertexes = 0;
|
||||||
tess.firstIndex = 0;
|
tess.firstIndex = 0;
|
||||||
|
tess.minIndex = 0;
|
||||||
|
tess.maxIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//================================================================================
|
//================================================================================
|
||||||
|
@ -1286,7 +1305,7 @@ RB_SurfaceFace
|
||||||
==============
|
==============
|
||||||
*/
|
*/
|
||||||
static void RB_SurfaceFace( srfSurfaceFace_t *srf ) {
|
static void RB_SurfaceFace( srfSurfaceFace_t *srf ) {
|
||||||
if( RB_SurfaceHelperVBO (srf->vbo, srf->ibo, srf->numVerts, srf->numTriangles * 3, srf->firstIndex, srf->dlightBits[backEnd.smpFrame], srf->pshadowBits[backEnd.smpFrame], qtrue ) )
|
if( RB_SurfaceHelperVBO (srf->vbo, srf->ibo, srf->numVerts, srf->numTriangles * 3, srf->firstIndex, srf->minIndex, srf->maxIndex, srf->dlightBits[backEnd.smpFrame], srf->pshadowBits[backEnd.smpFrame], qtrue ) )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1353,7 +1372,7 @@ static void RB_SurfaceGrid( srfGridMesh_t *srf ) {
|
||||||
int pshadowBits;
|
int pshadowBits;
|
||||||
//int *vDlightBits;
|
//int *vDlightBits;
|
||||||
|
|
||||||
if( RB_SurfaceHelperVBO (srf->vbo, srf->ibo, srf->numVerts, srf->numTriangles * 3, srf->firstIndex, srf->dlightBits[backEnd.smpFrame], srf->pshadowBits[backEnd.smpFrame], qtrue ) )
|
if( RB_SurfaceHelperVBO (srf->vbo, srf->ibo, srf->numVerts, srf->numTriangles * 3, srf->firstIndex, srf->minIndex, srf->maxIndex, srf->dlightBits[backEnd.smpFrame], srf->pshadowBits[backEnd.smpFrame], qtrue ) )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1611,7 +1630,7 @@ static void RB_SurfaceFlare(srfFlare_t *surf)
|
||||||
|
|
||||||
static void RB_SurfaceVBOMesh(srfVBOMesh_t * srf)
|
static void RB_SurfaceVBOMesh(srfVBOMesh_t * srf)
|
||||||
{
|
{
|
||||||
RB_SurfaceHelperVBO (srf->vbo, srf->ibo, srf->numVerts, srf->numIndexes, srf->firstIndex, srf->dlightBits[backEnd.smpFrame], srf->pshadowBits[backEnd.smpFrame], qfalse );
|
RB_SurfaceHelperVBO (srf->vbo, srf->ibo, srf->numVerts, srf->numIndexes, srf->firstIndex, srf->minIndex, srf->maxIndex, srf->dlightBits[backEnd.smpFrame], srf->pshadowBits[backEnd.smpFrame], qfalse );
|
||||||
}
|
}
|
||||||
|
|
||||||
void RB_SurfaceVBOMDVMesh(srfVBOMDVMesh_t * surface)
|
void RB_SurfaceVBOMDVMesh(srfVBOMDVMesh_t * surface)
|
||||||
|
@ -1636,6 +1655,8 @@ void RB_SurfaceVBOMDVMesh(srfVBOMDVMesh_t * surface)
|
||||||
|
|
||||||
tess.numIndexes += surface->numIndexes;
|
tess.numIndexes += surface->numIndexes;
|
||||||
tess.numVertexes += surface->numVerts;
|
tess.numVertexes += surface->numVerts;
|
||||||
|
tess.minIndex = surface->minIndex;
|
||||||
|
tess.maxIndex = surface->maxIndex;
|
||||||
|
|
||||||
//mdvModel = surface->mdvModel;
|
//mdvModel = surface->mdvModel;
|
||||||
//mdvSurface = surface->mdvSurface;
|
//mdvSurface = surface->mdvSurface;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue