gallivm/nir: Load all inputs into indirect inputs array

The code in `emit_load_var` that will attempt to read indirect inputs
expects the entire array of inputs to be there. Additionally the code
that populates `bld->inputs_array` will populate the array using the count
of `inputs_read`, without ensuring the inputs it copies are the ones read.

This change populates `bld->inputs_array` with the entire contents of bld->inputs
so indirect reads will always match up.

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26153>
This commit is contained in:
Lucas Fryzek 2023-11-10 15:01:26 -05:00 committed by Marge Bot
parent 898700ca64
commit 10367618da
5 changed files with 11 additions and 1 deletions

View file

@ -596,6 +596,7 @@ generate_vs(struct draw_llvm_variant *variant,
lp_jit_resources_constants(variant->gallivm, variant->resources_type, resources_ptr); lp_jit_resources_constants(variant->gallivm, variant->resources_type, resources_ptr);
LLVMValueRef ssbos_ptr = LLVMValueRef ssbos_ptr =
lp_jit_resources_ssbos(variant->gallivm, variant->resources_type, resources_ptr); lp_jit_resources_ssbos(variant->gallivm, variant->resources_type, resources_ptr);
struct draw_llvm_variant_key *key = &variant->key;
struct lp_build_tgsi_params params; struct lp_build_tgsi_params params;
memset(&params, 0, sizeof(params)); memset(&params, 0, sizeof(params));
@ -605,6 +606,7 @@ generate_vs(struct draw_llvm_variant *variant,
params.consts_ptr = consts_ptr; params.consts_ptr = consts_ptr;
params.system_values = system_values; params.system_values = system_values;
params.inputs = inputs; params.inputs = inputs;
params.num_inputs = key->nr_vertex_elements;
params.context_type = variant->context_type; params.context_type = variant->context_type;
params.context_ptr = context_ptr; params.context_ptr = context_ptr;
params.resources_type = variant->resources_type; params.resources_type = variant->resources_type;
@ -2454,6 +2456,7 @@ draw_gs_llvm_generate(struct draw_llvm *llvm,
variant->resources_type, variant->resources_type,
resources_ptr); resources_ptr);
if (llvm->draw->gs.geometry_shader->state.type == PIPE_SHADER_IR_TGSI) if (llvm->draw->gs.geometry_shader->state.type == PIPE_SHADER_IR_TGSI)
lp_build_tgsi_soa(variant->gallivm, lp_build_tgsi_soa(variant->gallivm,
tokens, tokens,

View file

@ -275,6 +275,7 @@ struct lp_build_nir_soa_context
LLVMValueRef consts_ptr; LLVMValueRef consts_ptr;
const LLVMValueRef (*inputs)[TGSI_NUM_CHANNELS]; const LLVMValueRef (*inputs)[TGSI_NUM_CHANNELS];
LLVMValueRef (*outputs)[TGSI_NUM_CHANNELS]; LLVMValueRef (*outputs)[TGSI_NUM_CHANNELS];
int num_inputs;
LLVMTypeRef context_type; LLVMTypeRef context_type;
LLVMValueRef context_ptr; LLVMValueRef context_ptr;
LLVMTypeRef resources_type; LLVMTypeRef resources_type;

View file

@ -2196,7 +2196,10 @@ emit_prologue(struct lp_build_nir_soa_context *bld)
{ {
struct gallivm_state * gallivm = bld->bld_base.base.gallivm; struct gallivm_state * gallivm = bld->bld_base.base.gallivm;
if (bld->indirects & nir_var_shader_in && !bld->gs_iface && !bld->tcs_iface && !bld->tes_iface) { if (bld->indirects & nir_var_shader_in && !bld->gs_iface && !bld->tcs_iface && !bld->tes_iface) {
uint32_t num_inputs = util_bitcount64(bld->bld_base.shader->info.inputs_read); uint32_t num_inputs = bld->num_inputs;
/* If this is an indirect case, the number of inputs should not be 0 */
assert(num_inputs > 0);
unsigned index, chan; unsigned index, chan;
LLVMTypeRef vec_type = bld->bld_base.base.vec_type; LLVMTypeRef vec_type = bld->bld_base.base.vec_type;
LLVMValueRef array_size = lp_build_const_int32(gallivm, num_inputs * 4); LLVMValueRef array_size = lp_build_const_int32(gallivm, num_inputs * 4);
@ -3037,6 +3040,7 @@ void lp_build_nir_soa_func(struct gallivm_state *gallivm,
bld.payload_ptr = params->payload_ptr; bld.payload_ptr = params->payload_ptr;
bld.coro = params->coro; bld.coro = params->coro;
bld.kernel_args_ptr = params->kernel_args; bld.kernel_args_ptr = params->kernel_args;
bld.num_inputs = params->num_inputs;
bld.indirects = 0; bld.indirects = 0;
if (shader->info.inputs_read_indirectly) if (shader->info.inputs_read_indirectly)
bld.indirects |= nir_var_shader_in; bld.indirects |= nir_var_shader_in;

View file

@ -267,6 +267,7 @@ struct lp_build_tgsi_params {
LLVMValueRef const_sizes_ptr; LLVMValueRef const_sizes_ptr;
const struct lp_bld_tgsi_system_values *system_values; const struct lp_bld_tgsi_system_values *system_values;
const LLVMValueRef (*inputs)[4]; const LLVMValueRef (*inputs)[4];
int num_inputs;
LLVMTypeRef context_type; LLVMTypeRef context_type;
LLVMValueRef context_ptr; LLVMValueRef context_ptr;
LLVMTypeRef resources_type; LLVMTypeRef resources_type;

View file

@ -1051,6 +1051,7 @@ generate_fs_loop(struct gallivm_state *gallivm,
params.consts_ptr = consts_ptr; params.consts_ptr = consts_ptr;
params.system_values = &system_values; params.system_values = &system_values;
params.inputs = interp->inputs; params.inputs = interp->inputs;
params.num_inputs = interp->num_attribs - 1;
params.context_type = context_type; params.context_type = context_type;
params.context_ptr = context_ptr; params.context_ptr = context_ptr;
params.resources_type = resources_type; params.resources_type = resources_type;