diff --git a/src/compiler/glsl/gl_nir_linker.c b/src/compiler/glsl/gl_nir_linker.c index 4689f275344..ed627cc039e 100644 --- a/src/compiler/glsl/gl_nir_linker.c +++ b/src/compiler/glsl/gl_nir_linker.c @@ -2975,23 +2975,20 @@ reserve_explicit_locations(struct gl_shader_program *prog, unsigned return_value = slots; struct range_entry *re = - util_range_remap(location, prog->UniformRemapTable); + util_range_insert_remap(location, max_loc, prog->UniformRemapTable, + NULL); if (!re) { - re = util_range_insert_remap(location, max_loc, - prog->UniformRemapTable, NULL); - if (!re) { - /* ARB_explicit_uniform_location specification states: - * - * "No two default-block uniform variables in the program can have - * the same location, even if they are unused, otherwise a compiler - * or linker error will be generated." - */ - linker_error(prog, - "location qualifier for uniform %s overlaps " - "previously used location\n", - *var_name); - return -1; - } + /* ARB_explicit_uniform_location specification states: + * + * "No two default-block uniform variables in the program can have + * the same location, even if they are unused, otherwise a compiler + * or linker error will be generated." + */ + linker_error(prog, + "location qualifier for uniform %s overlaps " + "previously used location\n", + *var_name); + return -1; } /* Check if location is already used. */ diff --git a/src/util/u_range_remap.c b/src/util/u_range_remap.c index b3a1cd0ce61..d56367497a0 100644 --- a/src/util/u_range_remap.c +++ b/src/util/u_range_remap.c @@ -83,9 +83,10 @@ get_range_entry(unsigned n, const struct list_head *r_list) return NULL; } -/* Insert a new range entry or update an existing entries pointer value if - * start and end match exactly. If the range overlaps an existing entry we - * return NULL. +/* Insert a new range entry or if ptr is non-null update an existing entries + * pointer value if start and end match exactly. If the range overlaps an + * existing entry we return NULL or if start and end match an entry exactly + * but ptr is null we return the existing entry. */ struct range_entry * util_range_insert_remap(unsigned start, unsigned end, @@ -148,6 +149,9 @@ util_range_insert_remap(unsigned start, unsigned end, mid++; } } else if (mid_entry->start == start && mid_entry->end == end) { + if (!ptr) + return mid_entry; + entry = mid_entry; goto insert_end; } else {