[quake3-commits] r2350 - trunk/code/rend2

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Tue Nov 6 19:06:51 EST 2012


Author: smiletheory
Date: 2012-11-06 19:06:51 -0500 (Tue, 06 Nov 2012)
New Revision: 2350

Modified:
   trunk/code/rend2/tr_backend.c
   trunk/code/rend2/tr_bsp.c
   trunk/code/rend2/tr_local.h
   trunk/code/rend2/tr_model.c
   trunk/code/rend2/tr_shade.c
   trunk/code/rend2/tr_sky.c
   trunk/code/rend2/tr_surface.c
Log:
When calling qglDrawRangeElementsEXT(), use proper start and end parameters.

Modified: trunk/code/rend2/tr_backend.c
===================================================================
--- trunk/code/rend2/tr_backend.c	2012-11-01 06:03:15 UTC (rev 2349)
+++ trunk/code/rend2/tr_backend.c	2012-11-07 00:06:51 UTC (rev 2350)
@@ -974,6 +974,8 @@
 	tess.numIndexes = 0;
 	tess.numVertexes = 0;
 	tess.firstIndex = 0;
+	tess.minIndex = 0;
+	tess.maxIndex = 0;
 
 	tess.xyz[tess.numVertexes][0] = x;
 	tess.xyz[tess.numVertexes][1] = y;
@@ -1021,6 +1023,8 @@
 	tess.indexes[tess.numIndexes++] = 0;
 	tess.indexes[tess.numIndexes++] = 2;
 	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
 	RB_UpdateVBOs(ATTR_POSITION | ATTR_TEXCOORD);
@@ -1035,7 +1039,7 @@
 	VectorSet4(color, 1, 1, 1, 1);
 	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_BindNullIBO();
@@ -1043,6 +1047,8 @@
 	tess.numIndexes = 0;
 	tess.numVertexes = 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) {

Modified: trunk/code/rend2/tr_bsp.c
===================================================================
--- trunk/code/rend2/tr_bsp.c	2012-11-01 06:03:15 UTC (rev 2349)
+++ trunk/code/rend2/tr_bsp.c	2012-11-07 00:06:51 UTC (rev 2350)
@@ -1939,11 +1939,16 @@
 			{
 				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(j = 0; j < 3; 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 @@
 			{
 				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(j = 0; j < 3; 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 @@
 			{
 				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(j = 0; j < 3; 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 @@
 		vboSurf->numVerts = numVerts;
 		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->fogIndex = surf1->fogIndex;
 

Modified: trunk/code/rend2/tr_local.h
===================================================================
--- trunk/code/rend2/tr_local.h	2012-11-01 06:03:15 UTC (rev 2349)
+++ trunk/code/rend2/tr_local.h	2012-11-07 00:06:51 UTC (rev 2350)
@@ -1151,6 +1151,8 @@
 	// BSP VBO offsets
 	int             firstVert;
 	int             firstIndex;
+	glIndex_t       minIndex;
+	glIndex_t       maxIndex;
 
 	// static render data
 	VBO_t          *vbo;		// points to bsp model VBO
@@ -1180,6 +1182,8 @@
 	// BSP VBO offsets
 	int             firstVert;
 	int             firstIndex;
+	glIndex_t       minIndex;
+	glIndex_t       maxIndex;
 
 	// static render data
 	VBO_t          *vbo;		// points to bsp model VBO
@@ -1209,6 +1213,8 @@
 	// BSP VBO offsets
 	int             firstVert;
 	int             firstIndex;
+	glIndex_t       minIndex;
+	glIndex_t       maxIndex;
 
 	// static render data
 	VBO_t          *vbo;		// points to bsp model VBO
@@ -1267,6 +1273,8 @@
 	int             numIndexes;
 	int             numVerts;
 	int				firstIndex;
+	glIndex_t       minIndex;
+	glIndex_t       maxIndex;
 
 	// static render data
 	VBO_t          *vbo;
@@ -1283,6 +1291,8 @@
 	// backEnd stats
 	int             numIndexes;
 	int             numVerts;
+	glIndex_t       minIndex;
+	glIndex_t       maxIndex;
 
 	// static render data
 	VBO_t          *vbo;
@@ -2363,11 +2373,15 @@
 	int			firstIndex;
 	int			numIndexes;
 	int			numVertexes;
+	glIndex_t   minIndex;
+	glIndex_t   maxIndex;
 
 	int         multiDrawPrimitives;
 	GLsizei     multiDrawNumIndexes[MAX_MULTIDRAW_PRIMITIVES];
-	GLvoid *    multiDrawFirstIndex[MAX_MULTIDRAW_PRIMITIVES];
-	GLvoid *    multiDrawLastIndex[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];
 
 	// info extracted from current shader
 	int			numPasses;
@@ -2382,7 +2396,7 @@
 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);}
 
-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_StageIteratorSky( void );
 void RB_StageIteratorVertexLitTexture( void );

Modified: trunk/code/rend2/tr_model.c
===================================================================
--- trunk/code/rend2/tr_model.c	2012-11-01 06:03:15 UTC (rev 2349)
+++ trunk/code/rend2/tr_model.c	2012-11-07 00:06:51 UTC (rev 2350)
@@ -762,6 +762,10 @@
 			vboSurf->mdvSurface = surf;
 			vboSurf->numIndexes = surf->numTriangles * 3;
 			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->ofs_xyz       = ofs_xyz;

Modified: trunk/code/rend2/tr_shade.c
===================================================================
--- trunk/code/rend2/tr_shade.c	2012-11-01 06:03:15 UTC (rev 2349)
+++ trunk/code/rend2/tr_shade.c	2012-11-07 00:06:51 UTC (rev 2350)
@@ -41,21 +41,22 @@
 ==================
 */
 
-void R_DrawElementsVBO( int numIndexes, int firstIndex )
+void R_DrawElementsVBO( int numIndexes, glIndex_t firstIndex, glIndex_t minIndex, glIndex_t maxIndex )
 {
 	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
 		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)
 	{
-		qglMultiDrawElementsEXT(GL_TRIANGLES, multiDrawNumIndexes, GL_INDEX_TYPE, multiDrawFirstIndex, multiDrawPrimitives);
+		qglMultiDrawElementsEXT(GL_TRIANGLES, multiDrawNumIndexes, GL_INDEX_TYPE, (const GLvoid **)multiDrawFirstIndex, multiDrawPrimitives);
 	}
 	else
 	{
@@ -65,7 +66,7 @@
 		{
 			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
@@ -153,11 +154,11 @@
 
 		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
 		{
-			R_DrawElementsVBO(input->numIndexes, input->firstIndex);
+			R_DrawElementsVBO(input->numIndexes, input->firstIndex, input->minIndex, input->maxIndex);
 		}
 	}
 
@@ -404,11 +405,12 @@
 
 		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
 		{
-			R_DrawElementsVBO(tess.numIndexes, tess.firstIndex);
+			R_DrawElementsVBO(tess.numIndexes, tess.firstIndex, tess.minIndex, tess.maxIndex);
 		}
 
 		backEnd.pc.c_totalIndexes += tess.numIndexes;
@@ -856,11 +858,11 @@
 
 		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
 		{
-			R_DrawElementsVBO(input->numIndexes, input->firstIndex);
+			R_DrawElementsVBO(input->numIndexes, input->firstIndex, input->minIndex, input->maxIndex);
 		}
 
 		backEnd.pc.c_totalIndexes += tess.numIndexes;
@@ -1052,11 +1054,11 @@
 
 		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
 		{
-			R_DrawElementsVBO(input->numIndexes, input->firstIndex);
+			R_DrawElementsVBO(input->numIndexes, input->firstIndex, input->minIndex, input->maxIndex);
 		}
 
 		backEnd.pc.c_totalIndexes += tess.numIndexes;
@@ -1127,11 +1129,11 @@
 
 		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
 		{
-			R_DrawElementsVBO(input->numIndexes, input->firstIndex);
+			R_DrawElementsVBO(input->numIndexes, input->firstIndex, input->minIndex, input->maxIndex);
 		}
 
 		backEnd.pc.c_totalIndexes += tess.numIndexes;
@@ -1197,11 +1199,12 @@
 
 	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
 	{
-		R_DrawElementsVBO(tess.numIndexes, tess.firstIndex);
+		R_DrawElementsVBO(tess.numIndexes, tess.firstIndex, tess.minIndex, tess.maxIndex);
 	}
 }
 
@@ -1519,11 +1522,11 @@
 		//
 		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
 		{
-			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
@@ -1583,11 +1586,11 @@
 
 			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
 			{
-				R_DrawElementsVBO(input->numIndexes, input->firstIndex);
+				R_DrawElementsVBO(input->numIndexes, input->firstIndex, input->minIndex, input->maxIndex);
 			}
 		}
 	}

Modified: trunk/code/rend2/tr_sky.c
===================================================================
--- trunk/code/rend2/tr_sky.c	2012-11-01 06:03:15 UTC (rev 2349)
+++ trunk/code/rend2/tr_sky.c	2012-11-07 00:06:51 UTC (rev 2350)
@@ -366,6 +366,8 @@
 	int s, t;
 	int firstVertex = tess.numVertexes;
 	//int firstIndex = tess.numIndexes;
+	int minIndex = tess.minIndex;
+	int maxIndex = tess.maxIndex;
 	vec4_t color;
 
 	//tess.numVertexes = 0;
@@ -415,6 +417,9 @@
 		}
 	}
 
+	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
 	RB_UpdateVBOs(ATTR_POSITION | ATTR_TEXCOORD);
 /*
@@ -458,7 +463,7 @@
 		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)));
 	
@@ -468,6 +473,8 @@
 	tess.numIndexes = tess.firstIndex;
 	tess.numVertexes = firstVertex;
 	tess.firstIndex = 0;
+	tess.minIndex = minIndex;
+	tess.maxIndex = maxIndex;
 }
 
 static void DrawSkyBox( shader_t *shader )

Modified: trunk/code/rend2/tr_surface.c
===================================================================
--- trunk/code/rend2/tr_surface.c	2012-11-01 06:03:15 UTC (rev 2349)
+++ trunk/code/rend2/tr_surface.c	2012-11-07 00:06:51 UTC (rev 2350)
@@ -214,16 +214,20 @@
 	tess.indexes[tess.numIndexes++] = 0;
 	tess.indexes[tess.numIndexes++] = 2;
 	tess.indexes[tess.numIndexes++] = 3;
+	tess.minIndex = 0;
+	tess.maxIndex = 3;
 
 	RB_UpdateVBOs(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.numVertexes = 0;
 	tess.firstIndex = 0;
+	tess.minIndex = 0;
+	tess.maxIndex = 0;
 }
 
 
@@ -461,7 +465,7 @@
 	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;
 	GLvoid *firstIndexOffset, *lastIndexOffset;
@@ -517,20 +521,26 @@
 	if (mergeBack != -1 && mergeForward == -1)
 	{
 		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++;
 	}
 	else if (mergeBack == -1 && mergeForward != -1)
 	{
 		tess.multiDrawNumIndexes[mergeForward] += numIndexes;
 		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++;
 	}
 	else if (mergeBack != -1 && mergeForward != -1)
 	{
 		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--;
 
 		if (mergeForward != tess.multiDrawPrimitives)
@@ -545,6 +555,8 @@
 		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++;
 	}
 
@@ -562,7 +574,7 @@
 =============
 */
 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;
 	}
@@ -623,6 +635,8 @@
 	tess.numVertexes = 0;
 	tess.numIndexes = 0;
 	tess.firstIndex = 0;
+	tess.minIndex = 0;
+	tess.maxIndex = 0;
 
 	for ( i = 0; i <= NUM_BEAM_SEGS; i++ ) {
 		VectorCopy(start_points[ i % NUM_BEAM_SEGS ], tess.xyz[tess.numVertexes++]);
@@ -639,6 +653,9 @@
 		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
 	RB_UpdateVBOs(ATTR_POSITION);
 	
@@ -658,11 +675,13 @@
 		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.numVertexes = 0;
 	tess.firstIndex = 0;
+	tess.minIndex = 0;
+	tess.maxIndex = 0;
 }
 
 //================================================================================
@@ -1286,7 +1305,7 @@
 ==============
 */
 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;
 	}
@@ -1353,7 +1372,7 @@
 	int     pshadowBits;
 	//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;
 	}
@@ -1611,7 +1630,7 @@
 
 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)
@@ -1636,6 +1655,8 @@
 
 	tess.numIndexes += surface->numIndexes;
 	tess.numVertexes += surface->numVerts;
+	tess.minIndex = surface->minIndex;
+	tess.maxIndex = surface->maxIndex;
 
 	//mdvModel = surface->mdvModel;
 	//mdvSurface = surface->mdvSurface;



More information about the quake3-commits mailing list