Commit e7dc9d71 by Olli Etuaho Committed by Commit Bot

Fix handling bvec on the right hand side of a logical op

The vector/matrix size matching is not done for logical ops similarly to other binary ops. For that reason both left and right hand side need to be checked for being scalar. BUG=angleproject:1601 TEST=angle_unittests Change-Id: Ie87da68d6cb0d439f0e6273d374fc7d836c82309 Reviewed-on: https://chromium-review.googlesource.com/406988Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
parent 8f447a7a
...@@ -3848,10 +3848,12 @@ TIntermTyped *TParseContext::addBinaryMathInternal(TOperator op, ...@@ -3848,10 +3848,12 @@ TIntermTyped *TParseContext::addBinaryMathInternal(TOperator op,
case EOpLogicalAnd: case EOpLogicalAnd:
ASSERT(!left->isArray() && !right->isArray() && !left->getType().getStruct() && ASSERT(!left->isArray() && !right->isArray() && !left->getType().getStruct() &&
!right->getType().getStruct()); !right->getType().getStruct());
if (left->getBasicType() != EbtBool || left->isMatrix() || left->isVector()) if (left->getBasicType() != EbtBool || !left->isScalar() || !right->isScalar())
{ {
return nullptr; return nullptr;
} }
// Basic types matching should have been already checked.
ASSERT(right->getBasicType() == EbtBool);
break; break;
case EOpAdd: case EOpAdd:
case EOpSub: case EOpSub:
......
...@@ -3038,3 +3038,22 @@ TEST_F(MalformedShaderTest, IncorrectUnsizedArray) ...@@ -3038,3 +3038,22 @@ TEST_F(MalformedShaderTest, IncorrectUnsizedArray)
FAIL() << "Shader compilation succeeded, expecting failure " << mInfoLog; FAIL() << "Shader compilation succeeded, expecting failure " << mInfoLog;
} }
} }
// Check compiler doesn't crash when a bvec is on the right hand side of a logical operator.
// ESSL 3.00.6 section 5.9.
TEST_F(MalformedShaderTest, LogicalOpRHSIsBVec)
{
const std::string &shaderString =
"#version 300 es\n"
"void main()\n"
"{\n"
" bool b;\n"
" bvec3 b3;\n"
" b && b3;\n"
"}\n";
if (compile(shaderString))
{
FAIL() << "Shader compilation succeeded, expecting failure " << mInfoLog;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment