From d6c37b190bcb917c6bd806bc4f9cd5b3b1f7501b Mon Sep 17 00:00:00 2001
From: John Kessenich <cepheus@frii.com>
Date: Sat, 22 Aug 2015 16:54:35 -0600
Subject: [PATCH] GL_OES_shader_multisample_interpolation: Include scalar
 swizzles as valid for interpolateAt*.

---
 Test/400.frag                               |  2 +-
 Test/440.frag                               |  1 +
 Test/baseResults/440.frag.out               | 20 ++++++++++++++++++++
 glslang/MachineIndependent/Intermediate.cpp |  4 +++-
 4 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/Test/400.frag b/Test/400.frag
index bda588ad3..7ca965fb3 100644
--- a/Test/400.frag
+++ b/Test/400.frag
@@ -126,7 +126,7 @@ void interp()
 
     interpolateAtSample(sampInArray, 1);        // ERROR
     interpolateAtSample(sampInArray[i], 0);
-    interpolateAtSample(s1.x, 2);               // ERROR
+    interpolateAtSample(s1.x, 2);
     interpolateAtSample(scalarIn, 1);
 
     interpolateAtOffset(sampInArray, vec2(0.2));         // ERROR
diff --git a/Test/440.frag b/Test/440.frag
index 3a20dabc1..2a352af45 100644
--- a/Test/440.frag
+++ b/Test/440.frag
@@ -144,4 +144,5 @@ sample in vec3 sampInArray[4];
 void interp()
 {
     interpolateAtCentroid(sampInArray[2].xy);
+    interpolateAtSample(sampInArray[2].x.x, 2);
 }
diff --git a/Test/baseResults/440.frag.out b/Test/baseResults/440.frag.out
index 6de68c70e..f24baed38 100644
--- a/Test/baseResults/440.frag.out
+++ b/Test/baseResults/440.frag.out
@@ -67,6 +67,16 @@ ERROR: node is still EOpNull!
 0:146              0 (const int)
 0:146            Constant:
 0:146              1 (const int)
+0:147      interpolateAtSample (global float)
+0:147        direct index (temp float)
+0:147          direct index (smooth sample temp 3-component vector of float)
+0:147            'sampInArray' (smooth sample in 4-element array of 3-component vector of float)
+0:147            Constant:
+0:147              2 (const int)
+0:147          Constant:
+0:147            0 (const int)
+0:147        Constant:
+0:147          2 (const int)
 0:?   Linker Objects
 0:?     'a' (layout(location=4 component=2 ) smooth in 2-component vector of float)
 0:?     'b' (layout(location=4 component=1 ) smooth in float)
@@ -125,6 +135,16 @@ ERROR: node is still EOpNull!
 0:146              0 (const int)
 0:146            Constant:
 0:146              1 (const int)
+0:147      interpolateAtSample (global float)
+0:147        direct index (temp float)
+0:147          direct index (smooth sample temp 3-component vector of float)
+0:147            'sampInArray' (smooth sample in 4-element array of 3-component vector of float)
+0:147            Constant:
+0:147              2 (const int)
+0:147          Constant:
+0:147            0 (const int)
+0:147        Constant:
+0:147          2 (const int)
 0:?   Linker Objects
 0:?     'a' (layout(location=4 component=2 ) smooth in 2-component vector of float)
 0:?     'b' (layout(location=4 component=1 ) smooth in float)
diff --git a/glslang/MachineIndependent/Intermediate.cpp b/glslang/MachineIndependent/Intermediate.cpp
index 35be93b84..7e4a160c5 100644
--- a/glslang/MachineIndependent/Intermediate.cpp
+++ b/glslang/MachineIndependent/Intermediate.cpp
@@ -882,7 +882,9 @@ const TIntermTyped* TIntermediate::findLValueBase(const TIntermTyped* node, bool
         if (! swizzleOkay) {
             if (op == EOpVectorSwizzle)
                 return nullptr;
-            if ((op == EOpIndexDirect || op == EOpIndexIndirect) && binary->getLeft()->getType().isVector() && ! binary->getLeft()->getType().isArray())
+            if ((op == EOpIndexDirect || op == EOpIndexIndirect) && 
+                (binary->getLeft()->getType().isVector() || binary->getLeft()->getType().isScalar()) && 
+                ! binary->getLeft()->getType().isArray())
                 return nullptr;
         }
         node = node->getAsBinaryNode()->getLeft();
-- 
GitLab