radeonsi/gfx11: always set MSAA_NUM_SAMPLES=0 for DCC_DECOMPRESS
authorMarek Olšák <marek.olsak@amd.com>
Tue, 24 Jan 2023 23:29:28 +0000 (18:29 -0500)
committerMarge Bot <emma+marge@anholt.net>
Fri, 3 Feb 2023 00:18:01 +0000 (00:18 +0000)
hw requirement

Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21041>

src/gallium/drivers/radeonsi/si_blit.c
src/gallium/drivers/radeonsi/si_pipe.h
src/gallium/drivers/radeonsi/si_state.c

index a6b85f7..7bf90fd 100644 (file)
@@ -467,6 +467,12 @@ static void si_blit_decompress_color(struct si_context *sctx, struct si_texture
    if (need_dcc_decompress) {
       custom_blend = sctx->custom_blend_dcc_decompress;
 
+      /* DCC_DECOMPRESS and ELIMINATE_FAST_CLEAR require MSAA_NUM_SAMPLES=0. */
+      if (sctx->gfx_level >= GFX11) {
+         sctx->gfx11_force_msaa_num_samples_zero = true;
+         si_mark_atom_dirty(sctx, &sctx->atoms.s.msaa_config);
+      }
+
       assert(vi_dcc_enabled(tex, first_level));
 
       /* disable levels without DCC */
@@ -475,8 +481,10 @@ static void si_blit_decompress_color(struct si_context *sctx, struct si_texture
             level_mask &= ~(1 << i);
       }
    } else if (tex->surface.fmask_size) {
+      assert(sctx->gfx_level < GFX11);
       custom_blend = sctx->custom_blend_fmask_decompress;
    } else {
+      assert(sctx->gfx_level < GFX11);
       custom_blend = sctx->custom_blend_eliminate_fastclear;
    }
 
@@ -542,6 +550,12 @@ static void si_blit_decompress_color(struct si_context *sctx, struct si_texture
    si_make_CB_shader_coherent(sctx, tex->buffer.b.b.nr_samples, vi_dcc_enabled(tex, first_level),
                               tex->surface.u.gfx9.color.dcc.pipe_aligned);
 
+   /* Restore gfx11_force_msaa_num_samples_zero. */
+   if (sctx->gfx11_force_msaa_num_samples_zero) {
+      sctx->gfx11_force_msaa_num_samples_zero = false;
+      si_mark_atom_dirty(sctx, &sctx->atoms.s.msaa_config);
+   }
+
 expand_fmask:
    if (need_fmask_expand && tex->surface.fmask_offset && !tex->fmask_is_identity) {
       assert(sctx->gfx_level < GFX11); /* no FMASK on gfx11 */
index 7bc8e60..69ca717 100644 (file)
@@ -1006,13 +1006,14 @@ struct si_context {
    unsigned wait_mem_number;
    uint16_t prefetch_L2_mask;
 
-   bool blitter_running;
-   bool suppress_update_ps_colorbuf0_slot;
+   bool blitter_running:1;
+   bool suppress_update_ps_colorbuf0_slot:1;
    bool is_noop:1;
    bool has_graphics:1;
    bool gfx_flush_in_progress : 1;
    bool gfx_last_ib_is_busy : 1;
    bool compute_is_busy : 1;
+   bool gfx11_force_msaa_num_samples_zero:1;
    int8_t pipeline_stats_enabled; /* -1 = unknown, 0 = disabled, 1 = enabled */
 
    unsigned num_gfx_cs_flushes;
@@ -1914,6 +1915,9 @@ static inline bool vi_tc_compat_htile_enabled(struct si_texture *tex, unsigned l
 
 static inline unsigned si_get_ps_iter_samples(struct si_context *sctx)
 {
+   if (sctx->gfx11_force_msaa_num_samples_zero)
+      return 1;
+
    if (sctx->ps_uses_fbfetch)
       return sctx->framebuffer.nr_color_samples;
 
index 0d51e85..340ed59 100644 (file)
@@ -3824,6 +3824,10 @@ static void si_emit_msaa_config(struct si_context *sctx)
     */
    coverage_samples = si_get_num_coverage_samples(sctx);
 
+   /* DCC_DECOMPRESS and ELIMINATE_FAST_CLEAR require MSAA_NUM_SAMPLES=0. */
+   if (sctx->gfx_level >= GFX11 && sctx->gfx11_force_msaa_num_samples_zero)
+      coverage_samples = 1;
+
    /* The DX10 diamond test is not required by GL and decreases line rasterization
     * performance, so don't use it.
     */
@@ -3857,7 +3861,7 @@ static void si_emit_msaa_config(struct si_context *sctx)
        sctx->smoothing_enabled) {
       if (sctx->framebuffer.state.zsbuf) {
          z_samples = sctx->framebuffer.state.zsbuf->texture->nr_samples;
-         z_samples = MAX2(1, z_samples);
+         z_samples = MIN2(MAX2(1, z_samples), coverage_samples);
       } else {
          z_samples = coverage_samples;
       }