Add basic support for arrays as return values in HLSL output

In HLSL output, user-defined functions that have an array as their return value
get changed so that they have the array as an out parameter instead.

Still missing: support for calling a function that has array as a return value
without assigning the array. Also support for assignments inside complex
expressions.

TEST=dEQP-GLES3.functional.shaders.arrays.return.*
BUG=angleproject:941

Change-Id: I79f5170139116a3dcfb2be2df5f0f79a3d955ca8
Reviewed-on: https://chromium-review.googlesource.com/266003
Reviewed-by: Olli Etuaho <oetuaho@nvidia.com>
Tested-by: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/compiler/translator/OutputHLSL.cpp b/src/compiler/translator/OutputHLSL.cpp
index 02c5fbd..03aab78 100644
--- a/src/compiler/translator/OutputHLSL.cpp
+++ b/src/compiler/translator/OutputHLSL.cpp
@@ -1475,11 +1475,11 @@
                 out << ")";
                 return false;
             }
-            else
-            {
-                const TString &functionName = addArrayAssignmentFunction(node->getType());
-                outputTriplet(visit, (functionName + "(").c_str(), ", ", ")");
-            }
+            // ArrayReturnValueToOutParameter should have eliminated expressions where a function call is assigned.
+            ASSERT(rightAgg == nullptr || rightAgg->getOp() != EOpFunctionCall);
+
+            const TString &functionName = addArrayAssignmentFunction(node->getType());
+            outputTriplet(visit, (functionName + "(").c_str(), ", ", ")");
         }
         else
         {
@@ -2077,6 +2077,10 @@
             bool lod0 = mInsideDiscontinuousLoop || mOutputLod0Function;
             if (node->isUserDefined())
             {
+                if (node->isArray())
+                {
+                    UNIMPLEMENTED();
+                }
                 size_t index = mCallDag.findIndex(node);
                 ASSERT(index != CallDAG::InvalidIndex);
                 lod0 &= mASTMetadataList[index].mNeedsLod0;
@@ -2842,7 +2846,7 @@
     {
         name = "x" + str(mUniqueIndex++);
     }
-    else
+    else if (!symbol->isInternal())
     {
         name = Decorate(name);
     }