aco: fix emitting TCS epilogs end on GFX9+
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Tue, 22 Aug 2023 18:36:57 +0000 (20:36 +0200)
committerMarge Bot <emma+marge@anholt.net>
Tue, 29 Aug 2023 09:30:07 +0000 (09:30 +0000)
With merged shaders, the long-jump should be emitted inside the
divergent if (ie. only for TCS invocations) and other non TCS
invocations should just end the program.

This fixes a bunch of failures with CTS by forcing TCS epilogs on
RDNA2.

Not sure how RadeonSI will handle that but maybe doing the merged
wave info thing in epilogs would help.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24832>

src/amd/compiler/aco_instruction_selection.cpp

index 70393d7..2e4f7af 100644 (file)
@@ -11530,11 +11530,6 @@ select_shader(isel_context& ctx, nir_shader* nir, const bool need_startpgm, cons
    nir_function_impl* func = nir_shader_get_entrypoint(nir);
    visit_cf_list(&ctx, &func->body);
 
-   if (endif_merged_wave_info) {
-      begin_divergent_if_else(&ctx, ic_merged_wave_info);
-      end_divergent_if(&ctx, ic_merged_wave_info);
-   }
-
    if (ctx.program->info.has_epilog) {
       if (ctx.stage == fragment_fs) {
          create_fs_jump_to_epilog(&ctx);
@@ -11551,6 +11546,11 @@ select_shader(isel_context& ctx, nir_shader* nir, const bool need_startpgm, cons
       }
    }
 
+   if (endif_merged_wave_info) {
+      begin_divergent_if_else(&ctx, ic_merged_wave_info);
+      end_divergent_if(&ctx, ic_merged_wave_info);
+   }
+
    if ((ctx.stage.sw == SWStage::VS &&
         (ctx.stage.hw == AC_HW_HULL_SHADER || ctx.stage.hw == AC_HW_LEGACY_GEOMETRY_SHADER)) ||
        (ctx.stage.sw == SWStage::TES && ctx.stage.hw == AC_HW_LEGACY_GEOMETRY_SHADER)) {
@@ -11714,7 +11714,9 @@ select_program(Program* program, unsigned shader_count, struct nir_shader* const
    append_logical_end(ctx.block);
    ctx.block->kind |= block_kind_uniform;
 
-   if (!ctx.program->info.has_epilog) {
+   if (!ctx.program->info.has_epilog ||
+       (shaders[shader_count - 1]->info.stage == MESA_SHADER_TESS_CTRL &&
+        options->gfx_level >= GFX9)) {
       Builder bld(ctx.program, ctx.block);
       bld.sopp(aco_opcode::s_endpgm);
    }