]> git.tdb.fi Git - libs/gl.git/commitdiff
Convert operands of shift operators to the same vector size
authorMikko Rasa <tdb@tdb.fi>
Thu, 8 Apr 2021 21:46:53 +0000 (00:46 +0300)
committerMikko Rasa <tdb@tdb.fi>
Fri, 9 Apr 2021 14:45:42 +0000 (17:45 +0300)
source/glsl/resolve.cpp
tests/glsl/binary_operators.glsl

index 2b18c84b653bbbc1195f30a69c362137ec5754db..fec3cf143130a583c38a961b38b70087309b555e 100644 (file)
@@ -745,6 +745,17 @@ void ExpressionResolver::visit(BinaryExpression &binary, bool assign)
                if(!left_size || (left_size==1 && right_size!=1) || (left_size>1 && right_size!=1 && right_size!=left_size))
                        return;
 
+               /* If the left operand is a vector and right is scalar, convert the right
+               operand to a vector too. */
+               if(left_size>1 && right_size==1)
+               {
+                       BasicTypeDeclaration *vec_right = find_type(*elem_right, basic_left->kind, basic_left->size);
+                       if(!vec_right)
+                               return;
+
+                       convert_to(binary.right, *vec_right);
+               }
+
                type = basic_left;
                // Don't perform conversion even if the operands are of different sizes.
                compat = SAME_TYPE;
index 0782b15a0a1bad76ed1aae2a5e2d029d20c4234f..d84962861e689408111836121181a1453c08e3e2 100644 (file)
@@ -47,7 +47,7 @@ void main()
        b = b||i!=j;
        ivec2 iv;
        i = i<<j;
-       iv = iv>>i;
+       iv = iv>>ivec2(i);
        mat4x2 m1;
        mat2x4 m2;
        vec4 v1 = vec4(1.0);