ac/nir: Emit legacy GS DONE signal in NIR.

Legacy GS needs to emit a DONE signal at the end. Do this in NIR
instead of in the backends.

Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
Reviewed-by: Qiang Yu <yuq825@gmail.com>
Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22690>
This commit is contained in:
Timur Kristóf
2023-04-25 18:38:12 +02:00
committed by Marge Bot
parent fffb2b33af
commit 025c1f5174
4 changed files with 12 additions and 47 deletions

View File

@@ -1100,6 +1100,18 @@ ac_nir_lower_legacy_gs(nir_shader *nir,
64,
s.vertex_count,
s.primitive_count);
/* Wait for all stores to finish. */
nir_scoped_barrier(b, .execution_scope = NIR_SCOPE_INVOCATION,
.memory_scope = NIR_SCOPE_DEVICE,
.memory_semantics = NIR_MEMORY_RELEASE,
.memory_modes = nir_var_shader_out | nir_var_mem_ssbo |
nir_var_mem_global | nir_var_image);
/* Signal that the GS is done. */
nir_sendmsg_amd(b, nir_load_gs_wave_id_amd(b),
.base = AC_SENDMSG_GS_OP_NOP | AC_SENDMSG_GS_DONE);
if (progress)
nir_metadata_preserve(impl, nir_metadata_none);
}

View File

@@ -11421,14 +11421,6 @@ select_program(Program* program, unsigned shader_count, struct nir_shader* const
visit_cf_list(&ctx, &func->body);
if (nir->info.stage == MESA_SHADER_GEOMETRY && !ngg_gs) {
Builder bld(ctx.program, ctx.block);
bld.barrier(aco_opcode::p_barrier,
memory_sync_info(storage_vmem_output, semantic_release, scope_device));
bld.sopp(aco_opcode::s_sendmsg, bld.m0(ctx.gs_wave_id), -1,
sendmsg_gs_done(false, false, 0));
}
if (ctx.stage == fragment_fs && ctx.program->info.ps.has_epilog) {
create_fs_jump_to_epilog(&ctx);

View File

@@ -280,37 +280,6 @@ radv_load_output(struct radv_shader_context *ctx, unsigned index, unsigned chan)
return LLVMBuildLoad2(ctx->ac.builder, type, output, "");
}
static void
emit_gs_epilogue(struct radv_shader_context *ctx)
{
if (ctx->ac.gfx_level >= GFX10)
ac_build_waitcnt(&ctx->ac, AC_WAIT_VSTORE);
ac_build_sendmsg(&ctx->ac, AC_SENDMSG_GS_OP_NOP | AC_SENDMSG_GS_DONE, ctx->gs_wave_id);
}
static void
handle_shader_outputs_post(struct ac_shader_abi *abi)
{
struct radv_shader_context *ctx = radv_shader_context_from_abi(abi);
switch (ctx->stage) {
case MESA_SHADER_VERTEX:
case MESA_SHADER_TESS_CTRL:
case MESA_SHADER_TESS_EVAL:
case MESA_SHADER_FRAGMENT:
break; /* Lowered in NIR */
case MESA_SHADER_GEOMETRY:
if (ctx->shader_info->is_ngg)
break; /* Lowered in NIR */
else
emit_gs_epilogue(ctx);
break;
default:
break;
}
}
static void
ac_llvm_finalize_module(struct radv_shader_context *ctx, LLVMPassManagerRef passmgr)
{
@@ -523,9 +492,6 @@ ac_translate_nir_to_llvm(struct ac_llvm_compiler *ac_llvm,
abort();
}
if (!gl_shader_stage_is_compute(shaders[shader_idx]->info.stage))
handle_shader_outputs_post(&ctx.abi);
if (check_merged_wave_info) {
LLVMBuildBr(ctx.ac.builder, merge_block);
LLVMPositionBuilderAtEnd(ctx.ac.builder, merge_block);

View File

@@ -98,11 +98,6 @@ static LLVMValueRef si_get_gs_wave_id(struct si_shader_context *ctx)
void si_llvm_gs_build_end(struct si_shader_context *ctx)
{
if (ctx->screen->info.gfx_level >= GFX10)
ac_build_waitcnt(&ctx->ac, AC_WAIT_VSTORE);
ac_build_sendmsg(&ctx->ac, AC_SENDMSG_GS_OP_NOP | AC_SENDMSG_GS_DONE, si_get_gs_wave_id(ctx));
if (ctx->screen->info.gfx_level >= GFX9)
ac_build_endif(&ctx->ac, ctx->merged_wrap_if_label);
}