On 06/03/2013 01:23 PM, Fabian Bieler wrote:
Uniform arrays are subject to beeing shrunk if higher members were not accessed.
^^^^^^
being
Update the max_array_access flag so array members that were only accessed in
the function are not optimized away.
This fixes Piglit test
spec/glsl-1.10/execution/samplers/in-parameter-array.shader_test.
Signed-off-by: Fabian Bieler <[email protected]>
---
src/glsl/ast_function.cpp | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp
index 00e0c05..9378894 100644
--- a/src/glsl/ast_function.cpp
+++ b/src/glsl/ast_function.cpp
@@ -322,6 +322,18 @@ generate_call(exec_list *instructions,
ir_function_signature *sig,
assert (!"Illegal formal parameter mode");
break;
}
+ } else if (formal->type->is_array()) {
+ /* Update the max_array_access field for array parameters.
+ * If the max_array_access of the formal parameter is zero, chances
+ * are we haven't parsed the function yet. Just set the array access
+ * to the whole array in that case.
+ */
What will be the size of 'u' in the following vertex shader with this
change? Will it be 3 or 16 or something else? Does that change of the
definition of foo is in a different compilation unit?
float foo(float [16]);
uniform float u[32];
void main()
{
gl_Position = vec4(foo(u));
}
float foo(float x[16])
{
return x[2];
}
+ const unsigned max_array_access = (formal->max_array_access != 0)
+ ? formal->max_array_access : (formal->type->array_size() - 1);
+ ir_variable *var = actual->whole_variable_referenced();
+ if (var)
+ var->max_array_access =
+ MAX2(var->max_array_access, max_array_access);
}
actual_iter.next();
_______________________________________________
mesa-dev mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-dev