From d0992fa15a4bfaff59de50e6084a0a14882d3bdb Mon Sep 17 00:00:00 2001 From: Samuel Iglesias Gonsalvez Date: Thu, 1 Oct 2015 14:46:01 +0200 Subject: main: buffer array variables can have array size of 0 if they are unsized From ARB_program_query_interface: For the property ARRAY_SIZE, a single integer identifying the number of active array elements of an active variable is written to . The array size returned is in units of the type associated with the property TYPE. For active variables not corresponding to an array of basic types, the value one is written to . If the variable is a shader storage block member in an array with no declared size, the value zero is written to . v2: - Unsized arrays of arrays have an array size different than zero v3: - Arrays and unsized arrays will have an array_stride > 0. Use it instead of is_unsized_array flag (Timothy). Signed-off-by: Samuel Iglesias Gonsalvez Reviewed-by: Timothy Arceri --- src/mesa/main/shader_query.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/mesa/main/shader_query.cpp') diff --git a/src/mesa/main/shader_query.cpp b/src/mesa/main/shader_query.cpp index ed0c89fda17..f1ab4904450 100644 --- a/src/mesa/main/shader_query.cpp +++ b/src/mesa/main/shader_query.cpp @@ -1308,8 +1308,15 @@ _mesa_program_resource_prop(struct gl_shader_program *shProg, switch (res->Type) { case GL_UNIFORM: case GL_BUFFER_VARIABLE: + /* Test if a buffer variable is an array or an unsized array. + * Unsized arrays return zero as array size. + */ + if (RESOURCE_UNI(res)->is_shader_storage && + RESOURCE_UNI(res)->array_stride > 0) + *val = RESOURCE_UNI(res)->array_elements; + else *val = MAX2(RESOURCE_UNI(res)->array_elements, 1); - return 1; + return 1; case GL_PROGRAM_INPUT: case GL_PROGRAM_OUTPUT: *val = MAX2(_mesa_program_resource_array_size(res), 1); -- cgit v1.2.3