summaryrefslogtreecommitdiffstats
path: root/src/glsl
diff options
context:
space:
mode:
authorRob Clark <robclark@freedesktop.org>2015-11-06 11:35:21 -0500
committerJason Ekstrand <jason.ekstrand@intel.com>2015-11-18 12:28:32 -0800
commitd27ae2cf8cd548fe822ae9bcf11ead1dadfed744 (patch)
tree6fc424e8adb72ec3f06d0b366d84e96cf59110b9 /src/glsl
parent624ec66653e2ce0abc6f4021111cf067b70741c1 (diff)
nir: add array length field
This will simplify things somewhat in clone. Signed-off-by: Rob Clark <robclark@freedesktop.org> Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com> Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Diffstat (limited to 'src/glsl')
-rw-r--r--src/glsl/nir/glsl_to_nir.cpp5
-rw-r--r--src/glsl/nir/nir.h5
2 files changed, 10 insertions, 0 deletions
diff --git a/src/glsl/nir/glsl_to_nir.cpp b/src/glsl/nir/glsl_to_nir.cpp
index 5e9d57205a3..e149d73e051 100644
--- a/src/glsl/nir/glsl_to_nir.cpp
+++ b/src/glsl/nir/glsl_to_nir.cpp
@@ -240,6 +240,8 @@ constant_copy(ir_constant *ir, void *mem_ctx)
unsigned total_elems = ir->type->components();
unsigned i;
+
+ ret->num_elements = 0;
switch (ir->type->base_type) {
case GLSL_TYPE_UINT:
for (i = 0; i < total_elems; i++)
@@ -264,6 +266,8 @@ constant_copy(ir_constant *ir, void *mem_ctx)
case GLSL_TYPE_STRUCT:
ret->elements = ralloc_array(mem_ctx, nir_constant *,
ir->type->length);
+ ret->num_elements = ir->type->length;
+
i = 0;
foreach_in_list(ir_constant, field, &ir->components) {
ret->elements[i] = constant_copy(field, mem_ctx);
@@ -274,6 +278,7 @@ constant_copy(ir_constant *ir, void *mem_ctx)
case GLSL_TYPE_ARRAY:
ret->elements = ralloc_array(mem_ctx, nir_constant *,
ir->type->length);
+ ret->num_elements = ir->type->length;
for (i = 0; i < ir->type->length; i++)
ret->elements[i] = constant_copy(ir->array_elements[i], mem_ctx);
diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
index 90f1e628fe0..3d65128e751 100644
--- a/src/glsl/nir/nir.h
+++ b/src/glsl/nir/nir.h
@@ -111,6 +111,11 @@ typedef struct nir_constant {
*/
union nir_constant_data value;
+ /* we could get this from the var->type but makes clone *much* easier to
+ * not have to care about the type.
+ */
+ unsigned num_elements;
+
/* Array elements / Structure Fields */
struct nir_constant **elements;
} nir_constant;