amd/common: replace set_userdata_location_indirect() by set_loc_desc()
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Wed, 20 Dec 2017 19:56:05 +0000 (20:56 +0100)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Wed, 27 Dec 2017 09:25:13 +0000 (10:25 +0100)
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/common/ac_nir_to_llvm.c

index d8289dea37b8295f09b330de15f29e100e3b4345..3b705b4b40dfc7ba5773a570d342b5517afbe320 100644 (file)
@@ -519,13 +519,17 @@ static void set_userdata_location_shader(struct nir_to_llvm_context *ctx,
        set_userdata_location(&ctx->shader_info->user_sgprs_locs.shader_data[idx], sgpr_idx, num_sgprs);
 }
 
-
-static void set_userdata_location_indirect(struct ac_userdata_info *ud_info, uint8_t sgpr_idx, uint8_t num_sgprs,
-                                          uint32_t indirect_offset)
+static void
+set_loc_desc(struct nir_to_llvm_context *ctx, int idx,  uint8_t *sgpr_idx,
+            uint32_t indirect_offset)
 {
-       ud_info->sgpr_idx = sgpr_idx;
-       ud_info->num_sgprs = num_sgprs;
-       ud_info->indirect = true;
+       struct ac_userdata_info *ud_info =
+               &ctx->shader_info->user_sgprs_locs.descriptor_sets[idx];
+       assert(ud_info);
+
+       ud_info->sgpr_idx = *sgpr_idx;
+       ud_info->num_sgprs = 2;
+       ud_info->indirect = indirect_offset > 0;
        ud_info->indirect_offset = indirect_offset;
 }
 
@@ -695,21 +699,18 @@ set_global_input_locs(struct nir_to_llvm_context *ctx, gl_shader_stage stage,
        if (!user_sgpr_info->indirect_all_descriptor_sets) {
                for (unsigned i = 0; i < num_sets; ++i) {
                        if (ctx->options->layout->set[i].layout->shader_stages & stage_mask) {
-                               set_userdata_location(&ctx->shader_info->user_sgprs_locs.descriptor_sets[i],
-                                                     user_sgpr_idx, 2);
+                               set_loc_desc(ctx, i, user_sgpr_idx, 0);
                        } else
                                ctx->descriptor_sets[i] = NULL;
                }
        } else {
-               uint32_t desc_sgpr_idx = *user_sgpr_idx;
                set_userdata_location_shader(ctx,
                                             AC_UD_INDIRECT_DESCRIPTOR_SETS,
                                             user_sgpr_idx, 2);
 
                for (unsigned i = 0; i < num_sets; ++i) {
                        if (ctx->options->layout->set[i].layout->shader_stages & stage_mask) {
-                               set_userdata_location_indirect(&ctx->shader_info->user_sgprs_locs.descriptor_sets[i],
-                                                              desc_sgpr_idx, 2, i * 8);
+                               set_loc_desc(ctx, i, user_sgpr_idx, i * 8);
                                ctx->descriptor_sets[i] =
                                        ac_build_load_to_sgpr(&ctx->ac,
                                                              desc_sets,