[Mesa-dev] [PATCH 2/5] radeonsi: eliminate PS OUT[1] if dual src blending is off and CB1 is not bound

Marek Olšák maraeo at gmail.com
Thu Aug 11 16:16:06 UTC 2016


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

All VP DX9 ports benefit from this.
---
 src/gallium/drivers/radeonsi/si_state.c         | 11 -----------
 src/gallium/drivers/radeonsi/si_state_shaders.c |  7 +++++++
 2 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c
index 94dbe4c..5d55448 100644
--- a/src/gallium/drivers/radeonsi/si_state.c
+++ b/src/gallium/drivers/radeonsi/si_state.c
@@ -2343,31 +2343,20 @@ static void si_set_framebuffer_state(struct pipe_context *ctx,
 		r600_context_add_resource_size(ctx, surf->base.texture);
 
 		p_atomic_inc(&rtex->framebuffers_bound);
 
 		if (rtex->dcc_gather_statistics) {
 			/* Dirty tracking must be enabled for DCC usage analysis. */
 			sctx->framebuffer.compressed_cb_mask |= 1 << i;
 			vi_separate_dcc_start_query(ctx, rtex);
 		}
 	}
-	/* Set the second SPI format for possible dual-src blending. */
-	if (i == 1 && surf) {
-		sctx->framebuffer.spi_shader_col_format |=
-			surf->spi_shader_col_format << (i * 4);
-		sctx->framebuffer.spi_shader_col_format_alpha |=
-			surf->spi_shader_col_format_alpha << (i * 4);
-		sctx->framebuffer.spi_shader_col_format_blend |=
-			surf->spi_shader_col_format_blend << (i * 4);
-		sctx->framebuffer.spi_shader_col_format_blend_alpha |=
-			surf->spi_shader_col_format_blend_alpha << (i * 4);
-	}
 
 	if (state->zsbuf) {
 		surf = (struct r600_surface*)state->zsbuf;
 
 		if (!surf->depth_initialized) {
 			si_init_depth_surface(sctx, surf);
 		}
 		r600_context_add_resource_size(ctx, surf->base.texture);
 	}
 
diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c b/src/gallium/drivers/radeonsi/si_state_shaders.c
index 87d0b7d..d821397 100644
--- a/src/gallium/drivers/radeonsi/si_state_shaders.c
+++ b/src/gallium/drivers/radeonsi/si_state_shaders.c
@@ -893,20 +893,27 @@ static inline void si_shader_selector_key(struct pipe_context *ctx,
 			 */
 			key->ps.epilog.spi_shader_col_format =
 				(blend->blend_enable_4bit & blend->need_src_alpha_4bit &
 				 sctx->framebuffer.spi_shader_col_format_blend_alpha) |
 				(blend->blend_enable_4bit & ~blend->need_src_alpha_4bit &
 				 sctx->framebuffer.spi_shader_col_format_blend) |
 				(~blend->blend_enable_4bit & blend->need_src_alpha_4bit &
 				 sctx->framebuffer.spi_shader_col_format_alpha) |
 				(~blend->blend_enable_4bit & ~blend->need_src_alpha_4bit &
 				 sctx->framebuffer.spi_shader_col_format);
+
+			/* The output for dual source blending should have
+			 * the same format as the first output.
+			 */
+			if (blend->dual_src_blend)
+				key->ps.epilog.spi_shader_col_format |=
+					(key->ps.epilog.spi_shader_col_format & 0xf) << 4;
 		} else
 			key->ps.epilog.spi_shader_col_format = sctx->framebuffer.spi_shader_col_format;
 
 		/* If alpha-to-coverage is enabled, we have to export alpha
 		 * even if there is no color buffer.
 		 */
 		if (!(key->ps.epilog.spi_shader_col_format & 0xf) &&
 		    blend && blend->alpha_to_coverage)
 			key->ps.epilog.spi_shader_col_format |= V_028710_SPI_SHADER_32_AR;
 
-- 
2.7.4



More information about the mesa-dev mailing list