[Mesa-dev] [PATCH 05/11] radeonsi: more const qualifiers in shader dump functions

Nicolai Hähnle nhaehnle at gmail.com
Mon May 8 15:35:55 UTC 2017


From: Nicolai Hähnle <nicolai.haehnle at amd.com>

---
 src/gallium/drivers/radeonsi/si_shader.c | 20 ++++++++++----------
 src/gallium/drivers/radeonsi/si_shader.h |  4 ++--
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c
index cf4b83b..12fac88 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -62,21 +62,21 @@ struct si_shader_output_values
 };
 
 static void si_init_shader_ctx(struct si_shader_context *ctx,
 			       struct si_screen *sscreen,
 			       LLVMTargetMachineRef tm);
 
 static void si_llvm_emit_barrier(const struct lp_build_tgsi_action *action,
 				 struct lp_build_tgsi_context *bld_base,
 				 struct lp_build_emit_data *emit_data);
 
-static void si_dump_shader_key(unsigned processor, struct si_shader *shader,
+static void si_dump_shader_key(unsigned processor, const struct si_shader *shader,
 			       FILE *f);
 
 static unsigned llvm_get_type_size(LLVMTypeRef type);
 
 static void si_build_vs_prolog_function(struct si_shader_context *ctx,
 					union si_shader_part_key *key);
 static void si_build_tcs_epilog_function(struct si_shader_context *ctx,
 					 union si_shader_part_key *key);
 static void si_build_ps_prolog_function(struct si_shader_context *ctx,
 					union si_shader_part_key *key);
@@ -6510,21 +6510,21 @@ void si_shader_apply_scratch_relocs(struct si_shader *shader,
 		if (!strcmp(scratch_rsrc_dword0_symbol, reloc->name)) {
 			util_memcpy_cpu_to_le32(shader->binary.code + reloc->offset,
 			&scratch_rsrc_dword0, 4);
 		} else if (!strcmp(scratch_rsrc_dword1_symbol, reloc->name)) {
 			util_memcpy_cpu_to_le32(shader->binary.code + reloc->offset,
 			&scratch_rsrc_dword1, 4);
 		}
 	}
 }
 
-static unsigned si_get_shader_binary_size(struct si_shader *shader)
+static unsigned si_get_shader_binary_size(const struct si_shader *shader)
 {
 	unsigned size = shader->binary.code_size;
 
 	if (shader->prolog)
 		size += shader->prolog->binary.code_size;
 	if (shader->previous_stage)
 		size += shader->previous_stage->binary.code_size;
 	if (shader->prolog2)
 		size += shader->prolog2->binary.code_size;
 	if (shader->epilog)
@@ -6642,27 +6642,27 @@ static void si_shader_dump_disassembly(const struct ac_shader_binary *binary,
 		fprintf(file, "Shader %s binary:\n", name);
 		for (i = 0; i < binary->code_size; i += 4) {
 			fprintf(file, "@0x%x: %02x%02x%02x%02x\n", i,
 				binary->code[i + 3], binary->code[i + 2],
 				binary->code[i + 1], binary->code[i]);
 		}
 	}
 }
 
 static void si_shader_dump_stats(struct si_screen *sscreen,
-				 struct si_shader *shader,
+				 const struct si_shader *shader,
 			         struct pipe_debug_callback *debug,
 			         unsigned processor,
 				 FILE *file,
 				 bool check_debug_option)
 {
-	struct si_shader_config *conf = &shader->config;
+	const struct si_shader_config *conf = &shader->config;
 	unsigned num_inputs = shader->selector ? shader->selector->info.num_inputs : 0;
 	unsigned code_size = si_get_shader_binary_size(shader);
 	unsigned lds_increment = sscreen->b.chip_class >= CIK ? 512 : 256;
 	unsigned lds_per_wave = 0;
 	unsigned max_simd_waves = 10;
 
 	/* Compute LDS usage for PS. */
 	switch (processor) {
 	case PIPE_SHADER_FRAGMENT:
 		/* The minimum usage per wave is (num_inputs * 48). The maximum
@@ -6734,21 +6734,21 @@ static void si_shader_dump_stats(struct si_screen *sscreen,
 	pipe_debug_message(debug, SHADER_INFO,
 			   "Shader Stats: SGPRS: %d VGPRS: %d Code Size: %d "
 			   "LDS: %d Scratch: %d Max Waves: %d Spilled SGPRs: %d "
 			   "Spilled VGPRs: %d PrivMem VGPRs: %d",
 			   conf->num_sgprs, conf->num_vgprs, code_size,
 			   conf->lds_size, conf->scratch_bytes_per_wave,
 			   max_simd_waves, conf->spilled_sgprs,
 			   conf->spilled_vgprs, conf->private_mem_vgprs);
 }
 
-const char *si_get_shader_name(struct si_shader *shader, unsigned processor)
+const char *si_get_shader_name(const struct si_shader *shader, unsigned processor)
 {
 	switch (processor) {
 	case PIPE_SHADER_VERTEX:
 		if (shader->key.as_es)
 			return "Vertex Shader as ES";
 		else if (shader->key.as_ls)
 			return "Vertex Shader as LS";
 		else
 			return "Vertex Shader as VS";
 	case PIPE_SHADER_TESS_CTRL:
@@ -6765,21 +6765,21 @@ const char *si_get_shader_name(struct si_shader *shader, unsigned processor)
 			return "Geometry Shader";
 	case PIPE_SHADER_FRAGMENT:
 		return "Pixel Shader";
 	case PIPE_SHADER_COMPUTE:
 		return "Compute Shader";
 	default:
 		return "Unknown Shader";
 	}
 }
 
-void si_shader_dump(struct si_screen *sscreen, struct si_shader *shader,
+void si_shader_dump(struct si_screen *sscreen, const struct si_shader *shader,
 		    struct pipe_debug_callback *debug, unsigned processor,
 		    FILE *file, bool check_debug_option)
 {
 	if (!check_debug_option ||
 	    r600_can_dump_shader(&sscreen->b, processor))
 		si_dump_shader_key(processor, shader, file);
 
 	if (!check_debug_option && shader->binary.llvm_ir_string) {
 		fprintf(file, "\n%s - main shader part - LLVM IR:\n\n",
 			si_get_shader_name(shader, processor));
@@ -7034,41 +7034,41 @@ si_generate_gs_copy_shader(struct si_screen *sscreen,
 
 	FREE(outputs);
 
 	if (r != 0) {
 		FREE(shader);
 		shader = NULL;
 	}
 	return shader;
 }
 
-static void si_dump_shader_key_vs(struct si_shader_key *key,
-				  struct si_vs_prolog_bits *prolog,
+static void si_dump_shader_key_vs(const struct si_shader_key *key,
+				  const struct si_vs_prolog_bits *prolog,
 				  const char *prefix, FILE *f)
 {
 	fprintf(f, "  %s.instance_divisors = {", prefix);
 	for (int i = 0; i < ARRAY_SIZE(prolog->instance_divisors); i++) {
 		fprintf(f, !i ? "%u" : ", %u",
 			prolog->instance_divisors[i]);
 	}
 	fprintf(f, "}\n");
 
 	fprintf(f, "  mono.vs.fix_fetch = {");
 	for (int i = 0; i < SI_MAX_ATTRIBS; i++)
 		fprintf(f, !i ? "%u" : ", %u", key->mono.vs_fix_fetch[i]);
 	fprintf(f, "}\n");
 }
 
-static void si_dump_shader_key(unsigned processor, struct si_shader *shader,
+static void si_dump_shader_key(unsigned processor, const struct si_shader *shader,
 			       FILE *f)
 {
-	struct si_shader_key *key = &shader->key;
+	const struct si_shader_key *key = &shader->key;
 
 	fprintf(f, "SHADER KEY\n");
 
 	switch (processor) {
 	case PIPE_SHADER_VERTEX:
 		si_dump_shader_key_vs(key, &key->part.vs.prolog,
 				      "part.vs.prolog", f);
 		fprintf(f, "  as_es = %u\n", key->as_es);
 		fprintf(f, "  as_ls = %u\n", key->as_ls);
 		fprintf(f, "  mono.vs_export_prim_id = %u\n",
diff --git a/src/gallium/drivers/radeonsi/si_shader.h b/src/gallium/drivers/radeonsi/si_shader.h
index 61269bd..317476f 100644
--- a/src/gallium/drivers/radeonsi/si_shader.h
+++ b/src/gallium/drivers/radeonsi/si_shader.h
@@ -593,33 +593,33 @@ int si_compile_tgsi_shader(struct si_screen *sscreen,
 			   struct si_shader *shader,
 			   bool is_monolithic,
 			   struct pipe_debug_callback *debug);
 int si_shader_create(struct si_screen *sscreen, LLVMTargetMachineRef tm,
 		     struct si_shader *shader,
 		     struct pipe_debug_callback *debug);
 void si_shader_destroy(struct si_shader *shader);
 unsigned si_shader_io_get_unique_index(unsigned semantic_name, unsigned index);
 unsigned si_shader_io_get_unique_index2(unsigned name, unsigned index);
 int si_shader_binary_upload(struct si_screen *sscreen, struct si_shader *shader);
-void si_shader_dump(struct si_screen *sscreen, struct si_shader *shader,
+void si_shader_dump(struct si_screen *sscreen, const struct si_shader *shader,
 		    struct pipe_debug_callback *debug, unsigned processor,
 		    FILE *f, bool check_debug_option);
 void si_multiwave_lds_size_workaround(struct si_screen *sscreen,
 				      unsigned *lds_size);
 void si_shader_apply_scratch_relocs(struct si_shader *shader,
 				    uint64_t scratch_va);
 void si_shader_binary_read_config(struct ac_shader_binary *binary,
 				  struct si_shader_config *conf,
 				  unsigned symbol_offset);
 unsigned si_get_spi_shader_z_format(bool writes_z, bool writes_stencil,
 				    bool writes_samplemask);
-const char *si_get_shader_name(struct si_shader *shader, unsigned processor);
+const char *si_get_shader_name(const struct si_shader *shader, unsigned processor);
 
 /* Inline helpers. */
 
 /* Return the pointer to the main shader part's pointer. */
 static inline struct si_shader **
 si_get_main_shader_part(struct si_shader_selector *sel,
 			struct si_shader_key *key)
 {
 	if (key->as_ls)
 		return &sel->main_shader_part_ls;
-- 
2.9.3



More information about the mesa-dev mailing list