mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-04 11:20:20 +01:00
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>
This commit is contained in:
parent
624ec66653
commit
d27ae2cf8c
2 changed files with 10 additions and 0 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue