[Mesa-dev] [PATCH 7/9] glsl: simplify varying matching

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


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

Unnamed struct types are now equal if they have the same field.
---
 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 d04f546..8a570ed 100644
--- a/src/compiler/glsl/link_varyings.cpp
+++ b/src/compiler/glsl/link_varyings.cpp
@@ -177,39 +177,20 @@ process_xfb_layout_qualifiers(void *mem_ctx, const gl_linked_shader *sh,
          create_xfb_varying_names(mem_ctx, type, &name, strlen(name), &i,
                                   var->name, member_type, varying_names);
          ralloc_free(name);
       }
    }
 
    assert(i == *num_tfeedback_decls);
    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.
  */
 static void
 cross_validate_types_and_qualifiers(struct gl_shader_program *prog,
                                     const ir_variable *input,
                                     const ir_variable *output,
                                     gl_shader_stage consumer_stage,
                                     gl_shader_stage producer_stage)
@@ -240,33 +221,29 @@ cross_validate_types_and_qualifiers(struct gl_shader_program *prog,
        * sizes are fixed later when update_array_sizes is called.
        *
        * From page 48 (page 54 of the PDF) of the GLSL 1.10 spec:
        *
        *     "Unlike user-defined varying variables, the built-in
        *     varying variables don't have a strict one-to-one
        *     correspondence between the vertex language and the
        *     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;
       }
    }
 
    /* Check that all of the qualifiers match between stages.
     */
 
    /* According to the OpenGL and OpenGLES GLSL specs, the centroid qualifier
     * should match until OpenGL 4.3 and OpenGLES 3.1. The OpenGLES 3.0
     * conformance test suite does not verify that the qualifiers must match.
     * The deqp test suite expects the opposite (OpenGLES 3.1) behavior for
-- 
2.9.3



More information about the mesa-dev mailing list