radv: replace grid_components_used by uses_grid_size
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 14 Dec 2017 11:51:07 +0000 (12:51 +0100)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 14 Dec 2017 21:19:42 +0000 (22:19 +0100)
Use a boolean instead because the number of needed SGPRs
is always 3.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/common/ac_nir_to_llvm.c
src/amd/common/ac_shader_info.c
src/amd/common/ac_shader_info.h

index ce25e57eba76c9721371c1f4a7064963c0eb9d5f..0e1d7e0082f81c44f77909d81184e537eef2e9c5 100644 (file)
@@ -576,7 +576,8 @@ static void allocate_user_sgprs(struct nir_to_llvm_context *ctx,
 
        switch (ctx->stage) {
        case MESA_SHADER_COMPUTE:
-               user_sgpr_info->sgpr_count += ctx->shader_info->info.cs.grid_components_used;
+               if (ctx->shader_info->info.cs.uses_grid_size)
+                       user_sgpr_info->sgpr_count += 3;
                break;
        case MESA_SHADER_FRAGMENT:
                user_sgpr_info->sgpr_count += ctx->shader_info->info.ps.needs_sample_positions;
@@ -745,7 +746,7 @@ static void create_function(struct nir_to_llvm_context *ctx,
        switch (stage) {
        case MESA_SHADER_COMPUTE:
                radv_define_common_user_sgprs_phase1(ctx, stage, has_previous_stage, previous_stage, &user_sgpr_info, &args, &desc_sets);
-               if (ctx->shader_info->info.cs.grid_components_used) {
+               if (ctx->shader_info->info.cs.uses_grid_size) {
                        add_user_sgpr_argument(&args, ctx->ac.v3i32,
                                               &ctx->num_work_groups);
                }
@@ -951,7 +952,7 @@ static void create_function(struct nir_to_llvm_context *ctx,
 
        switch (stage) {
        case MESA_SHADER_COMPUTE:
-               if (ctx->shader_info->info.cs.grid_components_used) {
+               if (ctx->shader_info->info.cs.uses_grid_size) {
                        set_userdata_location_shader(ctx, AC_UD_CS_GRID_SIZE,
                                                     &user_sgpr_idx, 3);
                }
index 53e584065ce7267c88eb9ee2507d9e220f82a9db..09dd4bbd558dd4dcf955d0be1348e965682e6d3e 100644 (file)
@@ -43,7 +43,7 @@ gather_intrinsic_info(nir_intrinsic_instr *instr, struct ac_shader_info *info)
                info->vs.needs_instance_id = true;
                break;
        case nir_intrinsic_load_num_work_groups:
-               info->cs.grid_components_used = instr->num_components;
+               info->cs.uses_grid_size = true;
                break;
        case nir_intrinsic_load_sample_id:
                info->ps.force_persample = true;
index c1d36a667eeef7d65b5b4ea5f781dd6eaaf2be33..3c809cce13ad0e13a5f85f841881e0a6f233d270 100644 (file)
@@ -42,7 +42,7 @@ struct ac_shader_info {
                bool uses_input_attachments;
        } ps;
        struct {
-               uint8_t grid_components_used;
+               bool uses_grid_size;
        } cs;
 };