Commit 558b038c by Olli Etuaho Committed by Commit Bot

Don't accept sampler operands for unary operators

Unary plus and minus used to be accepted with sampler operands. Increment/decrement operators also now generate a clearer error message if a sampler operand is supplied. TEST=angle_unittests BUG=angleproject:1480 Change-Id: I2c5165c4eaac7b023d96e46a177e36f6536b0125 Reviewed-on: https://chromium-review.googlesource.com/376319Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
parent 87fbe1c2
......@@ -3402,7 +3402,7 @@ TIntermTyped *TParseContext::createUnaryMath(TOperator op,
case EOpNegative:
case EOpPositive:
if (child->getBasicType() == EbtStruct || child->getBasicType() == EbtBool ||
child->isArray())
child->isArray() || IsSampler(child->getBasicType()))
{
return nullptr;
}
......
......@@ -2418,3 +2418,20 @@ TEST_F(MalformedComputeShaderTest, SpecialVariableWorkGroupSize)
FAIL() << "Shader compilation succeeded, expecting failure " << mInfoLog;
}
}
// It is illegal to apply an unary operator to a sampler.
TEST_F(MalformedShaderTest, SamplerUnaryOperator)
{
const std::string &shaderString =
"precision mediump float;\n"
"uniform sampler2D s;\n"
"void main()\n"
"{\n"
" -s;\n"
" gl_FragColor = vec4(0);\n"
"}\n";
if (compile(shaderString))
{
FAIL() << "Shader compilation succeeded, expecting failure " << mInfoLog;
}
}
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