util/range_remap: dont overwrite entry if ptr is NULL
If the ptr value is NULL and we match an existing entry during an insert call we now just return the existing value. This allows us to drop an extra lookup, this will become important as the following patches change `util_range_remap()` lookups to use a sorted array that is not created until after we have added all entries to our linked list. Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37754>
This commit is contained in:
committed by
Marge Bot
parent
a48ecca4d9
commit
35d5e903ac
@@ -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. */
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user