radeonsi: lower compute shader arguments
authorBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Thu, 17 Mar 2016 13:12:21 +0000 (14:12 +0100)
committerBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Tue, 19 Apr 2016 16:10:30 +0000 (18:10 +0200)
Signed-off-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/gallium/drivers/radeonsi/si_shader.c
src/gallium/drivers/radeonsi/si_shader.h

index c26960b1ca3d508fee59fb23bc0abb09b31d53a6..68171c831d281ea24891c4121cf67c89570f2f22 100644 (file)
@@ -1282,6 +1282,36 @@ static void declare_system_value(
                value = get_primitive_id(&radeon_bld->soa.bld_base, 0);
                break;
 
+       case TGSI_SEMANTIC_GRID_SIZE:
+               value = LLVMGetParam(radeon_bld->main_fn, SI_PARAM_GRID_SIZE);
+               break;
+
+       case TGSI_SEMANTIC_BLOCK_SIZE:
+       {
+               LLVMValueRef values[3];
+               unsigned i;
+               unsigned *properties = ctx->shader->selector->info.properties;
+               unsigned sizes[3] = {
+                       properties[TGSI_PROPERTY_CS_FIXED_BLOCK_WIDTH],
+                       properties[TGSI_PROPERTY_CS_FIXED_BLOCK_HEIGHT],
+                       properties[TGSI_PROPERTY_CS_FIXED_BLOCK_DEPTH]
+               };
+
+               for (i = 0; i < 3; ++i)
+                       values[i] = lp_build_const_int32(gallivm, sizes[i]);
+
+               value = lp_build_gather_values(gallivm, values, 3);
+               break;
+       }
+
+       case TGSI_SEMANTIC_BLOCK_ID:
+               value = LLVMGetParam(radeon_bld->main_fn, SI_PARAM_BLOCK_ID);
+               break;
+
+       case TGSI_SEMANTIC_THREAD_ID:
+               value = LLVMGetParam(radeon_bld->main_fn, SI_PARAM_THREAD_ID);
+               break;
+
        default:
                assert(!"unknown system value");
                return;
@@ -4823,6 +4853,14 @@ static void create_function(struct si_shader_context *ctx)
                }
                break;
 
+       case TGSI_PROCESSOR_COMPUTE:
+               params[SI_PARAM_GRID_SIZE] = v3i32;
+               params[SI_PARAM_BLOCK_ID] = v3i32;
+               last_sgpr = SI_PARAM_BLOCK_ID;
+
+               params[SI_PARAM_THREAD_ID] = v3i32;
+               num_params = SI_PARAM_THREAD_ID + 1;
+               break;
        default:
                assert(0 && "unimplemented shader");
                return;
@@ -5600,6 +5638,7 @@ void si_dump_shader_key(unsigned shader, union si_shader_key *key, FILE *f)
                break;
 
        case PIPE_SHADER_GEOMETRY:
+       case PIPE_SHADER_COMPUTE:
                break;
 
        case PIPE_SHADER_FRAGMENT:
@@ -5784,6 +5823,8 @@ int si_compile_tgsi_shader(struct si_screen *sscreen,
                else
                        bld_base->emit_epilogue = si_llvm_return_fs_outputs;
                break;
+       case TGSI_PROCESSOR_COMPUTE:
+               break;
        default:
                assert(!"Unsupported shader type");
                return -1;
index dab572c9d37904d42d86bf278b4e296cae08bf2c..738ddf65b57f5981de284e61792291a2fbe1e415 100644 (file)
@@ -122,6 +122,10 @@ enum {
        /* PS only */
        SI_SGPR_ALPHA_REF       = SI_NUM_RESOURCE_SGPRS,
        SI_PS_NUM_USER_SGPR,
+
+       /* CS only */
+       SI_SGPR_GRID_SIZE = SI_NUM_RESOURCE_SGPRS,
+       SI_CS_NUM_USER_SGPR = SI_SGPR_GRID_SIZE + 3
 };
 
 /* LLVM function parameter indices */
@@ -198,6 +202,11 @@ enum {
        SI_PARAM_SAMPLE_COVERAGE,
        SI_PARAM_POS_FIXED_PT,
 
+       /* CS only parameters */
+       SI_PARAM_GRID_SIZE = SI_NUM_RESOURCE_PARAMS,
+       SI_PARAM_BLOCK_ID,
+       SI_PARAM_THREAD_ID,
+
        SI_NUM_PARAMS = SI_PARAM_POS_FIXED_PT + 9, /* +8 for COLOR[0..1] */
 };