compiler/types: Use glsl_get_type_name() to access the type name

This will allow us later to store builtin names in a different way.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25191>
This commit is contained in:
Caio Oliveira 2023-09-12 12:11:18 -07:00 committed by Marge Bot
parent d1e9e7699e
commit bf01000a50
21 changed files with 118 additions and 118 deletions

View file

@ -913,7 +913,7 @@ public:
}
ast_type_specifier(const glsl_type *t)
: type(t), type_name(t->name), structure(NULL), array_specifier(NULL),
: type(t), type_name(glsl_get_type_name(t)), structure(NULL), array_specifier(NULL),
default_precision(ast_precision_none)
{
/* empty */

View file

@ -91,13 +91,13 @@ prototype_string(const glsl_type *return_type, const char *name,
char *str = NULL;
if (return_type != NULL)
str = ralloc_asprintf(NULL, "%s ", return_type->name);
str = ralloc_asprintf(NULL, "%s ", glsl_get_type_name(return_type));
ralloc_asprintf_append(&str, "%s(", name);
const char *comma = "";
foreach_in_list(const ir_variable, param, parameters) {
ralloc_asprintf_append(&str, "%s%s", comma, param->type->name);
ralloc_asprintf_append(&str, "%s%s", comma, glsl_get_type_name(param->type));
comma = ", ";
}
@ -741,7 +741,7 @@ match_subroutine_by_name(const char *name,
for (int i = 0; i < state->num_subroutine_types; i++) {
f = state->subroutine_types[i];
if (strcmp(f->name, var->type->without_array()->name))
if (strcmp(f->name, glsl_get_type_name(var->type->without_array())))
continue;
found = f;
break;
@ -1232,15 +1232,15 @@ process_vec_mat_constructor(exec_list *instructions,
if (ir->type != constructor_type->column_type()) {
_mesa_glsl_error(loc, state, "type error in matrix constructor: "
"expected: %s, found %s",
constructor_type->column_type()->name,
ir->type->name);
glsl_get_type_name(constructor_type->column_type()),
glsl_get_type_name(ir->type));
return ir_rvalue::error_value(ctx);
}
} else if (ir->type != constructor_type->get_scalar_type()) {
_mesa_glsl_error(loc, state, "type error in vector constructor: "
"expected: %s, found %s",
constructor_type->get_scalar_type()->name,
ir->type->name);
glsl_get_type_name(constructor_type->get_scalar_type()),
glsl_get_type_name(ir->type));
return ir_rvalue::error_value(ctx);
}
}
@ -1360,15 +1360,15 @@ process_array_constructor(exec_list *instructions,
} else if (element_type != ir->type) {
_mesa_glsl_error(loc, state, "type error in array constructor: "
"expected: %s, found %s",
element_type->name,
ir->type->name);
glsl_get_type_name(element_type),
glsl_get_type_name(ir->type));
return ir_rvalue::error_value(ctx);
}
} else if (ir->type != constructor_type->fields.array) {
_mesa_glsl_error(loc, state, "type error in array constructor: "
"expected: %s, found %s",
constructor_type->fields.array->name,
ir->type->name);
glsl_get_type_name(constructor_type->fields.array),
glsl_get_type_name(ir->type));
return ir_rvalue::error_value(ctx);
} else {
element_type = ir->type;
@ -1962,7 +1962,7 @@ process_record_constructor(exec_list *instructions,
"%s parameters in constructor for `%s'",
parameter_count > constructor_type->length
? "too many": "insufficient",
constructor_type->name);
glsl_get_type_name(constructor_type));
return ir_rvalue::error_value(ctx);
}
@ -1989,10 +1989,10 @@ process_record_constructor(exec_list *instructions,
_mesa_glsl_error(loc, state,
"parameter type mismatch in constructor for `%s.%s' "
"(%s vs %s)",
constructor_type->name,
glsl_get_type_name(constructor_type),
struct_field->name,
ir->type->name,
struct_field->type->name);
glsl_get_type_name(ir->type),
glsl_get_type_name(struct_field->type));
return ir_rvalue::error_value(ctx);
}
@ -2140,14 +2140,14 @@ ast_function_expression::hir(exec_list *instructions,
(!state->has_bindless() && constructor_type->contains_opaque())) {
_mesa_glsl_error(& loc, state, "cannot construct %s type `%s'",
state->has_bindless() ? "atomic" : "opaque",
constructor_type->name);
glsl_get_type_name(constructor_type));
return ir_rvalue::error_value(ctx);
}
if (constructor_type->is_subroutine()) {
_mesa_glsl_error(& loc, state,
"subroutine name cannot be a constructor `%s'",
constructor_type->name);
glsl_get_type_name(constructor_type));
return ir_rvalue::error_value(ctx);
}
@ -2208,14 +2208,14 @@ ast_function_expression::hir(exec_list *instructions,
if (components_used >= type_components) {
_mesa_glsl_error(& loc, state, "too many parameters to `%s' "
"constructor",
constructor_type->name);
glsl_get_type_name(constructor_type));
return ir_rvalue::error_value(ctx);
}
if (!is_valid_constructor(result->type, state)) {
_mesa_glsl_error(& loc, state, "cannot construct `%s' from a "
"non-numeric data type",
constructor_type->name);
glsl_get_type_name(constructor_type));
return ir_rvalue::error_value(ctx);
}
@ -2240,7 +2240,7 @@ ast_function_expression::hir(exec_list *instructions,
&& constructor_type->is_matrix()
&& !state->check_version(120, 100, &loc,
"cannot construct `%s' from a matrix",
constructor_type->name)) {
glsl_get_type_name(constructor_type))) {
return ir_rvalue::error_value(ctx);
}
@ -2254,7 +2254,7 @@ ast_function_expression::hir(exec_list *instructions,
&& constructor_type->is_matrix()) {
_mesa_glsl_error(& loc, state, "for matrix `%s' constructor, "
"matrix must be only parameter",
constructor_type->name);
glsl_get_type_name(constructor_type));
return ir_rvalue::error_value(ctx);
}
@ -2268,7 +2268,7 @@ ast_function_expression::hir(exec_list *instructions,
&& matrix_parameters == 0) {
_mesa_glsl_error(& loc, state, "too few components to construct "
"`%s'",
constructor_type->name);
glsl_get_type_name(constructor_type));
return ir_rvalue::error_value(ctx);
}

View file

@ -911,7 +911,7 @@ validate_assignment(struct _mesa_glsl_parse_state *state,
"%s of type %s cannot be assigned to "
"variable of type %s",
is_initializer ? "initializer" : "value",
rhs->type->name, lhs->type->name);
glsl_get_type_name(rhs->type), glsl_get_type_name(lhs->type));
return NULL;
}
@ -1714,7 +1714,7 @@ ast_expression::do_hir(exec_list *instructions,
if (type != orig_type) {
_mesa_glsl_error(& loc, state,
"could not implicitly convert "
"%s to %s", type->name, orig_type->name);
"%s to %s", glsl_get_type_name(type), glsl_get_type_name(orig_type));
type = glsl_type::error_type;
}
@ -1755,7 +1755,7 @@ ast_expression::do_hir(exec_list *instructions,
if (type != orig_type) {
_mesa_glsl_error(& loc, state,
"could not implicitly convert "
"%s to %s", type->name, orig_type->name);
"%s to %s", glsl_get_type_name(type), glsl_get_type_name(orig_type));
type = glsl_type::error_type;
}
@ -1822,7 +1822,7 @@ ast_expression::do_hir(exec_list *instructions,
if (type != orig_type) {
_mesa_glsl_error(& loc, state,
"could not implicitly convert "
"%s to %s", type->name, orig_type->name);
"%s to %s", glsl_get_type_name(type), glsl_get_type_name(orig_type));
type = glsl_type::error_type;
}
@ -1901,7 +1901,7 @@ ast_expression::do_hir(exec_list *instructions,
if (type->contains_opaque()) {
if (!(state->has_bindless() && (type->is_image() || type->is_sampler()))) {
_mesa_glsl_error(&loc, state, "variables of type %s cannot be "
"operands of the ?: operator", type->name);
"operands of the ?: operator", glsl_get_type_name(type));
error_emitted = true;
}
}
@ -2717,7 +2717,7 @@ select_gles_precision(unsigned qual_precision,
if (precision == ast_precision_none) {
_mesa_glsl_error(loc, state,
"No precision specified in this scope for type `%s'",
type->name);
glsl_get_type_name(type));
}
}
@ -3684,7 +3684,7 @@ validate_array_dimensions(const glsl_type *t,
_mesa_glsl_error(loc, state,
"only the outermost array dimension can "
"be unsized, but got %s",
top->name);
glsl_get_type_name(top));
break;
}
t = t->fields.array;
@ -5525,7 +5525,7 @@ ast_declarator_list::hir(exec_list *instructions,
"vertex shader input / attribute cannot have "
"type %s`%s'",
var->type->is_array() ? "array of " : "",
check_type->name);
glsl_get_type_name(check_type));
} else if (var->type->is_array() &&
!state->check_version(150, 0, &loc,
"vertex shader input / attribute "
@ -5565,7 +5565,7 @@ ast_declarator_list::hir(exec_list *instructions,
check_type->contains_opaque()) {
_mesa_glsl_error(&loc, state,
"fragment shader input cannot have type %s",
check_type->name);
glsl_get_type_name(check_type));
}
if (var->type->is_array() &&
var->type->fields.array->is_array()) {
@ -5622,7 +5622,7 @@ ast_declarator_list::hir(exec_list *instructions,
default:
_mesa_glsl_error(&loc, state,
"fragment shader output cannot have "
"type %s", check_type->name);
"type %s", glsl_get_type_name(check_type));
}
}
@ -6511,7 +6511,7 @@ ast_function_definition::hir(exec_list *instructions,
_mesa_glsl_error(& loc, state, "function `%s' has non-void return type "
"%s, but no return statement",
signature->function_name(),
signature->return_type->name);
glsl_get_type_name(signature->return_type));
}
/* Function definitions do not have r-values.
@ -6557,16 +6557,16 @@ ast_jump_statement::hir(exec_list *instructions,
_mesa_glsl_error(& loc, state,
"could not implicitly convert return value "
"to %s, in function `%s'",
state->current_function->return_type->name,
glsl_get_type_name(state->current_function->return_type),
state->current_function->function_name());
}
} else {
_mesa_glsl_error(& loc, state,
"`return' with wrong type %s, in function `%s' "
"returning %s",
ret_type->name,
glsl_get_type_name(ret_type),
state->current_function->function_name(),
state->current_function->return_type->name);
glsl_get_type_name(state->current_function->return_type));
}
} else if (state->current_function->return_type->base_type ==
GLSL_TYPE_VOID) {
@ -7132,7 +7132,7 @@ ast_case_label::hir(exec_list *instructions,
!integer_conversion_supported) {
_mesa_glsl_error(&loc, state, "type mismatch with switch "
"init-expression and case label (%s != %s)",
type_a->name, type_b->name);
glsl_get_type_name(type_a), glsl_get_type_name(type_b));
} else {
/* Conversion of the case label. */
if (type_a->base_type == GLSL_TYPE_INT) {
@ -7748,7 +7748,7 @@ ast_process_struct_or_iface_block_members(exec_list *instructions,
if (qual_offset % base_alignment) {
_mesa_glsl_error(&loc, state, "layout qualifier offset "
"must be a multiple of the base "
"alignment of %s", field_type->name);
"alignment of %s", glsl_get_type_name(field_type));
}
fields[i].offset = qual_offset;
next_offset = qual_offset + size;
@ -8396,7 +8396,7 @@ ast_interface_block::hir(exec_list *instructions,
validate_xfb_offset_qualifier(&loc, state, xfb_offset, block_type,
component_size);
if (!state->symbols->add_interface(block_type->name, block_type, var_mode)) {
if (!state->symbols->add_interface(glsl_get_type_name(block_type), block_type, var_mode)) {
YYLTYPE loc = this->get_location();
_mesa_glsl_error(&loc, state, "interface block `%s' with type `%s' "
"already taken in the current scope",

View file

@ -242,7 +242,7 @@ static const struct builtin_type_versions {
static inline void
add_type(glsl_symbol_table *symbols, const glsl_type *const type)
{
symbols->add_type(type->name, type);
symbols->add_type(glsl_get_type_name(type), type);
}
/**

View file

@ -2108,11 +2108,11 @@ _mesa_glsl_copy_symbols_from_table(struct exec_list *shader_ir,
const glsl_type *iface =
src->get_interface("gl_PerVertex", ir_var_shader_in);
if (iface)
dest->add_interface(iface->name, iface, ir_var_shader_in);
dest->add_interface(glsl_get_type_name(iface), iface, ir_var_shader_in);
iface = src->get_interface("gl_PerVertex", ir_var_shader_out);
if (iface)
dest->add_interface(iface->name, iface, ir_var_shader_out);
dest->add_interface(glsl_get_type_name(iface), iface, ir_var_shader_out);
}
}

View file

@ -228,12 +228,12 @@ ir_builder_print_visitor::visit(ir_variable *ir)
if (ir->data.mode == ir_var_temporary) {
print_with_indent("ir_variable *const r%04X = body.make_temp(glsl_type::%s_type, \"%s\");\n",
my_index,
ir->type->name,
glsl_get_type_name(ir->type),
ir->name);
} else {
print_with_indent("ir_variable *const r%04X = new(mem_ctx) ir_variable(glsl_type::%s_type, \"%s\", %s);\n",
my_index,
ir->type->name,
glsl_get_type_name(ir->type),
ir->name,
mode_str);
@ -287,7 +287,7 @@ ir_builder_print_visitor::visit_enter(ir_function_signature *ir)
indentation++;
print_with_indent("ir_function_signature *const sig =\n");
print_with_indent(" new(mem_ctx) ir_function_signature(glsl_type::%s_type, avail);\n",
ir->return_type->name);
glsl_get_type_name(ir->return_type));
print_with_indent("ir_factory body(&sig->body, mem_ctx);\n");
print_with_indent("sig->is_defined = true;\n\n");
@ -338,7 +338,7 @@ ir_builder_print_visitor::print_without_declaration(const ir_constant *ir)
if (memcmp(&ir->value, &all_zero, sizeof(all_zero)) == 0) {
print_without_indent("ir_constant::zero(mem_ctx, glsl_type::%s_type)",
ir->type->name);
glsl_get_type_name(ir->type));
}
}
@ -426,7 +426,7 @@ ir_builder_print_visitor::visit(ir_constant *ir)
print_with_indent("ir_constant *const r%04X = new(mem_ctx) ir_constant(glsl_type::%s_type, &r%04X_data);\n",
my_index,
ir->type->name,
glsl_get_type_name(ir->type),
my_index);
}

View file

@ -52,10 +52,10 @@ glsl_print_type(FILE *f, const glsl_type *t)
fprintf(f, "(array ");
glsl_print_type(f, t->fields.array);
fprintf(f, " %u)", t->length);
} else if (t->is_struct() && !is_gl_identifier(t->name)) {
fprintf(f, "%s@%p", t->name, (void *) t);
} else if (t->is_struct() && !is_gl_identifier(glsl_get_type_name(t))) {
fprintf(f, "%s@%p", glsl_get_type_name(t), (void *) t);
} else {
fprintf(f, "%s", t->name);
fprintf(f, "%s", glsl_get_type_name(t));
}
}
@ -69,7 +69,7 @@ _mesa_print_ir(FILE *f, exec_list *instructions,
const glsl_type *const s = state->user_structures[i];
fprintf(f, "(structure (%s) (%s@%p) (%u) (\n",
s->name, s->name, (void *) s, s->length);
glsl_get_type_name(s), glsl_get_type_name(s), (void *) s, s->length);
for (unsigned j = 0; j < s->length; j++) {
fprintf(f, "\t((");

View file

@ -150,13 +150,13 @@ ir_validate::visit_enter(class ir_dereference_array *ir)
if (!ir->array_index->type->is_scalar()) {
printf("ir_dereference_array @ %p does not have scalar index: %s\n",
(void *) ir, ir->array_index->type->name);
(void *) ir, glsl_get_type_name(ir->array_index->type));
abort();
}
if (!ir->array_index->type->is_integer_16_32()) {
printf("ir_dereference_array @ %p does not have integer index: %s\n",
(void *) ir, ir->array_index->type->name);
(void *) ir, glsl_get_type_name(ir->array_index->type));
abort();
}
@ -190,7 +190,7 @@ ir_validate::visit_enter(ir_discard *ir)
{
if (ir->condition && ir->condition->type != glsl_type::bool_type) {
printf("ir_discard condition %s type instead of bool.\n",
ir->condition->type->name);
glsl_get_type_name(ir->condition->type));
ir->print();
printf("\n");
abort();
@ -204,7 +204,7 @@ ir_validate::visit_enter(ir_if *ir)
{
if (ir->condition->type != glsl_type::bool_type) {
printf("ir_if condition %s type instead of bool.\n",
ir->condition->type->name);
glsl_get_type_name(ir->condition->type));
ir->print();
printf("\n");
abort();
@ -1129,7 +1129,7 @@ ir_validate::visit_enter(ir_call *ir)
if (ir->return_deref) {
if (ir->return_deref->type != callee->return_type) {
printf("callee type %s does not match return storage type %s\n",
callee->return_type->name, ir->return_deref->type->name);
glsl_get_type_name(callee->return_type), glsl_get_type_name(ir->return_deref->type));
abort();
}
} else if (callee->return_type != glsl_type::void_type) {

View file

@ -261,7 +261,7 @@ public:
} else {
const struct hash_entry *entry =
_mesa_hash_table_search(ht,
var->get_interface_type()->without_array()->name);
glsl_get_type_name(var->get_interface_type()->without_array()));
return entry ? (ir_variable *) entry->data : NULL;
}
}
@ -283,7 +283,7 @@ public:
_mesa_hash_table_insert(ht, ralloc_strdup(mem_ctx, location_str), var);
} else {
_mesa_hash_table_insert(ht,
var->get_interface_type()->without_array()->name, var);
glsl_get_type_name(var->get_interface_type()->without_array()), var);
}
}
@ -359,7 +359,7 @@ validate_intrastage_interface_blocks(struct gl_shader_program *prog,
} else if (!intrastage_match(prev_def, var, prog,
true /* match_precision */)) {
linker_error(prog, "definitions of interface block `%s' do not"
" match\n", iface_type->name);
" match\n", glsl_get_type_name(iface_type));
return;
}
}
@ -461,7 +461,7 @@ validate_interstage_inout_blocks(struct gl_shader_program *prog,
var->data.used && !producer_iface) {
linker_error(prog, "missing output builtin block %s redeclaration "
"in separable shader program",
var->get_interface_type()->name);
glsl_get_type_name(var->get_interface_type()));
return;
}
@ -482,7 +482,7 @@ validate_interstage_inout_blocks(struct gl_shader_program *prog,
var->data.used && !producer_iface) {
linker_error(prog, "missing input builtin block %s redeclaration "
"in separable shader program",
var->get_interface_type()->name);
glsl_get_type_name(var->get_interface_type()));
return;
}
@ -501,14 +501,14 @@ validate_interstage_inout_blocks(struct gl_shader_program *prog,
if (producer_def == NULL &&
!is_builtin_gl_in_block(var, consumer->Stage) && var->data.used) {
linker_error(prog, "Input block `%s' is not an output of "
"the previous stage\n", var->get_interface_type()->name);
"the previous stage\n", glsl_get_type_name(var->get_interface_type()));
return;
}
if (producer_def &&
!interstage_match(prog, producer_def, var, extra_array_level)) {
linker_error(prog, "definitions of interface block `%s' do not "
"match\n", var->get_interface_type()->name);
"match\n", glsl_get_type_name(var->get_interface_type()));
return;
}
}
@ -543,7 +543,7 @@ validate_interstage_uniform_blocks(struct gl_shader_program *prog,
*/
if (!intrastage_match(old_def, var, prog, false /* precision */)) {
linker_error(prog, "definitions of uniform block `%s' do not "
"match\n", var->get_interface_type()->name);
"match\n", glsl_get_type_name(var->get_interface_type()));
return;
}
}

View file

@ -29,7 +29,7 @@ static link_uniform_block_active *
process_block(void *mem_ctx, struct hash_table *ht, ir_variable *var)
{
const hash_entry *const existing_block =
_mesa_hash_table_search(ht, var->get_interface_type()->name);
_mesa_hash_table_search(ht, glsl_get_type_name(var->get_interface_type()));
const glsl_type *const block_type = var->is_interface_instance()
? var->type : var->get_interface_type();
@ -55,7 +55,7 @@ process_block(void *mem_ctx, struct hash_table *ht, ir_variable *var)
b->binding = 0;
}
_mesa_hash_table_insert(ht, var->get_interface_type()->name, (void *) b);
_mesa_hash_table_insert(ht, glsl_get_type_name(var->get_interface_type()), (void *) b);
return b;
} else {
link_uniform_block_active *const b =
@ -178,7 +178,7 @@ link_uniform_block_active_visitor::visit(ir_variable *var)
if (b == NULL) {
linker_error(this->prog,
"uniform block `%s' has mismatching definitions",
var->get_interface_type()->name);
glsl_get_type_name(var->get_interface_type()));
this->success = false;
return visit_stop;
}
@ -244,7 +244,7 @@ link_uniform_block_active_visitor::visit_enter(ir_dereference_array *ir)
if (b == NULL) {
linker_error(prog,
"uniform block `%s' has mismatching definitions",
var->get_interface_type()->name);
glsl_get_type_name(var->get_interface_type()));
this->success = false;
return visit_stop;
}
@ -282,7 +282,7 @@ link_uniform_block_active_visitor::visit(ir_dereference_variable *ir)
if (b == NULL) {
linker_error(this->prog,
"uniform block `%s' has mismatching definitions",
var->get_interface_type()->name);
glsl_get_type_name(var->get_interface_type()));
this->success = false;
return visit_stop;
}

View file

@ -306,7 +306,7 @@ process_block_array_leaf(const char *name,
parcel->buffer_size > consts->MaxShaderStorageBlockSize) {
linker_error(prog, "shader storage block `%s' has size %d, "
"which is larger than the maximum allowed (%d)",
b->type->name,
glsl_get_type_name(b->type),
parcel->buffer_size,
consts->MaxShaderStorageBlockSize);
}
@ -378,7 +378,7 @@ create_buffer_blocks(void *mem_ctx, const struct gl_constants *consts,
if (b->array != NULL) {
char *name = ralloc_strdup(NULL,
block_type->without_array()->name);
glsl_get_type_name(block_type->without_array()));
size_t name_length = strlen(name);
assert(b->has_instance_name);
@ -387,7 +387,7 @@ create_buffer_blocks(void *mem_ctx, const struct gl_constants *consts,
i);
ralloc_free(name);
} else {
process_block_array_leaf(block_type->name, blocks, &parcel,
process_block_array_leaf(glsl_get_type_name(block_type), blocks, &parcel,
variables, b, &i, 0,
0, consts, prog);
}

View file

@ -94,7 +94,7 @@ program_resource_visitor::process(ir_variable *var, const glsl_type *var_type,
false, record_array_count, NULL);
ralloc_free(name);
} else if (t_without_array->is_interface()) {
char *name = ralloc_strdup(NULL, t_without_array->name);
char *name = ralloc_strdup(NULL, glsl_get_type_name(t_without_array));
const glsl_struct_field *ifc_member = var->data.from_named_ifc_block ?
&t_without_array->
fields.structure[t_without_array->field_index(var->name)] : NULL;

View file

@ -103,9 +103,9 @@ cross_validate_types_and_qualifiers(const struct gl_constants *consts,
"declared as struct `%s'\n",
_mesa_shader_stage_to_string(producer_stage),
output->name,
output->type->name,
glsl_get_type_name(output->type),
_mesa_shader_stage_to_string(consumer_stage),
input->type->name);
glsl_get_type_name(input->type));
}
} else if (!output->type->is_array() || !is_gl_identifier(output->name)) {
/* There is a bit of a special case for gl_TexCoord. This
@ -131,9 +131,9 @@ cross_validate_types_and_qualifiers(const struct gl_constants *consts,
"but %s shader input declared as type `%s'\n",
_mesa_shader_stage_to_string(producer_stage),
output->name,
output->type->name,
glsl_get_type_name(output->type),
_mesa_shader_stage_to_string(consumer_stage),
input->type->name);
glsl_get_type_name(input->type));
return;
}
}

View file

@ -788,7 +788,7 @@ validate_intrastage_arrays(struct gl_shader_program *prog,
"`%s' but outermost dimension has an index"
" of `%i'\n",
mode_string(var),
var->name, var->type->name,
var->name, glsl_get_type_name(var->type),
existing->data.max_array_access);
}
existing->type = var->type;
@ -800,7 +800,7 @@ validate_intrastage_arrays(struct gl_shader_program *prog,
"`%s' but outermost dimension has an index"
" of `%i'\n",
mode_string(var),
var->name, existing->type->name,
var->name, glsl_get_type_name(existing->type),
var->data.max_array_access);
}
return true;
@ -869,8 +869,8 @@ cross_validate_globals(const struct gl_constants *consts,
linker_error(prog, "%s `%s' declared as type "
"`%s' and type `%s'\n",
mode_string(var),
var->name, var->type->name,
existing->type->name);
var->name, glsl_get_type_name(var->type),
glsl_get_type_name(existing->type));
return;
}
}
@ -1076,14 +1076,14 @@ cross_validate_globals(const struct gl_constants *consts,
linker_error(prog, "declarations for %s `%s` are inside block "
"`%s` and outside a block",
mode_string(var), var->name,
var_itype ? var_itype->name : existing_itype->name);
glsl_get_type_name(var_itype ? var_itype : existing_itype));
return;
} else if (strcmp(var_itype->name, existing_itype->name) != 0) {
} else if (strcmp(glsl_get_type_name(var_itype), glsl_get_type_name(existing_itype)) != 0) {
linker_error(prog, "declarations for %s `%s` are inside blocks "
"`%s` and `%s`",
mode_string(var), var->name,
existing_itype->name,
var_itype->name);
glsl_get_type_name(existing_itype),
glsl_get_type_name(var_itype));
return;
}
}
@ -1584,7 +1584,7 @@ private:
bool row_major = (bool) type->interface_row_major;
const glsl_type *new_ifc_type =
glsl_type::get_interface_instance(fields, num_fields,
packing, row_major, type->name);
packing, row_major, glsl_get_type_name(type));
delete [] fields;
return new_ifc_type;
}
@ -1615,7 +1615,7 @@ private:
bool row_major = (bool) ifc_type->interface_row_major;
const glsl_type *new_ifc_type =
glsl_type::get_interface_instance(fields, num_fields, packing,
row_major, ifc_type->name);
row_major, glsl_get_type_name(ifc_type));
delete [] fields;
for (unsigned i = 0; i < num_fields; i++) {
if (interface_vars[i] != NULL)

View file

@ -335,7 +335,7 @@ link_util_calculate_subroutine_compat(struct gl_shader_program *prog)
int count = 0;
if (p->sh.NumSubroutineFunctions == 0) {
linker_error(prog, "subroutine uniform %s defined but no valid functions found\n", uni->type->name);
linker_error(prog, "subroutine uniform %s defined but no valid functions found\n", glsl_get_type_name(uni->type));
continue;
}
for (unsigned f = 0; f < p->sh.NumSubroutineFunctions; f++) {

View file

@ -157,7 +157,7 @@ flatten_named_interface_blocks_declarations::run(exec_list *instructions)
char *iface_field_name =
ralloc_asprintf(mem_ctx, "%s %s.%s.%s",
var->data.mode == ir_var_shader_in ? "in" : "out",
iface_t->name, var->name, field_name);
glsl_get_type_name(iface_t), var->name, field_name);
hash_entry *entry = _mesa_hash_table_search(interface_namespace,
iface_field_name);
@ -290,7 +290,7 @@ flatten_named_interface_blocks_declarations::handle_rvalue(ir_rvalue **rvalue)
char *iface_field_name =
ralloc_asprintf(mem_ctx, "%s %s.%s.%s",
var->data.mode == ir_var_shader_in ? "in" : "out",
var->get_interface_type()->name,
glsl_get_type_name(var->get_interface_type()),
var->name,
ir->record->type->fields.structure[ir->field_idx].name);

View file

@ -155,9 +155,9 @@ check_instructions(exec_list *instructions,
EXPECT_EQ(ir_type_variable, ir->ir_type);
EXPECT_EQ(type, tmp1->type) <<
" Got " <<
tmp1->type->name <<
glsl_get_type_name(tmp1->type) <<
", expected " <<
type->name;
glsl_get_type_name(type);
ASSERT_FALSE(instructions->is_empty());
ir = (ir_instruction *) instructions->pop_head();
@ -421,9 +421,9 @@ TEST_F(compact_destination, uint64)
ASSERT_EQ(ir_type_dereference_variable, deref->ir_type);
EXPECT_EQ(type, deref->var->type) <<
" Got " <<
deref->var->type->name <<
glsl_get_type_name(deref->var->type) <<
", expected " <<
type->name;
glsl_get_type_name(type);
ir_instruction *ir;

View file

@ -382,7 +382,7 @@ const glsl_type *glsl_type::get_bare_type() const
bare_fields[i].name = this->fields.structure[i].name;
}
const glsl_type *bare_type =
get_struct_instance(bare_fields, this->length, this->name);
get_struct_instance(bare_fields, this->length, glsl_get_type_name(this));
delete[] bare_fields;
return bare_type;
}
@ -499,7 +499,7 @@ make_array_type(void *lin_ctx, const glsl_type *element_type, unsigned length,
*/
t->gl_type = element_type->gl_type;
const char *element_name = element_type->name;
const char *element_name = glsl_get_type_name(element_type);
char *n;
if (length == 0)
n = linear_asprintf(lin_ctx, "%s[]", element_name);
@ -751,7 +751,7 @@ glsl_type::get_explicit_matrix_instance(unsigned int base_type, unsigned int row
if (entry == NULL) {
char name[128];
snprintf(name, sizeof(name), "%sx%ua%uB%s", bare_type->name,
snprintf(name, sizeof(name), "%sx%ua%uB%s", glsl_get_type_name(bare_type),
explicit_stride, explicit_alignment, row_major ? "RM" : "");
void *lin_ctx = glsl_type_cache.lin_ctx;
@ -1314,7 +1314,7 @@ glsl_type::record_compare(const glsl_type *b, bool match_name,
* type, qualification, and declaration order."
*/
if (match_name)
if (strcmp(this->name, b->name) != 0)
if (strcmp(glsl_get_type_name(this), glsl_get_type_name(b)) != 0)
return false;
for (unsigned i = 0; i < this->length; i++) {
@ -1397,7 +1397,7 @@ glsl_type::record_key_compare(const void *a, const void *b)
const glsl_type *const key1 = (glsl_type *) a;
const glsl_type *const key2 = (glsl_type *) b;
return strcmp(key1->name, key2->name) == 0 &&
return strcmp(glsl_get_type_name(key1), glsl_get_type_name(key2)) == 0 &&
key1->record_compare(key2, true);
}
@ -1459,7 +1459,7 @@ glsl_type::get_struct_instance(const glsl_struct_field *fields,
assert(t->base_type == GLSL_TYPE_STRUCT);
assert(t->length == num_fields);
assert(strcmp(t->name, name) == 0);
assert(strcmp(glsl_get_type_name(t), name) == 0);
assert(t->packed == packed);
assert(t->explicit_alignment == explicit_alignment);
@ -1502,7 +1502,7 @@ glsl_type::get_interface_instance(const glsl_struct_field *fields,
assert(t->base_type == GLSL_TYPE_INTERFACE);
assert(t->length == num_fields);
assert(strcmp(t->name, block_name) == 0);
assert(strcmp(glsl_get_type_name(t), block_name) == 0);
return t;
}
@ -1527,14 +1527,14 @@ glsl_type::get_subroutine_instance(const char *subroutine_name)
if (entry == NULL) {
const glsl_type *t = make_subroutine_type(glsl_type_cache.lin_ctx, subroutine_name);
entry = _mesa_hash_table_insert_pre_hashed(subroutine_types, key_hash, t->name, (void *) t);
entry = _mesa_hash_table_insert_pre_hashed(subroutine_types, key_hash, glsl_get_type_name(t), (void *) t);
}
auto t = (const glsl_type *) entry->data;
simple_mtx_unlock(&glsl_type_cache_mutex);
assert(t->base_type == GLSL_TYPE_SUBROUTINE);
assert(strcmp(t->name, subroutine_name) == 0);
assert(strcmp(glsl_get_type_name(t), subroutine_name) == 0);
return t;
}
@ -2189,12 +2189,12 @@ glsl_type::get_explicit_std140_type(bool row_major) const
const glsl_type *type;
if (this->is_struct())
type = get_struct_instance(fields, this->length, this->name);
type = get_struct_instance(fields, this->length, glsl_get_type_name(this));
else
type = get_interface_instance(fields, this->length,
(enum glsl_interface_packing)this->interface_packing,
this->interface_row_major,
this->name);
glsl_get_type_name(this));
delete[] fields;
return type;
@ -2547,12 +2547,12 @@ glsl_type::get_explicit_std430_type(bool row_major) const
const glsl_type *type;
if (this->is_struct())
type = get_struct_instance(fields, this->length, this->name);
type = get_struct_instance(fields, this->length, glsl_get_type_name(this));
else
type = get_interface_instance(fields, this->length,
(enum glsl_interface_packing)this->interface_packing,
this->interface_row_major,
this->name);
glsl_get_type_name(this));
delete[] fields;
return type;
@ -2652,14 +2652,14 @@ glsl_type::get_explicit_type_for_size_align(glsl_type_size_align_func type_info,
const glsl_type *type;
if (this->is_struct()) {
type = get_struct_instance(fields, this->length, this->name,
type = get_struct_instance(fields, this->length, glsl_get_type_name(this),
this->packed, *alignment);
} else {
assert(!this->packed);
type = get_interface_instance(fields, this->length,
(enum glsl_interface_packing)this->interface_packing,
this->interface_row_major,
this->name);
glsl_get_type_name(this));
}
free(fields);
return type;
@ -2731,14 +2731,14 @@ glsl_type::replace_vec3_with_vec4() const
if (!needs_new_type) {
type = this;
} else if (this->is_struct()) {
type = get_struct_instance(fields, this->length, this->name,
type = get_struct_instance(fields, this->length, glsl_get_type_name(this),
this->packed, this->explicit_alignment);
} else {
assert(!this->packed);
type = get_interface_instance(fields, this->length,
(enum glsl_interface_packing)this->interface_packing,
this->interface_row_major,
this->name);
glsl_get_type_name(this));
}
free(fields);
return type;
@ -3022,7 +3022,7 @@ encode_type_to_blob(struct blob *blob, const glsl_type *type)
break;
case GLSL_TYPE_SUBROUTINE:
blob_write_uint32(blob, encoded.u32);
blob_write_string(blob, type->name);
blob_write_string(blob, glsl_get_type_name(type));
return;
case GLSL_TYPE_ATOMIC_UINT:
break;
@ -3051,7 +3051,7 @@ encode_type_to_blob(struct blob *blob, const glsl_type *type)
encoded.strct.interface_packing_or_packed = type->packed;
}
blob_write_uint32(blob, encoded.u32);
blob_write_string(blob, type->name);
blob_write_string(blob, glsl_get_type_name(type));
/* If we don't have enough bits for length, store it separately. */
if (encoded.strct.length == 0xfffff)

View file

@ -279,6 +279,8 @@ enum {
GLSL_PRECISION_LOW
};
const char *glsl_get_type_name(const struct glsl_type *type);
struct glsl_type {
uint32_t gl_type;
enum glsl_base_type base_type:8;
@ -971,7 +973,7 @@ struct glsl_type {
bool is_anonymous() const
{
return !strncmp(name, "#anon", 5);
return !strncmp(glsl_get_type_name(this), "#anon", 5);
}
/**

View file

@ -39,8 +39,6 @@
extern "C" {
#endif
const char *glsl_get_type_name(const struct glsl_type *type);
const struct glsl_type *glsl_get_struct_field(const struct glsl_type *type,
unsigned index);

View file

@ -742,7 +742,7 @@ log_uniform(const void *values, enum glsl_base_type basicType,
printf("Mesa: set program %u %s \"%s\" (loc %d, type \"%s\", "
"transpose = %s) to: ",
shProg->Name, extra, uni->name.string, location, uni->type->name,
shProg->Name, extra, uni->name.string, location, glsl_get_type_name(uni->type),
transpose ? "true" : "false");
for (unsigned i = 0; i < elems; i++) {
if (i != 0 && ((i % rows) == 0))