compiler: BLAKE3 ID for SPIR-V capture

Reviewed-by: Natalie Vock <natalie.vock@gmx.de>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36472>
This commit is contained in:
Caleb Callaway 2025-07-25 22:48:18 +00:00 committed by Marge Bot
parent 16a855ae61
commit df2f7bda4f

View file

@ -343,13 +343,11 @@ vtn_log_err(struct vtn_builder *b,
}
static void
vtn_dump_shader(struct vtn_builder *b, const char *path, const char *prefix)
vtn_dump_shader(struct vtn_builder *b, const char *path, const char *name)
{
static int idx = 0;
char filename[PATH_MAX];
int len = snprintf(filename, sizeof(filename), "%s/%s-%d.spirv",
path, prefix, idx++);
int len = snprintf(filename, sizeof(filename), "%s/0x%s.spirv",
path, name);
if (len < 0 || len >= sizeof(filename))
return;
@ -7235,16 +7233,19 @@ spirv_to_nir(const uint32_t *words, size_t word_count,
return NULL;
}
const char *dump_path = secure_getenv("MESA_SPIRV_DUMP_PATH");
if (dump_path)
vtn_dump_shader(b, dump_path, "spirv");
b->shader = nir_shader_create(b, stage, nir_options);
b->shader->info.float_controls_execution_mode = options->float_controls_execution_mode;
b->shader->info.cs.shader_index = options->shader_index;
b->shader->has_debug_info = options->debug_info;
_mesa_blake3_compute(words, word_count * sizeof(uint32_t), b->shader->info.source_blake3);
const char *dump_path = secure_getenv("MESA_SPIRV_DUMP_PATH");
if (dump_path) {
char blake3_str[BLAKE3_HEX_LEN];
_mesa_blake3_format(blake3_str, b->shader->info.source_blake3);
vtn_dump_shader(b, dump_path, blake3_str);
}
/* Skip the SPIR-V header, handled at vtn_create_builder */
words+= 5;