diff options
Diffstat (limited to 'src/amd/common')
-rw-r--r-- | src/amd/common/ac_nir_to_llvm.c | 26 | ||||
-rw-r--r-- | src/amd/common/ac_shader_info.c | 21 | ||||
-rw-r--r-- | src/amd/common/ac_shader_info.h | 4 |
3 files changed, 43 insertions, 8 deletions
diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c index dbb3b67b511..31b772f5669 100644 --- a/src/amd/common/ac_nir_to_llvm.c +++ b/src/amd/common/ac_nir_to_llvm.c @@ -614,10 +614,12 @@ static void create_function(struct nir_to_llvm_context *ctx) break; case MESA_SHADER_VERTEX: if (!ctx->is_gs_copy_shader) { - arg_types[arg_idx++] = const_array(ctx->v16i8, 16); /* vertex buffers */ + if (ctx->shader_info->info.vs.has_vertex_buffers) + arg_types[arg_idx++] = const_array(ctx->v16i8, 16); /* vertex buffers */ arg_types[arg_idx++] = ctx->i32; // base vertex arg_types[arg_idx++] = ctx->i32; // start instance - arg_types[arg_idx++] = ctx->i32; // draw index + if (ctx->shader_info->info.vs.needs_draw_id) + arg_types[arg_idx++] = ctx->i32; // draw index } user_sgpr_count = arg_idx; if (ctx->options->key.vs.as_es) @@ -773,14 +775,22 @@ static void create_function(struct nir_to_llvm_context *ctx) break; case MESA_SHADER_VERTEX: if (!ctx->is_gs_copy_shader) { - set_userdata_location_shader(ctx, AC_UD_VS_VERTEX_BUFFERS, user_sgpr_idx, 2); - user_sgpr_idx += 2; - ctx->vertex_buffers = LLVMGetParam(ctx->main_function, arg_idx++); - set_userdata_location_shader(ctx, AC_UD_VS_BASE_VERTEX_START_INSTANCE, user_sgpr_idx, 3); - user_sgpr_idx += 3; + if (ctx->shader_info->info.vs.has_vertex_buffers) { + set_userdata_location_shader(ctx, AC_UD_VS_VERTEX_BUFFERS, user_sgpr_idx, 2); + user_sgpr_idx += 2; + ctx->vertex_buffers = LLVMGetParam(ctx->main_function, arg_idx++); + } + unsigned vs_num = 2; + if (ctx->shader_info->info.vs.needs_draw_id) + vs_num++; + + set_userdata_location_shader(ctx, AC_UD_VS_BASE_VERTEX_START_INSTANCE, user_sgpr_idx, vs_num); + user_sgpr_idx += vs_num; + ctx->base_vertex = LLVMGetParam(ctx->main_function, arg_idx++); ctx->start_instance = LLVMGetParam(ctx->main_function, arg_idx++); - ctx->draw_index = LLVMGetParam(ctx->main_function, arg_idx++); + if (ctx->shader_info->info.vs.needs_draw_id) + ctx->draw_index = LLVMGetParam(ctx->main_function, arg_idx++); } if (ctx->options->key.vs.as_es) ctx->es2gs_offset = LLVMGetParam(ctx->main_function, arg_idx++); diff --git a/src/amd/common/ac_shader_info.c b/src/amd/common/ac_shader_info.c index 85252fea146..6ad562505cf 100644 --- a/src/amd/common/ac_shader_info.c +++ b/src/amd/common/ac_shader_info.c @@ -30,6 +30,9 @@ gather_intrinsic_info(nir_intrinsic_instr *instr, struct ac_shader_info *info) case nir_intrinsic_interp_var_at_sample: info->ps.needs_sample_positions = true; break; + case nir_intrinsic_load_draw_id: + info->vs.needs_draw_id = true; + break; default: break; } @@ -49,12 +52,30 @@ gather_info_block(nir_block *block, struct ac_shader_info *info) } } +static void +gather_info_input_decl(nir_shader *nir, + const struct ac_nir_compiler_options *options, + nir_variable *var, + struct ac_shader_info *info) +{ + switch (nir->stage) { + case MESA_SHADER_VERTEX: + info->vs.has_vertex_buffers = true; + break; + default: + break; + } +} + void ac_nir_shader_info_pass(struct nir_shader *nir, const struct ac_nir_compiler_options *options, struct ac_shader_info *info) { struct nir_function *func = (struct nir_function *)exec_list_get_head(&nir->functions); + nir_foreach_variable(variable, &nir->inputs) + gather_info_input_decl(nir, options, variable, info); + nir_foreach_block(block, func->impl) { gather_info_block(block, info); } diff --git a/src/amd/common/ac_shader_info.h b/src/amd/common/ac_shader_info.h index 5576c3b4bac..7e2b6c885a6 100644 --- a/src/amd/common/ac_shader_info.h +++ b/src/amd/common/ac_shader_info.h @@ -29,6 +29,10 @@ struct ac_nir_compiler_options; struct ac_shader_info { struct { + bool has_vertex_buffers; /* needs vertex buffers and base/start */ + bool needs_draw_id; + } vs; + struct { bool needs_sample_positions; } ps; }; |