Add support for EXT_YUV_target

Add new sampler type "__samplerExternal2DY2YEXT"
to sample a YUV texture image and output color value
without any color conversion,
new additional type to specify color space standard formula and
built-in functions for yuv to rgb transformation.

Change-Id: I1780650fe84cd75191c1ca1e4118e89d585bfd92
Reviewed-on: https://chromium-review.googlesource.com/454697
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/compiler/translator/ValidateOutputs.cpp b/src/compiler/translator/ValidateOutputs.cpp
index 2e0303c..733fe9a 100644
--- a/src/compiler/translator/ValidateOutputs.cpp
+++ b/src/compiler/translator/ValidateOutputs.cpp
@@ -25,7 +25,8 @@
     : TIntermTraverser(true, false, false),
       mMaxDrawBuffers(maxDrawBuffers),
       mAllowUnspecifiedOutputLocationResolution(
-          IsExtensionEnabled(extBehavior, "GL_EXT_blend_func_extended"))
+          IsExtensionEnabled(extBehavior, "GL_EXT_blend_func_extended")),
+      mUsesFragDepth(false)
 {
 }
 
@@ -41,14 +42,22 @@
 
     if (qualifier == EvqFragmentOut)
     {
-        if (symbol->getType().getLayoutQualifier().location == -1)
-        {
-            mUnspecifiedLocationOutputs.push_back(symbol);
-        }
-        else
+        if (symbol->getType().getLayoutQualifier().location != -1)
         {
             mOutputs.push_back(symbol);
         }
+        else if (symbol->getType().getLayoutQualifier().yuv == true)
+        {
+            mYuvOutputs.push_back(symbol);
+        }
+        else
+        {
+            mUnspecifiedLocationOutputs.push_back(symbol);
+        }
+    }
+    else if (qualifier == EvqFragDepth || qualifier == EvqFragDepthEXT)
+    {
+        mUsesFragDepth = true;
     }
 }
 
@@ -106,6 +115,18 @@
                   diagnostics);
         }
     }
+
+    if (!mYuvOutputs.empty() && (mYuvOutputs.size() > 1 || mUsesFragDepth || !mOutputs.empty() ||
+                                 !mUnspecifiedLocationOutputs.empty()))
+    {
+        for (const auto &symbol : mYuvOutputs)
+        {
+            error(*symbol,
+                  "not allowed to specify yuv qualifier when using depth or multiple color "
+                  "fragment outputs",
+                  diagnostics);
+        }
+    }
 }
 
 }  // namespace sh