diff --git a/README.OpenSource b/README.OpenSource index 19b7ba50dc97bdd7a46ea50ed479d6bba6d4a093..3a2651e0bf98df18fc82ff12dc80827478c135ca 100644 --- a/README.OpenSource +++ b/README.OpenSource @@ -6,7 +6,7 @@ "Version Number": "25.0.1", "Owner": "liaosirui@huawei.com", "Upstream URL": "https://gitlab.freedesktop.org/mesa/mesa", - "Description": "mesa is an open-source software implementation of OpenGL, Vulkan, and other graphics API specifications." + "Description": "mesa is an open-source software implementation of OpenGL, Vulkan, and other graphics API specifications.", "Dependencies": [ "zlib" ] } ] \ No newline at end of file diff --git a/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c b/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c index ca0b698253f06e11e91811f4fa155edc1469f7fd..43a5c55d3efc72cefcaff1eb5ef0944331cdbf9d 100644 --- a/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c +++ b/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c @@ -4720,6 +4720,8 @@ nir_to_spirv(struct nir_shader *s, const struct zink_shader_info *sinfo, const s struct ntv_context ctx = {0}; ctx.mem_ctx = ralloc_context(NULL); + ctx.builder.name_syms = _mesa_set_create(NULL, _mesa_hash_string, _mesa_key_string_equal); + ctx.builder.name_syms_index = 0; ctx.nir = s; ctx.builder.mem_ctx = ctx.mem_ctx; assert(spirv_version >= SPIRV_VERSION(1, 0)); diff --git a/src/gallium/drivers/zink/nir_to_spirv/spirv_builder.c b/src/gallium/drivers/zink/nir_to_spirv/spirv_builder.c index 7c0d62db3294e09ec9fa5e19ec31839091724f72..c1d5a79d44f21b780897ad5ff5e67340299aaf94 100644 --- a/src/gallium/drivers/zink/nir_to_spirv/spirv_builder.c +++ b/src/gallium/drivers/zink/nir_to_spirv/spirv_builder.c @@ -218,12 +218,28 @@ spirv_builder_emit_name(struct spirv_builder *b, SpvId target, ptr[i] = '_'; } } + char *new_name = NULL; + struct set_entry *entry = _mesa_set_search(b->name_syms, ptr); + if (entry != NULL) { + /* we have a collision with another name, append an _ + a unique index */ + asprintf(&new_name, "%s_%u", ptr, b->name_syms_index++); + } else { + /* Mark this one as seen */ + _mesa_set_add(b->name_syms, ptr); + } size_t pos = b->debug_names.num_words; spirv_buffer_prepare(&b->debug_names, b->mem_ctx, 2); spirv_buffer_emit_word(&b->debug_names, SpvOpName); spirv_buffer_emit_word(&b->debug_names, target); - int len = spirv_buffer_emit_string(&b->debug_names, b->mem_ctx, name); + int len = 0; + if (new_name != NULL) { + len = spirv_buffer_emit_string(&b->debug_names, b->mem_ctx, new_name); + free(new_name); + new_name = NULL; + } else { + len = spirv_buffer_emit_string(&b->debug_names, b->mem_ctx, name); + } b->debug_names.words[pos] |= (2 + len) << 16; } diff --git a/src/gallium/drivers/zink/nir_to_spirv/spirv_builder.h b/src/gallium/drivers/zink/nir_to_spirv/spirv_builder.h index 73facbe8d63583bf43744187eba9089d75c5253f..c0e08e604fbe00cdf189016dd77d106d06d6f1c6 100644 --- a/src/gallium/drivers/zink/nir_to_spirv/spirv_builder.h +++ b/src/gallium/drivers/zink/nir_to_spirv/spirv_builder.h @@ -60,6 +60,9 @@ struct spirv_builder { struct spirv_buffer instructions; SpvId prev_id; unsigned local_vars_begin; + + struct set* name_syms; + int name_syms_index; }; struct spriv_tex_src {