From fe980fbd898645eba1ac06a5061b3a48db4638b0 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Fri, 9 Apr 2021 00:46:53 +0300 Subject: [PATCH] Convert operands of shift operators to the same vector size --- source/glsl/resolve.cpp | 11 +++++++++++ tests/glsl/binary_operators.glsl | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) 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); -- 2.43.0