Commit 19f2f9eb by Qin Jiajia Committed by Commit Bot

Mark variable to call 'length()' as statically used

Bug: angleproject:3008 Change-Id: I8779706c667f49fddb0a741f5bf31c4af54db3e7 Reviewed-on: https://chromium-review.googlesource.com/c/1367404Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Jiajia Qin <jiajia.qin@intel.com>
parent 7ef08391
...@@ -5848,6 +5848,7 @@ TIntermTyped *TParseContext::addMethod(TFunctionLookup *fnCall, const TSourceLoc ...@@ -5848,6 +5848,7 @@ TIntermTyped *TParseContext::addMethod(TFunctionLookup *fnCall, const TSourceLoc
else else
{ {
TIntermUnary *node = new TIntermUnary(EOpArrayLength, thisNode, nullptr); TIntermUnary *node = new TIntermUnary(EOpArrayLength, thisNode, nullptr);
markStaticReadIfSymbol(thisNode);
node->setLine(loc); node->setLine(loc);
return node->fold(mDiagnostics); return node->fold(mDiagnostics);
} }
......
...@@ -2037,6 +2037,37 @@ TEST_F(CollectVertexVariablesTest, StaticallyUsedButNotActiveInstancedInterfaceB ...@@ -2037,6 +2037,37 @@ TEST_F(CollectVertexVariablesTest, StaticallyUsedButNotActiveInstancedInterfaceB
EXPECT_FALSE(field.active); EXPECT_FALSE(field.active);
} }
// Test an interface block member variable that is statically used. The variable is used to call
// array length method.
TEST_F(CollectVertexVariablesTest, StaticallyUsedInArrayLengthOp)
{
const std::string &shaderString =
R"(#version 300 es
uniform b
{
float f[3];
};
void main() {
if (f.length() > 1)
{
gl_Position = vec4(1.0);
}
else
{
gl_Position = vec4(0.0);
}
})";
compile(shaderString);
const std::vector<InterfaceBlock> &interfaceBlocks = mTranslator->getInterfaceBlocks();
ASSERT_EQ(1u, interfaceBlocks.size());
const InterfaceBlock &interfaceBlock = interfaceBlocks[0];
EXPECT_EQ("b", interfaceBlock.name);
EXPECT_TRUE(interfaceBlock.staticUse);
}
// Test a varying that is declared invariant but not otherwise used. // Test a varying that is declared invariant but not otherwise used.
TEST_F(CollectVertexVariablesTest, VaryingOnlyDeclaredInvariant) TEST_F(CollectVertexVariablesTest, VaryingOnlyDeclaredInvariant)
{ {
......
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