Mesa (staging/20.1): radeonsi: Fix omitted flush when moving suballocated texture

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri May 8 16:27:49 UTC 2020


Module: Mesa
Branch: staging/20.1
Commit: be882b566b1698b84622bef7da51d1954d852462
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=be882b566b1698b84622bef7da51d1954d852462

Author: Blaž Tomažič <blaz.tomazic at gmail.com>
Date:   Wed May  6 21:34:10 2020 +0200

radeonsi: Fix omitted flush when moving suballocated texture

Fixes: 5e805cc74bc52f97de8f6308fc06bc96623e7e09 "radeonsi: flush the context after resource_copy_region for buffer exports"

Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4925>
(cherry picked from commit 808eb20186a23be1a1917668e374243151e6699e)

---

 .pick_status.json                             |  2 +-
 src/gallium/drivers/radeonsi/si_descriptors.c |  2 +-
 src/gallium/drivers/radeonsi/si_pipe.h        |  3 ++-
 src/gallium/drivers/radeonsi/si_texture.c     | 17 +++++++++++++----
 4 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 829c4a7b4d5..6fd6cda8ab7 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -103,7 +103,7 @@
         "description": "radeonsi: Fix omitted flush when moving suballocated texture",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "master_sha": null,
         "because_sha": "5e805cc74bc52f97de8f6308fc06bc96623e7e09"
     },
diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c b/src/gallium/drivers/radeonsi/si_descriptors.c
index bf3ede49b39..6ba1f287f28 100644
--- a/src/gallium/drivers/radeonsi/si_descriptors.c
+++ b/src/gallium/drivers/radeonsi/si_descriptors.c
@@ -831,7 +831,7 @@ void si_update_ps_colorbuf0_slot(struct si_context *sctx)
       if (tex->buffer.b.b.nr_samples <= 1 && tex->cmask_buffer) {
          /* Disable CMASK. */
          assert(tex->cmask_buffer != &tex->buffer);
-         si_eliminate_fast_color_clear(sctx, tex);
+         si_eliminate_fast_color_clear(sctx, tex, NULL);
          si_texture_discard_cmask(sctx->screen, tex);
       }
 
diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h
index 30f7832f71c..de4f0e342c5 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.h
+++ b/src/gallium/drivers/radeonsi/si_pipe.h
@@ -1489,7 +1489,8 @@ void si_init_viewport_functions(struct si_context *ctx);
 bool si_prepare_for_dma_blit(struct si_context *sctx, struct si_texture *dst, unsigned dst_level,
                              unsigned dstx, unsigned dsty, unsigned dstz, struct si_texture *src,
                              unsigned src_level, const struct pipe_box *src_box);
-void si_eliminate_fast_color_clear(struct si_context *sctx, struct si_texture *tex);
+void si_eliminate_fast_color_clear(struct si_context *sctx, struct si_texture *tex,
+                                   bool *ctx_flushed);
 void si_texture_discard_cmask(struct si_screen *sscreen, struct si_texture *tex);
 bool si_init_flushed_depth_texture(struct pipe_context *ctx, struct pipe_resource *texture);
 void si_print_texture_info(struct si_screen *sscreen, struct si_texture *tex,
diff --git a/src/gallium/drivers/radeonsi/si_texture.c b/src/gallium/drivers/radeonsi/si_texture.c
index 0fc94a83afb..446eb239ab2 100644
--- a/src/gallium/drivers/radeonsi/si_texture.c
+++ b/src/gallium/drivers/radeonsi/si_texture.c
@@ -365,7 +365,8 @@ static void si_get_display_metadata(struct si_screen *sscreen, struct radeon_sur
    }
 }
 
-void si_eliminate_fast_color_clear(struct si_context *sctx, struct si_texture *tex)
+void si_eliminate_fast_color_clear(struct si_context *sctx, struct si_texture *tex,
+                                   bool *ctx_flushed)
 {
    struct si_screen *sscreen = sctx->screen;
    struct pipe_context *ctx = &sctx->b;
@@ -377,8 +378,14 @@ void si_eliminate_fast_color_clear(struct si_context *sctx, struct si_texture *t
    ctx->flush_resource(ctx, &tex->buffer.b.b);
 
    /* Flush only if any fast clear elimination took place. */
+   bool flushed = false;
    if (n != sctx->num_decompress_calls)
+   {
       ctx->flush(ctx, NULL, 0);
+      flushed = true;
+   }
+   if (ctx_flushed)
+      *ctx_flushed = flushed;
 
    if (ctx == sscreen->aux_context)
       simple_mtx_unlock(&sscreen->aux_context_lock);
@@ -931,9 +938,11 @@ static bool si_texture_get_handle(struct pipe_screen *screen, struct pipe_contex
       if (!(usage & PIPE_HANDLE_USAGE_EXPLICIT_FLUSH) &&
           (tex->cmask_buffer || tex->surface.dcc_offset)) {
          /* Eliminate fast clear (both CMASK and DCC) */
-         si_eliminate_fast_color_clear(sctx, tex);
-         /* eliminate_fast_color_clear flushes the context */
-         flush = false;
+         bool flushed;
+         si_eliminate_fast_color_clear(sctx, tex, &flushed);
+         /* eliminate_fast_color_clear sometimes flushes the context */
+         if (flushed)
+            flush = false;
 
          /* Disable CMASK if flush_resource isn't going
           * to be called.



More information about the mesa-commit mailing list