glsl: add gl_resource_name to precompute "name" properties later

This just adds the structure with a name and its update function.
strlen and others will be added in the following commits. The idea is to
parse and analyze the name in advance to make glGetUniformLocation faster.

Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13507>
This commit is contained in:
Marek Olšák
2021-10-22 19:19:48 -04:00
parent c216f1931d
commit dea558cbd2
18 changed files with 137 additions and 104 deletions
+16 -8
View File
@@ -1287,7 +1287,7 @@ interstage_cross_validate_uniform_blocks(struct gl_shader_program *prog,
if (index == -1) {
linker_error(prog, "buffer block `%s' has mismatching "
"definitions\n", sh_blks[j]->Name);
"definitions\n", sh_blks[j]->name.string);
for (unsigned k = 0; k <= i; k++) {
free(ifc_blk_stage_idx[k]);
@@ -3744,24 +3744,26 @@ create_shader_variable(struct gl_shader_program *shProg,
*/
if (in->data.mode == ir_var_system_value &&
in->data.location == SYSTEM_VALUE_VERTEX_ID_ZERO_BASE) {
out->name = ralloc_strdup(shProg, "gl_VertexID");
out->name.string = ralloc_strdup(shProg, "gl_VertexID");
} else if ((in->data.mode == ir_var_shader_out &&
in->data.location == VARYING_SLOT_TESS_LEVEL_OUTER) ||
(in->data.mode == ir_var_system_value &&
in->data.location == SYSTEM_VALUE_TESS_LEVEL_OUTER)) {
out->name = ralloc_strdup(shProg, "gl_TessLevelOuter");
out->name.string = ralloc_strdup(shProg, "gl_TessLevelOuter");
type = glsl_type::get_array_instance(glsl_type::float_type, 4);
} else if ((in->data.mode == ir_var_shader_out &&
in->data.location == VARYING_SLOT_TESS_LEVEL_INNER) ||
(in->data.mode == ir_var_system_value &&
in->data.location == SYSTEM_VALUE_TESS_LEVEL_INNER)) {
out->name = ralloc_strdup(shProg, "gl_TessLevelInner");
out->name.string = ralloc_strdup(shProg, "gl_TessLevelInner");
type = glsl_type::get_array_instance(glsl_type::float_type, 2);
} else {
out->name = ralloc_strdup(shProg, name);
out->name.string = ralloc_strdup(shProg, name);
}
if (!out->name)
resource_name_updated(&out->name);
if (!out->name.string)
return NULL;
/* The ARB_program_interface_query spec says:
@@ -4351,7 +4353,8 @@ link_assign_subroutine_types(struct gl_shader_program *prog)
p->sh.SubroutineFunctions = reralloc(p, p->sh.SubroutineFunctions,
struct gl_subroutine_function,
p->sh.NumSubroutineFunctions + 1);
p->sh.SubroutineFunctions[p->sh.NumSubroutineFunctions].name = ralloc_strdup(p, fn->name);
p->sh.SubroutineFunctions[p->sh.NumSubroutineFunctions].name.string = ralloc_strdup(p, fn->name);
resource_name_updated(&p->sh.SubroutineFunctions[p->sh.NumSubroutineFunctions].name);
p->sh.SubroutineFunctions[p->sh.NumSubroutineFunctions].num_compat_types = fn->num_subroutine_types;
p->sh.SubroutineFunctions[p->sh.NumSubroutineFunctions].types =
ralloc_array(p, const struct glsl_type *,
@@ -4402,7 +4405,7 @@ verify_subroutine_associated_funcs(struct gl_shader_program *prog)
*/
for (unsigned j = 0; j < p->sh.NumSubroutineFunctions; j++) {
unsigned definitions = 0;
char *name = p->sh.SubroutineFunctions[j].name;
char *name = p->sh.SubroutineFunctions[j].name.string;
ir_function *fn = symbols->get_function(name);
/* Calculate number of function definitions with the same name */
@@ -5034,3 +5037,8 @@ done:
ralloc_free(mem_ctx);
}
void
resource_name_updated(struct gl_resource_name *name)
{
}