1bf215546Sopenharmony_ci/*
2bf215546Sopenharmony_ci * Copyright © 2018 Google
3bf215546Sopenharmony_ci *
4bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
5bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
6bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation
7bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
9bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
10bf215546Sopenharmony_ci *
11bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next
12bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the
13bf215546Sopenharmony_ci * Software.
14bf215546Sopenharmony_ci *
15bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19bf215546Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20bf215546Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21bf215546Sopenharmony_ci * IN THE SOFTWARE.
22bf215546Sopenharmony_ci *
23bf215546Sopenharmony_ci */
24bf215546Sopenharmony_ci
25bf215546Sopenharmony_ci#ifndef ACO_INTERFACE_H
26bf215546Sopenharmony_ci#define ACO_INTERFACE_H
27bf215546Sopenharmony_ci
28bf215546Sopenharmony_ci#include "nir.h"
29bf215546Sopenharmony_ci
30bf215546Sopenharmony_ci#include "amd_family.h"
31bf215546Sopenharmony_ci
32bf215546Sopenharmony_ci#include "aco_shader_info.h"
33bf215546Sopenharmony_ci#ifdef __cplusplus
34bf215546Sopenharmony_ciextern "C" {
35bf215546Sopenharmony_ci#endif
36bf215546Sopenharmony_ci
37bf215546Sopenharmony_cistruct ac_shader_config;
38bf215546Sopenharmony_cistruct aco_shader_info;
39bf215546Sopenharmony_cistruct aco_vs_prolog_key;
40bf215546Sopenharmony_cistruct aco_ps_epilog_key;
41bf215546Sopenharmony_ci
42bf215546Sopenharmony_cistruct aco_compiler_statistic_info {
43bf215546Sopenharmony_ci   char name[32];
44bf215546Sopenharmony_ci   char desc[64];
45bf215546Sopenharmony_ci};
46bf215546Sopenharmony_ci
47bf215546Sopenharmony_citypedef void (aco_callback)(void **priv_ptr,
48bf215546Sopenharmony_ci                            gl_shader_stage stage,
49bf215546Sopenharmony_ci                            bool is_gs_copy_shader,
50bf215546Sopenharmony_ci                            const struct ac_shader_config *config,
51bf215546Sopenharmony_ci                            const char *llvm_ir_str,
52bf215546Sopenharmony_ci                            unsigned llvm_ir_size,
53bf215546Sopenharmony_ci                            const char *disasm_str,
54bf215546Sopenharmony_ci                            unsigned disasm_size,
55bf215546Sopenharmony_ci                            uint32_t *statistics,
56bf215546Sopenharmony_ci                            uint32_t stats_size,
57bf215546Sopenharmony_ci                            uint32_t exec_size,
58bf215546Sopenharmony_ci                            const uint32_t *code,
59bf215546Sopenharmony_ci                            uint32_t code_dw);
60bf215546Sopenharmony_ci
61bf215546Sopenharmony_citypedef void (aco_shader_part_callback)(void **priv_ptr,
62bf215546Sopenharmony_ci                                        uint32_t num_sgprs,
63bf215546Sopenharmony_ci                                        uint32_t num_vgprs,
64bf215546Sopenharmony_ci                                        uint32_t num_preserved_sgprs,
65bf215546Sopenharmony_ci                                        const uint32_t *code,
66bf215546Sopenharmony_ci                                        uint32_t code_size,
67bf215546Sopenharmony_ci                                        const char *disasm_str,
68bf215546Sopenharmony_ci                                        uint32_t disasm_size);
69bf215546Sopenharmony_ci
70bf215546Sopenharmony_ciextern const unsigned aco_num_statistics;
71bf215546Sopenharmony_ciextern const struct aco_compiler_statistic_info* aco_statistic_infos;
72bf215546Sopenharmony_ci
73bf215546Sopenharmony_civoid aco_compile_shader(const struct aco_compiler_options* options,
74bf215546Sopenharmony_ci                        const struct aco_shader_info* info,
75bf215546Sopenharmony_ci                        unsigned shader_count, struct nir_shader* const* shaders,
76bf215546Sopenharmony_ci                        const struct radv_shader_args *args,
77bf215546Sopenharmony_ci                        aco_callback *build_binary,
78bf215546Sopenharmony_ci                        void **binary);
79bf215546Sopenharmony_ci
80bf215546Sopenharmony_civoid aco_compile_vs_prolog(const struct aco_compiler_options* options,
81bf215546Sopenharmony_ci                           const struct aco_shader_info* info,
82bf215546Sopenharmony_ci                           const struct aco_vs_prolog_key* key,
83bf215546Sopenharmony_ci                           const struct radv_shader_args* args,
84bf215546Sopenharmony_ci                           aco_shader_part_callback *build_prolog,
85bf215546Sopenharmony_ci                           void **binary);
86bf215546Sopenharmony_ci
87bf215546Sopenharmony_civoid aco_compile_ps_epilog(const struct aco_compiler_options* options,
88bf215546Sopenharmony_ci                           const struct aco_shader_info* info,
89bf215546Sopenharmony_ci                           const struct aco_ps_epilog_key* key,
90bf215546Sopenharmony_ci                           const struct radv_shader_args* args,
91bf215546Sopenharmony_ci                           aco_shader_part_callback* build_epilog,
92bf215546Sopenharmony_ci                           void** binary);
93bf215546Sopenharmony_ci
94bf215546Sopenharmony_ciuint64_t aco_get_codegen_flags();
95bf215546Sopenharmony_ci
96bf215546Sopenharmony_ci#ifdef __cplusplus
97bf215546Sopenharmony_ci}
98bf215546Sopenharmony_ci#endif
99bf215546Sopenharmony_ci
100bf215546Sopenharmony_ci#endif
101