[Mesa-dev] [PATCH 3/3] glsl: Fix illegal implicit type conversions in type_compare()
Ian Romanick
idr at freedesktop.org
Tue Jul 26 17:43:27 PDT 2011
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 07/26/2011 04:08 PM, Chad Versace wrote:
> type_compare() allowed the following illegal implicit conversions:
> bool -> float
> bvecN -> vecN
>
> Fixes Piglit tests
> spec/glsl-1.20/compiler/built-in-functions/outerProduct-bvec*.vert.
Does this also fix array-ctor-implicit-conversion-bvec[234]-vec[234]?
It occurred to me the other day that these failures are probably related.
> Note: This is a candidate for the 7.10 and 7.11 branches.
> Signed-off-by: Chad Versace <chad at chad-versace.us>
> ---
> src/glsl/ir_function.cpp | 21 +++++++++++++--------
> 1 files changed, 13 insertions(+), 8 deletions(-)
>
> diff --git a/src/glsl/ir_function.cpp b/src/glsl/ir_function.cpp
> index e6ba359..2abc7aa 100644
> --- a/src/glsl/ir_function.cpp
> +++ b/src/glsl/ir_function.cpp
> @@ -45,18 +45,23 @@ type_compare(const glsl_type *to, const glsl_type *from)
> case GLSL_TYPE_BOOL:
> /* There is no implicit conversion to or from integer types or bool.
> */
> - if ((to->is_integer() != from->is_integer())
> - || (to->is_boolean() != from->is_boolean()))
> + if (to->base_type == from->base_type
> + && to->vector_elements == from->vector_elements
> + && to->matrix_columns == from->matrix_columns) {
> + return 1;
> + } else {
> return -1;
> -
> - /* FALLTHROUGH */
> + }
>
> case GLSL_TYPE_FLOAT:
> - if ((to->vector_elements != from->vector_elements)
> - || (to->matrix_columns != from->matrix_columns))
> + /* Integer types can be implicity converted to float. */
> + if ((from->base_type == GLSL_TYPE_FLOAT || from->is_integer())
> + && to->vector_elements == from->vector_elements
> + && to->matrix_columns == from->matrix_columns) {
> + return 1;
> + } else {
> return -1;
> -
> - return 1;
> + }
>
> case GLSL_TYPE_SAMPLER:
> case GLSL_TYPE_STRUCT:
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/
iEYEARECAAYFAk4vXy8ACgkQX1gOwKyEAw96hgCeKQiS0+fC6IV+NuEIwyr7kxZQ
YlAAmwTox4acBRuvQ5FTbRyaIZWPx6XJ
=QBlZ
-----END PGP SIGNATURE-----
More information about the mesa-dev
mailing list