Module: Mesa
Branch: main
Commit: f17e23e116234d7998efaaa9c7c1542ad085cde1
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f17e23e116234d7998efaaa9c7c1542ad085cde1

Author: Caio Oliveira <caio.olive...@intel.com>
Date:   Mon Dec 11 19:18:47 2023 -0800

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 <luoyongg...@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26656>

---

 src/compiler/glsl/ast_to_hir.cpp | 8 +++++++-
 src/compiler/glsl_types.h        | 5 -----
 src/compiler/glsl_types_impl.h   | 6 ------
 3 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp
index 0a0e2734f40..e947142e510 100644
--- a/src/compiler/glsl/ast_to_hir.cpp
+++ b/src/compiler/glsl/ast_to_hir.cpp
@@ -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))
diff --git a/src/compiler/glsl_types.h b/src/compiler/glsl_types.h
index 62986496714..8a92600eae9 100644
--- a/src/compiler/glsl_types.h
+++ b/src/compiler/glsl_types.h
@@ -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
     *
diff --git a/src/compiler/glsl_types_impl.h b/src/compiler/glsl_types_impl.h
index 68f8316dd28..5644f4da4ae 100644
--- a/src/compiler/glsl_types_impl.h
+++ b/src/compiler/glsl_types_impl.h
@@ -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

Reply via email to