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