From: Mikko Rasa Date: Thu, 8 Apr 2021 21:46:53 +0000 (+0300) Subject: Convert operands of shift operators to the same vector size X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=fe980fbd898645eba1ac06a5061b3a48db4638b0;p=libs%2Fgl.git Convert operands of shift operators to the same vector size --- diff --git a/source/glsl/resolve.cpp b/source/glsl/resolve.cpp index 2b18c84b..fec3cf14 100644 --- a/source/glsl/resolve.cpp +++ b/source/glsl/resolve.cpp @@ -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; diff --git a/tests/glsl/binary_operators.glsl b/tests/glsl/binary_operators.glsl index 0782b15a..d8496286 100644 --- a/tests/glsl/binary_operators.glsl +++ b/tests/glsl/binary_operators.glsl @@ -47,7 +47,7 @@ void main() b = b||i!=j; ivec2 iv; i = i<>i; + iv = iv>>ivec2(i); mat4x2 m1; mat2x4 m2; vec4 v1 = vec4(1.0);