diff options
author | Bas Nieuwenhuizen <[email protected]> | 2019-06-01 20:54:35 +0200 |
---|---|---|
committer | Bas Nieuwenhuizen <[email protected]> | 2019-08-12 23:00:24 +0200 |
commit | 5444d3e0c2bceafb1be7e2c3f5afa17415a08e9e (patch) | |
tree | 20e732629e6ad24e91a01c3d8fa9ecfd7da812cd /src/amd | |
parent | 739a2880f520a1ecd11a3fec8c3a38398b6dd1ce (diff) |
radv: Use string for nir dumping.
Reviewed-by: Dave Airlie <[email protected]>
Allows us to easily dump all nir shaders for combined variants in
vega and simplifies ownership.
Diffstat (limited to 'src/amd')
-rw-r--r-- | src/amd/vulkan/radv_debug.c | 5 | ||||
-rw-r--r-- | src/amd/vulkan/radv_pipeline.c | 3 | ||||
-rw-r--r-- | src/amd/vulkan/radv_shader.c | 27 | ||||
-rw-r--r-- | src/amd/vulkan/radv_shader.h | 2 |
4 files changed, 29 insertions, 8 deletions
diff --git a/src/amd/vulkan/radv_debug.c b/src/amd/vulkan/radv_debug.c index 49b7417e988..41d329182ae 100644 --- a/src/amd/vulkan/radv_debug.c +++ b/src/amd/vulkan/radv_debug.c @@ -503,9 +503,8 @@ radv_dump_shader(struct radv_pipeline *pipeline, radv_print_spirv(shader->spirv, shader->spirv_size, f); } - if (shader->nir) { - fprintf(f, "NIR:\n"); - nir_print_shader(shader->nir, f); + if (shader->nir_string) { + fprintf(f, "NIR:\n%s\n", shader->nir_string); } fprintf(f, "LLVM IR:\n%s\n", shader->llvm_ir_string); diff --git a/src/amd/vulkan/radv_pipeline.c b/src/amd/vulkan/radv_pipeline.c index 8e56e2cbd79..d297a4e078b 100644 --- a/src/amd/vulkan/radv_pipeline.c +++ b/src/amd/vulkan/radv_pipeline.c @@ -2660,8 +2660,7 @@ void radv_create_shaders(struct radv_pipeline *pipeline, for (int i = 0; i < MESA_SHADER_STAGES; ++i) { free(binaries[i]); if (nir[i]) { - if (!pipeline->device->keep_shader_info) - ralloc_free(nir[i]); + ralloc_free(nir[i]); if (radv_can_dump_shader_stats(device, modules[i])) radv_shader_dump_stats(device, diff --git a/src/amd/vulkan/radv_shader.c b/src/amd/vulkan/radv_shader.c index d06abb3d648..d0006cf84f5 100644 --- a/src/amd/vulkan/radv_shader.c +++ b/src/amd/vulkan/radv_shader.c @@ -1097,6 +1097,29 @@ radv_shader_variant_create(struct radv_device *device, return variant; } +static char * +radv_dump_nir_shaders(struct nir_shader * const *shaders, + int shader_count) +{ + char *data = NULL; + char *ret = NULL; + size_t size = 0; + FILE *f = open_memstream(&data, &size); + if (f) { + for (int i = 0; i < shader_count; ++i) + nir_print_shader(shaders[i], f); + fclose(f); + } + + ret = malloc(size + 1); + if (ret) { + memcpy(ret, data, size); + ret[size] = 0; + } + free(data); + return ret; +} + static struct radv_shader_variant * shader_variant_compile(struct radv_device *device, struct radv_shader_module *module, @@ -1176,8 +1199,8 @@ shader_variant_compile(struct radv_device *device, if (device->keep_shader_info) { + variant->nir_string = radv_dump_nir_shaders(shaders, shader_count); if (!gs_copy_shader && !module->nir) { - variant->nir = *shaders; variant->spirv = (uint32_t *)module->data; variant->spirv_size = module->size; } @@ -1239,7 +1262,7 @@ radv_shader_variant_destroy(struct radv_device *device, list_del(&variant->slab_list); mtx_unlock(&device->shader_slab_mutex); - ralloc_free(variant->nir); + free(variant->nir_string); free(variant->disasm_string); free(variant->llvm_ir_string); free(variant); diff --git a/src/amd/vulkan/radv_shader.h b/src/amd/vulkan/radv_shader.h index af097215f53..07437de7255 100644 --- a/src/amd/vulkan/radv_shader.h +++ b/src/amd/vulkan/radv_shader.h @@ -354,7 +354,7 @@ struct radv_shader_variant { /* debug only */ uint32_t *spirv; uint32_t spirv_size; - struct nir_shader *nir; + char *nir_string; char *disasm_string; char *llvm_ir_string; |