radv: Dump nir shaders before compiling

It will allow adding source locations that point to the nir_string to
the shader.

Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29298>
This commit is contained in:
Konstantin Seurer 2024-08-25 14:08:07 +02:00 committed by Marge Bot
parent aaf65d6219
commit 736c8c6f23
5 changed files with 30 additions and 4 deletions

View file

@ -125,12 +125,18 @@ radv_compile_cs(struct radv_device *device, struct vk_pipeline_cache *cache, str
nir_print_shader(cs_stage->nir, stderr);
}
char *nir_string = NULL;
if (keep_executable_info || dump_shader)
nir_string = radv_dump_nir_shaders(&cs_stage->nir, 1);
/* Compile NIR shader to AMD assembly. */
*cs_binary =
radv_shader_nir_to_asm(device, cs_stage, &cs_stage->nir, 1, NULL, keep_executable_info, keep_statistic_info);
cs_shader = radv_shader_create(device, cache, *cs_binary, keep_executable_info || dump_shader);
cs_shader->nir_string = nir_string;
radv_shader_generate_debug_info(device, dump_shader, keep_executable_info, *cs_binary, cs_shader, &cs_stage->nir, 1,
&cs_stage->info);

View file

@ -2275,13 +2275,20 @@ radv_create_gs_copy_shader(struct radv_device *device, struct vk_pipeline_cache
if (dump_shader)
simple_mtx_lock(&instance->shader_dump_mtx);
char *nir_string = NULL;
if (keep_executable_info || dump_shader)
nir_string = radv_dump_nir_shaders(&nir, 1);
*gs_copy_binary = radv_shader_nir_to_asm(device, &gs_copy_stage, &nir, 1, &key.gfx_state, keep_executable_info,
keep_statistic_info);
struct radv_shader *copy_shader =
radv_shader_create(device, cache, *gs_copy_binary, keep_executable_info || dump_shader);
if (copy_shader)
if (copy_shader) {
copy_shader->nir_string = nir_string;
radv_shader_generate_debug_info(device, dump_shader, keep_executable_info, *gs_copy_binary, copy_shader, &nir, 1,
&gs_copy_stage.info);
}
if (dump_shader)
simple_mtx_unlock(&instance->shader_dump_mtx);
@ -2335,9 +2342,16 @@ radv_graphics_shaders_nir_to_asm(struct radv_device *device, struct vk_pipeline_
nir_print_shader(nir_shaders[i], stderr);
}
char *nir_string = NULL;
if (keep_executable_info || dump_shader)
nir_string = radv_dump_nir_shaders(nir_shaders, shader_count);
binaries[s] = radv_shader_nir_to_asm(device, &stages[s], nir_shaders, shader_count, gfx_state,
keep_executable_info, keep_statistic_info);
shaders[s] = radv_shader_create(device, cache, binaries[s], keep_executable_info || dump_shader);
shaders[s]->nir_string = nir_string;
radv_shader_generate_debug_info(device, dump_shader, keep_executable_info, binaries[s], shaders[s], nir_shaders,
shader_count, &stages[s].info);

View file

@ -444,6 +444,10 @@ radv_rt_nir_to_asm(struct radv_device *device, struct vk_pipeline_cache *cache,
nir_print_shader(shaders[i], stderr);
}
char *nir_string = NULL;
if (keep_executable_info || dump_shader)
nir_string = radv_dump_nir_shaders(shaders, num_shaders);
/* Compile NIR shader to AMD assembly. */
binary =
radv_shader_nir_to_asm(device, stage, shaders, num_shaders, NULL, keep_executable_info, keep_statistic_info);
@ -461,6 +465,8 @@ radv_rt_nir_to_asm(struct radv_device *device, struct vk_pipeline_cache *cache,
shader = radv_shader_create(device, cache, binary, keep_executable_info || dump_shader);
if (shader) {
shader->nir_string = nir_string;
radv_shader_generate_debug_info(device, dump_shader, keep_executable_info, binary, shader, shaders, num_shaders,
&stage->info);

View file

@ -2851,7 +2851,7 @@ radv_shader_part_cache_get(struct radv_device *device, struct radv_shader_part_c
return shader_part;
}
static char *
char *
radv_dump_nir_shaders(struct nir_shader *const *shaders, int shader_count)
{
char *data = NULL;
@ -2968,8 +2968,6 @@ radv_capture_shader_executable_info(struct radv_device *device, struct radv_shad
struct nir_shader *const *shaders, int shader_count,
const struct radv_shader_binary *binary)
{
shader->nir_string = radv_dump_nir_shaders(shaders, shader_count);
if (binary->type == RADV_BINARY_TYPE_RTLD) {
#if !defined(USE_LIBELF)
return;

View file

@ -547,6 +547,8 @@ void radv_shader_generate_debug_info(struct radv_device *device, bool dump_shade
struct nir_shader *const *shaders, int shader_count,
struct radv_shader_info *info);
char *radv_dump_nir_shaders(struct nir_shader *const *shaders, int shader_count);
VkResult radv_shader_wait_for_upload(struct radv_device *device, uint64_t seq);
struct radv_shader_dma_submission *radv_shader_dma_pop_submission(struct radv_device *device);