[Mesa-dev] [PATCH 14/19] glsl: add support for sampler AoA with const index

Timothy Arceri t_arceri at yahoo.com.au
Sat Jun 20 05:33:11 PDT 2015


---
 src/mesa/program/sampler.cpp | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/mesa/program/sampler.cpp b/src/mesa/program/sampler.cpp
index 34eee6d..0017328 100644
--- a/src/mesa/program/sampler.cpp
+++ b/src/mesa/program/sampler.cpp
@@ -87,7 +87,17 @@ public:
       if (ir->type->without_array()->is_record()) {
 	 this->name = ralloc_asprintf(mem_ctx, "%s[%d]", name, i);
       } else {
-	 offset = i;
+         if (ir->type->is_array()) {
+            unsigned current_dim = 1;
+            const glsl_type *type = ir->type;
+            while (type->fields.array->is_array()) {
+               current_dim++;
+               type = type->fields.array;
+            }
+            offset += pow(ir->type->length, current_dim) * i;
+         } else {
+            offset += i;
+         }
       }
       return visit_continue;
    }
-- 
2.1.0



More information about the mesa-dev mailing list