[Mesa-dev] [PATCH 4/4] glsl: Fix implicit conversions in array constructors

Chad Versace chad at chad-versace.us
Wed Jul 27 00:00:41 PDT 2011


Array constructors obey narrower conversion rules than other constructors,
but process_array_constructor() was incorrectly applying the broader
rules. From page 33 (page 39 of the pdf) of the GLSL 1.20 spec, Section
5.4.4 Array Constructors:
    Each argument must be the same type as the element type of the array,
    or be a type that can be converted to the element type of the array
    according to Section 4.1.10 “Implicit Conversions.”

Fixes Piglit
spec/glsl-1.20/compiler/structure-and-array-operations/array-ctor-implicit-conversion-bvec*-vec*.vert.

If cherry-picked, the following commits are required:
    glsl: Refactor ast_function.cpp:type_compare() into a glsl_type method
    glsl: Fix illegal implicit type conversions

Note: This is a candidate for the 7.10 and 7.11 branches.
CC: Ian Romanick <ian.d.romanick at intel.com>
Signed-off-by: Chad Versace <chad at chad-versace.us>
---
 src/glsl/ast_function.cpp |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp
index bdb73f4..70961ab 100644
--- a/src/glsl/ast_function.cpp
+++ b/src/glsl/ast_function.cpp
@@ -448,7 +448,9 @@ process_array_constructor(exec_list *instructions,
 	    glsl_type::get_instance(GLSL_TYPE_FLOAT,
 				    ir->type->vector_elements,
 				    ir->type->matrix_columns);
-	 result = convert_component(ir, desired_type);
+	 if (result->type->implicit_conversion_compare(desired_type) >= 0) {
+	    result = convert_component(ir, desired_type);
+	 }
       }
 
       if (result->type != constructor_type->element_type()) {
-- 
1.7.6



More information about the mesa-dev mailing list