[Mesa-dev] [PATCH 3/3] glsl: Fix illegal implicit type conversions in type_compare()

Chad Versace chad at chad-versace.us
Tue Jul 26 16:08:04 PDT 2011


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.

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:
-- 
1.7.6



More information about the mesa-dev mailing list