diff options
author | Dave Airlie <[email protected]> | 2018-01-18 02:31:40 +0000 |
---|---|---|
committer | Dave Airlie <[email protected]> | 2018-01-18 19:47:40 +0000 |
commit | 3153d742078d9842d867e8affddf0b157de762f0 (patch) | |
tree | 8c41427cc6b6c91467fb679e8ea49d58a976dd51 /src/amd/common/ac_nir_to_llvm.c | |
parent | 5758a8c4027459fa5b51d47b4aba95c5126f3bfe (diff) |
ac/nir: account for view index in the user sgpr allocation.
The view index user sgpr wasn't being accounted for properly,
this refactors out the code to decide if it's required and then
uses that info to account for it.
Fixes: 180c1b924e (ac/nir: Add shader support for multiviews.)
Reviewed-by: Bas Nieuwenhuizen <[email protected]>
Signed-off-by: Dave Airlie <[email protected]>
Diffstat (limited to 'src/amd/common/ac_nir_to_llvm.c')
-rw-r--r-- | src/amd/common/ac_nir_to_llvm.c | 42 |
1 files changed, 34 insertions, 8 deletions
diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c index c53fb5cb1cd..02a46dab4db 100644 --- a/src/amd/common/ac_nir_to_llvm.c +++ b/src/amd/common/ac_nir_to_llvm.c @@ -543,8 +543,31 @@ struct user_sgpr_info { bool indirect_all_descriptor_sets; }; +static bool needs_view_index_sgpr(struct nir_to_llvm_context *ctx, + gl_shader_stage stage) +{ + switch (stage) { + case MESA_SHADER_VERTEX: + if (ctx->shader_info->info.needs_multiview_view_index || + (!ctx->options->key.vs.as_es && !ctx->options->key.vs.as_ls && ctx->options->key.has_multiview_view_index)) + return true; + break; + case MESA_SHADER_TESS_EVAL: + if (ctx->shader_info->info.needs_multiview_view_index || (!ctx->options->key.tes.as_es && ctx->options->key.has_multiview_view_index)) + return true; + case MESA_SHADER_GEOMETRY: + case MESA_SHADER_TESS_CTRL: + if (ctx->shader_info->info.needs_multiview_view_index) + return true; + default: + break; + } + return false; +} + static void allocate_user_sgprs(struct nir_to_llvm_context *ctx, gl_shader_stage stage, + bool needs_view_index, struct user_sgpr_info *user_sgpr_info) { memset(user_sgpr_info, 0, sizeof(struct user_sgpr_info)); @@ -600,6 +623,9 @@ static void allocate_user_sgprs(struct nir_to_llvm_context *ctx, break; } + if (needs_view_index) + user_sgpr_info->sgpr_count++; + if (ctx->shader_info->info.loads_push_constants) user_sgpr_info->sgpr_count += 2; @@ -771,8 +797,8 @@ static void create_function(struct nir_to_llvm_context *ctx, struct user_sgpr_info user_sgpr_info; struct arg_info args = {}; LLVMValueRef desc_sets; - - allocate_user_sgprs(ctx, stage, &user_sgpr_info); + bool needs_view_index = needs_view_index_sgpr(ctx, stage); + allocate_user_sgprs(ctx, stage, needs_view_index, &user_sgpr_info); if (user_sgpr_info.need_ring_offsets && !ctx->options->supports_spill) { add_arg(&args, ARG_SGPR, const_array(ctx->ac.v4i32, 16), @@ -810,7 +836,7 @@ static void create_function(struct nir_to_llvm_context *ctx, declare_vs_specific_input_sgprs(ctx, stage, has_previous_stage, previous_stage, &args); - if (ctx->shader_info->info.needs_multiview_view_index || (!ctx->options->key.vs.as_es && !ctx->options->key.vs.as_ls && ctx->options->key.has_multiview_view_index)) + if (needs_view_index) add_arg(&args, ARG_SGPR, ctx->ac.i32, &ctx->view_index); if (ctx->options->key.vs.as_es) add_arg(&args, ARG_SGPR, ctx->ac.i32, @@ -854,7 +880,7 @@ static void create_function(struct nir_to_llvm_context *ctx, &ctx->tcs_out_layout); add_arg(&args, ARG_SGPR, ctx->ac.i32, &ctx->tcs_in_layout); - if (ctx->shader_info->info.needs_multiview_view_index) + if (needs_view_index) add_arg(&args, ARG_SGPR, ctx->ac.i32, &ctx->view_index); @@ -879,7 +905,7 @@ static void create_function(struct nir_to_llvm_context *ctx, &ctx->tcs_out_layout); add_arg(&args, ARG_SGPR, ctx->ac.i32, &ctx->tcs_in_layout); - if (ctx->shader_info->info.needs_multiview_view_index) + if (needs_view_index) add_arg(&args, ARG_SGPR, ctx->ac.i32, &ctx->view_index); @@ -898,7 +924,7 @@ static void create_function(struct nir_to_llvm_context *ctx, &args, &desc_sets); add_arg(&args, ARG_SGPR, ctx->ac.i32, &ctx->tcs_offchip_layout); - if (ctx->shader_info->info.needs_multiview_view_index || (!ctx->options->key.tes.as_es && ctx->options->key.has_multiview_view_index)) + if (needs_view_index) add_arg(&args, ARG_SGPR, ctx->ac.i32, &ctx->view_index); if (ctx->options->key.tes.as_es) { @@ -945,7 +971,7 @@ static void create_function(struct nir_to_llvm_context *ctx, &ctx->gsvs_ring_stride); add_arg(&args, ARG_SGPR, ctx->ac.i32, &ctx->gsvs_num_entries); - if (ctx->shader_info->info.needs_multiview_view_index) + if (needs_view_index) add_arg(&args, ARG_SGPR, ctx->ac.i32, &ctx->view_index); @@ -976,7 +1002,7 @@ static void create_function(struct nir_to_llvm_context *ctx, &ctx->gsvs_ring_stride); add_arg(&args, ARG_SGPR, ctx->ac.i32, &ctx->gsvs_num_entries); - if (ctx->shader_info->info.needs_multiview_view_index) + if (needs_view_index) add_arg(&args, ARG_SGPR, ctx->ac.i32, &ctx->view_index); |