Mesa (master): glsl: simplify varying matching

Nicolai Hähnle nh at kemper.freedesktop.org
Tue Jun 13 07:36:29 UTC 2017


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

Author: Nicolai Hähnle <nicolai.haehnle at amd.com>
Date:   Mon May 15 08:30:51 2017 +0200

glsl: simplify varying matching

Unnamed struct types are now equal if they have the same field.

Reviewed-by: Timothy Arceri <tarceri at itsqueeze.com>

---

 src/compiler/glsl/link_varyings.cpp | 41 ++++++++-----------------------------
 1 file changed, 9 insertions(+), 32 deletions(-)

diff --git a/src/compiler/glsl/link_varyings.cpp b/src/compiler/glsl/link_varyings.cpp
index 910e2eda82..de3754c423 100644
--- a/src/compiler/glsl/link_varyings.cpp
+++ b/src/compiler/glsl/link_varyings.cpp
@@ -184,25 +184,6 @@ process_xfb_layout_qualifiers(void *mem_ctx, const gl_linked_shader *sh,
    return has_xfb_qualifiers;
 }
 
-static bool
-anonymous_struct_type_matches(const glsl_type *output_type,
-                              const glsl_type *to_match)
-{
-    while (output_type->is_array() && to_match->is_array()) {
-        /* if the lengths at each level don't match fail. */
-        if (output_type->length != to_match->length)
-            return false;
-        output_type = output_type->fields.array;
-        to_match = to_match->fields.array;
-    }
-
-    if (output_type->is_array() || to_match->is_array())
-        return false;
-    return output_type->is_anonymous() &&
-           to_match->is_anonymous() &&
-           to_match->record_compare(output_type);
-}
-
 /**
  * Validate the types and qualifiers of an output from one stage against the
  * matching input to another stage.
@@ -247,19 +228,15 @@ cross_validate_types_and_qualifiers(struct gl_shader_program *prog,
        *     fragment language."
        */
       if (!output->type->is_array() || !is_gl_identifier(output->name)) {
-         bool anon_matches = anonymous_struct_type_matches(output->type, type_to_match);
-
-         if (!anon_matches) {
-            linker_error(prog,
-                         "%s shader output `%s' declared as type `%s', "
-                         "but %s shader input declared as type `%s'\n",
-                         _mesa_shader_stage_to_string(producer_stage),
-                         output->name,
-                         output->type->name,
-                         _mesa_shader_stage_to_string(consumer_stage),
-                         input->type->name);
-            return;
-         }
+         linker_error(prog,
+                      "%s shader output `%s' declared as type `%s', "
+                      "but %s shader input declared as type `%s'\n",
+                      _mesa_shader_stage_to_string(producer_stage),
+                      output->name,
+                      output->type->name,
+                      _mesa_shader_stage_to_string(consumer_stage),
+                      input->type->name);
+         return;
       }
    }
 




More information about the mesa-commit mailing list