aco: extract aco_compile_shader_part from aco_compile_ps_epilog
authorQiang Yu <yuq825@gmail.com>
Wed, 2 Aug 2023 06:23:57 +0000 (08:23 +0200)
committerMarge Bot <emma+marge@anholt.net>
Wed, 2 Aug 2023 07:29:50 +0000 (07:29 +0000)
Will be shared with radeonsi tcs epilog and other shader parts build.

Signed-off-by: Qiang Yu <yuq825@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24417>

src/amd/compiler/aco_instruction_selection.cpp
src/amd/compiler/aco_interface.cpp
src/amd/compiler/aco_ir.h

index 6080f7b..fef2746 100644 (file)
@@ -11944,10 +11944,11 @@ select_vs_prolog(Program* program, const struct aco_vs_prolog_info* pinfo, ac_sh
 }
 
 void
-select_ps_epilog(Program* program, const struct aco_ps_epilog_info* einfo, ac_shader_config* config,
+select_ps_epilog(Program* program, void* pinfo, ac_shader_config* config,
                  const struct aco_compiler_options* options, const struct aco_shader_info* info,
                  const struct ac_shader_args* args)
 {
+   const struct aco_ps_epilog_info* einfo = (const struct aco_ps_epilog_info*)pinfo;
    isel_context ctx = setup_isel_context(program, 0, NULL, config, options, info, args, true);
 
    ctx.block->fp_mode = program->next_fp_mode;
index 45bf4aa..40995cc 100644 (file)
@@ -334,11 +334,17 @@ aco_compile_vs_prolog(const struct aco_compiler_options* options,
                    disasm.data(), disasm.size());
 }
 
-void
-aco_compile_ps_epilog(const struct aco_compiler_options* options,
-                      const struct aco_shader_info* info, const struct aco_ps_epilog_info* pinfo,
-                      const struct ac_shader_args* args, aco_shader_part_callback* build_epilog,
-                      void** binary)
+typedef void(select_shader_part_callback)(aco::Program* program, void* pinfo,
+                                          ac_shader_config* config,
+                                          const struct aco_compiler_options* options,
+                                          const struct aco_shader_info* info,
+                                          const struct ac_shader_args* args);
+
+static void
+aco_compile_shader_part(const struct aco_compiler_options* options,
+                        const struct aco_shader_info* info, const struct ac_shader_args* args,
+                        select_shader_part_callback select_shader_part, void* pinfo,
+                        aco_shader_part_callback* build_epilog, void** binary)
 {
    aco::init();
 
@@ -353,7 +359,7 @@ aco_compile_ps_epilog(const struct aco_compiler_options* options,
    program->debug.private_data = options->debug.private_data;
 
    /* Instruction selection */
-   aco::select_ps_epilog(program.get(), pinfo, &config, options, info, args);
+   select_shader_part(program.get(), pinfo, &config, options, info, args);
 
    aco_postprocess_shader(options, info, program);
 
@@ -370,3 +376,13 @@ aco_compile_ps_epilog(const struct aco_compiler_options* options,
    (*build_epilog)(binary, config.num_sgprs, config.num_vgprs, code.data(), code.size(),
                    disasm.data(), disasm.size());
 }
+
+void
+aco_compile_ps_epilog(const struct aco_compiler_options* options,
+                      const struct aco_shader_info* info, const struct aco_ps_epilog_info* pinfo,
+                      const struct ac_shader_args* args, aco_shader_part_callback* build_epilog,
+                      void** binary)
+{
+   aco_compile_shader_part(options, info, args, aco::select_ps_epilog, (void*)pinfo, build_epilog,
+                           binary);
+}
index e5adf95..775e82d 100644 (file)
@@ -2228,8 +2228,8 @@ void select_vs_prolog(Program* program, const struct aco_vs_prolog_info* pinfo,
                       ac_shader_config* config, const struct aco_compiler_options* options,
                       const struct aco_shader_info* info, const struct ac_shader_args* args);
 
-void select_ps_epilog(Program* program, const struct aco_ps_epilog_info* epilog_info,
-                      ac_shader_config* config, const struct aco_compiler_options* options,
+void select_ps_epilog(Program* program, void* pinfo, ac_shader_config* config,
+                      const struct aco_compiler_options* options,
                       const struct aco_shader_info* info, const struct ac_shader_args* args);
 
 void lower_phis(Program* program);