From 44eaee688b5967e87285a7e88864b4fb84441f0e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Fri, 14 Aug 2020 17:56:42 -0400 Subject: [PATCH] radeonsi: clean up code for loading VS inputs Acked-by: Pierre-Eric Pelloux-Prayer Reviewed-by: Connor Abbott Part-of: --- .../drivers/radeonsi/si_shader_llvm_vs.c | 40 ++++--------------- 1 file changed, 7 insertions(+), 33 deletions(-) diff --git a/src/gallium/drivers/radeonsi/si_shader_llvm_vs.c b/src/gallium/drivers/radeonsi/si_shader_llvm_vs.c index f0c93ac3264..76ea7e76c36 100644 --- a/src/gallium/drivers/radeonsi/si_shader_llvm_vs.c +++ b/src/gallium/drivers/radeonsi/si_shader_llvm_vs.c @@ -225,44 +225,18 @@ static void load_input_vs(struct si_shader_context *ctx, unsigned input_index, L out[i] = ac_to_float(&ctx->ac, fetches[i]); } -static void declare_input_vs(struct si_shader_context *ctx, unsigned input_index) -{ - LLVMValueRef input[4]; - - load_input_vs(ctx, input_index / 4, input); - - for (unsigned chan = 0; chan < 4; chan++) { - ctx->inputs[input_index + chan] = - LLVMBuildBitCast(ctx->ac.builder, input[chan], ctx->ac.i32, ""); - } -} - void si_llvm_load_vs_inputs(struct si_shader_context *ctx, struct nir_shader *nir) { - uint64_t processed_inputs = 0; - - nir_foreach_shader_in_variable (variable, nir) { - unsigned attrib_count = glsl_count_attribute_slots(variable->type, true); - unsigned input_idx = variable->data.driver_location; - unsigned loc = variable->data.location; + const struct si_shader_info *info = &ctx->shader->selector->info; - for (unsigned i = 0; i < attrib_count; i++) { - /* Packed components share the same location so skip - * them if we have already processed the location. - */ - if (processed_inputs & ((uint64_t)1 << (loc + i))) { - input_idx += 4; - continue; - } + for (unsigned i = 0; i < info->num_inputs; i++) { + LLVMValueRef values[4]; - declare_input_vs(ctx, input_idx); - if (glsl_type_is_dual_slot(variable->type)) { - input_idx += 4; - declare_input_vs(ctx, input_idx); - } + load_input_vs(ctx, i, values); - processed_inputs |= ((uint64_t)1 << (loc + i)); - input_idx += 4; + for (unsigned chan = 0; chan < 4; chan++) { + ctx->inputs[i * 4 + chan] = + LLVMBuildBitCast(ctx->ac.builder, values[chan], ctx->ac.i32, ""); } } } -- 2.30.2