summaryrefslogtreecommitdiffstats
path: root/src/amd/common
diff options
context:
space:
mode:
authorSamuel Pitoiset <[email protected]>2017-12-20 20:55:57 +0100
committerSamuel Pitoiset <[email protected]>2017-12-27 10:24:55 +0100
commitbedfa06eaf242a87c1b590f1504b8082d3d8ac1f (patch)
treea791571406fc67176667e6a9d04f81e5b7f16243 /src/amd/common
parent0f58f67abec711c1473fe5f815f122c7952bb0c7 (diff)
amd/common: rename radv_define_common_user_sgprs_phase1()
... to declare_global_input_sgprs(). Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Bas Nieuwenhuizen <[email protected]>
Diffstat (limited to 'src/amd/common')
-rw-r--r--src/amd/common/ac_nir_to_llvm.c112
1 files changed, 74 insertions, 38 deletions
diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
index a99b38ddaae..b2fc5b091a8 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -617,36 +617,6 @@ static void allocate_user_sgprs(struct nir_to_llvm_context *ctx,
}
static void
-radv_define_common_user_sgprs_phase1(struct nir_to_llvm_context *ctx,
- gl_shader_stage stage,
- bool has_previous_stage,
- gl_shader_stage previous_stage,
- const struct user_sgpr_info *user_sgpr_info,
- struct arg_info *args,
- LLVMValueRef *desc_sets)
-{
- unsigned num_sets = ctx->options->layout ? ctx->options->layout->num_sets : 0;
- unsigned stage_mask = 1 << stage;
- if (has_previous_stage)
- stage_mask |= 1 << previous_stage;
-
- /* 1 for each descriptor set */
- if (!user_sgpr_info->indirect_all_descriptor_sets) {
- for (unsigned i = 0; i < num_sets; ++i) {
- if (ctx->options->layout->set[i].layout->shader_stages & stage_mask) {
- add_user_sgpr_array_argument(args, const_array(ctx->ac.i8, 1024 * 1024), &ctx->descriptor_sets[i]);
- }
- }
- } else
- add_user_sgpr_array_argument(args, const_array(const_array(ctx->ac.i8, 1024 * 1024), 32), desc_sets);
-
- if (ctx->shader_info->info.needs_push_constants) {
- /* 1 for push constants and dynamic descriptors */
- add_user_sgpr_array_argument(args, const_array(ctx->ac.i8, 1024 * 1024), &ctx->push_constants);
- }
-}
-
-static void
radv_define_common_user_sgprs_phase2(struct nir_to_llvm_context *ctx,
gl_shader_stage stage,
bool has_previous_stage,
@@ -708,6 +678,43 @@ radv_define_vs_user_sgprs_phase2(struct nir_to_llvm_context *ctx,
}
static void
+declare_global_input_sgprs(struct nir_to_llvm_context *ctx,
+ gl_shader_stage stage,
+ bool has_previous_stage,
+ gl_shader_stage previous_stage,
+ const struct user_sgpr_info *user_sgpr_info,
+ struct arg_info *args,
+ LLVMValueRef *desc_sets)
+{
+ LLVMTypeRef type = const_array(ctx->ac.i8, 1024 * 1024);
+ unsigned num_sets = ctx->options->layout ?
+ ctx->options->layout->num_sets : 0;
+ unsigned stage_mask = 1 << stage;
+
+ if (has_previous_stage)
+ stage_mask |= 1 << previous_stage;
+
+ /* 1 for each descriptor set */
+ if (!user_sgpr_info->indirect_all_descriptor_sets) {
+ for (unsigned i = 0; i < num_sets; ++i) {
+ if (ctx->options->layout->set[i].layout->shader_stages & stage_mask) {
+ add_user_sgpr_array_argument(args, type,
+ &ctx->descriptor_sets[i]);
+ }
+ }
+ } else {
+ add_user_sgpr_array_argument(args, const_array(type, 32),
+ desc_sets);
+ }
+
+ if (ctx->shader_info->info.needs_push_constants) {
+ /* 1 for push constants and dynamic descriptors */
+ add_user_sgpr_array_argument(args, type,
+ &ctx->push_constants);
+ }
+}
+
+static void
declare_vs_specific_input_sgprs(struct nir_to_llvm_context *ctx,
gl_shader_stage stage,
bool has_previous_stage,
@@ -771,7 +778,10 @@ static void create_function(struct nir_to_llvm_context *ctx,
switch (stage) {
case MESA_SHADER_COMPUTE:
- radv_define_common_user_sgprs_phase1(ctx, stage, has_previous_stage, previous_stage, &user_sgpr_info, &args, &desc_sets);
+ declare_global_input_sgprs(ctx, stage, has_previous_stage,
+ previous_stage, &user_sgpr_info,
+ &args, &desc_sets);
+
if (ctx->shader_info->info.cs.uses_grid_size) {
add_user_sgpr_argument(&args, ctx->ac.v3i32,
&ctx->num_work_groups);
@@ -790,7 +800,9 @@ static void create_function(struct nir_to_llvm_context *ctx,
add_vgpr_argument(&args, ctx->ac.v3i32, &ctx->local_invocation_ids);
break;
case MESA_SHADER_VERTEX:
- radv_define_common_user_sgprs_phase1(ctx, stage, has_previous_stage, previous_stage, &user_sgpr_info, &args, &desc_sets);
+ declare_global_input_sgprs(ctx, stage, has_previous_stage,
+ previous_stage, &user_sgpr_info,
+ &args, &desc_sets);
declare_vs_specific_input_sgprs(ctx, stage, has_previous_stage,
previous_stage, &args);
@@ -814,7 +826,11 @@ static void create_function(struct nir_to_llvm_context *ctx,
add_sgpr_argument(&args, ctx->ac.i32, NULL); // unknown
add_sgpr_argument(&args, ctx->ac.i32, NULL); // unknown
- radv_define_common_user_sgprs_phase1(ctx, stage, has_previous_stage, previous_stage, &user_sgpr_info, &args, &desc_sets);
+ declare_global_input_sgprs(ctx, stage,
+ has_previous_stage,
+ previous_stage,
+ &user_sgpr_info, &args,
+ &desc_sets);
declare_vs_specific_input_sgprs(ctx, stage,
has_previous_stage,
previous_stage, &args);
@@ -833,7 +849,12 @@ static void create_function(struct nir_to_llvm_context *ctx,
declare_vs_input_vgprs(ctx, &args);
} else {
- radv_define_common_user_sgprs_phase1(ctx, stage, has_previous_stage, previous_stage, &user_sgpr_info, &args, &desc_sets);
+ declare_global_input_sgprs(ctx, stage,
+ has_previous_stage,
+ previous_stage,
+ &user_sgpr_info, &args,
+ &desc_sets);
+
add_user_sgpr_argument(&args, ctx->ac.i32, &ctx->tcs_offchip_layout); // tcs offchip layout
add_user_sgpr_argument(&args, ctx->ac.i32, &ctx->tcs_out_offsets); // tcs out offsets
add_user_sgpr_argument(&args, ctx->ac.i32, &ctx->tcs_out_layout); // tcs out layout
@@ -847,7 +868,10 @@ static void create_function(struct nir_to_llvm_context *ctx,
}
break;
case MESA_SHADER_TESS_EVAL:
- radv_define_common_user_sgprs_phase1(ctx, stage, has_previous_stage, previous_stage, &user_sgpr_info, &args, &desc_sets);
+ declare_global_input_sgprs(ctx, stage, has_previous_stage,
+ previous_stage, &user_sgpr_info,
+ &args, &desc_sets);
+
add_user_sgpr_argument(&args, ctx->ac.i32, &ctx->tcs_offchip_layout); // 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))
add_user_sgpr_argument(&args, ctx->ac.i32, &ctx->view_index);
@@ -872,7 +896,11 @@ static void create_function(struct nir_to_llvm_context *ctx,
add_sgpr_argument(&args, ctx->ac.i32, NULL); // unknown
add_sgpr_argument(&args, ctx->ac.i32, NULL); // unknown
- radv_define_common_user_sgprs_phase1(ctx, stage, has_previous_stage, previous_stage, &user_sgpr_info, &args, &desc_sets);
+ declare_global_input_sgprs(ctx, stage,
+ has_previous_stage,
+ previous_stage,
+ &user_sgpr_info, &args,
+ &desc_sets);
if (previous_stage == MESA_SHADER_TESS_EVAL) {
add_user_sgpr_argument(&args, ctx->ac.i32, &ctx->tcs_offchip_layout); // tcs offchip layout
@@ -900,7 +928,12 @@ static void create_function(struct nir_to_llvm_context *ctx,
declare_tes_input_vgprs(ctx, &args);
}
} else {
- radv_define_common_user_sgprs_phase1(ctx, stage, has_previous_stage, previous_stage, &user_sgpr_info, &args, &desc_sets);
+ declare_global_input_sgprs(ctx, stage,
+ has_previous_stage,
+ previous_stage,
+ &user_sgpr_info, &args,
+ &desc_sets);
+
add_user_sgpr_argument(&args, ctx->ac.i32, &ctx->gsvs_ring_stride); // gsvs stride
add_user_sgpr_argument(&args, ctx->ac.i32, &ctx->gsvs_num_entries); // gsvs num entires
if (ctx->shader_info->info.needs_multiview_view_index)
@@ -918,7 +951,10 @@ static void create_function(struct nir_to_llvm_context *ctx,
}
break;
case MESA_SHADER_FRAGMENT:
- radv_define_common_user_sgprs_phase1(ctx, stage, has_previous_stage, previous_stage, &user_sgpr_info, &args, &desc_sets);
+ declare_global_input_sgprs(ctx, stage, has_previous_stage,
+ previous_stage, &user_sgpr_info,
+ &args, &desc_sets);
+
if (ctx->shader_info->info.ps.needs_sample_positions)
add_user_sgpr_argument(&args, ctx->ac.i32, &ctx->sample_pos_offset); /* sample position offset */
add_sgpr_argument(&args, ctx->ac.i32, &ctx->prim_mask); /* prim mask */