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/Program.cpp b/src/libANGLE/Program.cpp
index cc66a72..6c101e2 100644
--- a/src/libANGLE/Program.cpp
+++ b/src/libANGLE/Program.cpp
@@ -1808,17 +1808,20 @@
// If uniform is a image type, insert it into the mImageBindings array.
for (unsigned int imageIndex : mState.mImageUniformRange)
{
- // ES3.1 (section 7.6.1) and GLSL ES3.1 (section 4.4.5), Uniform*i{v}
- // commands cannot load values into a uniform defined as an image,
- // if declare without a binding qualifier, the image variable is
- // initially bound to unit zero.
+ // ES3.1 (section 7.6.1) and GLSL ES3.1 (section 4.4.5), Uniform*i{v} commands
+ // cannot load values into a uniform defined as an image. if declare without a
+ // binding qualifier, any uniform image variable (include all elements of
+ // unbound image array) shoud be bound to unit zero.
auto &imageUniform = mState.mUniforms[imageIndex];
if (imageUniform.binding == -1)
{
- imageUniform.binding = 0;
+ mState.mImageBindings.emplace_back(ImageBinding(imageUniform.elementCount()));
}
- mState.mImageBindings.emplace_back(
- ImageBinding(imageUniform.binding, imageUniform.elementCount()));
+ else
+ {
+ mState.mImageBindings.emplace_back(
+ ImageBinding(imageUniform.binding, imageUniform.elementCount()));
+ }
}
high = low;