glsl: move resource_name_updated() to linker_util.cpp

We want to remove the old linker.cpp file in following patches so move
this util function to the util code file.

Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31500>
This commit is contained in:
Timothy Arceri 2024-10-02 14:16:43 +10:00 committed by Marge Bot
parent 08e25e091b
commit 13301e2509
4 changed files with 26 additions and 23 deletions

View file

@ -148,25 +148,3 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
return;
#endif
}
void
resource_name_updated(struct gl_resource_name *name)
{
if (name->string) {
name->length = strlen(name->string);
const char *last_square_bracket = strrchr(name->string, '[');
if (last_square_bracket) {
name->last_square_bracket = last_square_bracket - name->string;
name->suffix_is_zero_square_bracketed =
strcmp(last_square_bracket, "[0]") == 0;
} else {
name->last_square_bracket = -1;
name->suffix_is_zero_square_bracketed = false;
}
} else {
name->length = 0;
name->last_square_bracket = -1;
name->suffix_is_zero_square_bracketed = false;
}
}

View file

@ -507,3 +507,25 @@ _mesa_glsl_can_implicitly_convert(const glsl_type *from, const glsl_type *desire
return false;
}
void
resource_name_updated(struct gl_resource_name *name)
{
if (name->string) {
name->length = strlen(name->string);
const char *last_square_bracket = strrchr(name->string, '[');
if (last_square_bracket) {
name->last_square_bracket = last_square_bracket - name->string;
name->suffix_is_zero_square_bracketed =
strcmp(last_square_bracket, "[0]") == 0;
} else {
name->last_square_bracket = -1;
name->suffix_is_zero_square_bracketed = false;
}
} else {
name->length = 0;
name->last_square_bracket = -1;
name->suffix_is_zero_square_bracketed = false;
}
}

View file

@ -129,6 +129,9 @@ link_util_mark_array_elements_referenced(const struct array_deref_range *dr,
unsigned count, unsigned array_depth,
BITSET_WORD *bits);
void
resource_name_updated(struct gl_resource_name *name);
/**
* Get the string value for an interpolation qualifier
*

View file

@ -29,9 +29,9 @@
* Supports serializing and deserializing glsl programs using a blob.
*/
#include "compiler/glsl/linker_util.h"
#include "compiler/glsl_types.h"
#include "compiler/shader_info.h"
#include "ir_uniform.h"
#include "main/mtypes.h"
#include "main/shaderobj.h"
#include "program/program.h"