compiler/glsl: Reduce scope of is_anonymous

This a GLSL parser specific detail, so move it there.  Also
add a comment pointing to where #anon prefix is used.

Reviewed-by: Yonggang Luo <luoyonggang@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26656>
This commit is contained in:
Caio Oliveira 2023-12-11 19:18:47 -08:00 committed by Marge Bot
parent 8458cd49e0
commit f17e23e116
3 changed files with 7 additions and 12 deletions

View file

@ -7912,6 +7912,12 @@ ast_process_struct_or_iface_block_members(exec_list *instructions,
return decl_count;
}
static bool
is_anonymous(const glsl_type *t)
{
/* See handling for struct_specifier in glsl_parser.yy. */
return !strncmp(glsl_get_type_name(t), "#anon", 5);
}
ir_rvalue *
ast_struct_specifier::hir(exec_list *instructions,
@ -7950,7 +7956,7 @@ ast_struct_specifier::hir(exec_list *instructions,
type = glsl_type::get_struct_instance(fields, decl_count, this->name);
if (!type->is_anonymous() && !state->symbols->add_type(name, type)) {
if (!is_anonymous(type) && !state->symbols->add_type(name, type)) {
const glsl_type *match = state->symbols->get_type(name);
/* allow struct matching for desktop GL - older UE4 does this */
if (match != NULL && state->is_version(130, 0) && match->record_compare(type, true, false))

View file

@ -546,11 +546,6 @@ struct glsl_type {
enum glsl_interface_packing get_internal_ifc_packing(bool std430_supported) const;
bool get_interface_row_major() const;
/**
* Query if a type is unnamed/anonymous (named by the parser)
*/
bool is_anonymous() const;
/**
* Get the type of a structure field
*

View file

@ -279,12 +279,6 @@ glsl_type::is_uint_16_32() const
base_type == GLSL_TYPE_UINT16;
}
inline bool
glsl_type::is_anonymous() const
{
return !strncmp(glsl_get_type_name(this), "#anon", 5);
}
inline unsigned glsl_type::arrays_of_arrays_size() const { return glsl_get_aoa_size(this); }
inline unsigned