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 <mhpreda@gmail.com> Reviewed-by: Brian Paul <brianp@vmware.com> Reviewed-by: Roland Scheidegger <sroland@vmware.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18932>
This commit is contained in:
@@ -545,12 +545,14 @@ struct lp_build_tgsi_soa_context
|
|||||||
* set in the indirect_files field.
|
* set in the indirect_files field.
|
||||||
* The temps[] array above is unused then.
|
* The temps[] array above is unused then.
|
||||||
*/
|
*/
|
||||||
|
LLVMTypeRef temps_array_type;
|
||||||
LLVMValueRef temps_array;
|
LLVMValueRef temps_array;
|
||||||
|
|
||||||
/* We allocate/use this array of output if (1 << TGSI_FILE_OUTPUT) is
|
/* We allocate/use this array of output if (1 << TGSI_FILE_OUTPUT) is
|
||||||
* set in the indirect_files field.
|
* set in the indirect_files field.
|
||||||
* The outputs[] array above is unused then.
|
* The outputs[] array above is unused then.
|
||||||
*/
|
*/
|
||||||
|
LLVMTypeRef outputs_array_type;
|
||||||
LLVMValueRef outputs_array;
|
LLVMValueRef outputs_array;
|
||||||
|
|
||||||
/* We allocate/use this array of inputs if (1 << TGSI_FILE_INPUT) is
|
/* We allocate/use this array of inputs if (1 << TGSI_FILE_INPUT) is
|
||||||
|
@@ -447,15 +447,18 @@ get_file_ptr(struct lp_build_tgsi_soa_context *bld,
|
|||||||
LLVMBuilderRef builder = bld->bld_base.base.gallivm->builder;
|
LLVMBuilderRef builder = bld->bld_base.base.gallivm->builder;
|
||||||
LLVMValueRef (*array_of_vars)[TGSI_NUM_CHANNELS];
|
LLVMValueRef (*array_of_vars)[TGSI_NUM_CHANNELS];
|
||||||
LLVMValueRef var_of_array;
|
LLVMValueRef var_of_array;
|
||||||
|
LLVMTypeRef type_of_array;
|
||||||
|
|
||||||
switch (file) {
|
switch (file) {
|
||||||
case TGSI_FILE_TEMPORARY:
|
case TGSI_FILE_TEMPORARY:
|
||||||
array_of_vars = bld->temps;
|
array_of_vars = bld->temps;
|
||||||
var_of_array = bld->temps_array;
|
var_of_array = bld->temps_array;
|
||||||
|
type_of_array = bld->temps_array_type;
|
||||||
break;
|
break;
|
||||||
case TGSI_FILE_OUTPUT:
|
case TGSI_FILE_OUTPUT:
|
||||||
array_of_vars = bld->outputs;
|
array_of_vars = bld->outputs;
|
||||||
var_of_array = bld->outputs_array;
|
var_of_array = bld->outputs_array;
|
||||||
|
type_of_array = bld->outputs_array_type;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
assert(0);
|
assert(0);
|
||||||
@@ -466,13 +469,15 @@ get_file_ptr(struct lp_build_tgsi_soa_context *bld,
|
|||||||
|
|
||||||
if (bld->indirect_files & (1 << file)) {
|
if (bld->indirect_files & (1 << file)) {
|
||||||
LLVMValueRef lindex = lp_build_const_int32(bld->bld_base.base.gallivm, index * 4 + chan);
|
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];
|
LLVMValueRef gep[2];
|
||||||
gep[0] = lp_build_const_int32(bld->bld_base.base.gallivm, 0);
|
gep[0] = lp_build_const_int32(bld->bld_base.base.gallivm, 0);
|
||||||
gep[1] = lindex;
|
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 {
|
} 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 {
|
else {
|
||||||
@@ -4293,6 +4298,7 @@ static void emit_prologue(struct lp_build_tgsi_context * bld_base)
|
|||||||
|
|
||||||
if (bld->indirect_files & (1 << TGSI_FILE_TEMPORARY)) {
|
if (bld->indirect_files & (1 << TGSI_FILE_TEMPORARY)) {
|
||||||
unsigned array_size = bld_base->info->file_max[TGSI_FILE_TEMPORARY] * 4 + 4;
|
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,
|
bld->temps_array = lp_build_alloca_undef(gallivm,
|
||||||
LLVMArrayType(bld_base->base.vec_type, array_size),
|
LLVMArrayType(bld_base->base.vec_type, array_size),
|
||||||
"temp_array");
|
"temp_array");
|
||||||
@@ -4302,6 +4308,7 @@ static void emit_prologue(struct lp_build_tgsi_context * bld_base)
|
|||||||
LLVMValueRef array_size =
|
LLVMValueRef array_size =
|
||||||
lp_build_const_int32(gallivm,
|
lp_build_const_int32(gallivm,
|
||||||
bld_base->info->file_max[TGSI_FILE_OUTPUT] * 4 + 4);
|
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->outputs_array = lp_build_array_alloca(gallivm,
|
||||||
bld_base->base.vec_type, array_size,
|
bld_base->base.vec_type, array_size,
|
||||||
"output_array");
|
"output_array");
|
||||||
|
Reference in New Issue
Block a user