Skip to content

glsl: fix error handling of length() usage on unsized arrays

length() method can only be called on unsized array, if it's a last member of a shader storage block.

From GLSL 4.60.7 spec, section 4.1.9 "Arrays":

   If an array has not been explicitly sized and is the last declared
   member of a shader storage block, the value returned will not be a
   constant expression and will be determined at runtime based on the
   size of the buffer object providing storage for the block. Such
   arrays are runtime sized.
   ...
   The length() method cannot be called on an array that is not
   runtime sized and also has not yet been explicitly sized; this
   results in a compile-time error.

Calling length() on unsized arrays was originally introduced with ARB_shader_storage_buffer_object extension. It has been in core since version 4.3. However, until GLSL 4.60.5, there was a contradiction, that allowed calling length() method on any unsized array, not just the last member of a shader storage block. It was changed in the 5-th revision.

From GLSL 4.60.7, section 1.1.3 "Changes from Revision 4 of GLSL 4.6":

 - Private GLSL issue 32: Remove length() method contradiction:
   Non runtime-sized arrays only support length() on explicitly sized arrays.

Signed-off-by: Yevhenii Kolesnikov yevhenii.kolesnikov@globallogic.com

Piglit test: piglit!239 (closed)

Edited by Timothy Arceri

Merge request reports