return (glsl_type *) entry->data;
}
+bool
+glsl_type::compare_no_precision(const glsl_type *b) const
+{
+ if (this == b)
+ return true;
+
+ if (this->is_array()) {
+ if (!b->is_array() || this->length != b->length)
+ return false;
+
+ const glsl_type *b_no_array = b->fields.array;
+
+ return this->fields.array->compare_no_precision(b_no_array);
+ }
+
+ if (this->is_struct()) {
+ if (!b->is_struct())
+ return false;
+ } else if (this->is_interface()) {
+ if (!b->is_interface())
+ return false;
+ } else {
+ return false;
+ }
+
+ return record_compare(b,
+ true, /* match_name */
+ true, /* match_locations */
+ false /* match_precision */);
+}
bool
glsl_type::record_compare(const glsl_type *b, bool match_name,
- bool match_locations) const
+ bool match_locations, bool match_precision) const
{
if (this->length != b->length)
return false;
return false;
for (unsigned i = 0; i < this->length; i++) {
- if (this->fields.structure[i].type != b->fields.structure[i].type)
- return false;
+ if (match_precision) {
+ if (this->fields.structure[i].type != b->fields.structure[i].type)
+ return false;
+ } else {
+ const glsl_type *ta = this->fields.structure[i].type;
+ const glsl_type *tb = b->fields.structure[i].type;
+ if (!ta->compare_no_precision(tb))
+ return false;
+ }
if (strcmp(this->fields.structure[i].name,
b->fields.structure[i].name) != 0)
return false;
if (this->fields.structure[i].image_format
!= b->fields.structure[i].image_format)
return false;
- if (this->fields.structure[i].precision
+ if (match_precision &&
+ this->fields.structure[i].precision
!= b->fields.structure[i].precision)
return false;
if (this->fields.structure[i].explicit_xfb_buffer
int coordinate_components() const;
/**
+ * Compares whether this type matches another type without taking into
+ * account the precision in structures.
+ *
+ * This is applied recursively so that structures containing structure
+ * members can also ignore the precision.
+ */
+ bool compare_no_precision(const glsl_type *b) const;
+
+ /**
* Compare a record type against another record type.
*
* This is useful for matching record types declared on the same shader
* same struct is defined in a block which has a location set on it.
*/
bool record_compare(const glsl_type *b, bool match_name,
- bool match_locations = true) const;
+ bool match_locations = true,
+ bool match_precision = true) const;
/**
* Get the type interface packing.