[Mesa-dev] [PATCH 2/5] radeonsi: use the colorbuffer count from the shader key

Marek Olšák maraeo at gmail.com
Thu Dec 5 09:43:01 PST 2013


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

As a result, the initialization of write_all must be done before
the compilation.
---
 src/gallium/drivers/radeonsi/radeonsi_shader.c |  6 ++----
 src/gallium/drivers/radeonsi/radeonsi_shader.h |  1 -
 src/gallium/drivers/radeonsi/si_state.c        | 16 +++++-----------
 3 files changed, 7 insertions(+), 16 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/radeonsi_shader.c b/src/gallium/drivers/radeonsi/radeonsi_shader.c
index 96cc1aa..85ad289 100644
--- a/src/gallium/drivers/radeonsi/radeonsi_shader.c
+++ b/src/gallium/drivers/radeonsi/radeonsi_shader.c
@@ -1189,13 +1189,13 @@ handle_semantic:
 		/* Specify whether the EXEC mask represents the valid mask */
 		last_args[1] = uint->one;
 
-		if (shader->fs_write_all && shader->nr_cbufs > 1) {
+		if (shader->fs_write_all && si_shader_ctx->shader->key.ps.nr_cbufs > 1) {
 			int i;
 
 			/* Specify that this is not yet the last export */
 			last_args[2] = lp_build_const_int32(base->gallivm, 0);
 
-			for (i = 1; i < shader->nr_cbufs; i++) {
+			for (i = 1; i < si_shader_ctx->shader->key.ps.nr_cbufs; i++) {
 				/* Specify the target we are exporting */
 				last_args[3] = lp_build_const_int32(base->gallivm,
 								    V_008DFC_SQ_EXP_MRT + i);
@@ -2033,8 +2033,6 @@ int si_pipe_shader_create(
 	preload_samplers(&si_shader_ctx);
 	preload_streamout_buffers(&si_shader_ctx);
 
-	shader->shader.nr_cbufs = rctx->framebuffer.nr_cbufs;
-
 	/* Dump TGSI code before doing TGSI->LLVM conversion in case the
 	 * conversion fails. */
 	if (dump) {
diff --git a/src/gallium/drivers/radeonsi/radeonsi_shader.h b/src/gallium/drivers/radeonsi/radeonsi_shader.h
index 174035d..5e5a27f 100644
--- a/src/gallium/drivers/radeonsi/radeonsi_shader.h
+++ b/src/gallium/drivers/radeonsi/radeonsi_shader.h
@@ -115,7 +115,6 @@ struct si_shader {
 	bool			vs_out_point_size;
 	bool			vs_out_edgeflag;
 	bool			vs_out_layer;
-	unsigned		nr_cbufs;
 	unsigned		nr_pos_exports;
 	unsigned		clip_dist_write;
 };
diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c
index 7bae72a..9831fd8 100644
--- a/src/gallium/drivers/radeonsi/si_state.c
+++ b/src/gallium/drivers/radeonsi/si_state.c
@@ -33,6 +33,7 @@
 #include "util/u_upload_mgr.h"
 #include "util/u_format_s3tc.h"
 #include "tgsi/tgsi_parse.h"
+#include "tgsi/tgsi_scan.h"
 #include "radeonsi_pipe.h"
 #include "radeonsi_shader.h"
 #include "si_state.h"
@@ -2225,17 +2226,6 @@ int si_shader_select(struct pipe_context *ctx,
 			FREE(shader);
 			return r;
 		}
-
-		/* We don't know the value of fs_write_all property until we built
-		 * at least one variant, so we may need to recompute the key (include
-		 * rctx->framebuffer.nr_cbufs) after building first variant. */
-		if (sel->type == PIPE_SHADER_FRAGMENT &&
-		    sel->num_shaders == 0 &&
-		    shader->shader.fs_write_all) {
-			sel->fs_write_all = 1;
-			si_shader_selector_key(ctx, sel, &shader->key);
-		}
-
 		sel->num_shaders++;
 	}
 
@@ -2254,10 +2244,14 @@ static void *si_create_shader_state(struct pipe_context *ctx,
 {
 	struct si_pipe_shader_selector *sel = CALLOC_STRUCT(si_pipe_shader_selector);
 	int r;
+	struct tgsi_shader_info info;
+
+	tgsi_scan_shader(state->tokens, &info);
 
 	sel->type = pipe_shader_type;
 	sel->tokens = tgsi_dup_tokens(state->tokens);
 	sel->so = state->stream_output;
+	sel->fs_write_all = info.color0_writes_all_cbufs;
 
 	r = si_shader_select(ctx, sel, NULL);
 	if (r) {
-- 
1.8.3.2



More information about the mesa-dev mailing list