r600g: flush FMASK and CMASK when changing colorbuffers on Evergreen
authorMarek Olšák <maraeo@gmail.com>
Tue, 25 Sep 2012 01:11:22 +0000 (03:11 +0200)
committerMarek Olšák <maraeo@gmail.com>
Thu, 27 Sep 2012 17:14:44 +0000 (19:14 +0200)
This fixes rare graphical corruption.

NOTE: This is a candidate for the stable branches.

src/gallium/drivers/r600/evergreen_state.c
src/gallium/drivers/r600/r600.h
src/gallium/drivers/r600/r600_hw_context.c
src/gallium/drivers/r600/r600_hw_context_priv.h
src/gallium/drivers/r600/r600_state.c
src/gallium/drivers/r600/r600d.h

index 98dbb2f5e692d21218c5fd5d6d60862d04ba04f5..7bedfec0503555219b8194b70e515877ba099ea4 100644 (file)
@@ -1458,6 +1458,10 @@ static void evergreen_set_framebuffer_state(struct pipe_context *ctx,
 
        if (rctx->framebuffer.state.nr_cbufs) {
                rctx->flags |= R600_CONTEXT_CB_FLUSH;
+
+               if (rctx->framebuffer.state.cbufs[0]->texture->nr_samples > 1) {
+                       rctx->flags |= R600_CONTEXT_FLUSH_AND_INV_CB_META;
+               }
        }
        if (rctx->framebuffer.state.zsbuf) {
                rctx->flags |= R600_CONTEXT_DB_FLUSH;
index 83d21a42a9202ad7824be04c8e8dfafb95efdbf8..7d434169d9ea9c6847214999fa12b1bb6dcc3946 100644 (file)
@@ -190,6 +190,7 @@ struct r600_so_target {
 #define R600_CONTEXT_WAIT_IDLE                 (1 << 7)
 #define R600_CONTEXT_FLUSH_AND_INV             (1 << 8)
 #define R600_CONTEXT_HTILE_ERRATA              (1 << 9)
+#define R600_CONTEXT_FLUSH_AND_INV_CB_META     (1 << 10)
 
 struct r600_context;
 struct r600_screen;
index 38dd7b643ae499884160cbb3b681fe3fe292a2a8..5b93d05573da95c876334b38c85572292deb226b 100644 (file)
@@ -684,6 +684,12 @@ void r600_flush_emit(struct r600_context *rctx)
                cs->buf[cs->cdw++] = EVENT_TYPE(EVENT_TYPE_PS_PARTIAL_FLUSH) | EVENT_INDEX(4);
        }
 
+       if (rctx->chip_class >= R700 &&
+           (rctx->flags & R600_CONTEXT_FLUSH_AND_INV_CB_META)) {
+               cs->buf[cs->cdw++] = PKT3(PKT3_EVENT_WRITE, 0, 0);
+               cs->buf[cs->cdw++] = EVENT_TYPE(EVENT_TYPE_FLUSH_AND_INV_CB_META) | EVENT_INDEX(0);
+       }
+
        if (rctx->flags & R600_CONTEXT_FLUSH_AND_INV) {
                cs->buf[cs->cdw++] = PKT3(PKT3_EVENT_WRITE, 0, 0);
                cs->buf[cs->cdw++] = EVENT_TYPE(EVENT_TYPE_CACHE_FLUSH_AND_INV_EVENT) | EVENT_INDEX(0);
index 83474b016f49d8b612263742f833d3d6f99a6e9f..85fd74dce923f791216fd8a4464cdc8ba6a2ae0f 100644 (file)
@@ -29,7 +29,7 @@
 #include "r600_pipe.h"
 
 /* the number of CS dwords for flushing and drawing */
-#define R600_MAX_FLUSH_CS_DWORDS 44
+#define R600_MAX_FLUSH_CS_DWORDS 46
 #define R600_MAX_DRAW_CS_DWORDS 34
 
 /* these flags are used in register flags and added into block flags */
index 1b7869c3e65d90a0ed3648f9387f85725cddd5bc..60c861fc8e0b7f0ac5465e3ee0fd1cfb8ade6597 100644 (file)
@@ -1456,6 +1456,11 @@ static void r600_set_framebuffer_state(struct pipe_context *ctx,
 
        if (rctx->framebuffer.state.nr_cbufs) {
                rctx->flags |= R600_CONTEXT_CB_FLUSH;
+
+               if (rctx->chip_class >= R700 &&
+                   rctx->framebuffer.state.cbufs[0]->texture->nr_samples > 1) {
+                       rctx->flags |= R600_CONTEXT_FLUSH_AND_INV_CB_META;
+               }
        }
        if (rctx->framebuffer.state.zsbuf) {
                rctx->flags |= R600_CONTEXT_DB_FLUSH;
index cf0059a4b365893fda2ad4b6ecceafdc51f21389..4b46bd7613aa73a69e0b5a1524e2746511ed26c2 100644 (file)
 #define EVENT_TYPE_CACHE_FLUSH_AND_INV_EVENT   0x16
 #define EVENT_TYPE_SO_VGTSTREAMOUT_FLUSH       0x1f
 #define EVENT_TYPE_SAMPLE_STREAMOUTSTATS       0x20
+#define EVENT_TYPE_FLUSH_AND_INV_CB_META       46 /* supported on r700+ */
 #define                EVENT_TYPE(x)                           ((x) << 0)
 #define                EVENT_INDEX(x)                          ((x) << 8)
                 /* 0 - any non-TS event