radeonsi: clean up code for loading VS inputs
authorMarek Olšák <marek.olsak@amd.com>
Fri, 14 Aug 2020 21:56:42 +0000 (17:56 -0400)
committerMarek Olšák <marek.olsak@amd.com>
Thu, 3 Sep 2020 02:45:38 +0000 (22:45 -0400)
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6445>

src/gallium/drivers/radeonsi/si_shader_llvm_vs.c

index f0c93ac3264a90f889d9de301c8f44f8c4c5b18a..76ea7e76c366517987c3f5524ed0c36e1ecce925 100644 (file)
@@ -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, "");
       }
    }
 }