From 5a0fcf11f0d82f0bd20cd15addfa8086d715c16b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Fri, 3 Jan 2020 16:20:40 -0500 Subject: [PATCH] radeonsi/gfx10: move s_sendmsg gs_alloc_req to the beginning of shaders This will allow us to merge some IF blocks in shaders. Acked-by: Pierre-Eric Pelloux-Prayer --- src/gallium/drivers/radeonsi/gfx10_shader_ngg.c | 10 +++++++--- src/gallium/drivers/radeonsi/si_shader.c | 5 +++++ src/gallium/drivers/radeonsi/si_shader_internal.h | 1 + 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/radeonsi/gfx10_shader_ngg.c b/src/gallium/drivers/radeonsi/gfx10_shader_ngg.c index b7b7edc46e7..2f6f9fe3cc2 100644 --- a/src/gallium/drivers/radeonsi/gfx10_shader_ngg.c +++ b/src/gallium/drivers/radeonsi/gfx10_shader_ngg.c @@ -123,6 +123,13 @@ static LLVMValueRef ngg_get_vertices_per_prim(struct si_shader_context *ctx, } } +void gfx10_ngg_build_sendmsg_gs_alloc_req(struct si_shader_context *ctx) +{ + ac_build_sendmsg_gs_alloc_req(&ctx->ac, get_wave_id_in_tg(ctx), + ngg_get_vtx_cnt(ctx), + ngg_get_prim_cnt(ctx)); +} + static void build_streamout_vertex(struct si_shader_context *ctx, LLVMValueRef *so_buffer, LLVMValueRef *wg_offset_dw, unsigned stream, LLVMValueRef offset_vtx, @@ -646,9 +653,6 @@ void gfx10_emit_ngg_epilogue(struct ac_shader_abi *abi, ac_build_endif(&ctx->ac, 5400); } - ac_build_sendmsg_gs_alloc_req(&ctx->ac, get_wave_id_in_tg(ctx), - ngg_get_vtx_cnt(ctx), ngg_get_prim_cnt(ctx)); - /* Update query buffer */ if (ctx->screen->use_ngg_streamout && !info->properties[TGSI_PROPERTY_VS_BLIT_SGPRS_AMD]) { diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c index 766d25b396e..592a486424a 100644 --- a/src/gallium/drivers/radeonsi/si_shader.c +++ b/src/gallium/drivers/radeonsi/si_shader.c @@ -2421,6 +2421,11 @@ static bool si_build_main_function(struct si_shader_context *ctx, (shader->key.as_ngg && !shader->key.as_es))) ac_init_exec_full_mask(&ctx->ac); + if ((ctx->type == PIPE_SHADER_VERTEX || + ctx->type == PIPE_SHADER_TESS_EVAL) && + shader->key.as_ngg && !shader->key.as_es) + gfx10_ngg_build_sendmsg_gs_alloc_req(ctx); + if (ctx->type == PIPE_SHADER_TESS_CTRL || ctx->type == PIPE_SHADER_GEOMETRY) { if (ctx->type == PIPE_SHADER_GEOMETRY && shader->key.as_ngg) { diff --git a/src/gallium/drivers/radeonsi/si_shader_internal.h b/src/gallium/drivers/radeonsi/si_shader_internal.h index 80011edb3d5..b8d2ac84fca 100644 --- a/src/gallium/drivers/radeonsi/si_shader_internal.h +++ b/src/gallium/drivers/radeonsi/si_shader_internal.h @@ -299,6 +299,7 @@ void si_llvm_emit_streamout(struct si_shader_context *ctx, unsigned noutput, unsigned stream); void si_create_function(struct si_shader_context *ctx); +void gfx10_ngg_build_sendmsg_gs_alloc_req(struct si_shader_context *ctx); void gfx10_emit_ngg_epilogue(struct ac_shader_abi *abi, unsigned max_outputs, LLVMValueRef *addrs); -- 2.30.2