aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChris Forbes <[email protected]>2014-05-16 21:28:09 +1200
committerChris Forbes <[email protected]>2014-07-26 16:46:03 +1200
commit9c90a633786ab8e204c118ec92015eb3ae194349 (patch)
treea4851f6d4c59c87ce8b2a008ec1f173441b16361 /src
parent8eae5ceb99b71854db566e18222f400641c23f39 (diff)
glsl: Mark entire UBO array active if indexed with non-constant.
Without doing a lot more work, we have no idea which indices may be used at runtime, so just mark them all. Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/glsl/link_uniform_block_active_visitor.cpp50
1 files changed, 31 insertions, 19 deletions
diff --git a/src/glsl/link_uniform_block_active_visitor.cpp b/src/glsl/link_uniform_block_active_visitor.cpp
index d19ce20c782..854309f9baa 100644
--- a/src/glsl/link_uniform_block_active_visitor.cpp
+++ b/src/glsl/link_uniform_block_active_visitor.cpp
@@ -109,32 +109,44 @@ link_uniform_block_active_visitor::visit_enter(ir_dereference_array *ir)
assert((b->num_array_elements == 0) == (b->array_elements == NULL));
assert(b->type != NULL);
- /* Determine whether or not this array index has already been added to the
- * list of active array indices. At this point all constant folding must
- * have occured, and the array index must be a constant.
- */
ir_constant *c = ir->array_index->as_constant();
- assert(c != NULL);
- const unsigned idx = c->get_uint_component(0);
+ if (c) {
+ /* Index is a constant, so mark just that element used, if not already */
+ const unsigned idx = c->get_uint_component(0);
- unsigned i;
- for (i = 0; i < b->num_array_elements; i++) {
- if (b->array_elements[i] == idx)
- break;
- }
+ unsigned i;
+ for (i = 0; i < b->num_array_elements; i++) {
+ if (b->array_elements[i] == idx)
+ break;
+ }
- assert(i <= b->num_array_elements);
+ assert(i <= b->num_array_elements);
- if (i == b->num_array_elements) {
- b->array_elements = reralloc(this->mem_ctx,
- b->array_elements,
- unsigned,
- b->num_array_elements + 1);
+ if (i == b->num_array_elements) {
+ b->array_elements = reralloc(this->mem_ctx,
+ b->array_elements,
+ unsigned,
+ b->num_array_elements + 1);
- b->array_elements[b->num_array_elements] = idx;
+ b->array_elements[b->num_array_elements] = idx;
- b->num_array_elements++;
+ b->num_array_elements++;
+ }
+ } else {
+ /* The array index is not a constant, so mark the entire array used. */
+ assert(b->type->is_array());
+ if (b->num_array_elements < b->type->length) {
+ b->num_array_elements = b->type->length;
+ b->array_elements = reralloc(this->mem_ctx,
+ b->array_elements,
+ unsigned,
+ b->num_array_elements);
+
+ for (unsigned i = 0; i < b->num_array_elements; i++) {
+ b->array_elements[i] = i;
+ }
+ }
}
return visit_continue_with_parent;