[Mesa-dev] [PATCH 4/9] radv: store the shader binary into radv_shader_variant

Samuel Pitoiset samuel.pitoiset at gmail.com
Tue Sep 5 19:17:09 UTC 2017


This will allow to dump the active shaders when a hang is
detected. Only the ASM will be dumped for now.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
---
 src/amd/vulkan/radv_shader.c | 27 ++++++++++++++-------------
 src/amd/vulkan/radv_shader.h |  1 +
 2 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/src/amd/vulkan/radv_shader.c b/src/amd/vulkan/radv_shader.c
index de7d9a2752..44a1f64737 100644
--- a/src/amd/vulkan/radv_shader.c
+++ b/src/amd/vulkan/radv_shader.c
@@ -326,10 +326,10 @@ radv_destroy_shader_slabs(struct radv_device *device)
 static void
 radv_fill_shader_variant(struct radv_device *device,
 			 struct radv_shader_variant *variant,
-			 struct ac_shader_binary *binary,
 			 gl_shader_stage stage)
 {
 	bool scratch_enabled = variant->config.scratch_bytes_per_wave > 0;
+	struct ac_shader_binary *binary = &variant->binary;
 	unsigned vgpr_comp_cnt = 0;
 
 	if (scratch_enabled && !device->llvm_supports_spill)
@@ -387,12 +387,13 @@ shader_variant_create(struct radv_device *device,
 	bool dump_shaders = device->debug_flags & RADV_DEBUG_DUMP_SHADERS;
 	enum ac_target_machine_options tm_options = 0;
 	struct radv_shader_variant *variant;
-	struct ac_shader_binary binary;
+	struct ac_shader_binary *binary;
 	LLVMTargetMachineRef tm;
 
 	variant = calloc(1, sizeof(struct radv_shader_variant));
 	if (!variant)
 		return NULL;
+	binary = &variant->binary;
 
 	options->family = chip_family;
 	options->chip_class = device->physical_device->rad_info.chip_class;
@@ -404,28 +405,28 @@ shader_variant_create(struct radv_device *device,
 	tm = ac_create_target_machine(chip_family, tm_options);
 
 	if (gs_copy_shader) {
-		ac_create_gs_copy_shader(tm, shader, &binary, &variant->config,
+		ac_create_gs_copy_shader(tm, shader, binary, &variant->config,
 					 &variant->info, options, dump_shaders);
 	} else {
-		ac_compile_nir_shader(tm, &binary, &variant->config,
+		ac_compile_nir_shader(tm, binary, &variant->config,
 				      &variant->info, shader, options,
 				      dump_shaders);
 	}
 
 	LLVMDisposeTargetMachine(tm);
 
-	radv_fill_shader_variant(device, variant, &binary, stage);
+	radv_fill_shader_variant(device, variant, stage);
 
 	if (code_out) {
-		*code_out = binary.code;
-		*code_size_out = binary.code_size;
+		*code_out = binary->code;
+		*code_size_out = binary->code_size;
 	} else
-		free(binary.code);
-	free(binary.config);
-	free(binary.rodata);
-	free(binary.global_symbol_offsets);
-	free(binary.relocs);
-	free(binary.disasm_string);
+		free(binary->code);
+	free(binary->config);
+	free(binary->rodata);
+	free(binary->global_symbol_offsets);
+	free(binary->relocs);
+	free(binary->disasm_string);
 	variant->ref_count = 1;
 	return variant;
 }
diff --git a/src/amd/vulkan/radv_shader.h b/src/amd/vulkan/radv_shader.h
index b0bf22eb76..aaf6e49e80 100644
--- a/src/amd/vulkan/radv_shader.h
+++ b/src/amd/vulkan/radv_shader.h
@@ -44,6 +44,7 @@ struct radv_shader_variant {
 
 	struct radeon_winsys_bo *bo;
 	uint64_t bo_offset;
+	struct ac_shader_binary binary;
 	struct ac_shader_config config;
 	struct ac_shader_variant_info info;
 	unsigned rsrc1;
-- 
2.14.1



More information about the mesa-dev mailing list