spirv/nir: add support for AMD_shader_ballot and Groups capability
[mesa.git] / src / compiler / shader_info.h
1 /*
2 * Copyright © 2016 Intel 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
25 #ifndef SHADER_INFO_H
26 #define SHADER_INFO_H
27
28 #include "shader_enums.h"
29 #include <stdint.h>
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 struct spirv_supported_capabilities {
36 bool address;
37 bool atomic_storage;
38 bool derivative_group;
39 bool descriptor_array_dynamic_indexing;
40 bool descriptor_array_non_uniform_indexing;
41 bool descriptor_indexing;
42 bool device_group;
43 bool draw_parameters;
44 bool float64;
45 bool fragment_shader_sample_interlock;
46 bool fragment_shader_pixel_interlock;
47 bool geometry_streams;
48 bool image_ms_array;
49 bool image_read_without_format;
50 bool image_write_without_format;
51 bool int8;
52 bool int16;
53 bool int64;
54 bool int64_atomics;
55 bool kernel;
56 bool min_lod;
57 bool multiview;
58 bool physical_storage_buffer_address;
59 bool post_depth_coverage;
60 bool runtime_descriptor_array;
61 bool shader_viewport_index_layer;
62 bool stencil_export;
63 bool storage_8bit;
64 bool storage_16bit;
65 bool storage_image_ms;
66 bool subgroup_arithmetic;
67 bool subgroup_ballot;
68 bool subgroup_basic;
69 bool subgroup_quad;
70 bool subgroup_shuffle;
71 bool subgroup_vote;
72 bool tessellation;
73 bool transform_feedback;
74 bool variable_pointers;
75 bool float16;
76 bool amd_gcn_shader;
77 bool amd_shader_ballot;
78 bool amd_trinary_minmax;
79 };
80
81 typedef struct shader_info {
82 const char *name;
83
84 /* Descriptive name provided by the client; may be NULL */
85 const char *label;
86
87 /** The shader stage, such as MESA_SHADER_VERTEX. */
88 gl_shader_stage stage;
89
90 /** The shader stage in a non SSO linked program that follows this stage,
91 * such as MESA_SHADER_FRAGMENT.
92 */
93 gl_shader_stage next_stage;
94
95 /* Number of textures used by this shader */
96 unsigned num_textures;
97 /* Number of uniform buffers used by this shader */
98 unsigned num_ubos;
99 /* Number of atomic buffers used by this shader */
100 unsigned num_abos;
101 /* Number of shader storage buffers used by this shader */
102 unsigned num_ssbos;
103 /* Number of images used by this shader */
104 unsigned num_images;
105
106 /* Which inputs are actually read */
107 uint64_t inputs_read;
108 /* Which outputs are actually written */
109 uint64_t outputs_written;
110 /* Which outputs are actually read */
111 uint64_t outputs_read;
112 /* Which system values are actually read */
113 uint64_t system_values_read;
114
115 /* Which patch inputs are actually read */
116 uint32_t patch_inputs_read;
117 /* Which patch outputs are actually written */
118 uint32_t patch_outputs_written;
119 /* Which patch outputs are read */
120 uint32_t patch_outputs_read;
121
122 /* Whether or not this shader ever uses textureGather() */
123 bool uses_texture_gather;
124
125 /** Bitfield of which textures are used */
126 uint32_t textures_used;
127
128 /** Bitfield of which textures are used by texelFetch() */
129 uint32_t textures_used_by_txf;
130
131 /**
132 * True if this shader uses the fddx/fddy opcodes.
133 *
134 * Note that this does not include the "fine" and "coarse" variants.
135 */
136 bool uses_fddx_fddy;
137
138 /**
139 * True if this shader uses 64-bit ALU operations
140 */
141 bool uses_64bit;
142
143 /* The size of the gl_ClipDistance[] array, if declared. */
144 unsigned clip_distance_array_size;
145
146 /* The size of the gl_CullDistance[] array, if declared. */
147 unsigned cull_distance_array_size;
148
149 /* Whether or not separate shader objects were used */
150 bool separate_shader;
151
152 /** Was this shader linked with any transform feedback varyings? */
153 bool has_transform_feedback_varyings;
154
155 union {
156 struct {
157 /* Which inputs are doubles */
158 uint64_t double_inputs;
159
160 /* True if the shader writes position in window space coordinates pre-transform */
161 bool window_space_position;
162 } vs;
163
164 struct {
165 /** The number of vertices recieves per input primitive */
166 unsigned vertices_in;
167
168 /** The output primitive type (GL enum value) */
169 unsigned output_primitive;
170
171 /** The input primitive type (GL enum value) */
172 unsigned input_primitive;
173
174 /** The maximum number of vertices the geometry shader might write. */
175 unsigned vertices_out;
176
177 /** 1 .. MAX_GEOMETRY_SHADER_INVOCATIONS */
178 unsigned invocations;
179
180 /** Whether or not this shader uses EndPrimitive */
181 bool uses_end_primitive;
182
183 /** Whether or not this shader uses non-zero streams */
184 bool uses_streams;
185 } gs;
186
187 struct {
188 bool uses_discard;
189
190 /**
191 * Whether any inputs are declared with the "sample" qualifier.
192 */
193 bool uses_sample_qualifier;
194
195 /**
196 * Whether early fragment tests are enabled as defined by
197 * ARB_shader_image_load_store.
198 */
199 bool early_fragment_tests;
200
201 /**
202 * Defined by INTEL_conservative_rasterization.
203 */
204 bool inner_coverage;
205
206 bool post_depth_coverage;
207
208 /**
209 * \name ARB_fragment_coord_conventions
210 * @{
211 */
212 bool pixel_center_integer;
213 bool origin_upper_left;
214 /*@}*/
215
216 bool pixel_interlock_ordered;
217 bool pixel_interlock_unordered;
218 bool sample_interlock_ordered;
219 bool sample_interlock_unordered;
220
221 /**
222 * Flags whether NIR's base types on the FS color outputs should be
223 * ignored.
224 *
225 * GLSL requires that fragment shader output base types match the
226 * render target's base types for the behavior to be defined. From
227 * the GL 4.6 spec:
228 *
229 * "If the values written by the fragment shader do not match the
230 * format(s) of the corresponding color buffer(s), the result is
231 * undefined."
232 *
233 * However, for NIR shaders translated from TGSI, we don't have the
234 * output types any more, so the driver will need to do whatever
235 * fixups are necessary to handle effectively untyped data being
236 * output from the FS.
237 */
238 bool untyped_color_outputs;
239
240 /** gl_FragDepth layout for ARB_conservative_depth. */
241 enum gl_frag_depth_layout depth_layout;
242 } fs;
243
244 struct {
245 unsigned local_size[3];
246
247 bool local_size_variable;
248
249 /**
250 * Size of shared variables accessed by the compute shader.
251 */
252 unsigned shared_size;
253
254
255 /**
256 * pointer size is:
257 * AddressingModelLogical: 0 (default)
258 * AddressingModelPhysical32: 32
259 * AddressingModelPhysical64: 64
260 */
261 unsigned ptr_size;
262
263 /*
264 * Arrangement of invocations used to calculate derivatives in a compute
265 * shader. From NV_compute_shader_derivatives.
266 */
267 enum gl_derivative_group derivative_group;
268 } cs;
269
270 /* Applies to both TCS and TES. */
271 struct {
272 /** The number of vertices in the TCS output patch. */
273 unsigned tcs_vertices_out;
274
275 uint32_t primitive_mode; /* GL_TRIANGLES, GL_QUADS or GL_ISOLINES */
276 enum gl_tess_spacing spacing;
277 /** Is the vertex order counterclockwise? */
278 bool ccw;
279 bool point_mode;
280 } tess;
281 };
282 } shader_info;
283
284 #ifdef __cplusplus
285 }
286 #endif
287
288 #endif /* SHADER_INFO_H */