radeonsi: set DB_EQAA.MAX_ANCHOR_SAMPLES correctly
authorMarek Olšák <marek.olsak@amd.com>
Wed, 16 May 2018 02:04:20 +0000 (22:04 -0400)
committerMarek Olšák <marek.olsak@amd.com>
Thu, 24 May 2018 17:41:57 +0000 (13:41 -0400)
Tested-by: Dieter Nützel <Dieter@nuetzel-hh.de>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/gallium/drivers/radeonsi/si_state.c

index f4e29f68b29630f9717fbe7c27125cb931f7a8c4..3a7e928df5325aa7d9ddd655677e8f1328fe13a6 100644 (file)
@@ -3340,7 +3340,7 @@ static void si_emit_msaa_config(struct si_context *sctx)
                           S_028804_INCOHERENT_EQAA_READS(1) |
                           S_028804_INTERPOLATE_COMP_Z(1) |
                           S_028804_STATIC_ANCHOR_ASSOCIATIONS(1);
-       unsigned coverage_samples, color_samples;
+       unsigned coverage_samples, color_samples, z_samples;
 
        /* S: Coverage samples (up to 16x):
         * - Scan conversion samples (PA_SC_AA_CONFIG.MSAA_NUM_SAMPLES)
@@ -3386,10 +3386,17 @@ static void si_emit_msaa_config(struct si_context *sctx)
        if (sctx->framebuffer.nr_samples > 1) {
                coverage_samples = sctx->framebuffer.nr_samples;
                color_samples = sctx->framebuffer.nr_color_samples;
+
+               if (sctx->framebuffer.state.zsbuf) {
+                       z_samples = sctx->framebuffer.state.zsbuf->texture->nr_samples;
+                       z_samples = MAX2(1, z_samples);
+               } else {
+                       z_samples = coverage_samples;
+               }
        } else if (sctx->smoothing_enabled) {
-               coverage_samples = color_samples = SI_NUM_SMOOTH_AA_SAMPLES;
+               coverage_samples = color_samples = z_samples = SI_NUM_SMOOTH_AA_SAMPLES;
        } else {
-               coverage_samples = color_samples = 1;
+               coverage_samples = color_samples = z_samples = 1;
        }
 
        /* Required by OpenGL line rasterization.
@@ -3411,6 +3418,7 @@ static void si_emit_msaa_config(struct si_context *sctx)
                        8, /* 16x MSAA */
                };
                unsigned log_samples = util_logbase2(coverage_samples);
+               unsigned log_z_samples = util_logbase2(z_samples);
                unsigned ps_iter_samples = si_get_ps_iter_samples(sctx);
                unsigned log_ps_iter_samples = util_logbase2(ps_iter_samples);
 
@@ -3424,7 +3432,7 @@ static void si_emit_msaa_config(struct si_context *sctx)
                if (sctx->framebuffer.nr_samples > 1) {
                        radeon_set_context_reg(cs, R_028804_DB_EQAA,
                                               db_eqaa |
-                                              S_028804_MAX_ANCHOR_SAMPLES(log_samples) |
+                                              S_028804_MAX_ANCHOR_SAMPLES(log_z_samples) |
                                               S_028804_PS_ITER_SAMPLES(log_ps_iter_samples) |
                                               S_028804_MASK_EXPORT_NUM_SAMPLES(log_samples) |
                                               S_028804_ALPHA_TO_MASK_NUM_SAMPLES(log_samples));