diff options
Diffstat (limited to 'src/amd/common')
-rw-r--r-- | src/amd/common/ac_nir_to_llvm.c | 13 | ||||
-rw-r--r-- | src/amd/common/ac_shader_info.c | 3 | ||||
-rw-r--r-- | src/amd/common/ac_shader_info.h | 3 |
3 files changed, 14 insertions, 5 deletions
diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c index 31b772f5669..f8543563293 100644 --- a/src/amd/common/ac_nir_to_llvm.c +++ b/src/amd/common/ac_nir_to_llvm.c @@ -604,7 +604,8 @@ static void create_function(struct nir_to_llvm_context *ctx) switch (ctx->stage) { case MESA_SHADER_COMPUTE: - arg_types[arg_idx++] = LLVMVectorType(ctx->i32, 3); /* grid size */ + if (ctx->shader_info->info.cs.grid_components_used) + arg_types[arg_idx++] = LLVMVectorType(ctx->i32, ctx->shader_info->info.cs.grid_components_used); /* grid size */ user_sgpr_count = arg_idx; arg_types[arg_idx++] = LLVMVectorType(ctx->i32, 3); arg_types[arg_idx++] = ctx->i32; @@ -762,10 +763,12 @@ static void create_function(struct nir_to_llvm_context *ctx) switch (ctx->stage) { case MESA_SHADER_COMPUTE: - set_userdata_location_shader(ctx, AC_UD_CS_GRID_SIZE, user_sgpr_idx, 3); - user_sgpr_idx += 3; - ctx->num_work_groups = - LLVMGetParam(ctx->main_function, arg_idx++); + if (ctx->shader_info->info.cs.grid_components_used) { + set_userdata_location_shader(ctx, AC_UD_CS_GRID_SIZE, user_sgpr_idx, ctx->shader_info->info.cs.grid_components_used); + user_sgpr_idx += ctx->shader_info->info.cs.grid_components_used; + ctx->num_work_groups = + LLVMGetParam(ctx->main_function, arg_idx++); + } ctx->workgroup_ids = LLVMGetParam(ctx->main_function, arg_idx++); ctx->tg_size = diff --git a/src/amd/common/ac_shader_info.c b/src/amd/common/ac_shader_info.c index 6ad562505cf..ef3692563b2 100644 --- a/src/amd/common/ac_shader_info.c +++ b/src/amd/common/ac_shader_info.c @@ -33,6 +33,9 @@ gather_intrinsic_info(nir_intrinsic_instr *instr, struct ac_shader_info *info) case nir_intrinsic_load_draw_id: info->vs.needs_draw_id = true; break; + case nir_intrinsic_load_num_work_groups: + info->cs.grid_components_used = instr->num_components; + break; default: break; } diff --git a/src/amd/common/ac_shader_info.h b/src/amd/common/ac_shader_info.h index 7e2b6c885a6..ed97d06d56b 100644 --- a/src/amd/common/ac_shader_info.h +++ b/src/amd/common/ac_shader_info.h @@ -35,6 +35,9 @@ struct ac_shader_info { struct { bool needs_sample_positions; } ps; + struct { + uint8_t grid_components_used; + } cs; }; void |