1bf215546Sopenharmony_ci/*
2bf215546Sopenharmony_ci * Copyright © 2016 Red Hat.
3bf215546Sopenharmony_ci * Copyright © 2016 Bas Nieuwenhuizen
4bf215546Sopenharmony_ci *
5bf215546Sopenharmony_ci * based in part on anv driver which is:
6bf215546Sopenharmony_ci * Copyright © 2015 Intel Corporation
7bf215546Sopenharmony_ci *
8bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
9bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
10bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation
11bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
13bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
14bf215546Sopenharmony_ci *
15bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next
16bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the
17bf215546Sopenharmony_ci * Software.
18bf215546Sopenharmony_ci *
19bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
22bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23bf215546Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24bf215546Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
25bf215546Sopenharmony_ci * IN THE SOFTWARE.
26bf215546Sopenharmony_ci */
27bf215546Sopenharmony_ci#ifndef ACO_SHADER_INFO_H
28bf215546Sopenharmony_ci#define ACO_SHADER_INFO_H
29bf215546Sopenharmony_ci
30bf215546Sopenharmony_ci#include "shader_enums.h"
31bf215546Sopenharmony_ci
32bf215546Sopenharmony_ci#ifdef __cplusplus
33bf215546Sopenharmony_ciextern "C" {
34bf215546Sopenharmony_ci#endif
35bf215546Sopenharmony_ci
36bf215546Sopenharmony_ci#define ACO_MAX_SO_OUTPUTS 64
37bf215546Sopenharmony_ci#define ACO_MAX_SO_BUFFERS 4
38bf215546Sopenharmony_ci#define ACO_MAX_VERTEX_ATTRIBS 32
39bf215546Sopenharmony_ci#define ACO_MAX_VBS 32
40bf215546Sopenharmony_ci
41bf215546Sopenharmony_cistruct aco_vs_input_state {
42bf215546Sopenharmony_ci   uint32_t instance_rate_inputs;
43bf215546Sopenharmony_ci   uint32_t nontrivial_divisors;
44bf215546Sopenharmony_ci   uint32_t post_shuffle;
45bf215546Sopenharmony_ci   /* Having two separate fields instead of a single uint64_t makes it easier to remove attributes
46bf215546Sopenharmony_ci    * using bitwise arithmetic.
47bf215546Sopenharmony_ci    */
48bf215546Sopenharmony_ci   uint32_t alpha_adjust_lo;
49bf215546Sopenharmony_ci   uint32_t alpha_adjust_hi;
50bf215546Sopenharmony_ci
51bf215546Sopenharmony_ci   uint32_t divisors[ACO_MAX_VERTEX_ATTRIBS];
52bf215546Sopenharmony_ci   uint8_t formats[ACO_MAX_VERTEX_ATTRIBS];
53bf215546Sopenharmony_ci};
54bf215546Sopenharmony_ci
55bf215546Sopenharmony_cistruct aco_vs_prolog_key {
56bf215546Sopenharmony_ci   struct aco_vs_input_state state;
57bf215546Sopenharmony_ci   unsigned num_attributes;
58bf215546Sopenharmony_ci   uint32_t misaligned_mask;
59bf215546Sopenharmony_ci   bool is_ngg;
60bf215546Sopenharmony_ci   gl_shader_stage next_stage;
61bf215546Sopenharmony_ci};
62bf215546Sopenharmony_ci
63bf215546Sopenharmony_cistruct aco_ps_epilog_key {
64bf215546Sopenharmony_ci   uint32_t spi_shader_col_format;
65bf215546Sopenharmony_ci
66bf215546Sopenharmony_ci   /* Bitmasks, each bit represents one of the 8 MRTs. */
67bf215546Sopenharmony_ci   uint8_t color_is_int8;
68bf215546Sopenharmony_ci   uint8_t color_is_int10;
69bf215546Sopenharmony_ci   uint8_t enable_mrt_output_nan_fixup;
70bf215546Sopenharmony_ci};
71bf215546Sopenharmony_ci
72bf215546Sopenharmony_cistruct aco_vp_output_info {
73bf215546Sopenharmony_ci   uint8_t vs_output_param_offset[VARYING_SLOT_MAX];
74bf215546Sopenharmony_ci   uint8_t clip_dist_mask;
75bf215546Sopenharmony_ci   uint8_t cull_dist_mask;
76bf215546Sopenharmony_ci   uint8_t param_exports;
77bf215546Sopenharmony_ci   uint8_t prim_param_exports;
78bf215546Sopenharmony_ci   bool writes_pointsize;
79bf215546Sopenharmony_ci   bool writes_layer;
80bf215546Sopenharmony_ci   bool writes_layer_per_primitive;
81bf215546Sopenharmony_ci   bool writes_viewport_index;
82bf215546Sopenharmony_ci   bool writes_viewport_index_per_primitive;
83bf215546Sopenharmony_ci   bool writes_primitive_shading_rate;
84bf215546Sopenharmony_ci   bool writes_primitive_shading_rate_per_primitive;
85bf215546Sopenharmony_ci   bool export_prim_id;
86bf215546Sopenharmony_ci   bool export_clip_dists;
87bf215546Sopenharmony_ci};
88bf215546Sopenharmony_ci
89bf215546Sopenharmony_cistruct aco_stream_output {
90bf215546Sopenharmony_ci   uint8_t location;
91bf215546Sopenharmony_ci   uint8_t buffer;
92bf215546Sopenharmony_ci   uint16_t offset;
93bf215546Sopenharmony_ci   uint8_t component_mask;
94bf215546Sopenharmony_ci   uint8_t stream;
95bf215546Sopenharmony_ci};
96bf215546Sopenharmony_ci
97bf215546Sopenharmony_cistruct aco_streamout_info {
98bf215546Sopenharmony_ci   uint16_t num_outputs;
99bf215546Sopenharmony_ci   struct aco_stream_output outputs[ACO_MAX_SO_OUTPUTS];
100bf215546Sopenharmony_ci   uint16_t strides[ACO_MAX_SO_BUFFERS];
101bf215546Sopenharmony_ci};
102bf215546Sopenharmony_ci
103bf215546Sopenharmony_cistruct aco_shader_info {
104bf215546Sopenharmony_ci   uint8_t wave_size;
105bf215546Sopenharmony_ci   bool is_ngg;
106bf215546Sopenharmony_ci   bool has_ngg_culling;
107bf215546Sopenharmony_ci   bool has_ngg_early_prim_export;
108bf215546Sopenharmony_ci   uint32_t num_tess_patches;
109bf215546Sopenharmony_ci   unsigned workgroup_size;
110bf215546Sopenharmony_ci   struct {
111bf215546Sopenharmony_ci      struct aco_vp_output_info outinfo;
112bf215546Sopenharmony_ci      bool as_es;
113bf215546Sopenharmony_ci      bool as_ls;
114bf215546Sopenharmony_ci      bool tcs_in_out_eq;
115bf215546Sopenharmony_ci      uint64_t tcs_temp_only_input_mask;
116bf215546Sopenharmony_ci      bool use_per_attribute_vb_descs;
117bf215546Sopenharmony_ci      uint32_t vb_desc_usage_mask;
118bf215546Sopenharmony_ci      bool has_prolog;
119bf215546Sopenharmony_ci      bool dynamic_inputs;
120bf215546Sopenharmony_ci   } vs;
121bf215546Sopenharmony_ci   struct {
122bf215546Sopenharmony_ci      uint8_t output_usage_mask[VARYING_SLOT_VAR31 + 1];
123bf215546Sopenharmony_ci      uint8_t num_stream_output_components[4];
124bf215546Sopenharmony_ci      uint8_t output_streams[VARYING_SLOT_VAR31 + 1];
125bf215546Sopenharmony_ci      unsigned vertices_out;
126bf215546Sopenharmony_ci   } gs;
127bf215546Sopenharmony_ci   struct {
128bf215546Sopenharmony_ci      uint32_t num_lds_blocks;
129bf215546Sopenharmony_ci   } tcs;
130bf215546Sopenharmony_ci   struct {
131bf215546Sopenharmony_ci      struct aco_vp_output_info outinfo;
132bf215546Sopenharmony_ci      bool as_es;
133bf215546Sopenharmony_ci   } tes;
134bf215546Sopenharmony_ci   struct {
135bf215546Sopenharmony_ci      bool writes_z;
136bf215546Sopenharmony_ci      bool writes_stencil;
137bf215546Sopenharmony_ci      bool writes_sample_mask;
138bf215546Sopenharmony_ci      bool has_epilog;
139bf215546Sopenharmony_ci      uint32_t num_interp;
140bf215546Sopenharmony_ci      unsigned spi_ps_input;
141bf215546Sopenharmony_ci   } ps;
142bf215546Sopenharmony_ci   struct {
143bf215546Sopenharmony_ci      uint8_t subgroup_size;
144bf215546Sopenharmony_ci   } cs;
145bf215546Sopenharmony_ci   struct {
146bf215546Sopenharmony_ci      struct aco_vp_output_info outinfo;
147bf215546Sopenharmony_ci   } ms;
148bf215546Sopenharmony_ci   struct aco_streamout_info so;
149bf215546Sopenharmony_ci
150bf215546Sopenharmony_ci   uint32_t gfx9_gs_ring_lds_size;
151bf215546Sopenharmony_ci};
152bf215546Sopenharmony_ci
153bf215546Sopenharmony_cienum aco_compiler_debug_level {
154bf215546Sopenharmony_ci   ACO_COMPILER_DEBUG_LEVEL_PERFWARN,
155bf215546Sopenharmony_ci   ACO_COMPILER_DEBUG_LEVEL_ERROR,
156bf215546Sopenharmony_ci};
157bf215546Sopenharmony_ci
158bf215546Sopenharmony_cistruct aco_stage_input {
159bf215546Sopenharmony_ci   uint32_t optimisations_disabled : 1;
160bf215546Sopenharmony_ci   uint32_t image_2d_view_of_3d : 1;
161bf215546Sopenharmony_ci   struct {
162bf215546Sopenharmony_ci      uint32_t instance_rate_inputs;
163bf215546Sopenharmony_ci      uint32_t instance_rate_divisors[ACO_MAX_VERTEX_ATTRIBS];
164bf215546Sopenharmony_ci      uint8_t vertex_attribute_formats[ACO_MAX_VERTEX_ATTRIBS];
165bf215546Sopenharmony_ci      uint32_t vertex_attribute_bindings[ACO_MAX_VERTEX_ATTRIBS];
166bf215546Sopenharmony_ci      uint32_t vertex_attribute_offsets[ACO_MAX_VERTEX_ATTRIBS];
167bf215546Sopenharmony_ci      uint32_t vertex_attribute_strides[ACO_MAX_VERTEX_ATTRIBS];
168bf215546Sopenharmony_ci      uint8_t vertex_binding_align[ACO_MAX_VBS];
169bf215546Sopenharmony_ci   } vs;
170bf215546Sopenharmony_ci
171bf215546Sopenharmony_ci   struct {
172bf215546Sopenharmony_ci      unsigned tess_input_vertices;
173bf215546Sopenharmony_ci   } tcs;
174bf215546Sopenharmony_ci
175bf215546Sopenharmony_ci   struct {
176bf215546Sopenharmony_ci      uint32_t col_format;
177bf215546Sopenharmony_ci      uint8_t num_samples;
178bf215546Sopenharmony_ci
179bf215546Sopenharmony_ci      /* Used to export alpha through MRTZ for alpha-to-coverage (GFX11+). */
180bf215546Sopenharmony_ci      bool alpha_to_coverage_via_mrtz;
181bf215546Sopenharmony_ci   } ps;
182bf215546Sopenharmony_ci};
183bf215546Sopenharmony_ci
184bf215546Sopenharmony_cistruct aco_compiler_options {
185bf215546Sopenharmony_ci   struct aco_stage_input key;
186bf215546Sopenharmony_ci   bool robust_buffer_access;
187bf215546Sopenharmony_ci   bool dump_shader;
188bf215546Sopenharmony_ci   bool dump_preoptir;
189bf215546Sopenharmony_ci   bool record_ir;
190bf215546Sopenharmony_ci   bool record_stats;
191bf215546Sopenharmony_ci   bool has_ls_vgpr_init_bug;
192bf215546Sopenharmony_ci   bool wgp_mode;
193bf215546Sopenharmony_ci   enum radeon_family family;
194bf215546Sopenharmony_ci   enum amd_gfx_level gfx_level;
195bf215546Sopenharmony_ci   uint32_t address32_hi;
196bf215546Sopenharmony_ci   struct {
197bf215546Sopenharmony_ci      void (*func)(void *private_data, enum aco_compiler_debug_level level, const char *message);
198bf215546Sopenharmony_ci      void *private_data;
199bf215546Sopenharmony_ci   } debug;
200bf215546Sopenharmony_ci};
201bf215546Sopenharmony_ci
202bf215546Sopenharmony_ci#ifdef __cplusplus
203bf215546Sopenharmony_ci}
204bf215546Sopenharmony_ci#endif
205bf215546Sopenharmony_ci#endif
206