[Mesa-dev] [PATCH 1/2] glsl: extract function for record comparisons

Grigori Goronzy greg at chown.ath.cx
Tue Dec 3 04:51:11 PST 2013


Ping? Can anyone review this, please?

Grigori

On 27.11.2013 00:15, Grigori Goronzy wrote:
> ---
>   src/glsl/glsl_types.cpp | 61 +++++++++++++++++++++++++++----------------------
>   src/glsl/glsl_types.h   |  7 ++++++
>   2 files changed, 41 insertions(+), 27 deletions(-)
>
> diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp
> index f740130..6c9727e 100644
> --- a/src/glsl/glsl_types.cpp
> +++ b/src/glsl/glsl_types.cpp
> @@ -447,6 +447,39 @@ glsl_type::get_array_instance(const glsl_type *base, unsigned array_size)
>   }
>
>
> +bool
> +glsl_type::record_compare(const glsl_type *b) const
> +{
> +   if (this->length != b->length)
> +      return false;
> +
> +   if (this->interface_packing != b->interface_packing)
> +      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].row_major
> +         != b->fields.structure[i].row_major)
> +        return false;
> +      if (this->fields.structure[i].location
> +          != b->fields.structure[i].location)
> +         return false;
> +      if (this->fields.structure[i].interpolation
> +          != b->fields.structure[i].interpolation)
> +         return false;
> +      if (this->fields.structure[i].centroid
> +          != b->fields.structure[i].centroid)
> +         return false;
> +   }
> +
> +   return true;
> +}
> +
> +
>   int
>   glsl_type::record_key_compare(const void *a, const void *b)
>   {
> @@ -459,33 +492,7 @@ glsl_type::record_key_compare(const void *a, const void *b)
>      if (strcmp(key1->name, key2->name) != 0)
>         return 1;
>
> -   if (key1->length != key2->length)
> -      return 1;
> -
> -   if (key1->interface_packing != key2->interface_packing)
> -      return 1;
> -
> -   for (unsigned i = 0; i < key1->length; i++) {
> -      if (key1->fields.structure[i].type != key2->fields.structure[i].type)
> -	 return 1;
> -      if (strcmp(key1->fields.structure[i].name,
> -		 key2->fields.structure[i].name) != 0)
> -	 return 1;
> -      if (key1->fields.structure[i].row_major
> -         != key2->fields.structure[i].row_major)
> -        return 1;
> -      if (key1->fields.structure[i].location
> -          != key2->fields.structure[i].location)
> -         return 1;
> -      if (key1->fields.structure[i].interpolation
> -          != key2->fields.structure[i].interpolation)
> -         return 1;
> -      if (key1->fields.structure[i].centroid
> -          != key2->fields.structure[i].centroid)
> -         return 1;
> -   }
> -
> -   return 0;
> +   return !key1->record_compare(key2);
>   }
>
>
> diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h
> index 96eee5e..dcc98e0 100644
> --- a/src/glsl/glsl_types.h
> +++ b/src/glsl/glsl_types.h
> @@ -542,6 +542,13 @@ struct glsl_type {
>       */
>      int sampler_coordinate_components() const;
>
> +   /**
> +    * Compare a record type against another record type.
> +    *
> +    * This is useful for matching record types declared across shader stages.
> +    */
> +   bool record_compare(const glsl_type *b) const;
> +
>   private:
>      /**
>       * ralloc context for all glsl_type allocations
>



More information about the mesa-dev mailing list