clean up cache flush emission into one place
authorDave Airlie <airlied@linux.ie>
Fri, 22 Jun 2007 09:18:04 +0000 (19:18 +1000)
committerDave Airlie <airlied@linux.ie>
Fri, 22 Jun 2007 09:18:04 +0000 (19:18 +1000)
makes gears work with swtcl

src/mesa/drivers/dri/r300/r300_emit.c
src/mesa/drivers/dri/r300/r300_emit.h
src/mesa/drivers/dri/r300/r300_ioctl.c
src/mesa/drivers/dri/r300/r300_render.c
src/mesa/drivers/dri/r300/r300_swtcl.c

index adeb688d1980a7045015d4aaad79c776511f1e3a..a7763bd76e67f79c2713624f7fa3251abd635382 100644 (file)
@@ -532,3 +532,19 @@ void r300ReleaseArrays(GLcontext * ctx)
                r300ReleaseDmaRegion(rmesa, &rmesa->state.aos[i], __FUNCTION__);
        }
 }
+
+void r300EmitCacheFlush(r300ContextPtr rmesa)
+{
+        int cmd_reserved = 0;
+       int cmd_written = 0;
+
+       drm_radeon_cmd_header_t *cmd = NULL;
+
+       reg_start(R300_RB3D_DSTCACHE_CTLSTAT, 0);
+       e32(R300_RB3D_DSTCACHE_UNKNOWN_0A);
+
+       reg_start(R300_RB3D_ZCACHE_CTLSTAT, 0);
+       e32(R300_RB3D_ZCACHE_UNKNOWN_03);
+
+
+}
index ce7279bbef47365c379bc7e075bacd7b2378262c..400e97f6f85dd73fcc9c02714e36ca55a5ac74bb 100644 (file)
@@ -228,4 +228,5 @@ extern void r300ReleaseArrays(GLcontext * ctx);
 extern int r300PrimitiveType(r300ContextPtr rmesa, int prim);
 extern int r300NumVerts(r300ContextPtr rmesa, int num_verts, int prim);
 
+extern void r300EmitCacheFlush(r300ContextPtr rmesa);
 #endif
index f7a44832e9b2095d6704d16a6de48723f9182718..1001c4ec07387cfb56e431fb055391163d588993 100644 (file)
@@ -172,11 +172,7 @@ static void r300ClearBuffer(r300ContextPtr r300, int flags, int buffer)
        cmd2[7].u = r300PackFloat32(ctx->Color.ClearColor[2]);
        cmd2[8].u = r300PackFloat32(ctx->Color.ClearColor[3]);
 
-       reg_start(R300_RB3D_DSTCACHE_CTLSTAT, 0);
-       e32(R300_RB3D_DSTCACHE_UNKNOWN_0A);
-
-       reg_start(R300_RB3D_ZCACHE_CTLSTAT, 0);
-       e32(R300_RB3D_ZCACHE_UNKNOWN_03);
+       r300EmitCacheFlush(rmesa);
        cp_wait(rmesa, R300_WAIT_3D | R300_WAIT_3D_CLEAN);
 }
 
index 7d97245281f99f52637186a951dbda41ddf8ae23..db935795c7995015c5e79d975d0fdb6c92407ccc 100644 (file)
@@ -287,9 +287,6 @@ static GLboolean r300RunRender(GLcontext * ctx,
 {
        r300ContextPtr rmesa = R300_CONTEXT(ctx);
        int i;
-       int cmd_reserved = 0;
-       int cmd_written = 0;
-       drm_radeon_cmd_header_t *cmd = NULL;
        TNLcontext *tnl = TNL_CONTEXT(ctx);
        struct vertex_buffer *vb = &tnl->vb;
 
@@ -303,12 +300,7 @@ static GLboolean r300RunRender(GLcontext * ctx,
 
        r300UpdateShaderStates(rmesa);
 
-       reg_start(R300_RB3D_DSTCACHE_CTLSTAT, 0);
-       e32(R300_RB3D_DSTCACHE_UNKNOWN_0A);
-
-       reg_start(R300_RB3D_ZCACHE_CTLSTAT, 0);
-       e32(R300_RB3D_ZCACHE_UNKNOWN_03);
-
+       r300EmitCacheFlush(rmesa);
        r300EmitState(rmesa);
 
        for (i = 0; i < vb->PrimitiveCount; i++) {
@@ -318,11 +310,7 @@ static GLboolean r300RunRender(GLcontext * ctx,
                r300RunRenderPrimitive(rmesa, ctx, start, end, prim);
        }
 
-       reg_start(R300_RB3D_DSTCACHE_CTLSTAT, 0);
-       e32(R300_RB3D_DSTCACHE_UNKNOWN_0A);
-
-       reg_start(R300_RB3D_ZCACHE_CTLSTAT, 0);
-       e32(R300_RB3D_ZCACHE_UNKNOWN_03);
+       r300EmitCacheFlush(rmesa);
 
 #ifdef USER_BUFFERS
        r300UseArrays(ctx);
index 35b0235aa14618fb16b00ae4202ce41d833d7a0a..e340f0b6e33bc48d64ec45d38a91028dff7bb83e 100644 (file)
@@ -370,7 +370,7 @@ static void flush_last_swtcl_prim( r300ContextPtr rmesa  )
 
       if (rmesa->dma.current.start != rmesa->dma.current.ptr) {
 
-       r300EnsureCmdBufSpace( rmesa, rmesa->hw.max_state_size + (8*sizeof(int)), __FUNCTION__);
+       r300EnsureCmdBufSpace( rmesa, rmesa->hw.max_state_size + (12*sizeof(int)), __FUNCTION__);
        r300EmitVertexAOS( rmesa,
                           rmesa->swtcl.vertex_size,
                           current_offset);
@@ -378,6 +378,8 @@ static void flush_last_swtcl_prim( r300ContextPtr rmesa  )
        r300EmitVbufPrim( rmesa,
                          rmesa->swtcl.hw_primitive,
                          rmesa->swtcl.numverts);
+
+       r300EmitCacheFlush(rmesa);
       }
 
       rmesa->swtcl.numverts = 0;
@@ -679,11 +681,7 @@ static void r300ChooseRenderState( GLcontext *ctx )
 
 static void r300RenderStart(GLcontext *ctx)
 {
-  r300ContextPtr rmesa = R300_CONTEXT( ctx );
-       int cmd_reserved = 0;
-       int cmd_written = 0;
-       drm_radeon_cmd_header_t *cmd = NULL;
-
+        r300ContextPtr rmesa = R300_CONTEXT( ctx );
        //      fprintf(stderr, "%s\n", __FUNCTION__);
 
        r300ChooseRenderState(ctx);     
@@ -691,11 +689,7 @@ static void r300RenderStart(GLcontext *ctx)
 
        r300UpdateShaderStates(rmesa);
 
-       reg_start(R300_RB3D_DSTCACHE_CTLSTAT, 0);
-       e32(R300_RB3D_DSTCACHE_UNKNOWN_0A);
-       
-       reg_start(R300_RB3D_ZCACHE_CTLSTAT, 0);
-       e32(R300_RB3D_ZCACHE_UNKNOWN_03);
+       r300EmitCacheFlush(rmesa);
        
        if (rmesa->dma.flush != 0 && 
            rmesa->dma.flush != flush_last_swtcl_prim)
@@ -705,16 +699,6 @@ static void r300RenderStart(GLcontext *ctx)
 
 static void r300RenderFinish(GLcontext *ctx)
 {
-        r300ContextPtr rmesa = R300_CONTEXT( ctx );
-       int cmd_reserved = 0;
-       int cmd_written = 0;
-       drm_radeon_cmd_header_t *cmd = NULL;
-
-       reg_start(R300_RB3D_DSTCACHE_CTLSTAT, 0);
-       e32(R300_RB3D_DSTCACHE_UNKNOWN_0A);
-
-       reg_start(R300_RB3D_ZCACHE_CTLSTAT, 0);
-       e32(R300_RB3D_ZCACHE_UNKNOWN_03);
 }
 
 static void r300RasterPrimitive( GLcontext *ctx, GLuint hwprim )