From 833a74351c71d9a5cb91dd1846ddfd96cd96f7bb Mon Sep 17 00:00:00 2001 From: Emma Anholt Date: Thu, 2 Feb 2023 14:04:56 -0800 Subject: [PATCH] gallivm: Fix the type of array nir_registers. This now matches how they get dereffed by get_soa_array_offsets() -- each array element has num_components vecs inside of it, rather than each components has an array in it. Reviewed-by: Dave Airlie Part-of: --- src/gallium/auxiliary/gallivm/lp_bld_nir.c | 4 ++-- src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_nir.c b/src/gallium/auxiliary/gallivm/lp_bld_nir.c index 3fe4629be5e..c2b82a7b0c9 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_nir.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_nir.c @@ -2711,10 +2711,10 @@ get_register_type(struct lp_build_nir_context *bld_base, get_int_bld(bld_base, true, reg->bit_size == 1 ? 32 : reg->bit_size); LLVMTypeRef type = int_bld->vec_type; - if (reg->num_array_elems) - type = LLVMArrayType(type, reg->num_array_elems); if (reg->num_components > 1) type = LLVMArrayType(type, reg->num_components); + if (reg->num_array_elems) + type = LLVMArrayType(type, reg->num_array_elems); return type; } diff --git a/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c index 3a01549e2f3..0ea4f4b67b7 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c @@ -227,7 +227,7 @@ get_soa_array_offsets(struct lp_build_context *uint_bld, lp_build_const_int_vec(gallivm, uint_bld->type, uint_bld->type.length); LLVMValueRef index_vec; - /* index_vec = (indirect_index * 4 + chan_index) * length + offsets */ + /* index_vec = (indirect_index * num_components + chan_index) * length + offsets */ index_vec = lp_build_mul(uint_bld, indirect_index, lp_build_const_int_vec(uint_bld->gallivm, uint_bld->type, num_components)); index_vec = lp_build_add(uint_bld, index_vec, chan_vec); index_vec = lp_build_mul(uint_bld, index_vec, length_vec);