radeonsi: add nir support for gs epilogue
authorTimothy Arceri <tarceri@itsqueeze.com>
Thu, 9 Nov 2017 02:34:37 +0000 (13:34 +1100)
committerTimothy Arceri <tarceri@itsqueeze.com>
Mon, 4 Dec 2017 01:52:18 +0000 (12:52 +1100)
v2: add emit_gs_epilogue() helper function to reduce duplication.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/gallium/drivers/radeonsi/si_shader.c

index aa9af1541de9ef4ddd6c0e970e4e05b1025eda0e..e8b4ec7b98633422e2d894c33bac0b394d529998 100644 (file)
@@ -3247,10 +3247,8 @@ static LLVMValueRef si_get_gs_wave_id(struct si_shader_context *ctx)
                return LLVMGetParam(ctx->main_fn, ctx->param_gs_wave_id);
 }
 
                return LLVMGetParam(ctx->main_fn, ctx->param_gs_wave_id);
 }
 
-static void si_llvm_emit_gs_epilogue(struct lp_build_tgsi_context *bld_base)
+static void emit_gs_epilogue(struct si_shader_context *ctx)
 {
 {
-       struct si_shader_context *ctx = si_shader_context(bld_base);
-
        ac_build_sendmsg(&ctx->ac, AC_SENDMSG_GS_OP_NOP | AC_SENDMSG_GS_DONE,
                         si_get_gs_wave_id(ctx));
 
        ac_build_sendmsg(&ctx->ac, AC_SENDMSG_GS_OP_NOP | AC_SENDMSG_GS_DONE,
                         si_get_gs_wave_id(ctx));
 
@@ -3258,6 +3256,24 @@ static void si_llvm_emit_gs_epilogue(struct lp_build_tgsi_context *bld_base)
                lp_build_endif(&ctx->merged_wrap_if_state);
 }
 
                lp_build_endif(&ctx->merged_wrap_if_state);
 }
 
+static void si_llvm_emit_gs_epilogue(struct ac_shader_abi *abi,
+                                    unsigned max_outputs,
+                                    LLVMValueRef *addrs)
+{
+       struct si_shader_context *ctx = si_shader_context_from_abi(abi);
+       struct tgsi_shader_info UNUSED *info = &ctx->shader->selector->info;
+
+       assert(info->num_outputs <= max_outputs);
+
+       emit_gs_epilogue(ctx);
+}
+
+static void si_tgsi_emit_gs_epilogue(struct lp_build_tgsi_context *bld_base)
+{
+       struct si_shader_context *ctx = si_shader_context(bld_base);
+       emit_gs_epilogue(ctx);
+}
+
 static void si_llvm_emit_vs_epilogue(struct ac_shader_abi *abi,
                                     unsigned max_outputs,
                                     LLVMValueRef *addrs)
 static void si_llvm_emit_vs_epilogue(struct ac_shader_abi *abi,
                                     unsigned max_outputs,
                                     LLVMValueRef *addrs)
@@ -5758,7 +5774,8 @@ static bool si_compile_tgsi_main(struct si_shader_context *ctx,
        case PIPE_SHADER_GEOMETRY:
                bld_base->emit_fetch_funcs[TGSI_FILE_INPUT] = fetch_input_gs;
                ctx->abi.emit_vertex = si_llvm_emit_vertex;
        case PIPE_SHADER_GEOMETRY:
                bld_base->emit_fetch_funcs[TGSI_FILE_INPUT] = fetch_input_gs;
                ctx->abi.emit_vertex = si_llvm_emit_vertex;
-               bld_base->emit_epilogue = si_llvm_emit_gs_epilogue;
+               ctx->abi.emit_outputs = si_llvm_emit_gs_epilogue;
+               bld_base->emit_epilogue = si_tgsi_emit_gs_epilogue;
                break;
        case PIPE_SHADER_FRAGMENT:
                ctx->load_input = declare_input_fs;
                break;
        case PIPE_SHADER_FRAGMENT:
                ctx->load_input = declare_input_fs;