[Mesa-dev] [PATCH 01/13] radeonsi: get tgsi_shader_info only once before compilation

Marek Olšák maraeo at gmail.com
Tue Sep 30 09:46:40 PDT 2014


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

---
 src/gallium/drivers/radeonsi/si_shader.c | 25 +++++++++++--------------
 src/gallium/drivers/radeonsi/si_shader.h |  2 ++
 src/gallium/drivers/radeonsi/si_state.c  | 10 +++-------
 3 files changed, 16 insertions(+), 21 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c
index 9d2cc80..276ba81 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -2805,7 +2805,6 @@ int si_shader_create(struct si_screen *sscreen, struct si_shader *shader)
 {
 	struct si_shader_selector *sel = shader->selector;
 	struct si_shader_context si_shader_ctx;
-	struct tgsi_shader_info shader_info;
 	struct lp_build_tgsi_context * bld_base;
 	LLVMModuleRef mod;
 	int r = 0;
@@ -2826,13 +2825,11 @@ int si_shader_create(struct si_screen *sscreen, struct si_shader *shader)
 	radeon_llvm_context_init(&si_shader_ctx.radeon_bld);
 	bld_base = &si_shader_ctx.radeon_bld.soa.bld_base;
 
-	tgsi_scan_shader(sel->tokens, &shader_info);
-
-	if (shader_info.uses_kill)
+	if (sel->info.uses_kill)
 		shader->db_shader_control |= S_02880C_KILL_ENABLE(1);
 
-	shader->uses_instanceid = shader_info.uses_instanceid;
-	bld_base->info = &shader_info;
+	shader->uses_instanceid = sel->info.uses_instanceid;
+	bld_base->info = &sel->info;
 	bld_base->emit_fetch_funcs[TGSI_FILE_CONSTANT] = fetch_constant;
 
 	bld_base->op_actions[TGSI_OPCODE_TEX] = tex_action;
@@ -2876,16 +2873,16 @@ int si_shader_create(struct si_screen *sscreen, struct si_shader *shader)
 		bld_base->emit_fetch_funcs[TGSI_FILE_INPUT] = fetch_input_gs;
 		bld_base->emit_epilogue = si_llvm_emit_gs_epilogue;
 
-		for (i = 0; i < shader_info.num_properties; i++) {
-			switch (shader_info.properties[i].name) {
+		for (i = 0; i < sel->info.num_properties; i++) {
+			switch (sel->info.properties[i].name) {
 			case TGSI_PROPERTY_GS_INPUT_PRIM:
-				shader->gs_input_prim = shader_info.properties[i].data[0];
+				shader->gs_input_prim = sel->info.properties[i].data[0];
 				break;
 			case TGSI_PROPERTY_GS_OUTPUT_PRIM:
-				shader->gs_output_prim = shader_info.properties[i].data[0];
+				shader->gs_output_prim = sel->info.properties[i].data[0];
 				break;
 			case TGSI_PROPERTY_GS_MAX_OUTPUT_VERTICES:
-				shader->gs_max_out_vertices = shader_info.properties[i].data[0];
+				shader->gs_max_out_vertices = sel->info.properties[i].data[0];
 				break;
 			}
 		}
@@ -2897,10 +2894,10 @@ int si_shader_create(struct si_screen *sscreen, struct si_shader *shader)
 		si_shader_ctx.radeon_bld.load_input = declare_input_fs;
 		bld_base->emit_epilogue = si_llvm_emit_fs_epilogue;
 
-		for (i = 0; i < shader_info.num_properties; i++) {
-			switch (shader_info.properties[i].name) {
+		for (i = 0; i < sel->info.num_properties; i++) {
+			switch (sel->info.properties[i].name) {
 			case TGSI_PROPERTY_FS_DEPTH_LAYOUT:
-				switch (shader_info.properties[i].data[0]) {
+				switch (sel->info.properties[i].data[0]) {
 				case TGSI_FS_DEPTH_LAYOUT_GREATER:
 					shader->db_shader_control |=
 						S_02880C_CONSERVATIVE_Z_EXPORT(V_02880C_EXPORT_GREATER_THAN_Z);
diff --git a/src/gallium/drivers/radeonsi/si_shader.h b/src/gallium/drivers/radeonsi/si_shader.h
index d8a63df..8f5b431 100644
--- a/src/gallium/drivers/radeonsi/si_shader.h
+++ b/src/gallium/drivers/radeonsi/si_shader.h
@@ -30,6 +30,7 @@
 #define SI_SHADER_H
 
 #include <llvm-c/Core.h> /* LLVMModuleRef */
+#include "tgsi/tgsi_scan.h"
 
 #define SI_SGPR_CONST		0
 #define SI_SGPR_SAMPLER		2
@@ -117,6 +118,7 @@ struct si_shader_selector {
 
 	struct tgsi_token       *tokens;
 	struct pipe_stream_output_info  so;
+	struct tgsi_shader_info		info;
 
 	unsigned	num_shaders;
 
diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c
index ed90f13..0e2d6c4 100644
--- a/src/gallium/drivers/radeonsi/si_state.c
+++ b/src/gallium/drivers/radeonsi/si_state.c
@@ -30,7 +30,6 @@
 #include "radeon/r600_cs.h"
 
 #include "tgsi/tgsi_parse.h"
-#include "tgsi/tgsi_scan.h"
 #include "util/u_format.h"
 #include "util/u_format_s3tc.h"
 #include "util/u_framebuffer.h"
@@ -2311,13 +2310,10 @@ static void *si_create_shader_state(struct pipe_context *ctx,
 	sel->type = pipe_shader_type;
 	sel->tokens = tgsi_dup_tokens(state->tokens);
 	sel->so = state->stream_output;
+	tgsi_scan_shader(state->tokens, &sel->info);
 
-	if (pipe_shader_type == PIPE_SHADER_FRAGMENT) {
-		struct tgsi_shader_info info;
-
-		tgsi_scan_shader(state->tokens, &info);
-		sel->fs_write_all = info.color0_writes_all_cbufs;
-	}
+	if (pipe_shader_type == PIPE_SHADER_FRAGMENT)
+		sel->fs_write_all = sel->info.color0_writes_all_cbufs;
 
 	r = si_shader_select(ctx, sel);
 	if (r) {
-- 
1.9.1



More information about the mesa-dev mailing list