From 8c3ab49c6b48299935751009c4109a4d2a3b8912 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Timur=20Krist=C3=B3f?= Date: Mon, 24 Feb 2020 15:27:43 +0100 Subject: [PATCH] aco: Don't generate an if when the first part of a merged HS or GS is empty. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit In some cases (eg. in a few tessellation CTS tests) the VS part of a merged HS is completely empty. Let's not generate a divergent if in these cases. (LLVM also doesn't do it.) No pipeline DB changes, only affects the CTS. Signed-off-by: Timur Kristóf Reviewed-by: Rhys Perry Part-of: --- src/amd/compiler/aco_instruction_selection.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/amd/compiler/aco_instruction_selection.cpp b/src/amd/compiler/aco_instruction_selection.cpp index e8902ecdde6..62d14e6f824 100644 --- a/src/amd/compiler/aco_instruction_selection.cpp +++ b/src/amd/compiler/aco_instruction_selection.cpp @@ -9598,8 +9598,16 @@ void select_program(Program *program, split_arguments(&ctx, startpgm); } + /* In a merged VS+TCS HS, the VS implementation can be completely empty. */ + nir_function_impl *func = nir_shader_get_entrypoint(nir); + bool empty_shader = nir_cf_list_is_empty_block(&func->body) && + ((nir->info.stage == MESA_SHADER_VERTEX && + (ctx.stage == vertex_tess_control_hs || ctx.stage == vertex_geometry_gs)) || + (nir->info.stage == MESA_SHADER_TESS_EVAL && + ctx.stage == tess_eval_geometry_gs)); + if_context ic; - if (shader_count >= 2) { + if (shader_count >= 2 && !empty_shader) { Builder bld(ctx.program, ctx.block); Temp count = bld.sop2(aco_opcode::s_bfe_u32, bld.def(s1), bld.def(s1, scc), get_arg(&ctx, args->merged_wave_info), Operand((8u << 16) | (i * 8u))); Temp thread_id = emit_mbcnt(&ctx, bld.def(v1)); @@ -9623,7 +9631,6 @@ void select_program(Program *program, if (ctx.stage == fragment_fs) handle_bc_optimize(&ctx); - nir_function_impl *func = nir_shader_get_entrypoint(nir); visit_cf_list(&ctx, &func->body); if (ctx.program->info->so.num_outputs && (ctx.stage == vertex_vs || ctx.stage == tess_eval_vs)) @@ -9642,7 +9649,7 @@ void select_program(Program *program, if (ctx.stage == fragment_fs) create_fs_exports(&ctx); - if (shader_count >= 2) { + if (shader_count >= 2 && !empty_shader) { begin_divergent_if_else(&ctx, &ic); end_divergent_if(&ctx, &ic); } -- 2.30.2