Bind all elements of unbound image arrays to unit zero

Spec GLSL ES 3.10, section 4.4.5, Any uniform sampler, image or atomic
counter variable declared without a binding qualifier is initially bound
to unit zero. If the binding qualifier is used with an array, the first
element of the array takes the specified unit and each subsequent element
takes the next consecutive unit.

BUG=angleproject:1987
TEST=angle_end2end_tests:ComputeShaderTest

Change-Id: I6a8188449a91bf3e8ded37e067205dcae4e47fa7
Reviewed-on: https://chromium-review.googlesource.com/547977
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/MemoryProgramCache.cpp b/src/libANGLE/MemoryProgramCache.cpp
index e34a18a..9dac603 100644
--- a/src/libANGLE/MemoryProgramCache.cpp
+++ b/src/libANGLE/MemoryProgramCache.cpp
@@ -310,12 +310,16 @@
     unsigned int imageRangeLow  = stream.readInt<unsigned int>();
     unsigned int imageRangeHigh = stream.readInt<unsigned int>();
     state->mImageUniformRange   = RangeUI(imageRangeLow, imageRangeHigh);
-    unsigned int imageCount     = stream.readInt<unsigned int>();
-    for (unsigned int imageIndex = 0; imageIndex < imageCount; ++imageIndex)
+    unsigned int imageBindingCount = stream.readInt<unsigned int>();
+    for (unsigned int imageIndex = 0; imageIndex < imageBindingCount; ++imageIndex)
     {
-        GLuint boundImageUnit = stream.readInt<unsigned int>();
-        size_t elementCount   = stream.readInt<size_t>();
-        state->mImageBindings.emplace_back(ImageBinding(boundImageUnit, elementCount));
+        unsigned int elementCount = stream.readInt<unsigned int>();
+        ImageBinding imageBinding(elementCount);
+        for (unsigned int i = 0; i < elementCount; ++i)
+        {
+            imageBinding.boundImageUnits[i] = stream.readInt<unsigned int>();
+        }
+        state->mImageBindings.emplace_back(imageBinding);
     }
 
     unsigned int atomicCounterRangeLow  = stream.readInt<unsigned int>();
@@ -466,8 +470,11 @@
     stream.writeInt(state.getImageBindings().size());
     for (const auto &imageBinding : state.getImageBindings())
     {
-        stream.writeInt(imageBinding.boundImageUnit);
-        stream.writeInt(imageBinding.elementCount);
+        stream.writeInt(imageBinding.boundImageUnits.size());
+        for (size_t i = 0; i < imageBinding.boundImageUnits.size(); ++i)
+        {
+            stream.writeInt(imageBinding.boundImageUnits[i]);
+        }
     }
 
     stream.writeInt(state.getAtomicCounterUniformRange().low());