aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTorne (Richard Coles) <torne@google.com>2014-12-18 15:59:32 +0000
committerTorne (Richard Coles) <torne@google.com>2014-12-18 15:59:32 +0000
commit55f0c03fac9708db6a56a6402cc4c0af3ad4f2de (patch)
treeca8e03163a72d944dd14aa30292c408c420d77aa
parent4c7a4d460bf561e482334ea2efdb4b4a56947a4f (diff)
parentb523b79b45a72fb933b4fd0fcd81fe570de778c8 (diff)
downloadangle-55f0c03fac9708db6a56a6402cc4c0af3ad4f2de.tar.gz
Merge from Chromium at DEPS revision 40.0.2214.45
This commit was generated by merge_to_master.py. Change-Id: Ibc0b9d3009c7ddc09a3d73607cbd6534785fb040
-rw-r--r--src/compiler/translator/ParseContext.cpp2
-rw-r--r--src/compiler/translator/SymbolTable.h6
-rw-r--r--src/compiler/translator/util.cpp2
-rw-r--r--tests/compiler_tests/ShaderVariable_test.cpp25
4 files changed, 30 insertions, 5 deletions
diff --git a/src/compiler/translator/ParseContext.cpp b/src/compiler/translator/ParseContext.cpp
index 37969b54..72e179fc 100644
--- a/src/compiler/translator/ParseContext.cpp
+++ b/src/compiler/translator/ParseContext.cpp
@@ -1375,7 +1375,7 @@ TIntermAggregate* TParseContext::parseInvariantDeclaration(const TSourceLoc &inv
recover();
return NULL;
}
- symbolTable.addInvariantVarying(*identifier);
+ symbolTable.addInvariantVarying(std::string(identifier->c_str()));
const TVariable *variable = getNamedVariable(identifierLoc, identifier, symbol);
ASSERT(variable);
const TType &type = variable->getType();
diff --git a/src/compiler/translator/SymbolTable.h b/src/compiler/translator/SymbolTable.h
index 9cd74218..afb973ae 100644
--- a/src/compiler/translator/SymbolTable.h
+++ b/src/compiler/translator/SymbolTable.h
@@ -413,7 +413,7 @@ class TSymbolTable
// This records invariant varyings declared through
// "invariant varying_name;".
- void addInvariantVarying(const TString &originalName)
+ void addInvariantVarying(const std::string &originalName)
{
mInvariantVaryings.insert(originalName);
}
@@ -421,7 +421,7 @@ class TSymbolTable
// if it is set as invariant during the varying variable
// declaration - this piece of information is stored in the
// variable's type, not here.
- bool isVaryingInvariant(const TString &originalName) const
+ bool isVaryingInvariant(const std::string &originalName) const
{
return (mGlobalInvariant ||
mInvariantVaryings.count(originalName) > 0);
@@ -445,7 +445,7 @@ class TSymbolTable
typedef TMap<TBasicType, TPrecision> PrecisionStackLevel;
std::vector< PrecisionStackLevel *> precisionStack;
- std::set<TString> mInvariantVaryings;
+ std::set<std::string> mInvariantVaryings;
bool mGlobalInvariant;
static int uniqueIdCounter;
diff --git a/src/compiler/translator/util.cpp b/src/compiler/translator/util.cpp
index 8cc06a65..42a995ee 100644
--- a/src/compiler/translator/util.cpp
+++ b/src/compiler/translator/util.cpp
@@ -307,7 +307,7 @@ void GetVariableTraverser::setTypeSpecificInfo(
break;
case EvqVaryingIn:
case EvqVaryingOut:
- if (mSymbolTable.isVaryingInvariant(name))
+ if (mSymbolTable.isVaryingInvariant(std::string(name.c_str())))
{
variable->isInvariant = true;
}
diff --git a/tests/compiler_tests/ShaderVariable_test.cpp b/tests/compiler_tests/ShaderVariable_test.cpp
index b642260f..7fda29e7 100644
--- a/tests/compiler_tests/ShaderVariable_test.cpp
+++ b/tests/compiler_tests/ShaderVariable_test.cpp
@@ -218,4 +218,29 @@ TEST(ShaderVariableTest, IsSameVaryingWithDifferentInvariance)
EXPECT_TRUE(vx.isSameVaryingAtLinkTime(fx));
}
+// Test that using invariant varyings doesn't trigger a double delete.
+TEST(ShaderVariableTest, InvariantDoubleDeleteBug)
+{
+ ShBuiltInResources resources;
+ ShInitBuiltInResources(&resources);
+
+ ShHandle compiler = ShConstructCompiler(GL_VERTEX_SHADER, SH_GLES2_SPEC, SH_GLSL_OUTPUT, &resources);
+ EXPECT_NE(static_cast<ShHandle>(0), compiler);
+
+ const char *program[] =
+ {
+ "attribute vec4 position;\n"
+ "varying float v;\n"
+ "invariant v;\n"
+ "void main() {\n"
+ " v = 1.0;\n"
+ " gl_Position = position;\n"
+ "}"
+ };
+
+ EXPECT_TRUE(ShCompile(compiler, program, 1, SH_OBJECT_CODE));
+ EXPECT_TRUE(ShCompile(compiler, program, 1, SH_OBJECT_CODE));
+ ShDestruct(compiler);
+}
+
} // namespace sh