Commit 76acee83 by Olli Etuaho Committed by Nicolas Capens

Name mangle function prototypes and print them in interm output

This patch changes function prototype handling so that they get assigned the same kind of a mangled name as function definitions and function calls. This name is now also printed in interm output so that function prototypes can be accurately identified in the interm output. BUG=angle:821 TEST=compiler_tests Change-Id: Ia150b8ac5b816b8096c964767cd8666bdee28539 Reviewed-on: https://chromium-review.googlesource.com/227390Reviewed-by: 's avatarNicolas Capens <capn@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarOlli Etuaho <oetuaho@nvidia.com> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
parent e2632d24
...@@ -575,7 +575,7 @@ bool TOutputGLSLBase::visitAggregate(Visit visit, TIntermAggregate *node) ...@@ -575,7 +575,7 @@ bool TOutputGLSLBase::visitAggregate(Visit visit, TIntermAggregate *node)
// Function declaration. // Function declaration.
ASSERT(visit == PreVisit); ASSERT(visit == PreVisit);
writeVariableType(node->getType()); writeVariableType(node->getType());
out << " " << hashName(node->getName()); out << " " << hashFunctionName(node->getName());
out << "("; out << "(";
writeFunctionParameters(*(node->getSequence())); writeFunctionParameters(*(node->getSequence()));
......
...@@ -1939,7 +1939,7 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node) ...@@ -1939,7 +1939,7 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
case EOpPrototype: case EOpPrototype:
if (visit == PreVisit) if (visit == PreVisit)
{ {
out << TypeString(node->getType()) << " " << Decorate(node->getName()) << (mOutputLod0Function ? "Lod0(" : "("); out << TypeString(node->getType()) << " " << Decorate(TFunction::unmangleName(node->getName())) << (mOutputLod0Function ? "Lod0(" : "(");
TIntermSequence *arguments = node->getSequence(); TIntermSequence *arguments = node->getSequence();
......
...@@ -780,7 +780,7 @@ declaration ...@@ -780,7 +780,7 @@ declaration
TIntermAggregate *prototype = new TIntermAggregate; TIntermAggregate *prototype = new TIntermAggregate;
prototype->setType(function.getReturnType()); prototype->setType(function.getReturnType());
prototype->setName(function.getName()); prototype->setName(function.getMangledName());
for (size_t i = 0; i < function.getParamCount(); i++) for (size_t i = 0; i < function.getParamCount(); i++)
{ {
......
...@@ -3304,7 +3304,7 @@ yyreduce: ...@@ -3304,7 +3304,7 @@ yyreduce:
TIntermAggregate *prototype = new TIntermAggregate; TIntermAggregate *prototype = new TIntermAggregate;
prototype->setType(function.getReturnType()); prototype->setType(function.getReturnType());
prototype->setName(function.getName()); prototype->setName(function.getMangledName());
for (size_t i = 0; i < function.getParamCount(); i++) for (size_t i = 0; i < function.getParamCount(); i++)
{ {
......
...@@ -295,6 +295,7 @@ bool TOutputTraverser::visitAggregate(Visit visit, TIntermAggregate *node) ...@@ -295,6 +295,7 @@ bool TOutputTraverser::visitAggregate(Visit visit, TIntermAggregate *node)
case EOpFunction: out << "Function Definition: " << node->getName(); break; case EOpFunction: out << "Function Definition: " << node->getName(); break;
case EOpFunctionCall: out << "Function Call: " << node->getName(); break; case EOpFunctionCall: out << "Function Call: " << node->getName(); break;
case EOpParameters: out << "Function Parameters: "; break; case EOpParameters: out << "Function Parameters: "; break;
case EOpPrototype: out << "Function Prototype: " << node->getName(); break;
case EOpConstructFloat: out << "Construct float"; break; case EOpConstructFloat: out << "Construct float"; break;
case EOpConstructVec2: out << "Construct vec2"; break; case EOpConstructVec2: out << "Construct vec2"; break;
......
...@@ -53,6 +53,24 @@ class TypeTrackingTest : public testing::Test ...@@ -53,6 +53,24 @@ class TypeTrackingTest : public testing::Test
std::string mInfoLog; std::string mInfoLog;
}; };
TEST_F(TypeTrackingTest, FunctionPrototypeMangling)
{
const std::string &shaderString =
"precision mediump float;\n"
"float fun(float a);\n"
"uniform float f;\n"
"void main() {\n"
" float ff = fun(f);\n"
" gl_FragColor = vec4(ff);\n"
"}\n"
"float fun(float a) {\n"
" return a * 2.0;\n"
"}\n";
compile(shaderString);
ASSERT_TRUE(foundInIntermediateTree("Function Prototype: fun(f1;"));
ASSERT_TRUE(foundInIntermediateTree("Function Definition: fun(f1;"));
};
TEST_F(TypeTrackingTest, BuiltInFunctionResultPrecision) TEST_F(TypeTrackingTest, BuiltInFunctionResultPrecision)
{ {
const std::string &shaderString = const std::string &shaderString =
......
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