From: Samuel Pitoiset Date: Mon, 28 Oct 2019 15:56:15 +0000 (+0100) Subject: radv: fix dumping SPIR-V into hang reports X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d4e0bef1bbbe442fb6006ed13dac7ab7bca5e3fd;p=mesa.git radv: fix dumping SPIR-V into hang reports Signed-off-by: Samuel Pitoiset Reviewed-by: Bas Nieuwenhuizen --- diff --git a/src/amd/vulkan/radv_debug.c b/src/amd/vulkan/radv_debug.c index 60a386e4864..68d361f41dd 100644 --- a/src/amd/vulkan/radv_debug.c +++ b/src/amd/vulkan/radv_debug.c @@ -643,7 +643,7 @@ radv_check_gpu_hangs(struct radv_queue *queue, struct radeon_cmdbuf *cs) } void -radv_print_spirv(uint32_t *data, uint32_t size, FILE *fp) +radv_print_spirv(const char *data, uint32_t size, FILE *fp) { char path[] = "/tmp/fileXXXXXX"; char line[2048], command[128]; diff --git a/src/amd/vulkan/radv_debug.h b/src/amd/vulkan/radv_debug.h index 2ec460ec15a..1a8de6a6ba4 100644 --- a/src/amd/vulkan/radv_debug.h +++ b/src/amd/vulkan/radv_debug.h @@ -82,7 +82,7 @@ void radv_check_gpu_hangs(struct radv_queue *queue, struct radeon_cmdbuf *cs); void -radv_print_spirv(uint32_t *data, uint32_t size, FILE *fp); +radv_print_spirv(const char *data, uint32_t size, FILE *fp); void radv_dump_enabled_options(struct radv_device *device, FILE *f); diff --git a/src/amd/vulkan/radv_shader.c b/src/amd/vulkan/radv_shader.c index a5ad594207d..c841a2f0726 100644 --- a/src/amd/vulkan/radv_shader.c +++ b/src/amd/vulkan/radv_shader.c @@ -312,7 +312,7 @@ radv_shader_compile_to_nir(struct radv_device *device, assert(module->size % 4 == 0); if (device->instance->debug_flags & RADV_DEBUG_DUMP_SPIRV) - radv_print_spirv(spirv, module->size, stderr); + radv_print_spirv(module->data, module->size, stderr); uint32_t num_spec_entries = 0; struct nir_spirv_specialization *spec_entries = NULL; @@ -1145,7 +1145,14 @@ shader_variant_compile(struct radv_device *device, if (keep_shader_info) { variant->nir_string = radv_dump_nir_shaders(shaders, shader_count); if (!gs_copy_shader && !module->nir) { - variant->spirv = (uint32_t *)module->data; + variant->spirv = malloc(module->size); + if (!variant->spirv) { + free(variant); + free(binary); + return NULL; + } + + memcpy(variant->spirv, module->data, module->size); variant->spirv_size = module->size; } } @@ -1211,6 +1218,7 @@ radv_shader_variant_destroy(struct radv_device *device, list_del(&variant->slab_list); mtx_unlock(&device->shader_slab_mutex); + free(variant->spirv); free(variant->nir_string); free(variant->disasm_string); free(variant->ir_string); diff --git a/src/amd/vulkan/radv_shader.h b/src/amd/vulkan/radv_shader.h index 5af3296150e..0eca6ef0e79 100644 --- a/src/amd/vulkan/radv_shader.h +++ b/src/amd/vulkan/radv_shader.h @@ -366,7 +366,7 @@ struct radv_shader_variant { /* debug only */ bool aco_used; - uint32_t *spirv; + char *spirv; uint32_t spirv_size; char *nir_string; char *disasm_string;