[Mesa-dev] [PATCH 5/6] radeonsi: round ps_iter_samples in set_min_samples

Marek Olšák maraeo at gmail.com
Thu May 17 01:47:26 UTC 2018


From: Marek Olšák <marek.olsak at amd.com>

---
 src/gallium/drivers/radeonsi/si_state.c         | 6 ++++--
 src/gallium/drivers/radeonsi/si_state_shaders.c | 2 +-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c
index 5bbf134b706..f4e29f68b29 100644
--- a/src/gallium/drivers/radeonsi/si_state.c
+++ b/src/gallium/drivers/radeonsi/si_state.c
@@ -3405,22 +3405,21 @@ static void si_emit_msaa_config(struct si_context *sctx)
 		/* distance from the pixel center, indexed by log2(nr_samples) */
 		static unsigned max_dist[] = {
 			0, /* unused */
 			4, /* 2x MSAA */
 			6, /* 4x MSAA */
 			7, /* 8x MSAA */
 			8, /* 16x MSAA */
 		};
 		unsigned log_samples = util_logbase2(coverage_samples);
 		unsigned ps_iter_samples = si_get_ps_iter_samples(sctx);
-		unsigned log_ps_iter_samples =
-			util_logbase2(util_next_power_of_two(ps_iter_samples));
+		unsigned log_ps_iter_samples = util_logbase2(ps_iter_samples);
 
 		radeon_set_context_reg_seq(cs, R_028BDC_PA_SC_LINE_CNTL, 2);
 		radeon_emit(cs, sc_line_cntl |
 			    S_028BDC_EXPAND_LINE_WIDTH(1)); /* R_028BDC_PA_SC_LINE_CNTL */
 		radeon_emit(cs, S_028BE0_MSAA_NUM_SAMPLES(log_samples) |
 			    S_028BE0_MAX_SAMPLE_DIST(max_dist[log_samples]) |
 			    S_028BE0_MSAA_EXPOSED_SAMPLES(log_samples)); /* R_028BE0_PA_SC_AA_CONFIG */
 
 		if (sctx->framebuffer.nr_samples > 1) {
 			radeon_set_context_reg(cs, R_028804_DB_EQAA,
@@ -3461,20 +3460,23 @@ void si_update_ps_iter_samples(struct si_context *sctx)
 	if (sctx->framebuffer.nr_samples > 1)
 		si_mark_atom_dirty(sctx, &sctx->atoms.s.msaa_config);
 	if (sctx->screen->dpbb_allowed)
 		si_mark_atom_dirty(sctx, &sctx->atoms.s.dpbb_state);
 }
 
 static void si_set_min_samples(struct pipe_context *ctx, unsigned min_samples)
 {
 	struct si_context *sctx = (struct si_context *)ctx;
 
+	/* The hardware can only do sample shading with 2^n samples. */
+	min_samples = util_next_power_of_two(min_samples);
+
 	if (sctx->ps_iter_samples == min_samples)
 		return;
 
 	sctx->ps_iter_samples = min_samples;
 	sctx->do_update_shaders = true;
 
 	si_update_ps_iter_samples(sctx);
 }
 
 /*
diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c b/src/gallium/drivers/radeonsi/si_state_shaders.c
index 2e215b91ce8..1b618502e85 100644
--- a/src/gallium/drivers/radeonsi/si_state_shaders.c
+++ b/src/gallium/drivers/radeonsi/si_state_shaders.c
@@ -1407,21 +1407,21 @@ static inline void si_shader_selector_key(struct pipe_context *ctx,
 
 			key->part.ps.prolog.poly_stipple = rs->poly_stipple_enable && is_poly;
 			key->part.ps.epilog.poly_line_smoothing = ((is_poly && rs->poly_smooth) ||
 							      (is_line && rs->line_smooth)) &&
 							     sctx->framebuffer.nr_samples <= 1;
 			key->part.ps.epilog.clamp_color = rs->clamp_fragment_color;
 
 			if (sctx->ps_iter_samples > 1 &&
 			    sel->info.reads_samplemask) {
 				key->part.ps.prolog.samplemask_log_ps_iter =
-					util_logbase2(util_next_power_of_two(sctx->ps_iter_samples));
+					util_logbase2(sctx->ps_iter_samples);
 			}
 
 			if (rs->force_persample_interp &&
 			    rs->multisample_enable &&
 			    sctx->framebuffer.nr_samples > 1 &&
 			    sctx->ps_iter_samples > 1) {
 				key->part.ps.prolog.force_persp_sample_interp =
 					sel->info.uses_persp_center ||
 					sel->info.uses_persp_centroid;
 
-- 
2.17.0



More information about the mesa-dev mailing list