diff options
author | Marek Olšák <[email protected]> | 2017-04-24 17:27:37 +0200 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2017-04-28 21:57:44 +0200 |
commit | 7a515a607cf47c5ca3b02856d65dc9b963f94d83 (patch) | |
tree | 8c6b5e353bfc8bdb7bfcc6181bf5a898dbcfaf16 /src/gallium/drivers/radeonsi/si_shader.c | |
parent | 46e48d404417ffe3c619287d6504f0504357d8b2 (diff) |
radeonsi: don't load unused compute shader input SGPRs and VGPRs
Basically, don't load GRID_SIZE or BLOCK_SIZE if they are unused, determine
whether to load BLOCK_ID for each component separately, and set the number
of THREAD_ID VGPRs to load. Now we should get the maximum CS launch wave
rate in most cases.
Reviewed-by: Nicolai Hähnle <[email protected]>
Diffstat (limited to 'src/gallium/drivers/radeonsi/si_shader.c')
-rw-r--r-- | src/gallium/drivers/radeonsi/si_shader.c | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c index c0e190c04d7..77dd6b1a3a6 100644 --- a/src/gallium/drivers/radeonsi/si_shader.c +++ b/src/gallium/drivers/radeonsi/si_shader.c @@ -1592,7 +1592,7 @@ static void declare_system_value(struct si_shader_context *ctx, break; case TGSI_SEMANTIC_GRID_SIZE: - value = LLVMGetParam(ctx->main_fn, SI_PARAM_GRID_SIZE); + value = LLVMGetParam(ctx->main_fn, ctx->param_grid_size); break; case TGSI_SEMANTIC_BLOCK_SIZE: @@ -1613,17 +1613,28 @@ static void declare_system_value(struct si_shader_context *ctx, value = lp_build_gather_values(gallivm, values, 3); } else { - value = LLVMGetParam(ctx->main_fn, SI_PARAM_BLOCK_SIZE); + value = LLVMGetParam(ctx->main_fn, ctx->param_block_size); } break; } case TGSI_SEMANTIC_BLOCK_ID: - value = LLVMGetParam(ctx->main_fn, SI_PARAM_BLOCK_ID); + { + LLVMValueRef values[3]; + + for (int i = 0; i < 3; i++) { + values[i] = ctx->i32_0; + if (ctx->param_block_id[i] >= 0) { + values[i] = LLVMGetParam(ctx->main_fn, + ctx->param_block_id[i]); + } + } + value = lp_build_gather_values(gallivm, values, 3); break; + } case TGSI_SEMANTIC_THREAD_ID: - value = LLVMGetParam(ctx->main_fn, SI_PARAM_THREAD_ID); + value = LLVMGetParam(ctx->main_fn, ctx->param_thread_id); break; case TGSI_SEMANTIC_HELPER_INVOCATION: @@ -6185,13 +6196,19 @@ static void create_function(struct si_shader_context *ctx) case PIPE_SHADER_COMPUTE: declare_default_desc_pointers(ctx, params, &num_params); - params[SI_PARAM_GRID_SIZE] = v3i32; - params[SI_PARAM_BLOCK_SIZE] = v3i32; - params[SI_PARAM_BLOCK_ID] = v3i32; - last_sgpr = SI_PARAM_BLOCK_ID; + if (shader->selector->info.uses_grid_size) + params[ctx->param_grid_size = num_params++] = v3i32; + if (shader->selector->info.uses_block_size) + params[ctx->param_block_size = num_params++] = v3i32; + + for (i = 0; i < 3; i++) { + ctx->param_block_id[i] = -1; + if (shader->selector->info.uses_block_id[i]) + params[ctx->param_block_id[i] = num_params++] = ctx->i32; + } + last_sgpr = num_params - 1; - params[SI_PARAM_THREAD_ID] = v3i32; - num_params = SI_PARAM_THREAD_ID + 1; + params[ctx->param_thread_id = num_params++] = v3i32; break; default: assert(0 && "unimplemented shader"); |