radeonsi/gfx10: move s_sendmsg gs_alloc_req to the beginning of shaders
authorMarek Olšák <marek.olsak@amd.com>
Fri, 3 Jan 2020 21:20:40 +0000 (16:20 -0500)
committerMarek Olšák <marek.olsak@amd.com>
Mon, 20 Jan 2020 21:16:11 +0000 (16:16 -0500)
This will allow us to merge some IF blocks in shaders.

Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
src/gallium/drivers/radeonsi/gfx10_shader_ngg.c
src/gallium/drivers/radeonsi/si_shader.c
src/gallium/drivers/radeonsi/si_shader_internal.h

index b7b7edc46e7146901169bb1a58951de02b61ca52..2f6f9fe3cc2a384df05df8cee03481b96c44f394 100644 (file)
@@ -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]) {
index 766d25b396e5136ad96fc7527afd036ecaad6d81..592a486424ac821588ec13f964733a7c5ca9c31d 100644 (file)
@@ -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) {
index 80011edb3d5dcb861be81e50fc125476bec07179..b8d2ac84fca54e55728ae0ff66d34257078e4d51 100644 (file)
@@ -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);