ac/radeonsi: add num_work_groups to the abi
authorTimothy Arceri <tarceri@itsqueeze.com>
Fri, 2 Feb 2018 03:33:06 +0000 (14:33 +1100)
committerTimothy Arceri <tarceri@itsqueeze.com>
Tue, 6 Feb 2018 21:43:08 +0000 (08:43 +1100)
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/amd/common/ac_nir_to_llvm.c
src/amd/common/ac_shader_abi.h
src/gallium/drivers/radeonsi/si_shader.c
src/gallium/drivers/radeonsi/si_shader_internal.h

index 4588feb690eb004623fbb02ef4eea5b49a8b7efd..e44afbb9b226a005ea60dc971f4f3800cef0cb25 100644 (file)
@@ -90,7 +90,6 @@ struct nir_to_llvm_context {
        LLVMValueRef ring_offsets;
        LLVMValueRef push_constants;
        LLVMValueRef view_index;
-       LLVMValueRef num_work_groups;
        LLVMValueRef tg_size;
 
        LLVMValueRef vertex_buffers;
@@ -780,7 +779,7 @@ static void create_function(struct nir_to_llvm_context *ctx,
 
                if (ctx->shader_info->info.cs.uses_grid_size) {
                        add_arg(&args, ARG_SGPR, ctx->ac.v3i32,
-                               &ctx->num_work_groups);
+                               &ctx->abi.num_work_groups);
                }
 
                for (int i = 0; i < 3; i++) {
@@ -4376,7 +4375,7 @@ static void visit_intrinsic(struct ac_nir_context *ctx,
                result = ctx->abi->instance_id;
                break;
        case nir_intrinsic_load_num_work_groups:
-               result = ctx->nctx->num_work_groups;
+               result = ctx->abi->num_work_groups;
                break;
        case nir_intrinsic_load_local_invocation_index:
                result = visit_load_local_invocation_index(ctx->nctx);
index 55842ea342d38379b7f01245b0dafe478fe3e3ab..9499c1a15fd04eb169354cde0043ff7b4e9e2c51 100644 (file)
@@ -56,6 +56,7 @@ struct ac_shader_abi {
        LLVMValueRef prim_mask;
        /* CS */
        LLVMValueRef local_invocation_ids;
+       LLVMValueRef num_work_groups;
        LLVMValueRef workgroup_ids[3];
 
        /* For VS and PS: pre-loaded shader inputs.
index b2ff5b24e684eb17841ecad27bfa357f51d75153..f7413a2d6f01b7089ed4f1ad94ef4e041964d6db 100644 (file)
@@ -2146,7 +2146,7 @@ void si_load_system_value(struct si_shader_context *ctx,
                break;
 
        case TGSI_SEMANTIC_GRID_SIZE:
-               value = LLVMGetParam(ctx->main_fn, ctx->param_grid_size);
+               value = ctx->abi.num_work_groups;
                break;
 
        case TGSI_SEMANTIC_BLOCK_SIZE:
@@ -4879,7 +4879,7 @@ static void create_function(struct si_shader_context *ctx)
                declare_global_desc_pointers(ctx, &fninfo);
                declare_per_stage_desc_pointers(ctx, &fninfo, true);
                if (shader->selector->info.uses_grid_size)
-                       ctx->param_grid_size = add_arg(&fninfo, ARG_SGPR, v3i32);
+                       add_arg_assign(&fninfo, ARG_SGPR, v3i32, &ctx->abi.num_work_groups);
                if (shader->selector->info.uses_block_size)
                        ctx->param_block_size = add_arg(&fninfo, ARG_SGPR, v3i32);
 
index aed6ea07f0bfc1e3267357cea7204406c80f9b99..02d5fc8e379c4af1f34f984433512b001419e434 100644 (file)
@@ -184,7 +184,6 @@ struct si_shader_context {
        int param_gs_vtx23_offset; /* in dwords (GFX9) */
        int param_gs_vtx45_offset; /* in dwords (GFX9) */
        /* CS */
-       int param_grid_size;
        int param_block_size;
 
        LLVMTargetMachineRef tm;