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