radeonsi: Fix omitted flush when moving suballocated texture
authorBlaž Tomažič <blaz.tomazic@gmail.com>
Wed, 6 May 2020 19:34:10 +0000 (21:34 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Thu, 7 May 2020 21:00:08 +0000 (17:00 -0400)
Fixes: 5e805cc74bc52f97de8f6308fc06bc96623e7e09 "radeonsi: flush the context after resource_copy_region for buffer exports"
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4925>

src/gallium/drivers/radeonsi/si_descriptors.c
src/gallium/drivers/radeonsi/si_pipe.h
src/gallium/drivers/radeonsi/si_texture.c

index 572523992ccb080b583a443940b1d3e0860e94e1..7e1218d5d3086ef4472971f34b1113395ccde92b 100644 (file)
@@ -835,7 +835,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);
       }
 
index a5dbf655928427d1422832b1e12b55858c6b0d10..ae5a043e28fa36c3f86a64ac38ecd8fddb534af0 100644 (file)
@@ -1496,7 +1496,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,
index d84261d48e12a058d1cab63bd58a7af05e591c98..ab2a234f16ab1ec758d9d5ccc6da09944647d329 100644 (file)
@@ -314,7 +314,8 @@ static int si_init_surface(struct si_screen *sscreen, struct radeon_surf *surfac
    return 0;
 }
 
-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;
@@ -326,8 +327,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);
@@ -705,9 +712,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.