+/**
+ * Return true if interface members mismatch and its not allowed by GLSL.
+ */
+static bool
+interstage_member_mismatch(struct gl_shader_program *prog,
+ const glsl_type *c, const glsl_type *p) {
+
+ if (c->length != p->length)
+ return true;
+
+ for (unsigned i = 0; i < c->length; i++) {
+ if (c->fields.structure[i].type != p->fields.structure[i].type)
+ return true;
+ if (strcmp(c->fields.structure[i].name,
+ p->fields.structure[i].name) != 0)
+ return true;
+ if (c->fields.structure[i].location !=
+ p->fields.structure[i].location)
+ return true;
+ if (c->fields.structure[i].patch !=
+ p->fields.structure[i].patch)
+ return true;
+
+ /* From Section 4.5 (Interpolation Qualifiers) of the GLSL 4.40 spec:
+ *
+ * "It is a link-time error if, within the same stage, the
+ * interpolation qualifiers of variables of the same name do not
+ * match."
+ */
+ if (prog->IsES || prog->data->Version < 440)
+ if (c->fields.structure[i].interpolation !=
+ p->fields.structure[i].interpolation)
+ return true;
+
+ /* From Section 4.3.4 (Input Variables) of the GLSL ES 3.0 spec:
+ *
+ * "The output of the vertex shader and the input of the fragment
+ * shader form an interface. For this interface, vertex shader
+ * output variables and fragment shader input variables of the same
+ * name must match in type and qualification (other than precision
+ * and out matching to in).
+ *
+ * The table in Section 9.2.1 Linked Shaders of the GLSL ES 3.1 spec
+ * says that centroid no longer needs to match for varyings.
+ *
+ * The table in Section 9.2.1 Linked Shaders of the GLSL ES 3.2 spec
+ * says that sample need not match for varyings.
+ */
+ if (!prog->IsES || prog->data->Version < 310)
+ if (c->fields.structure[i].centroid !=
+ p->fields.structure[i].centroid)
+ return true;
+ if (!prog->IsES)
+ if (c->fields.structure[i].sample !=
+ p->fields.structure[i].sample)
+ return true;
+ }
+
+ return false;
+}
+