xref: /aosp_15_r20/external/mesa3d/src/amd/compiler/aco_interface.h (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1 /*
2  * Copyright © 2018 Google
3  *
4  * SPDX-License-Identifier: MIT
5  */
6 
7 #ifndef ACO_INTERFACE_H
8 #define ACO_INTERFACE_H
9 
10 #include "aco_shader_info.h"
11 
12 #include "nir.h"
13 
14 #include "amd_family.h"
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
19 /* Special launch size to indicate this dispatch is a 1D dispatch converted into a 2D one */
20 #define ACO_RT_CONVERTED_2D_LAUNCH_SIZE -1u
21 
22 struct ac_shader_config;
23 struct aco_shader_info;
24 struct aco_vs_prolog_info;
25 struct aco_ps_epilog_info;
26 struct radeon_info;
27 
28 struct aco_compiler_statistic_info {
29    char name[32];
30    char desc[64];
31 };
32 
33 typedef void(aco_callback)(void** priv_ptr, const struct ac_shader_config* config,
34                            const char* llvm_ir_str, unsigned llvm_ir_size, const char* disasm_str,
35                            unsigned disasm_size, uint32_t* statistics, uint32_t stats_size,
36                            uint32_t exec_size, const uint32_t* code, uint32_t code_dw,
37                            const struct aco_symbol* symbols, unsigned num_symbols);
38 
39 typedef void(aco_shader_part_callback)(void** priv_ptr, uint32_t num_sgprs, uint32_t num_vgprs,
40                                        const uint32_t* code, uint32_t code_size,
41                                        const char* disasm_str, uint32_t disasm_size);
42 
43 extern const struct aco_compiler_statistic_info* aco_statistic_infos;
44 
45 void aco_compile_shader(const struct aco_compiler_options* options,
46                         const struct aco_shader_info* info, unsigned shader_count,
47                         struct nir_shader* const* shaders, const struct ac_shader_args* args,
48                         aco_callback* build_binary, void** binary);
49 
50 void aco_compile_rt_prolog(const struct aco_compiler_options* options,
51                            const struct aco_shader_info* info, const struct ac_shader_args* in_args,
52                            const struct ac_shader_args* out_args, aco_callback* build_prolog,
53                            void** binary);
54 
55 void aco_compile_vs_prolog(const struct aco_compiler_options* options,
56                            const struct aco_shader_info* info,
57                            const struct aco_vs_prolog_info* prolog_info,
58                            const struct ac_shader_args* args,
59                            aco_shader_part_callback* build_prolog, void** binary);
60 
61 void aco_compile_ps_epilog(const struct aco_compiler_options* options,
62                            const struct aco_shader_info* info,
63                            const struct aco_ps_epilog_info* epilog_info,
64                            const struct ac_shader_args* args,
65                            aco_shader_part_callback* build_epilog, void** binary);
66 
67 void aco_compile_ps_prolog(const struct aco_compiler_options* options,
68                            const struct aco_shader_info* info,
69                            const struct aco_ps_prolog_info* pinfo,
70                            const struct ac_shader_args* args,
71                            aco_shader_part_callback* build_prolog, void** binary);
72 
73 uint64_t aco_get_codegen_flags();
74 
75 bool aco_is_gpu_supported(const struct radeon_info* info);
76 
77 bool aco_nir_op_supports_packed_math_16bit(const nir_alu_instr* alu);
78 
79 void aco_print_asm(const struct radeon_info *info, unsigned wave_size,
80                    uint32_t *binary, unsigned num_dw);
81 
82 #ifdef __cplusplus
83 }
84 #endif
85 
86 #endif
87