diff --git a/src/gallium/drivers/iris/iris_program.c b/src/gallium/drivers/iris/iris_program.c index 155d862dda4..7a6674e7841 100644 --- a/src/gallium/drivers/iris/iris_program.c +++ b/src/gallium/drivers/iris/iris_program.c @@ -54,6 +54,7 @@ #include "iris_context.h" #include "iris_pipe.h" #include "nir/tgsi_to_nir.h" +#include "git_sha1.h" static inline enum intel_vue_layout vue_layout(bool separate_shader) @@ -1832,6 +1833,36 @@ iris_schedule_compile(struct iris_screen *screen, } } +static debug_archiver * +iris_debug_archiver_open(void *tmp_ctx, struct iris_screen *screen, + struct iris_uncompiled_shader *ish, const void *key, + unsigned key_size) +{ + if (!INTEL_DEBUG(DEBUG_MDA) || !screen->brw) + return NULL; + + char name[SHA1_DIGEST_STRING_LENGTH + 5] = {}; + { + struct mesa_sha1 ctx; + unsigned char hash[SHA1_DIGEST_LENGTH]; + + _mesa_sha1_init(&ctx); + _mesa_sha1_update(&ctx, ish->nir->info.source_blake3, BLAKE3_OUT_LEN); + _mesa_sha1_update(&ctx, key, key_size); + _mesa_sha1_final(&ctx, hash); + + _mesa_sha1_format(name, hash); + } + memcpy(&name[SHA1_DIGEST_STRING_LENGTH - 1], ".iris", 5); + + debug_archiver *debug_archiver = + debug_archiver_open(tmp_ctx, name, PACKAGE_VERSION MESA_GIT_SHA1); + + debug_archiver_set_prefix(debug_archiver, + _mesa_shader_stage_to_abbrev(ish->nir->info.stage)); + return debug_archiver; +} + /** * Compile a vertex shader, and upload the assembly. */ @@ -1851,6 +1882,9 @@ iris_compile_vs(struct iris_screen *screen, nir_shader *nir = nir_shader_clone(mem_ctx, ish->nir); const struct iris_vs_prog_key *const key = &shader->key.vs; + debug_archiver *debug_archiver = + iris_debug_archiver_open(mem_ctx, screen, ish, key, sizeof(*key)); + if (key->vue.nr_userclip_plane_consts) { nir_function_impl *impl = nir_shader_get_entrypoint(nir); /* Check if variables were found. */ @@ -1888,6 +1922,7 @@ iris_compile_vs(struct iris_screen *screen, .nir = nir, .log_data = dbg, .source_hash = ish->source_hash, + .archiver = debug_archiver, }, .key = &brw_key, .prog_data = brw_prog_data, @@ -1938,6 +1973,8 @@ iris_compile_vs(struct iris_screen *screen, #endif } + debug_archiver_close(debug_archiver); + if (program == NULL) { dbg_printf("Failed to compile vertex shader: %s\n", error); ralloc_free(mem_ctx); @@ -2104,6 +2141,9 @@ iris_compile_tcs(struct iris_screen *screen, source_hash = *(uint32_t*)nir->info.source_blake3; } + debug_archiver *debug_archiver = + iris_debug_archiver_open(mem_ctx, screen, ish, key, sizeof(*key)); + iris_setup_uniforms(devinfo, mem_ctx, nir, &system_values, &num_system_values, &num_cbufs); iris_setup_binding_table(devinfo, nir, &bt, /* num_render_targets */ 0, @@ -2122,6 +2162,7 @@ iris_compile_tcs(struct iris_screen *screen, .nir = nir, .log_data = dbg, .source_hash = source_hash, + .archiver = debug_archiver, }, .key = &brw_key, .prog_data = brw_prog_data, @@ -2164,6 +2205,8 @@ iris_compile_tcs(struct iris_screen *screen, #endif } + debug_archiver_close(debug_archiver); + if (program == NULL) { dbg_printf("Failed to compile control shader: %s\n", error); ralloc_free(mem_ctx); @@ -2287,6 +2330,9 @@ iris_compile_tes(struct iris_screen *screen, nir_shader *nir = nir_shader_clone(mem_ctx, ish->nir); const struct iris_tes_prog_key *const key = &shader->key.tes; + debug_archiver *debug_archiver = + iris_debug_archiver_open(mem_ctx, screen, ish, key, sizeof(*key)); + if (key->vue.nr_userclip_plane_consts) { nir_function_impl *impl = nir_shader_get_entrypoint(nir); nir_lower_clip_vs(nir, (1 << key->vue.nr_userclip_plane_consts) - 1, @@ -2325,6 +2371,7 @@ iris_compile_tes(struct iris_screen *screen, .nir = nir, .log_data = dbg, .source_hash = ish->source_hash, + .archiver = debug_archiver, }, .key = &brw_key, .prog_data = brw_prog_data, @@ -2375,6 +2422,8 @@ iris_compile_tes(struct iris_screen *screen, #endif } + debug_archiver_close(debug_archiver); + if (program == NULL) { dbg_printf("Failed to compile evaluation shader: %s\n", error); ralloc_free(mem_ctx); @@ -2476,6 +2525,9 @@ iris_compile_gs(struct iris_screen *screen, nir_shader *nir = nir_shader_clone(mem_ctx, ish->nir); const struct iris_gs_prog_key *const key = &shader->key.gs; + debug_archiver *debug_archiver = + iris_debug_archiver_open(mem_ctx, screen, ish, key, sizeof(*key)); + if (key->vue.nr_userclip_plane_consts) { nir_function_impl *impl = nir_shader_get_entrypoint(nir); nir_lower_clip_gs(nir, (1 << key->vue.nr_userclip_plane_consts) - 1, @@ -2513,6 +2565,7 @@ iris_compile_gs(struct iris_screen *screen, .nir = nir, .log_data = dbg, .source_hash = ish->source_hash, + .archiver = debug_archiver, }, .key = &brw_key, .prog_data = brw_prog_data, @@ -2561,6 +2614,8 @@ iris_compile_gs(struct iris_screen *screen, #endif } + debug_archiver_close(debug_archiver); + if (program == NULL) { dbg_printf("Failed to compile geometry shader: %s\n", error); ralloc_free(mem_ctx); @@ -2659,6 +2714,9 @@ iris_compile_fs(struct iris_screen *screen, nir_shader *nir = nir_shader_clone(mem_ctx, ish->nir); const struct iris_fs_prog_key *const key = &shader->key.fs; + debug_archiver *debug_archiver = + iris_debug_archiver_open(mem_ctx, screen, ish, key, sizeof(*key)); + iris_setup_uniforms(devinfo, mem_ctx, nir, &system_values, &num_system_values, &num_cbufs); @@ -2696,6 +2754,7 @@ iris_compile_fs(struct iris_screen *screen, .nir = nir, .log_data = dbg, .source_hash = ish->source_hash, + .archiver = debug_archiver, }, .key = &brw_key, .prog_data = brw_prog_data, @@ -2748,6 +2807,8 @@ iris_compile_fs(struct iris_screen *screen, #endif } + debug_archiver_close(debug_archiver); + if (program == NULL) { dbg_printf("Failed to compile fragment shader: %s\n", error); ralloc_free(mem_ctx); @@ -3002,6 +3063,9 @@ iris_compile_cs(struct iris_screen *screen, nir_shader *nir = nir_shader_clone(mem_ctx, ish->nir); const struct iris_cs_prog_key *const key = &shader->key.cs; + debug_archiver *debug_archiver = + iris_debug_archiver_open(mem_ctx, screen, ish, key, sizeof(*key)); + if (screen->brw) NIR_PASS(_, nir, brw_nir_lower_cs_intrinsics, devinfo, NULL); else @@ -3033,6 +3097,7 @@ iris_compile_cs(struct iris_screen *screen, .nir = nir, .log_data = dbg, .source_hash = ish->source_hash, + .archiver = debug_archiver, }, .key = &brw_key, .prog_data = brw_prog_data, @@ -3073,6 +3138,8 @@ iris_compile_cs(struct iris_screen *screen, #endif } + debug_archiver_close(debug_archiver); + if (program == NULL) { dbg_printf("Failed to compile compute shader: %s\n", error);