From fbe7b6f6a20cee3c21fe1e3ab11dc98d65fbd4fa Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Thu, 29 Sep 2022 14:24:20 +1000 Subject: [PATCH] gallium/tgsi: handle temps/outputs array. The old code used GetElementType on a pointer, to pick a path, I cant find a test to hit the second path, so just hardcode it for now. Reviewed-by: Mihai Preda Reviewed-by: Brian Paul Reviewed-by: Roland Scheidegger Part-of: --- src/gallium/auxiliary/gallivm/lp_bld_tgsi.h | 2 ++ src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 13 ++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h index 9a675b306e7..31067e01654 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h @@ -545,12 +545,14 @@ struct lp_build_tgsi_soa_context * set in the indirect_files field. * The temps[] array above is unused then. */ + LLVMTypeRef temps_array_type; LLVMValueRef temps_array; /* We allocate/use this array of output if (1 << TGSI_FILE_OUTPUT) is * set in the indirect_files field. * The outputs[] array above is unused then. */ + LLVMTypeRef outputs_array_type; LLVMValueRef outputs_array; /* We allocate/use this array of inputs if (1 << TGSI_FILE_INPUT) is diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index a05039fa98d..f33de194484 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -447,15 +447,18 @@ get_file_ptr(struct lp_build_tgsi_soa_context *bld, LLVMBuilderRef builder = bld->bld_base.base.gallivm->builder; LLVMValueRef (*array_of_vars)[TGSI_NUM_CHANNELS]; LLVMValueRef var_of_array; + LLVMTypeRef type_of_array; switch (file) { case TGSI_FILE_TEMPORARY: array_of_vars = bld->temps; var_of_array = bld->temps_array; + type_of_array = bld->temps_array_type; break; case TGSI_FILE_OUTPUT: array_of_vars = bld->outputs; var_of_array = bld->outputs_array; + type_of_array = bld->outputs_array_type; break; default: assert(0); @@ -466,13 +469,15 @@ get_file_ptr(struct lp_build_tgsi_soa_context *bld, if (bld->indirect_files & (1 << file)) { LLVMValueRef lindex = lp_build_const_int32(bld->bld_base.base.gallivm, index * 4 + chan); - if (LLVMGetTypeKind(LLVMGetElementType(LLVMTypeOf(var_of_array))) == LLVMArrayTypeKind) { + /* I'm not sure the other path ever gets hit, but leave until someone figures it out, + this check doesn't work with opaque pointers. */ + if (1) {//LLVMGetTypeKind(LLVMGetElementType(LLVMTypeOf(var_of_array))) == LLVMArrayTypeKind) { LLVMValueRef gep[2]; gep[0] = lp_build_const_int32(bld->bld_base.base.gallivm, 0); gep[1] = lindex; - return LLVMBuildGEP2(builder, bld->bld_base.base.vec_type, var_of_array, gep, 2, ""); + return LLVMBuildGEP2(builder, type_of_array, var_of_array, gep, 2, ""); } else { - return LLVMBuildGEP2(builder, bld->bld_base.base.vec_type, var_of_array, &lindex, 1, ""); + return LLVMBuildGEP2(builder, type_of_array, var_of_array, &lindex, 1, ""); } } else { @@ -4293,6 +4298,7 @@ static void emit_prologue(struct lp_build_tgsi_context * bld_base) if (bld->indirect_files & (1 << TGSI_FILE_TEMPORARY)) { unsigned array_size = bld_base->info->file_max[TGSI_FILE_TEMPORARY] * 4 + 4; + bld->temps_array_type = LLVMArrayType(bld_base->base.vec_type, array_size); bld->temps_array = lp_build_alloca_undef(gallivm, LLVMArrayType(bld_base->base.vec_type, array_size), "temp_array"); @@ -4302,6 +4308,7 @@ static void emit_prologue(struct lp_build_tgsi_context * bld_base) LLVMValueRef array_size = lp_build_const_int32(gallivm, bld_base->info->file_max[TGSI_FILE_OUTPUT] * 4 + 4); + bld->outputs_array_type = bld_base->base.vec_type; bld->outputs_array = lp_build_array_alloca(gallivm, bld_base->base.vec_type, array_size, "output_array");