glsl: Return correct number of coordinate components for cubemap array images.
authorFrancisco Jerez <currojerez@riseup.net>
Wed, 19 Nov 2014 16:22:07 +0000 (18:22 +0200)
committerFrancisco Jerez <currojerez@riseup.net>
Tue, 10 Feb 2015 13:49:43 +0000 (15:49 +0200)
Cubemap array images are unlike cubemap array samplers in that they don't need
an additional coordinate to index individual cubemaps in the array, instead
they behave like a 2D array of 6n layers, with n the number of cubemaps in the
array.  Take this exception into account.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/glsl/glsl_types.cpp

index b4223f4f06e85a286aa8d69204636a1841956e98..2dfa2ba74042185094bac5b1653213d896afa70a 100644 (file)
@@ -1225,8 +1225,13 @@ glsl_type::coordinate_components() const
       break;
    }
 
-   /* Array textures need an additional component for the array index. */
-   if (sampler_array)
+   /* Array textures need an additional component for the array index, except
+    * for cubemap array images that behave like a 2D array of interleaved
+    * cubemap faces.
+    */
+   if (sampler_array &&
+       !(base_type == GLSL_TYPE_IMAGE &&
+         sampler_dimensionality == GLSL_SAMPLER_DIM_CUBE))
       size += 1;
 
    return size;