r300g: fix and cleanup flushing before clearing CMASK, ZMASK, and HIZ
authorMarek Olšák <maraeo@gmail.com>
Mon, 14 Jan 2013 00:38:51 +0000 (01:38 +0100)
committerMarek Olšák <maraeo@gmail.com>
Tue, 15 Jan 2013 20:50:34 +0000 (21:50 +0100)
src/gallium/drivers/r300/r300_blit.c
src/gallium/drivers/r300/r300_context.c
src/gallium/drivers/r300/r300_context.h
src/gallium/drivers/r300/r300_emit.c

index 2bb6063846b5aa72bdff79adcf061232fa91cc3e..e903e9a57cc0a03741121fd49532ad3507cab0ec 100644 (file)
@@ -295,12 +295,14 @@ static void r300_clear(struct pipe_context* pipe,
                         r300_depth_clear_value(fb->zsbuf->format, depth, stencil);
 
                     r300_mark_atom_dirty(r300, &r300->zmask_clear);
+                    r300_mark_atom_dirty(r300, &r300->gpu_flush);
                     buffers &= ~PIPE_CLEAR_DEPTHSTENCIL;
                 }
 
                 if (hiz_clear) {
                     r300->hiz_clear_value = r300_hiz_clear_value(depth);
                     r300_mark_atom_dirty(r300, &r300->hiz_clear);
+                    r300_mark_atom_dirty(r300, &r300->gpu_flush);
                 }
                 r300->num_z_clears++;
             }
@@ -339,6 +341,7 @@ static void r300_clear(struct pipe_context* pipe,
             if (r300->screen->cmask_resource == fb->cbufs[0]->texture) {
                 r300_set_clear_color(r300, color);
                 r300_mark_atom_dirty(r300, &r300->cmask_clear);
+                r300_mark_atom_dirty(r300, &r300->gpu_flush);
                 buffers &= ~PIPE_CLEAR_COLOR;
             }
         }
@@ -375,6 +378,7 @@ static void r300_clear(struct pipe_context* pipe,
          * procedure. */
         /* Calculate zmask_clear and hiz_clear atom sizes. */
         unsigned dwords =
+            r300->gpu_flush.size +
             (r300->zmask_clear.dirty ? r300->zmask_clear.size : 0) +
             (r300->hiz_clear.dirty ? r300->hiz_clear.size : 0) +
             (r300->cmask_clear.dirty ? r300->cmask_clear.size : 0) +
@@ -386,6 +390,9 @@ static void r300_clear(struct pipe_context* pipe,
         }
 
         /* Emit clear packets. */
+        r300_emit_gpu_flush(r300, r300->gpu_flush.size, r300->gpu_flush.state);
+        r300->gpu_flush.dirty = FALSE;
+
         if (r300->zmask_clear.dirty) {
             r300_emit_zmask_clear(r300, r300->zmask_clear.size,
                                   r300->zmask_clear.state);
index a6fccc6e02caddbda15a0166802a630f946f7c0b..d8af13f99548285a6ac4f713b9feb15256ed9504 100644 (file)
@@ -204,9 +204,9 @@ static boolean r300_setup_atoms(struct r300_context* r300)
     R300_INIT_ATOM(texture_cache_inval, 2);
     R300_INIT_ATOM(textures_state, 0);
     /* Clear commands */
-    R300_INIT_ATOM(hiz_clear, r300->screen->caps.hiz_ram > 0 ? 6 : 0);
-    R300_INIT_ATOM(zmask_clear, r300->screen->caps.zmask_ram > 0 ? 6 : 0);
-    R300_INIT_ATOM(cmask_clear, 6);
+    R300_INIT_ATOM(hiz_clear, r300->screen->caps.hiz_ram > 0 ? 4 : 0);
+    R300_INIT_ATOM(zmask_clear, r300->screen->caps.zmask_ram > 0 ? 4 : 0);
+    R300_INIT_ATOM(cmask_clear, 4);
     /* ZB (unpipelined), SU. */
     R300_INIT_ATOM(query_start, 4);
 
index 33851519bd87bedf7f08833baea583fe8c7b83e4..8f8dc0c8a796deb8ff6f34fae61c35323269f90b 100644 (file)
@@ -487,6 +487,13 @@ struct r300_context {
      * performance and stability if not handled with care. */
     /* GPU flush. */
     struct r300_atom gpu_flush;
+    /* Clears must be emitted immediately after the flush. */
+    /* HiZ clear */
+    struct r300_atom hiz_clear;
+    /* zmask clear */
+    struct r300_atom zmask_clear;
+    /* cmask clear */
+    struct r300_atom cmask_clear;
     /* Anti-aliasing (MSAA) state. */
     struct r300_atom aa_state;
     /* Framebuffer state. */
@@ -537,12 +544,6 @@ struct r300_context {
     struct r300_atom texture_cache_inval;
     /* Textures state. */
     struct r300_atom textures_state;
-    /* HiZ clear */
-    struct r300_atom hiz_clear;
-    /* zmask clear */
-    struct r300_atom zmask_clear;
-    /* cmask clear */
-    struct r300_atom cmask_clear;
     /* Occlusion query. */
     struct r300_atom query_start;
 
index 9ea084fac2d555ca6a1b9dd208ae70edd5326afe..b3dc2a041be289c652423a20ea0795ec0beb558d 100644 (file)
@@ -1210,9 +1210,6 @@ void r300_emit_hiz_clear(struct r300_context *r300, unsigned size, void *state)
     tex = r300_resource(fb->zsbuf->texture);
 
     BEGIN_CS(size);
-    OUT_CS_REG(R300_ZB_ZCACHE_CTLSTAT,
-        R300_ZB_ZCACHE_CTLSTAT_ZC_FLUSH_FLUSH_AND_FREE |
-        R300_ZB_ZCACHE_CTLSTAT_ZC_FREE_FREE);
     OUT_CS_PKT3(R300_PACKET3_3D_CLEAR_HIZ, 2);
     OUT_CS(0);
     OUT_CS(tex->tex.hiz_dwords[fb->zsbuf->u.tex.level]);
@@ -1235,9 +1232,6 @@ void r300_emit_zmask_clear(struct r300_context *r300, unsigned size, void *state
     tex = r300_resource(fb->zsbuf->texture);
 
     BEGIN_CS(size);
-    OUT_CS_REG(R300_ZB_ZCACHE_CTLSTAT,
-        R300_ZB_ZCACHE_CTLSTAT_ZC_FLUSH_FLUSH_AND_FREE |
-        R300_ZB_ZCACHE_CTLSTAT_ZC_FREE_FREE);
     OUT_CS_PKT3(R300_PACKET3_3D_CLEAR_ZMASK, 2);
     OUT_CS(0);
     OUT_CS(tex->tex.zmask_dwords[fb->zsbuf->u.tex.level]);
@@ -1259,9 +1253,6 @@ void r300_emit_cmask_clear(struct r300_context *r300, unsigned size, void *state
     tex = r300_resource(fb->cbufs[0]->texture);
 
     BEGIN_CS(size);
-    OUT_CS_REG(R300_RB3D_DSTCACHE_CTLSTAT,
-               R300_RB3D_DSTCACHE_CTLSTAT_DC_FREE_FREE_3D_TAGS |
-               R300_RB3D_DSTCACHE_CTLSTAT_DC_FLUSH_FLUSH_DIRTY_3D);
     OUT_CS_PKT3(R300_PACKET3_3D_CLEAR_CMASK, 2);
     OUT_CS(0);
     OUT_CS(tex->tex.cmask_dwords);