[Mesa-dev] [PATCH 3/6] glsl: Accept nonconstant array references in lower_ubo_reference

Chris Forbes chrisf at ijw.co.nz
Sat Jul 12 18:51:58 PDT 2014


Instead of falling back to just the block name (which we won't find),
look for the first element of the block array. We'll deal with the rest
in the backend by arranging for the blocks to be laid out contiguously.

Signed-off-by: Chris Forbes <chrisf at ijw.co.nz>
---
 src/glsl/lower_ubo_reference.cpp | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/glsl/lower_ubo_reference.cpp b/src/glsl/lower_ubo_reference.cpp
index 90e65bd..85e9c7d 100644
--- a/src/glsl/lower_ubo_reference.cpp
+++ b/src/glsl/lower_ubo_reference.cpp
@@ -102,6 +102,16 @@ interface_field_name(void *mem_ctx, char *base_name, ir_dereference *d)
 
          d = a->array->as_dereference();
          previous_index = a->array_index->as_constant();
+
+         if (!previous_index) {
+            /* The array index is not a constant, so let's find
+             * the first element of the array. Elsewhere we guarantee
+             * that the entire array is valid if used with a non-constant
+             * index.
+             */
+            previous_index = new(mem_ctx) ir_constant(0u);
+         }
+
          break;
       }
 
-- 
2.0.1



More information about the mesa-dev mailing list