Commit bb52c523 by Olli Etuaho Committed by Commit Bot

Invariant declaration doesn't make a variable active

Invariant declarations didn't affect static use before, but now they are also skipped in CollectVariables so an invariant declaration is not enough in itself to mark a variable as active. This fixes an assert in CollectVariables. BUG=chromium:829553 TEST=angle_unittests Change-Id: I3e51d2916f091bcc283af136a4abc846ff71447d Reviewed-on: https://chromium-review.googlesource.com/999532Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
parent 6c59e4a1
......@@ -119,6 +119,7 @@ class CollectVariablesTraverser : public TIntermTraverser
GLenum shaderType,
const TExtensionBehavior &extensionBehavior);
bool visitInvariantDeclaration(Visit visit, TIntermInvariantDeclaration *node) override;
void visitSymbol(TIntermSymbol *symbol) override;
bool visitDeclaration(Visit, TIntermDeclaration *node) override;
bool visitBinary(Visit visit, TIntermBinary *binaryNode) override;
......@@ -336,11 +337,17 @@ InterfaceBlock *CollectVariablesTraverser::recordGLInUsed(const TType &glInType)
}
}
// We want to check whether a uniform/varying is statically used
// because we only count the used ones in packing computing.
// Also, gl_FragCoord, gl_PointCoord, and gl_FrontFacing count
// toward varying counting if they are statically used in a fragment
// shader.
bool CollectVariablesTraverser::visitInvariantDeclaration(Visit visit,
TIntermInvariantDeclaration *node)
{
// We should not mark variables as active just based on an invariant declaration, so we don't
// traverse the symbols declared invariant.
return false;
}
// We want to check whether a uniform/varying is active because we need to skip updating inactive
// ones. We also only count the active ones in packing computing. Also, gl_FragCoord, gl_PointCoord,
// and gl_FrontFacing count toward varying counting if they are active in a fragment shader.
void CollectVariablesTraverser::visitSymbol(TIntermSymbol *symbol)
{
ASSERT(symbol != nullptr);
......
......@@ -2035,4 +2035,26 @@ TEST_F(CollectVertexVariablesTest, StaticallyUsedButNotActiveInstancedInterfaceB
// See TODO in CollectVariables.cpp about tracking instanced interface block field static use.
// EXPECT_TRUE(field.staticUse);
EXPECT_FALSE(field.active);
}
\ No newline at end of file
}
// Test a varying that is declared invariant but not otherwise used.
TEST_F(CollectVertexVariablesTest, VaryingOnlyDeclaredInvariant)
{
const std::string &shaderString =
R"(precision mediump float;
varying float vf;
invariant vf;
void main()
{
})";
compile(shaderString);
const auto &varyings = mTranslator->getOutputVaryings();
ASSERT_EQ(1u, varyings.size());
const Varying &varying = varyings[0];
EXPECT_EQ("vf", varying.name);
EXPECT_FALSE(varying.staticUse);
EXPECT_FALSE(varying.active);
}
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