Commit e623bd46 by Jamie Madill

Revert "Fix setting const qualifier on indexing expression"

Failing to compile shaders which are used in some layout_tests, see http://crbug.com/538692 for logs and bad shaders. We should diagnose if the shaders are faulty or if there's a bug in this CL and take appropriate action, but first priority is to get the tests running again. BUG=538692 BUG=angleproject:1170 This reverts commit 16a79cd1. Change-Id: Iea14c58d87041bcf5ba645b7076ba0936dea6b9d Reviewed-on: https://chromium-review.googlesource.com/303794Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 4fbec003
...@@ -2872,36 +2872,51 @@ TIntermTyped *TParseContext::addIndexExpression(TIntermTyped *baseExpression, ...@@ -2872,36 +2872,51 @@ TIntermTyped *TParseContext::addIndexExpression(TIntermTyped *baseExpression,
} }
else if (baseExpression->isArray()) else if (baseExpression->isArray())
{ {
TType indexedType = baseExpression->getType(); const TType &baseType = baseExpression->getType();
indexedType.clearArrayness(); if (baseType.getStruct())
indexedExpression->setType(indexedType); {
TType copyOfType(baseType.getStruct());
indexedExpression->setType(copyOfType);
}
else if (baseType.isInterfaceBlock())
{
TType copyOfType(baseType.getInterfaceBlock(), baseType.getQualifier(),
baseType.getLayoutQualifier(), 0);
indexedExpression->setType(copyOfType);
}
else
{
indexedExpression->setType(
TType(baseExpression->getBasicType(), baseExpression->getPrecision(), EvqTemporary,
static_cast<unsigned char>(baseExpression->getNominalSize()),
static_cast<unsigned char>(baseExpression->getSecondarySize())));
}
if (baseExpression->getType().getQualifier() == EvqConst)
{
indexedExpression->getTypePointer()->setQualifier(EvqConst);
}
} }
else if (baseExpression->isMatrix()) else if (baseExpression->isMatrix())
{ {
TQualifier qualifier =
baseExpression->getType().getQualifier() == EvqConst ? EvqConst : EvqTemporary;
indexedExpression->setType(TType(baseExpression->getBasicType(), indexedExpression->setType(TType(baseExpression->getBasicType(),
baseExpression->getPrecision(), EvqTemporary, baseExpression->getPrecision(), qualifier,
static_cast<unsigned char>(baseExpression->getRows()))); static_cast<unsigned char>(baseExpression->getRows())));
} }
else if (baseExpression->isVector()) else if (baseExpression->isVector())
{ {
TQualifier qualifier =
baseExpression->getType().getQualifier() == EvqConst ? EvqConst : EvqTemporary;
indexedExpression->setType( indexedExpression->setType(
TType(baseExpression->getBasicType(), baseExpression->getPrecision(), EvqTemporary)); TType(baseExpression->getBasicType(), baseExpression->getPrecision(), qualifier));
} }
else else
{ {
indexedExpression->setType(baseExpression->getType()); indexedExpression->setType(baseExpression->getType());
} }
if (baseExpression->getType().getQualifier() == EvqConst &&
indexExpression->getType().getQualifier() == EvqConst)
{
indexedExpression->getTypePointer()->setQualifier(EvqConst);
}
else
{
indexedExpression->getTypePointer()->setQualifier(EvqTemporary);
}
return indexedExpression; return indexedExpression;
} }
......
...@@ -872,21 +872,3 @@ TEST_F(MalformedShaderTest, FragmentShaderInputStructWithInt) ...@@ -872,21 +872,3 @@ TEST_F(MalformedShaderTest, FragmentShaderInputStructWithInt)
FAIL() << "Shader compilation succeeded, expecting failure " << mInfoLog; FAIL() << "Shader compilation succeeded, expecting failure " << mInfoLog;
} }
} }
// Selecting a field of a vector that's the result of dynamic indexing a constant array should work.
TEST_F(MalformedShaderTest, ShaderSelectingFieldOfVectorIndexedFromArray)
{
const std::string &shaderString =
"#version 300 es\n"
"precision mediump float;\n"
"out vec4 my_FragColor;\n"
"uniform int i;\n"
"void main() {\n"
" float f = vec2[1](vec2(0.0, 0.1))[i].x;\n"
" my_FragColor = vec4(f);\n"
"}\n";
if (!compile(shaderString))
{
FAIL() << "Shader compilation failed, expecting success " << 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