Commit 415f29e0 by Olli Etuaho Committed by Commit Bot

Disallow layout+invariant combo on ESSL 3.00 variable declarations

This combination is not allowed by the formal grammar in the ESSL 3.00 spec, and should still be disallowed in ESSL 3.00 shaders even though the shader parser now implements the more flexible ESSL 3.10 grammar. BUG=angleproject:1507 TEST=angle_unittests Change-Id: I766a468fd7314c7e60e020b5b204aa6950263633 Reviewed-on: https://chromium-review.googlesource.com/381933Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
parent 5796127e
......@@ -135,6 +135,16 @@ bool HasRepeatingQualifiers(const TTypeQualifierBuilder::QualifierSequence &qual
*errorMessage = "The layout qualifier specified multiple times.";
return true;
}
if (invariantFound && !areQualifierChecksRelaxed)
{
// This combination is not correct according to the syntax specified in the
// formal grammar in the ESSL 3.00 spec. In ESSL 3.10 the grammar does not have
// a similar restriction.
*errorMessage =
"The layout qualifier and invariant qualifier cannot coexist in the same "
"declaration according to the grammar.";
return true;
}
layoutFound = true;
const TLayoutQualifier &currentQualifier =
static_cast<const TLayoutQualifierWrapper *>(qualifiers[i])->getQualifier();
......
......@@ -2516,3 +2516,20 @@ TEST_F(MalformedShaderTest, InvariantDeclarationWithLayoutQualifier)
FAIL() << "Shader compilation succeeded, expecting failure " << mInfoLog;
}
}
// Variable declaration with both invariant and layout qualifiers is not valid in the formal grammar
// provided in the ESSL 3.00 spec. ESSL 3.10 starts allowing this combination, but ESSL 3.00 should
// still disallow it.
TEST_F(MalformedShaderTest, VariableDeclarationWithInvariantAndLayoutQualifierESSL300)
{
const std::string &shaderString =
"#version 300 es\n"
"precision mediump float;\n"
"invariant layout(location = 0) out vec4 my_FragColor;\n"
"void main() {\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