[Mesa-dev] [PATCH 5/9] glsl: stop considering unnamed and named structures equal

Nicolai Hähnle nhaehnle at gmail.com
Mon May 15 09:27:29 UTC 2017


From: Nicolai Hähnle <nicolai.haehnle at amd.com>

Previously, if an unnamed and a named struct contained the same fields,
they were considered the same type during linking of globals.

The discussion around commit e018ea81bf58 ("glsl: Structures must have
same name to be considered same type.") doesn't seem to have considered
this thoroughly, and I see no evidence that an unnamed struct should
ever be considered to be the same type as a named struct.
---
 src/compiler/glsl_types.cpp | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/src/compiler/glsl_types.cpp b/src/compiler/glsl_types.cpp
index 063d3f1..188b72f 100644
--- a/src/compiler/glsl_types.cpp
+++ b/src/compiler/glsl_types.cpp
@@ -920,27 +920,23 @@ glsl_type::record_compare(const glsl_type *b, bool match_locations) const
 
    if (this->interface_row_major != b->interface_row_major)
       return false;
 
    /* From the GLSL 4.20 specification (Sec 4.2):
     *
     *     "Structures must have the same name, sequence of type names, and
     *     type definitions, and field names to be considered the same type."
     *
     * GLSL ES behaves the same (Ver 1.00 Sec 4.2.4, Ver 3.00 Sec 4.2.5).
-    *
-    * Note that we cannot force type name check when comparing unnamed
-    * structure types, these have a unique name assigned during parsing.
     */
-   if (!this->is_anonymous() && !b->is_anonymous())
-      if (strcmp(this->name, b->name) != 0)
-         return false;
+   if (strcmp(this->name, b->name) != 0)
+      return false;
 
    for (unsigned i = 0; i < this->length; i++) {
       if (this->fields.structure[i].type != b->fields.structure[i].type)
          return false;
       if (strcmp(this->fields.structure[i].name,
                  b->fields.structure[i].name) != 0)
          return false;
       if (this->fields.structure[i].matrix_layout
          != b->fields.structure[i].matrix_layout)
         return false;
-- 
2.9.3



More information about the mesa-dev mailing list