1 /*
2 * Copyright © 2019 Valve Corporation.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 */
23
24 #ifndef RADV_SHADER_ARGS_H
25 #define RADV_SHADER_ARGS_H
26
27 #include "compiler/shader_enums.h"
28 #include "util/list.h"
29 #include "util/macros.h"
30 #include "ac_shader_args.h"
31 #include "amd_family.h"
32 #include "radv_constants.h"
33 #include "radv_shader.h"
34
35 struct radv_shader_args {
36 struct ac_shader_args ac;
37
38 struct ac_arg descriptor_sets[MAX_SETS];
39 /* User data 2/3. same as ring_offsets but for task shaders. */
40 struct ac_arg task_ring_offsets;
41
42 /* Streamout */
43 struct ac_arg streamout_buffers;
44
45 /* Emulated query */
46 struct ac_arg shader_query_state;
47
48 /* NGG */
49 struct ac_arg ngg_provoking_vtx;
50
51 /* NGG GS */
52 struct ac_arg ngg_culling_settings;
53 struct ac_arg ngg_viewport_scale[2];
54 struct ac_arg ngg_viewport_translate[2];
55
56 /* Fragment shaders */
57 struct ac_arg ps_epilog_pc;
58 struct ac_arg ps_state;
59
60 struct ac_arg prolog_inputs;
61 struct ac_arg vs_inputs[MAX_VERTEX_ATTRIBS];
62
63 /* PS epilogs */
64 struct ac_arg colors[MAX_RTS];
65 struct ac_arg depth;
66 struct ac_arg stencil;
67 struct ac_arg sample_mask;
68
69 /* TCS */
70 /* # [0:5] = the number of patch control points
71 * # [6:11] = the number of tessellation patches
72 * # [12:19] = the LS-HS vertex stride in DWORDS
73 */
74 struct ac_arg tcs_offchip_layout;
75 struct ac_arg tcs_epilog_pc;
76
77 /* TCS epilogs */
78 struct ac_arg patch_base;
79 struct ac_arg tcs_out_current_patch_data_offset;
80 struct ac_arg invocation_id;
81 struct ac_arg rel_patch_id;
82
83 /* TES */
84 /* # [0:7] = the number of tessellation patches
85 * # [8:15] = the number of TCS vertices output
86 */
87 struct ac_arg tes_state;
88
89 /* GS */
90 struct ac_arg vgt_esgs_ring_itemsize;
91
92 /* NGG VS streamout */
93 struct ac_arg num_verts_per_prim;
94
95 /* For non-monolithic VS or TES on GFX9+. */
96 struct ac_arg next_stage_pc;
97
98 struct radv_userdata_locations user_sgprs_locs;
99 unsigned num_user_sgprs;
100
101 bool explicit_scratch_args;
102 bool remap_spi_ps_input;
103 bool load_grid_size_from_user_sgpr;
104 };
105
106 static inline struct radv_shader_args *
radv_shader_args_from_ac(struct ac_shader_args * args)107 radv_shader_args_from_ac(struct ac_shader_args *args)
108 {
109 return container_of(args, struct radv_shader_args, ac);
110 }
111
112 struct radv_graphics_state_key;
113 struct radv_shader_info;
114
115 void radv_declare_shader_args(const struct radv_device *device, const struct radv_graphics_state_key *gfx_state,
116 const struct radv_shader_info *info, gl_shader_stage stage,
117 gl_shader_stage previous_stage, struct radv_shader_args *args);
118
119 void radv_declare_ps_epilog_args(const struct radv_device *device, const struct radv_ps_epilog_key *key,
120 struct radv_shader_args *args);
121
122 void radv_declare_tcs_epilog_args(const struct radv_device *device, const struct radv_tcs_epilog_key *key,
123 struct radv_shader_args *args);
124
125 void radv_declare_rt_shader_args(enum amd_gfx_level gfx_level, struct radv_shader_args *args);
126 #endif
127