Fix ambiguous function call issues in HLSL output

D3D compiler can't resolve between these overloaded functions:

float4 vec4(float2x2 x0);
float4 vec4(float4 x0);

Include the parameter types in the function name to disambiguate
between overloaded user-defined functions and constructors, like this:

float4 vec4_float2x2(float2x2 x0);
float4 vec4_float4(float4 x0);

This is only done for float2x2 and float4 parameters, other parameter
types like float2x3 vs. float3x2 don't need this.

BUG=angleproject:1099
BUG=angleproject:1030
TEST=angle_end2end_tests,
     dEQP-GLES3.functional.attribute_location.* (10 more tests pass),
     dEQP-GLES2.functional.attribute_location.*

Change-Id: Ief047d41b0adbc238393c3c13cb29771cbb83d58
Reviewed-on: https://chromium-review.googlesource.com/329882
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/compiler/translator/OutputHLSL.cpp b/src/compiler/translator/OutputHLSL.cpp
index 31a62de..dc43b11 100644
--- a/src/compiler/translator/OutputHLSL.cpp
+++ b/src/compiler/translator/OutputHLSL.cpp
@@ -2221,12 +2221,12 @@
                 return false;
             }
 
-            TString name = DecorateFunctionIfNeeded(node->getNameObj());
-            out << TypeString(node->getType()) << " " << name
-                << (mOutputLod0Function ? "Lod0(" : "(");
-
             TIntermSequence *arguments = node->getSequence();
 
+            TString name = DecorateFunctionIfNeeded(node->getNameObj());
+            out << TypeString(node->getType()) << " " << name << DisambiguateFunctionName(arguments)
+                << (mOutputLod0Function ? "Lod0(" : "(");
+
             for (unsigned int i = 0; i < arguments->size(); i++)
             {
                 TIntermSymbol *symbol = (*arguments)[i]->getAsSymbolNode();
@@ -2271,6 +2271,9 @@
 
             out << TypeString(node->getType()) << " ";
 
+            TIntermSequence *sequence  = node->getSequence();
+            TIntermSequence *arguments = (*sequence)[0]->getAsAggregate()->getSequence();
+
             if (name == "main")
             {
                 out << "gl_main(";
@@ -2278,12 +2281,9 @@
             else
             {
                 out << DecorateFunctionIfNeeded(node->getNameObj())
-                    << (mOutputLod0Function ? "Lod0(" : "(");
+                    << DisambiguateFunctionName(arguments) << (mOutputLod0Function ? "Lod0(" : "(");
             }
 
-            TIntermSequence *sequence = node->getSequence();
-            TIntermSequence *arguments = (*sequence)[0]->getAsAggregate()->getSequence();
-
             for (unsigned int i = 0; i < arguments->size(); i++)
             {
                 TIntermSymbol *symbol = (*arguments)[i]->getAsSymbolNode();
@@ -2347,7 +2347,9 @@
                 ASSERT(index != CallDAG::InvalidIndex);
                 lod0 &= mASTMetadataList[index].mNeedsLod0;
 
-                out << DecorateFunctionIfNeeded(node->getNameObj()) << (lod0 ? "Lod0(" : "(");
+                out << DecorateFunctionIfNeeded(node->getNameObj());
+                out << DisambiguateFunctionName(node->getSequence());
+                out << (lod0 ? "Lod0(" : "(");
             }
             else
             {
@@ -3285,9 +3287,9 @@
 
     if (visit == PreVisit)
     {
-        mStructureHLSL->addConstructor(type, name, parameters);
+        TString constructorName = mStructureHLSL->addConstructor(type, name, parameters);
 
-        out << name << "(";
+        out << constructorName << "(";
     }
     else if (visit == InVisit)
     {