Mesa (r6xx-rewrite): r6xx/r7xx: fix buffer aging bug

Alex Deucher agd5f at kemper.freedesktop.org
Wed Jul 15 00:10:01 UTC 2009


Module: Mesa
Branch: r6xx-rewrite
Commit: 9385e4e1ff343c135532ddde04c0febf297003d7
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=9385e4e1ff343c135532ddde04c0febf297003d7

Author: Alex Deucher <alexdeucher at gmail.com>
Date:   Tue Jul 14 20:08:27 2009 -0400

r6xx/r7xx: fix buffer aging bug

We were using sparse indexing for aos, while the common
code expected packed indexing.

---

 src/mesa/drivers/dri/r600/r700_chip.c     |   34 +++++++++++++++-------------
 src/mesa/drivers/dri/r600/r700_vertprog.c |   27 ++++++++++++----------
 2 files changed, 33 insertions(+), 28 deletions(-)

diff --git a/src/mesa/drivers/dri/r600/r700_chip.c b/src/mesa/drivers/dri/r600/r700_chip.c
index ae380d8..9bd892a 100644
--- a/src/mesa/drivers/dri/r600/r700_chip.c
+++ b/src/mesa/drivers/dri/r600/r700_chip.c
@@ -355,7 +355,7 @@ int r700SetupStreams(GLcontext * ctx)
 	struct vertex_buffer *vb = &tnl->vb;
 
     unsigned int unBit;
-	unsigned int i;
+    unsigned int i, j = 0;
 
     BEGIN_BATCH_NO_AUTOSTATE(6);
     R600_OUT_BATCH(CP_PACKET3(R600_IT_SET_CTL_CONST, 1));
@@ -374,21 +374,23 @@ int r700SetupStreams(GLcontext * ctx)
 		unBit = 1 << i;
 		if(vpc->mesa_program.Base.InputsRead & unBit)
 		{
-			rcommon_emit_vector(ctx,
-					    &context->radeon.tcl.aos[i],
-					    vb->AttribPtr[i]->data,
-					    vb->AttribPtr[i]->size,
-					    vb->AttribPtr[i]->stride,
-					    vb->Count);
-
-			/* currently aos are packed */
-			r700SetupVTXConstants(ctx,
-					      i,
-					      (void*)(&context->radeon.tcl.aos[i]),
-					      (unsigned int)context->radeon.tcl.aos[i].components,
-					      (unsigned int)context->radeon.tcl.aos[i].stride * 4,
-					      (unsigned int)context->radeon.tcl.aos[i].count);
-
+			if (!context->radeon.tcl.aos[j].bo) {
+				rcommon_emit_vector(ctx,
+						    &context->radeon.tcl.aos[j],
+						    vb->AttribPtr[i]->data,
+						    vb->AttribPtr[i]->size,
+						    vb->AttribPtr[i]->stride,
+						    vb->Count);
+
+				/* currently aos are packed */
+				r700SetupVTXConstants(ctx,
+						      j,
+						      (void*)(&context->radeon.tcl.aos[j]),
+						      (unsigned int)context->radeon.tcl.aos[j].components,
+						      (unsigned int)context->radeon.tcl.aos[j].stride * 4,
+						      (unsigned int)context->radeon.tcl.aos[j].count);
+				j++;
+			}
 			context->radeon.tcl.aos_count++;
 		}
 	}
diff --git a/src/mesa/drivers/dri/r600/r700_vertprog.c b/src/mesa/drivers/dri/r600/r700_vertprog.c
index b83e6f1..a3720fb 100644
--- a/src/mesa/drivers/dri/r600/r700_vertprog.c
+++ b/src/mesa/drivers/dri/r600/r700_vertprog.c
@@ -115,7 +115,7 @@ unsigned int Map_Vertex_Input(r700_AssemblerBase       *pAsm,
 					  struct gl_vertex_program *mesa_vp,
 					  unsigned int unStart)
 {
-    int i;
+	int i, j = 0;
 	unsigned int unBit;
 	unsigned int unTotal = unStart;
 	for(i=0; i<VERT_ATTRIB_MAX; i++)
@@ -123,7 +123,8 @@ unsigned int Map_Vertex_Input(r700_AssemblerBase       *pAsm,
 		unBit = 1 << i;
 		if(mesa_vp->Base.InputsRead & unBit)
 		{
-			pAsm->ucVP_AttributeMap[i] = unTotal++;
+			pAsm->ucVP_AttributeMap[j] = unTotal++;
+			j++;
 		}
 	}
 	return (unTotal - unStart);
@@ -133,7 +134,7 @@ GLboolean Process_Vertex_Program_Vfetch_Instructions(
 						struct r700_vertex_program *vp,
 						struct gl_vertex_program   *mesa_vp)
 {
-    int i;
+	int i, j = 0;
     unsigned int unBit;
 	VTX_FETCH_METHOD vtxFetchMethod;
 	vtxFetchMethod.bEnableMini          = GL_FALSE;
@@ -145,11 +146,12 @@ GLboolean Process_Vertex_Program_Vfetch_Instructions(
 		if(mesa_vp->Base.InputsRead & unBit)
 		{
 			assemble_vfetch_instruction(&vp->r700AsmCode,
-								i,
-                                vp->r700AsmCode.ucVP_AttributeMap[i],
-								vp->aos_desc[i].size,
-                                vp->aos_desc[i].type,
-								&vtxFetchMethod);
+						    j,
+						    vp->r700AsmCode.ucVP_AttributeMap[j],
+						    vp->aos_desc[j].size,
+						    vp->aos_desc[j].type,
+						    &vtxFetchMethod);
+			j++;
 		}
 	}
 	
@@ -305,15 +307,16 @@ void r700SelectVertexShader(GLcontext *ctx)
 	struct vertex_buffer *vb = &tnl->vb;
 
     unsigned int unBit;
-	unsigned int i;
+    unsigned int i, j = 0;
 	for(i=0; i<VERT_ATTRIB_MAX; i++)
 	{
 		unBit = 1 << i;
 		if(vpc->mesa_program.Base.InputsRead & unBit) /* ctx->Array.ArrayObj->xxxxxxx */
 		{
-            vpc->aos_desc[i].size   = vb->AttribPtr[i]->size;
-            vpc->aos_desc[i].stride = vb->AttribPtr[i]->size * sizeof(GL_FLOAT);/* when emit array, data is packed. vb->AttribPtr[i]->stride;*/
-			vpc->aos_desc[i].type   = GL_FLOAT;
+			vpc->aos_desc[j].size   = vb->AttribPtr[i]->size;
+			vpc->aos_desc[j].stride = vb->AttribPtr[i]->size * sizeof(GL_FLOAT);/* when emit array, data is packed. vb->AttribPtr[i]->stride;*/
+			vpc->aos_desc[j].type   = GL_FLOAT;
+			j++;
 		}
 	}
 




More information about the mesa-commit mailing list