r600g: only do necessary cache flushes in cp_dma_clear_buffer
authorMarek Olšák <marek.olsak@amd.com>
Thu, 26 May 2016 15:18:13 +0000 (17:18 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Sat, 4 Jun 2016 13:42:33 +0000 (15:42 +0200)
The main impact is that fast color clear doesn't flush TC, CONST, DB.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Tested-by: Grazvydas Ignotas <notasas@gmail.com>
Tested-by: Dieter Nützel <Dieter@nuetzel-hh.de>
src/gallium/drivers/r600/evergreen_hw_context.c
src/gallium/drivers/r600/r600_pipe.h

index 2feb8015082e95d5d8fecd8162f3e992fb381c23..06f034823419637667aa36d0f5c36ac39f708280 100644 (file)
@@ -102,15 +102,7 @@ void evergreen_cp_dma_clear_buffer(struct r600_context *rctx,
        offset += r600_resource(dst)->gpu_address;
 
        /* Flush the cache where the resource is bound. */
-       rctx->b.flags |= R600_CONTEXT_INV_CONST_CACHE |
-                        R600_CONTEXT_INV_VERTEX_CACHE |
-                        R600_CONTEXT_INV_TEX_CACHE |
-                        R600_CONTEXT_FLUSH_AND_INV |
-                        R600_CONTEXT_FLUSH_AND_INV_CB |
-                        R600_CONTEXT_FLUSH_AND_INV_DB |
-                        R600_CONTEXT_FLUSH_AND_INV_CB_META |
-                        R600_CONTEXT_FLUSH_AND_INV_DB_META |
-                        R600_CONTEXT_STREAMOUT_FLUSH |
+       rctx->b.flags |= r600_get_flush_flags(coher) |
                         R600_CONTEXT_WAIT_3D_IDLE;
 
        while (size) {
@@ -158,9 +150,4 @@ void evergreen_cp_dma_clear_buffer(struct r600_context *rctx,
         */
        if (coher == R600_COHERENCY_SHADER)
                r600_emit_pfp_sync_me(rctx);
-
-       /* Invalidate the read caches. */
-       rctx->b.flags |= R600_CONTEXT_INV_CONST_CACHE |
-                        R600_CONTEXT_INV_VERTEX_CACHE |
-                        R600_CONTEXT_INV_TEX_CACHE;
 }
index 313bf69c31441354ad1c60ee2d95169fd1147113..9677bb64387733988888fb562e2b098bf5f62efa 100644 (file)
@@ -932,6 +932,23 @@ static inline bool r600_can_read_depth(struct r600_texture *rtex)
                rtex->resource.b.b.format == PIPE_FORMAT_Z32_FLOAT);
 }
 
+static inline unsigned r600_get_flush_flags(enum r600_coherency coher)
+{
+       switch (coher) {
+       default:
+       case R600_COHERENCY_NONE:
+               return 0;
+       case R600_COHERENCY_SHADER:
+               return R600_CONTEXT_INV_CONST_CACHE |
+                      R600_CONTEXT_INV_VERTEX_CACHE |
+                      R600_CONTEXT_INV_TEX_CACHE |
+                      R600_CONTEXT_STREAMOUT_FLUSH;
+       case R600_COHERENCY_CB_META:
+               return R600_CONTEXT_FLUSH_AND_INV_CB |
+                      R600_CONTEXT_FLUSH_AND_INV_CB_META;
+       }
+}
+
 #define     V_028A6C_OUTPRIM_TYPE_POINTLIST            0
 #define     V_028A6C_OUTPRIM_TYPE_LINESTRIP            1
 #define     V_028A6C_OUTPRIM_TYPE_TRISTRIP             2