spirv: fixup infinite recursion with shader replacement
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run

While trying to use that feature on RADV I ran into an infinite
recursion.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Fixes: 97b4a6d0e3 ("compiler: SPIR-V shader replacement")
Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41751>
This commit is contained in:
Lionel Landwerlin 2026-05-22 14:03:57 +03:00 committed by Marge Bot
parent 5b07e5e8e4
commit 88418718a9
2 changed files with 8 additions and 2 deletions

View file

@ -145,6 +145,9 @@ struct spirv_to_nir_options {
/* If GroupNonUniform capability is used, set this api subgroup size. */
uint8_t group_non_uniform_subgroup_size;
/* Don't look at MESA_SPIRV_READ_PATH for replacements */
bool ignore_replacement;
};
enum spirv_verify_result {

View file

@ -7622,7 +7622,10 @@ spirv_to_nir(const uint32_t *words, size_t word_count,
}
const char *read_path = os_get_option_secure("MESA_SPIRV_READ_PATH");
if (read_path) {
if (!options->ignore_replacement && read_path) {
struct spirv_to_nir_options replace_options = *options;
replace_options.ignore_replacement = true;
char blake3_str[BLAKE3_HEX_LEN];
_mesa_blake3_format(blake3_str, b->shader->info.source_blake3);
@ -7675,7 +7678,7 @@ spirv_to_nir(const uint32_t *words, size_t word_count,
ralloc_free(b->shader);
ralloc_free(b);
nir_shader* result = spirv_to_nir(replacement_words, replacement_size / sizeof(uint32_t),
spec, stage, entry_point_name, options,
spec, stage, entry_point_name, &replace_options,
nir_options);
free((void *)replacement_words);