Commit d561057f by Olli Etuaho

Fix ValidateLimitations for folded non-constant expressions

ANGLE recently gained the ability to constant fold some expressions that are not constant expressions. ValidateLimitations should continue to recognize all cases where an expression is not a constant expression. BUG=angleproject:851 TEST=angle_unittests Change-Id: I8ad0552a59213cdd6af9a220ffd672be9752271d Reviewed-on: https://chromium-review.googlesource.com/317281Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tryjob-Request: Olli Etuaho <oetuaho@nvidia.com> Tested-by: 's avatarOlli Etuaho <oetuaho@nvidia.com> Reviewed-by: 's avatarZhenyao Mo <zmo@chromium.org>
parent b0f0b81d
......@@ -433,8 +433,8 @@ bool ValidateLimitations::validateOperation(TIntermOperator *node,
bool ValidateLimitations::isConstExpr(TIntermNode *node)
{
ASSERT(node != NULL);
return node->getAsConstantUnion() != NULL;
ASSERT(node != nullptr);
return node->getAsConstantUnion() != nullptr && node->getAsTyped()->getQualifier() == EvqConst;
}
bool ValidateLimitations::isConstIndexExpr(TIntermNode *node)
......
......@@ -84,6 +84,22 @@ class MalformedWebGL2ShaderTest : public MalformedShaderTest
}
};
class MalformedWebGL1ShaderTest : public MalformedShaderTest
{
public:
MalformedWebGL1ShaderTest() {}
protected:
void SetUp() override
{
ShBuiltInResources resources;
ShInitBuiltInResources(&resources);
mTranslator = new TranslatorESSL(GL_FRAGMENT_SHADER, SH_WEBGL_SPEC);
ASSERT_TRUE(mTranslator->Init(resources));
}
};
// This is a test for a bug that used to exist in ANGLE:
// Calling a function with all parameters missing should not succeed.
TEST_F(MalformedShaderTest, FunctionParameterMismatch)
......@@ -1353,3 +1369,23 @@ TEST_F(MalformedShaderTest, NoPrecisionSampler3D)
FAIL() << "Shader compilation succeeded, expecting failure " << mInfoLog;
}
}
// Test that using a non-constant expression in a for loop initializer is forbidden in WebGL 1.0,
// even when ANGLE is able to constant fold the initializer.
// ESSL 1.00 Appendix A.
TEST_F(MalformedWebGL1ShaderTest, NonConstantLoopIndex)
{
const std::string &shaderString =
"precision mediump float;\n"
"uniform int u;\n"
"void main()\n"
"{\n"
" for (int i = (true ? 1 : u); i < 5; ++i) {\n"
" gl_FragColor = vec4(0.0);\n"
" }\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