• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Mesa 3-D graphics library
3  *
4  * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
5  * Copyright (C) 2009  VMware, Inc.  All Rights Reserved.
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining a
8  * copy of this software and associated documentation files (the "Software"),
9  * to deal in the Software without restriction, including without limitation
10  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11  * and/or sell copies of the Software, and to permit persons to whom the
12  * Software is furnished to do so, subject to the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be included
15  * in all copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
20  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23  * OTHER DEALINGS IN THE SOFTWARE.
24  */
25 
26 #ifndef SHADER_ENUMS_H
27 #define SHADER_ENUMS_H
28 
29 #include "util/macros.h"
30 
31 #include <stdbool.h>
32 
33 /* Project-wide (GL and Vulkan) maximum. */
34 #define MAX_DRAW_BUFFERS 8
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 /**
41  * Shader stages.
42  *
43  * The order must match how shaders are ordered in the pipeline.
44  * The GLSL linker assumes that if i<j, then the j-th shader is
45  * executed later than the i-th shader.
46  */
47 typedef enum
48 {
49    MESA_SHADER_NONE = -1,
50    MESA_SHADER_VERTEX = 0,
51    MESA_SHADER_TESS_CTRL = 1,
52    MESA_SHADER_TESS_EVAL = 2,
53    MESA_SHADER_GEOMETRY = 3,
54    MESA_SHADER_FRAGMENT = 4,
55    MESA_SHADER_COMPUTE = 5,
56 
57    /* Vulkan-only stages. */
58    MESA_SHADER_TASK         = 6,
59    MESA_SHADER_MESH         = 7,
60    MESA_SHADER_RAYGEN       = 8,
61    MESA_SHADER_ANY_HIT      = 9,
62    MESA_SHADER_CLOSEST_HIT  = 10,
63    MESA_SHADER_MISS         = 11,
64    MESA_SHADER_INTERSECTION = 12,
65    MESA_SHADER_CALLABLE     = 13,
66 
67    /* must be last so it doesn't affect the GL pipeline */
68    MESA_SHADER_KERNEL = 14,
69 } gl_shader_stage;
70 
71 static inline bool
gl_shader_stage_is_compute(gl_shader_stage stage)72 gl_shader_stage_is_compute(gl_shader_stage stage)
73 {
74    return stage == MESA_SHADER_COMPUTE || stage == MESA_SHADER_KERNEL;
75 }
76 
77 static inline bool
gl_shader_stage_is_mesh(gl_shader_stage stage)78 gl_shader_stage_is_mesh(gl_shader_stage stage)
79 {
80    return stage == MESA_SHADER_TASK ||
81           stage == MESA_SHADER_MESH;
82 }
83 
84 static inline bool
gl_shader_stage_uses_workgroup(gl_shader_stage stage)85 gl_shader_stage_uses_workgroup(gl_shader_stage stage)
86 {
87    return stage == MESA_SHADER_COMPUTE ||
88           stage == MESA_SHADER_KERNEL ||
89           stage == MESA_SHADER_TASK ||
90           stage == MESA_SHADER_MESH;
91 }
92 
93 static inline bool
gl_shader_stage_is_callable(gl_shader_stage stage)94 gl_shader_stage_is_callable(gl_shader_stage stage)
95 {
96    return stage == MESA_SHADER_ANY_HIT ||
97           stage == MESA_SHADER_CLOSEST_HIT ||
98           stage == MESA_SHADER_MISS ||
99           stage == MESA_SHADER_INTERSECTION ||
100           stage == MESA_SHADER_CALLABLE;
101 }
102 
103 static inline bool
gl_shader_stage_can_set_fragment_shading_rate(gl_shader_stage stage)104 gl_shader_stage_can_set_fragment_shading_rate(gl_shader_stage stage)
105 {
106    /* According to EXT_fragment_shading_rate :
107     *
108     *    "This extension adds support for setting the fragment shading rate
109     *     for a primitive in vertex, geometry, and mesh shading stages"
110     */
111    return stage == MESA_SHADER_VERTEX ||
112           stage == MESA_SHADER_GEOMETRY ||
113           stage == MESA_SHADER_MESH;
114 }
115 
116 /**
117  * Number of STATE_* values we need to address any GL state.
118  * Used to dimension arrays.
119  */
120 #define STATE_LENGTH 4
121 
122 typedef short gl_state_index16; /* see enum gl_state_index */
123 
124 const char *gl_shader_stage_name(gl_shader_stage stage);
125 
126 /**
127  * Translate a gl_shader_stage to a short shader stage name for debug
128  * printouts and error messages.
129  */
130 const char *_mesa_shader_stage_to_string(unsigned stage);
131 
132 /**
133  * Translate a gl_shader_stage to a shader stage abbreviation (VS, GS, FS)
134  * for debug printouts and error messages.
135  */
136 const char *_mesa_shader_stage_to_abbrev(unsigned stage);
137 
138 /**
139  * GL related stages (not including CL)
140  */
141 #define MESA_SHADER_STAGES (MESA_SHADER_COMPUTE + 1)
142 
143 /**
144  * Vulkan stages (not including CL)
145  */
146 #define MESA_VULKAN_SHADER_STAGES (MESA_SHADER_CALLABLE + 1)
147 
148 /**
149  * All stages
150  */
151 #define MESA_ALL_SHADER_STAGES (MESA_SHADER_KERNEL + 1)
152 
153 
154 /**
155  * Indexes for vertex program attributes.
156  * GL_NV_vertex_program aliases generic attributes over the conventional
157  * attributes.  In GL_ARB_vertex_program shader the aliasing is optional.
158  * In GL_ARB_vertex_shader / OpenGL 2.0 the aliasing is disallowed (the
159  * generic attributes are distinct/separate).
160  */
161 typedef enum
162 {
163    VERT_ATTRIB_POS,
164    VERT_ATTRIB_NORMAL,
165    VERT_ATTRIB_COLOR0,
166    VERT_ATTRIB_COLOR1,
167    VERT_ATTRIB_FOG,
168    VERT_ATTRIB_COLOR_INDEX,
169    VERT_ATTRIB_TEX0,
170    VERT_ATTRIB_TEX1,
171    VERT_ATTRIB_TEX2,
172    VERT_ATTRIB_TEX3,
173    VERT_ATTRIB_TEX4,
174    VERT_ATTRIB_TEX5,
175    VERT_ATTRIB_TEX6,
176    VERT_ATTRIB_TEX7,
177    VERT_ATTRIB_POINT_SIZE,
178    VERT_ATTRIB_GENERIC0,
179    VERT_ATTRIB_GENERIC1,
180    VERT_ATTRIB_GENERIC2,
181    VERT_ATTRIB_GENERIC3,
182    VERT_ATTRIB_GENERIC4,
183    VERT_ATTRIB_GENERIC5,
184    VERT_ATTRIB_GENERIC6,
185    VERT_ATTRIB_GENERIC7,
186    VERT_ATTRIB_GENERIC8,
187    VERT_ATTRIB_GENERIC9,
188    VERT_ATTRIB_GENERIC10,
189    VERT_ATTRIB_GENERIC11,
190    VERT_ATTRIB_GENERIC12,
191    VERT_ATTRIB_GENERIC13,
192    VERT_ATTRIB_GENERIC14,
193    VERT_ATTRIB_GENERIC15,
194    /* This must be last to keep VS inputs and vertex attributes in the same
195     * order in st/mesa, and st/mesa always adds edgeflags as the last input.
196     */
197    VERT_ATTRIB_EDGEFLAG,
198    VERT_ATTRIB_MAX
199 } gl_vert_attrib;
200 
201 const char *gl_vert_attrib_name(gl_vert_attrib attrib);
202 
203 /**
204  * Max number of texture coordinate units.  This mainly just applies to
205  * the fixed-function vertex code.  This will be difficult to raise above
206  * eight because of various vertex attribute bitvectors.
207  */
208 #define MAX_TEXTURE_COORD_UNITS     8
209 #define MAX_VERTEX_GENERIC_ATTRIBS  16
210 
211 /**
212  * Symbolic constats to help iterating over
213  * specific blocks of vertex attributes.
214  *
215  * VERT_ATTRIB_TEX
216  *   include the classic texture coordinate attributes.
217  * VERT_ATTRIB_GENERIC
218  *   include the OpenGL 2.0+ GLSL generic shader attributes.
219  *   These alias the generic GL_ARB_vertex_shader attributes.
220  * VERT_ATTRIB_MAT
221  *   include the generic shader attributes used to alias
222  *   varying material values for the TNL shader programs.
223  *   They are located at the end of the generic attribute
224  *   block not to overlap with the generic 0 attribute.
225  */
226 #define VERT_ATTRIB_TEX(i)          (VERT_ATTRIB_TEX0 + (i))
227 #define VERT_ATTRIB_TEX_MAX         MAX_TEXTURE_COORD_UNITS
228 
229 #define VERT_ATTRIB_GENERIC(i)      (VERT_ATTRIB_GENERIC0 + (i))
230 #define VERT_ATTRIB_GENERIC_MAX     MAX_VERTEX_GENERIC_ATTRIBS
231 
232 #define VERT_ATTRIB_MAT0            \
233    (VERT_ATTRIB_GENERIC_MAX - VERT_ATTRIB_MAT_MAX)
234 #define VERT_ATTRIB_MAT(i)          \
235    VERT_ATTRIB_GENERIC((i) + VERT_ATTRIB_MAT0)
236 #define VERT_ATTRIB_MAT_MAX         MAT_ATTRIB_MAX
237 
238 /**
239  * Bitflags for vertex attributes.
240  * These are used in bitfields in many places.
241  */
242 /*@{*/
243 #define VERT_BIT_POS             BITFIELD_BIT(VERT_ATTRIB_POS)
244 #define VERT_BIT_NORMAL          BITFIELD_BIT(VERT_ATTRIB_NORMAL)
245 #define VERT_BIT_COLOR0          BITFIELD_BIT(VERT_ATTRIB_COLOR0)
246 #define VERT_BIT_COLOR1          BITFIELD_BIT(VERT_ATTRIB_COLOR1)
247 #define VERT_BIT_FOG             BITFIELD_BIT(VERT_ATTRIB_FOG)
248 #define VERT_BIT_COLOR_INDEX     BITFIELD_BIT(VERT_ATTRIB_COLOR_INDEX)
249 #define VERT_BIT_TEX0            BITFIELD_BIT(VERT_ATTRIB_TEX0)
250 #define VERT_BIT_TEX1            BITFIELD_BIT(VERT_ATTRIB_TEX1)
251 #define VERT_BIT_TEX2            BITFIELD_BIT(VERT_ATTRIB_TEX2)
252 #define VERT_BIT_TEX3            BITFIELD_BIT(VERT_ATTRIB_TEX3)
253 #define VERT_BIT_TEX4            BITFIELD_BIT(VERT_ATTRIB_TEX4)
254 #define VERT_BIT_TEX5            BITFIELD_BIT(VERT_ATTRIB_TEX5)
255 #define VERT_BIT_TEX6            BITFIELD_BIT(VERT_ATTRIB_TEX6)
256 #define VERT_BIT_TEX7            BITFIELD_BIT(VERT_ATTRIB_TEX7)
257 #define VERT_BIT_POINT_SIZE      BITFIELD_BIT(VERT_ATTRIB_POINT_SIZE)
258 #define VERT_BIT_GENERIC0        BITFIELD_BIT(VERT_ATTRIB_GENERIC0)
259 #define VERT_BIT_EDGEFLAG        BITFIELD_BIT(VERT_ATTRIB_EDGEFLAG)
260 
261 #define VERT_BIT(i)              BITFIELD_BIT(i)
262 #define VERT_BIT_ALL             BITFIELD_RANGE(0, VERT_ATTRIB_MAX)
263 
264 #define VERT_BIT_FF_ALL          (BITFIELD_RANGE(0, VERT_ATTRIB_GENERIC0) | \
265                                   VERT_BIT_EDGEFLAG)
266 #define VERT_BIT_TEX(i)          VERT_BIT(VERT_ATTRIB_TEX(i))
267 #define VERT_BIT_TEX_ALL         \
268    BITFIELD_RANGE(VERT_ATTRIB_TEX(0), VERT_ATTRIB_TEX_MAX)
269 
270 #define VERT_BIT_GENERIC(i)      VERT_BIT(VERT_ATTRIB_GENERIC(i))
271 #define VERT_BIT_GENERIC_ALL     \
272    BITFIELD_RANGE(VERT_ATTRIB_GENERIC(0), VERT_ATTRIB_GENERIC_MAX)
273 
274 #define VERT_BIT_MAT(i)	         VERT_BIT(VERT_ATTRIB_MAT(i))
275 #define VERT_BIT_MAT_ALL         \
276    BITFIELD_RANGE(VERT_ATTRIB_MAT(0), VERT_ATTRIB_MAT_MAX)
277 
278 #define VERT_ATTRIB_SELECT_RESULT_OFFSET VERT_ATTRIB_GENERIC(3)
279 #define VERT_BIT_SELECT_RESULT_OFFSET VERT_BIT_GENERIC(3)
280 /*@}*/
281 
282 #define MAX_VARYING 32 /**< number of float[4] vectors */
283 
284 /**
285  * Indexes for vertex shader outputs, geometry shader inputs/outputs, and
286  * fragment shader inputs.
287  *
288  * Note that some of these values are not available to all pipeline stages.
289  *
290  * When this enum is updated, the following code must be updated too:
291  * - vertResults (in prog_print.c's arb_output_attrib_string())
292  * - fragAttribs (in prog_print.c's arb_input_attrib_string())
293  * - _mesa_varying_slot_in_fs()
294  * - _mesa_varying_slot_name_for_stage()
295  */
296 typedef enum
297 {
298    VARYING_SLOT_POS,
299    VARYING_SLOT_COL0, /* COL0 and COL1 must be contiguous */
300    VARYING_SLOT_COL1,
301    VARYING_SLOT_FOGC,
302    VARYING_SLOT_TEX0, /* TEX0-TEX7 must be contiguous */
303    VARYING_SLOT_TEX1,
304    VARYING_SLOT_TEX2,
305    VARYING_SLOT_TEX3,
306    VARYING_SLOT_TEX4,
307    VARYING_SLOT_TEX5,
308    VARYING_SLOT_TEX6,
309    VARYING_SLOT_TEX7,
310    VARYING_SLOT_PSIZ, /* Does not appear in FS */
311    VARYING_SLOT_BFC0, /* Does not appear in FS */
312    VARYING_SLOT_BFC1, /* Does not appear in FS */
313    VARYING_SLOT_EDGE, /* Does not appear in FS */
314    VARYING_SLOT_CLIP_VERTEX, /* Does not appear in FS */
315    VARYING_SLOT_CLIP_DIST0,
316    VARYING_SLOT_CLIP_DIST1,
317    VARYING_SLOT_CULL_DIST0,
318    VARYING_SLOT_CULL_DIST1,
319    VARYING_SLOT_PRIMITIVE_ID, /* Does not appear in VS */
320    VARYING_SLOT_LAYER, /* Appears as VS or GS output */
321    VARYING_SLOT_VIEWPORT, /* Appears as VS or GS output */
322    VARYING_SLOT_FACE, /* FS only */
323    VARYING_SLOT_PNTC, /* FS only */
324    VARYING_SLOT_TESS_LEVEL_OUTER, /* Only appears as TCS output. */
325    VARYING_SLOT_TESS_LEVEL_INNER, /* Only appears as TCS output. */
326    VARYING_SLOT_BOUNDING_BOX0, /* Only appears as TCS output. */
327    VARYING_SLOT_BOUNDING_BOX1, /* Only appears as TCS output. */
328    VARYING_SLOT_VIEW_INDEX,
329    VARYING_SLOT_VIEWPORT_MASK, /* Does not appear in FS */
330    VARYING_SLOT_PRIMITIVE_SHADING_RATE = VARYING_SLOT_FACE, /* Does not appear in FS. */
331 
332    VARYING_SLOT_PRIMITIVE_COUNT = VARYING_SLOT_TESS_LEVEL_OUTER, /* Only appears in MESH. */
333    VARYING_SLOT_PRIMITIVE_INDICES = VARYING_SLOT_TESS_LEVEL_INNER, /* Only appears in MESH. */
334    VARYING_SLOT_TASK_COUNT = VARYING_SLOT_BOUNDING_BOX0, /* Only appears in TASK. */
335    VARYING_SLOT_CULL_PRIMITIVE = VARYING_SLOT_BOUNDING_BOX0, /* Only appears in MESH. */
336 
337    VARYING_SLOT_VAR0 = 32, /* First generic varying slot */
338    /* the remaining are simply for the benefit of gl_varying_slot_name()
339     * and not to be construed as an upper bound:
340     */
341    VARYING_SLOT_VAR1,
342    VARYING_SLOT_VAR2,
343    VARYING_SLOT_VAR3,
344    VARYING_SLOT_VAR4,
345    VARYING_SLOT_VAR5,
346    VARYING_SLOT_VAR6,
347    VARYING_SLOT_VAR7,
348    VARYING_SLOT_VAR8,
349    VARYING_SLOT_VAR9,
350    VARYING_SLOT_VAR10,
351    VARYING_SLOT_VAR11,
352    VARYING_SLOT_VAR12,
353    VARYING_SLOT_VAR13,
354    VARYING_SLOT_VAR14,
355    VARYING_SLOT_VAR15,
356    VARYING_SLOT_VAR16,
357    VARYING_SLOT_VAR17,
358    VARYING_SLOT_VAR18,
359    VARYING_SLOT_VAR19,
360    VARYING_SLOT_VAR20,
361    VARYING_SLOT_VAR21,
362    VARYING_SLOT_VAR22,
363    VARYING_SLOT_VAR23,
364    VARYING_SLOT_VAR24,
365    VARYING_SLOT_VAR25,
366    VARYING_SLOT_VAR26,
367    VARYING_SLOT_VAR27,
368    VARYING_SLOT_VAR28,
369    VARYING_SLOT_VAR29,
370    VARYING_SLOT_VAR30,
371    VARYING_SLOT_VAR31,
372    /* Per-patch varyings for tessellation. */
373    VARYING_SLOT_PATCH0,
374    VARYING_SLOT_PATCH1,
375    VARYING_SLOT_PATCH2,
376    VARYING_SLOT_PATCH3,
377    VARYING_SLOT_PATCH4,
378    VARYING_SLOT_PATCH5,
379    VARYING_SLOT_PATCH6,
380    VARYING_SLOT_PATCH7,
381    VARYING_SLOT_PATCH8,
382    VARYING_SLOT_PATCH9,
383    VARYING_SLOT_PATCH10,
384    VARYING_SLOT_PATCH11,
385    VARYING_SLOT_PATCH12,
386    VARYING_SLOT_PATCH13,
387    VARYING_SLOT_PATCH14,
388    VARYING_SLOT_PATCH15,
389    VARYING_SLOT_PATCH16,
390    VARYING_SLOT_PATCH17,
391    VARYING_SLOT_PATCH18,
392    VARYING_SLOT_PATCH19,
393    VARYING_SLOT_PATCH20,
394    VARYING_SLOT_PATCH21,
395    VARYING_SLOT_PATCH22,
396    VARYING_SLOT_PATCH23,
397    VARYING_SLOT_PATCH24,
398    VARYING_SLOT_PATCH25,
399    VARYING_SLOT_PATCH26,
400    VARYING_SLOT_PATCH27,
401    VARYING_SLOT_PATCH28,
402    VARYING_SLOT_PATCH29,
403    VARYING_SLOT_PATCH30,
404    VARYING_SLOT_PATCH31,
405    /* 32 16-bit vec4 slots packed in 16 32-bit vec4 slots for GLES/mediump.
406     * They are really just additional generic slots used for 16-bit data to
407     * prevent conflicts between neighboring mediump and non-mediump varyings
408     * that can't be packed without breaking one or the other, which is
409     * a limitation of separate shaders. This allows linking shaders in 32 bits
410     * and then get an optimally packed 16-bit varyings by remapping the IO
411     * locations to these slots. The remapping can also be undone trivially.
412     *
413     * nir_io_semantics::high_16bit determines which half of the slot is
414     * accessed. The low and high halves share the same IO "base" number.
415     * Drivers can treat these as 32-bit slots everywhere except for FP16
416     * interpolation.
417     */
418    VARYING_SLOT_VAR0_16BIT,
419    VARYING_SLOT_VAR1_16BIT,
420    VARYING_SLOT_VAR2_16BIT,
421    VARYING_SLOT_VAR3_16BIT,
422    VARYING_SLOT_VAR4_16BIT,
423    VARYING_SLOT_VAR5_16BIT,
424    VARYING_SLOT_VAR6_16BIT,
425    VARYING_SLOT_VAR7_16BIT,
426    VARYING_SLOT_VAR8_16BIT,
427    VARYING_SLOT_VAR9_16BIT,
428    VARYING_SLOT_VAR10_16BIT,
429    VARYING_SLOT_VAR11_16BIT,
430    VARYING_SLOT_VAR12_16BIT,
431    VARYING_SLOT_VAR13_16BIT,
432    VARYING_SLOT_VAR14_16BIT,
433    VARYING_SLOT_VAR15_16BIT,
434 
435    NUM_TOTAL_VARYING_SLOTS,
436 } gl_varying_slot;
437 
438 
439 #define VARYING_SLOT_MAX	(VARYING_SLOT_VAR0 + MAX_VARYING)
440 #define VARYING_SLOT_TESS_MAX	(VARYING_SLOT_PATCH0 + MAX_VARYING)
441 #define MAX_VARYINGS_INCL_PATCH (VARYING_SLOT_TESS_MAX - VARYING_SLOT_VAR0)
442 
443 const char *gl_varying_slot_name_for_stage(gl_varying_slot slot,
444                                            gl_shader_stage stage);
445 
446 /**
447  * Determine if the given gl_varying_slot appears in the fragment shader.
448  */
449 static inline bool
_mesa_varying_slot_in_fs(gl_varying_slot slot)450 _mesa_varying_slot_in_fs(gl_varying_slot slot)
451 {
452    switch (slot) {
453    case VARYING_SLOT_PSIZ:
454    case VARYING_SLOT_BFC0:
455    case VARYING_SLOT_BFC1:
456    case VARYING_SLOT_EDGE:
457    case VARYING_SLOT_CLIP_VERTEX:
458    case VARYING_SLOT_LAYER:
459    case VARYING_SLOT_TESS_LEVEL_OUTER:
460    case VARYING_SLOT_TESS_LEVEL_INNER:
461    case VARYING_SLOT_BOUNDING_BOX0:
462    case VARYING_SLOT_BOUNDING_BOX1:
463    case VARYING_SLOT_VIEWPORT_MASK:
464       return false;
465    default:
466       return true;
467    }
468 }
469 
470 /**
471  * Bitflags for varying slots.
472  */
473 /*@{*/
474 #define VARYING_BIT_POS BITFIELD64_BIT(VARYING_SLOT_POS)
475 #define VARYING_BIT_COL0 BITFIELD64_BIT(VARYING_SLOT_COL0)
476 #define VARYING_BIT_COL1 BITFIELD64_BIT(VARYING_SLOT_COL1)
477 #define VARYING_BIT_FOGC BITFIELD64_BIT(VARYING_SLOT_FOGC)
478 #define VARYING_BIT_TEX0 BITFIELD64_BIT(VARYING_SLOT_TEX0)
479 #define VARYING_BIT_TEX1 BITFIELD64_BIT(VARYING_SLOT_TEX1)
480 #define VARYING_BIT_TEX2 BITFIELD64_BIT(VARYING_SLOT_TEX2)
481 #define VARYING_BIT_TEX3 BITFIELD64_BIT(VARYING_SLOT_TEX3)
482 #define VARYING_BIT_TEX4 BITFIELD64_BIT(VARYING_SLOT_TEX4)
483 #define VARYING_BIT_TEX5 BITFIELD64_BIT(VARYING_SLOT_TEX5)
484 #define VARYING_BIT_TEX6 BITFIELD64_BIT(VARYING_SLOT_TEX6)
485 #define VARYING_BIT_TEX7 BITFIELD64_BIT(VARYING_SLOT_TEX7)
486 #define VARYING_BIT_TEX(U) BITFIELD64_BIT(VARYING_SLOT_TEX0 + (U))
487 #define VARYING_BITS_TEX_ANY BITFIELD64_RANGE(VARYING_SLOT_TEX0, \
488                                               MAX_TEXTURE_COORD_UNITS)
489 #define VARYING_BIT_PSIZ BITFIELD64_BIT(VARYING_SLOT_PSIZ)
490 #define VARYING_BIT_BFC0 BITFIELD64_BIT(VARYING_SLOT_BFC0)
491 #define VARYING_BIT_BFC1 BITFIELD64_BIT(VARYING_SLOT_BFC1)
492 #define VARYING_BITS_COLOR (VARYING_BIT_COL0 | \
493                             VARYING_BIT_COL1 |        \
494                             VARYING_BIT_BFC0 |        \
495                             VARYING_BIT_BFC1)
496 #define VARYING_BIT_EDGE BITFIELD64_BIT(VARYING_SLOT_EDGE)
497 #define VARYING_BIT_CLIP_VERTEX BITFIELD64_BIT(VARYING_SLOT_CLIP_VERTEX)
498 #define VARYING_BIT_CLIP_DIST0 BITFIELD64_BIT(VARYING_SLOT_CLIP_DIST0)
499 #define VARYING_BIT_CLIP_DIST1 BITFIELD64_BIT(VARYING_SLOT_CLIP_DIST1)
500 #define VARYING_BIT_CULL_DIST0 BITFIELD64_BIT(VARYING_SLOT_CULL_DIST0)
501 #define VARYING_BIT_CULL_DIST1 BITFIELD64_BIT(VARYING_SLOT_CULL_DIST1)
502 #define VARYING_BIT_PRIMITIVE_ID BITFIELD64_BIT(VARYING_SLOT_PRIMITIVE_ID)
503 #define VARYING_BIT_LAYER BITFIELD64_BIT(VARYING_SLOT_LAYER)
504 #define VARYING_BIT_VIEWPORT BITFIELD64_BIT(VARYING_SLOT_VIEWPORT)
505 #define VARYING_BIT_FACE BITFIELD64_BIT(VARYING_SLOT_FACE)
506 #define VARYING_BIT_PRIMITIVE_SHADING_RATE BITFIELD64_BIT(VARYING_SLOT_PRIMITIVE_SHADING_RATE)
507 #define VARYING_BIT_PNTC BITFIELD64_BIT(VARYING_SLOT_PNTC)
508 #define VARYING_BIT_TESS_LEVEL_OUTER BITFIELD64_BIT(VARYING_SLOT_TESS_LEVEL_OUTER)
509 #define VARYING_BIT_TESS_LEVEL_INNER BITFIELD64_BIT(VARYING_SLOT_TESS_LEVEL_INNER)
510 #define VARYING_BIT_BOUNDING_BOX0 BITFIELD64_BIT(VARYING_SLOT_BOUNDING_BOX0)
511 #define VARYING_BIT_BOUNDING_BOX1 BITFIELD64_BIT(VARYING_SLOT_BOUNDING_BOX1)
512 #define VARYING_BIT_VIEWPORT_MASK BITFIELD64_BIT(VARYING_SLOT_VIEWPORT_MASK)
513 #define VARYING_BIT_VAR(V) BITFIELD64_BIT(VARYING_SLOT_VAR0 + (V))
514 /*@}*/
515 
516 /**
517  * If the gl_register_file is PROGRAM_SYSTEM_VALUE, the register index will be
518  * one of these values.  If a NIR variable's mode is nir_var_system_value, it
519  * will be one of these values.
520  */
521 typedef enum
522 {
523    /**
524     * \name System values applicable to all shaders
525     */
526    /*@{*/
527 
528    /**
529     * Builtin variables added by GL_ARB_shader_ballot.
530     */
531    /*@{*/
532 
533    /**
534     * From the GL_ARB_shader-ballot spec:
535     *
536     *    "A sub-group is a collection of invocations which execute in lockstep.
537     *     The variable <gl_SubGroupSizeARB> is the maximum number of
538     *     invocations in a sub-group. The maximum <gl_SubGroupSizeARB>
539     *     supported in this extension is 64."
540     *
541     * The spec defines this as a uniform. However, it's highly unlikely that
542     * implementations actually treat it as a uniform (which is loaded from a
543     * constant buffer). Most likely, this is an implementation-wide constant,
544     * or perhaps something that depends on the shader stage.
545     */
546    SYSTEM_VALUE_SUBGROUP_SIZE,
547 
548    /**
549     * From the GL_ARB_shader_ballot spec:
550     *
551     *    "The variable <gl_SubGroupInvocationARB> holds the index of the
552     *     invocation within sub-group. This variable is in the range 0 to
553     *     <gl_SubGroupSizeARB>-1, where <gl_SubGroupSizeARB> is the total
554     *     number of invocations in a sub-group."
555     */
556    SYSTEM_VALUE_SUBGROUP_INVOCATION,
557 
558    /**
559     * From the GL_ARB_shader_ballot spec:
560     *
561     *    "The <gl_SubGroup??MaskARB> variables provide a bitmask for all
562     *     invocations, with one bit per invocation starting with the least
563     *     significant bit, according to the following table,
564     *
565     *       variable               equation for bit values
566     *       --------------------   ------------------------------------
567     *       gl_SubGroupEqMaskARB   bit index == gl_SubGroupInvocationARB
568     *       gl_SubGroupGeMaskARB   bit index >= gl_SubGroupInvocationARB
569     *       gl_SubGroupGtMaskARB   bit index >  gl_SubGroupInvocationARB
570     *       gl_SubGroupLeMaskARB   bit index <= gl_SubGroupInvocationARB
571     *       gl_SubGroupLtMaskARB   bit index <  gl_SubGroupInvocationARB
572     */
573    SYSTEM_VALUE_SUBGROUP_EQ_MASK,
574    SYSTEM_VALUE_SUBGROUP_GE_MASK,
575    SYSTEM_VALUE_SUBGROUP_GT_MASK,
576    SYSTEM_VALUE_SUBGROUP_LE_MASK,
577    SYSTEM_VALUE_SUBGROUP_LT_MASK,
578    /*@}*/
579 
580    /**
581     * Builtin variables added by VK_KHR_subgroups
582     */
583    /*@{*/
584    SYSTEM_VALUE_NUM_SUBGROUPS,
585    SYSTEM_VALUE_SUBGROUP_ID,
586    /*@}*/
587 
588    /*@}*/
589 
590    /**
591     * \name Vertex shader system values
592     */
593    /*@{*/
594    /**
595     * OpenGL-style vertex ID.
596     *
597     * Section 2.11.7 (Shader Execution), subsection Shader Inputs, of the
598     * OpenGL 3.3 core profile spec says:
599     *
600     *     "gl_VertexID holds the integer index i implicitly passed by
601     *     DrawArrays or one of the other drawing commands defined in section
602     *     2.8.3."
603     *
604     * Section 2.8.3 (Drawing Commands) of the same spec says:
605     *
606     *     "The commands....are equivalent to the commands with the same base
607     *     name (without the BaseVertex suffix), except that the ith element
608     *     transferred by the corresponding draw call will be taken from
609     *     element indices[i] + basevertex of each enabled array."
610     *
611     * Additionally, the overview in the GL_ARB_shader_draw_parameters spec
612     * says:
613     *
614     *     "In unextended GL, vertex shaders have inputs named gl_VertexID and
615     *     gl_InstanceID, which contain, respectively the index of the vertex
616     *     and instance. The value of gl_VertexID is the implicitly passed
617     *     index of the vertex being processed, which includes the value of
618     *     baseVertex, for those commands that accept it."
619     *
620     * gl_VertexID gets basevertex added in.  This differs from DirectX where
621     * SV_VertexID does \b not get basevertex added in.
622     *
623     * \note
624     * If all system values are available, \c SYSTEM_VALUE_VERTEX_ID will be
625     * equal to \c SYSTEM_VALUE_VERTEX_ID_ZERO_BASE plus
626     * \c SYSTEM_VALUE_BASE_VERTEX.
627     *
628     * \sa SYSTEM_VALUE_VERTEX_ID_ZERO_BASE, SYSTEM_VALUE_BASE_VERTEX
629     */
630    SYSTEM_VALUE_VERTEX_ID,
631 
632    /**
633     * Instanced ID as supplied to gl_InstanceID
634     *
635     * Values assigned to gl_InstanceID always begin with zero, regardless of
636     * the value of baseinstance.
637     *
638     * Section 11.1.3.9 (Shader Inputs) of the OpenGL 4.4 core profile spec
639     * says:
640     *
641     *     "gl_InstanceID holds the integer instance number of the current
642     *     primitive in an instanced draw call (see section 10.5)."
643     *
644     * Through a big chain of pseudocode, section 10.5 describes that
645     * baseinstance is not counted by gl_InstanceID.  In that section, notice
646     *
647     *     "If an enabled vertex attribute array is instanced (it has a
648     *     non-zero divisor as specified by VertexAttribDivisor), the element
649     *     index that is transferred to the GL, for all vertices, is given by
650     *
651     *         floor(instance/divisor) + baseinstance
652     *
653     *     If an array corresponding to an attribute required by a vertex
654     *     shader is not enabled, then the corresponding element is taken from
655     *     the current attribute state (see section 10.2)."
656     *
657     * Note that baseinstance is \b not included in the value of instance.
658     */
659    SYSTEM_VALUE_INSTANCE_ID,
660 
661    /**
662     * Vulkan InstanceIndex.
663     *
664     * InstanceIndex = gl_InstanceID + gl_BaseInstance
665     */
666    SYSTEM_VALUE_INSTANCE_INDEX,
667 
668    /**
669     * DirectX-style vertex ID.
670     *
671     * Unlike \c SYSTEM_VALUE_VERTEX_ID, this system value does \b not include
672     * the value of basevertex.
673     *
674     * \sa SYSTEM_VALUE_VERTEX_ID, SYSTEM_VALUE_BASE_VERTEX
675     */
676    SYSTEM_VALUE_VERTEX_ID_ZERO_BASE,
677 
678    /**
679     * Value of \c basevertex passed to \c glDrawElementsBaseVertex and similar
680     * functions.
681     *
682     * \sa SYSTEM_VALUE_VERTEX_ID, SYSTEM_VALUE_VERTEX_ID_ZERO_BASE
683     */
684    SYSTEM_VALUE_BASE_VERTEX,
685 
686    /**
687     * Depending on the type of the draw call (indexed or non-indexed),
688     * is the value of \c basevertex passed to \c glDrawElementsBaseVertex and
689     * similar, or is the value of \c first passed to \c glDrawArrays and
690     * similar.
691     *
692     * \note
693     * It can be used to calculate the \c SYSTEM_VALUE_VERTEX_ID as
694     * \c SYSTEM_VALUE_VERTEX_ID_ZERO_BASE plus \c SYSTEM_VALUE_FIRST_VERTEX.
695     *
696     * \sa SYSTEM_VALUE_VERTEX_ID_ZERO_BASE, SYSTEM_VALUE_VERTEX_ID
697     */
698    SYSTEM_VALUE_FIRST_VERTEX,
699 
700    /**
701     * If the Draw command used to start the rendering was an indexed draw
702     * or not (~0/0). Useful to calculate \c SYSTEM_VALUE_BASE_VERTEX as
703     * \c SYSTEM_VALUE_IS_INDEXED_DRAW & \c SYSTEM_VALUE_FIRST_VERTEX.
704     */
705    SYSTEM_VALUE_IS_INDEXED_DRAW,
706 
707    /**
708     * Value of \c baseinstance passed to instanced draw entry points
709     *
710     * \sa SYSTEM_VALUE_INSTANCE_ID
711     */
712    SYSTEM_VALUE_BASE_INSTANCE,
713 
714    /**
715     * From _ARB_shader_draw_parameters:
716     *
717     *   "Additionally, this extension adds a further built-in variable,
718     *    gl_DrawID to the shading language. This variable contains the index
719     *    of the draw currently being processed by a Multi* variant of a
720     *    drawing command (such as MultiDrawElements or
721     *    MultiDrawArraysIndirect)."
722     *
723     * If GL_ARB_multi_draw_indirect is not supported, this is always 0.
724     */
725    SYSTEM_VALUE_DRAW_ID,
726    /*@}*/
727 
728    /**
729     * \name Geometry shader system values
730     */
731    /*@{*/
732    SYSTEM_VALUE_INVOCATION_ID,  /**< (Also in Tessellation Control shader) */
733    /*@}*/
734 
735    /**
736     * \name Fragment shader system values
737     */
738    /*@{*/
739    SYSTEM_VALUE_FRAG_COORD,
740    SYSTEM_VALUE_POINT_COORD,
741    SYSTEM_VALUE_LINE_COORD, /**< Coord along axis perpendicular to line */
742    SYSTEM_VALUE_FRONT_FACE,
743    SYSTEM_VALUE_SAMPLE_ID,
744    SYSTEM_VALUE_SAMPLE_POS,
745    SYSTEM_VALUE_SAMPLE_POS_OR_CENTER,
746    SYSTEM_VALUE_SAMPLE_MASK_IN,
747    SYSTEM_VALUE_HELPER_INVOCATION,
748    SYSTEM_VALUE_COLOR0,
749    SYSTEM_VALUE_COLOR1,
750    /*@}*/
751 
752    /**
753     * \name Tessellation Evaluation shader system values
754     */
755    /*@{*/
756    SYSTEM_VALUE_TESS_COORD,
757    SYSTEM_VALUE_VERTICES_IN,    /**< Tessellation vertices in input patch */
758    SYSTEM_VALUE_PRIMITIVE_ID,
759    SYSTEM_VALUE_TESS_LEVEL_OUTER, /**< TES input */
760    SYSTEM_VALUE_TESS_LEVEL_INNER, /**< TES input */
761    SYSTEM_VALUE_TESS_LEVEL_OUTER_DEFAULT, /**< TCS input for passthru TCS */
762    SYSTEM_VALUE_TESS_LEVEL_INNER_DEFAULT, /**< TCS input for passthru TCS */
763    /*@}*/
764 
765    /**
766     * \name Compute shader system values
767     */
768    /*@{*/
769    SYSTEM_VALUE_LOCAL_INVOCATION_ID,
770    SYSTEM_VALUE_LOCAL_INVOCATION_INDEX,
771    SYSTEM_VALUE_GLOBAL_INVOCATION_ID,
772    SYSTEM_VALUE_BASE_GLOBAL_INVOCATION_ID,
773    SYSTEM_VALUE_GLOBAL_INVOCATION_INDEX,
774    SYSTEM_VALUE_WORKGROUP_ID,
775    SYSTEM_VALUE_WORKGROUP_INDEX,
776    SYSTEM_VALUE_NUM_WORKGROUPS,
777    SYSTEM_VALUE_WORKGROUP_SIZE,
778    SYSTEM_VALUE_GLOBAL_GROUP_SIZE,
779    SYSTEM_VALUE_WORK_DIM,
780    SYSTEM_VALUE_USER_DATA_AMD,
781    /*@}*/
782 
783    /** Required for VK_KHR_device_group */
784    SYSTEM_VALUE_DEVICE_INDEX,
785 
786    /** Required for VK_KHX_multiview */
787    SYSTEM_VALUE_VIEW_INDEX,
788 
789    /**
790     * Driver internal vertex-count, used (for example) for drivers to
791     * calculate stride for stream-out outputs.  Not externally visible.
792     */
793    SYSTEM_VALUE_VERTEX_CNT,
794 
795    /**
796     * Required for AMD_shader_explicit_vertex_parameter and also used for
797     * varying-fetch instructions.
798     *
799     * The _SIZE value is "primitive size", used to scale i/j in primitive
800     * space to pixel space.
801     */
802    SYSTEM_VALUE_BARYCENTRIC_PERSP_PIXEL,
803    SYSTEM_VALUE_BARYCENTRIC_PERSP_SAMPLE,
804    SYSTEM_VALUE_BARYCENTRIC_PERSP_CENTROID,
805    SYSTEM_VALUE_BARYCENTRIC_PERSP_CENTER_RHW,
806    SYSTEM_VALUE_BARYCENTRIC_LINEAR_PIXEL,
807    SYSTEM_VALUE_BARYCENTRIC_LINEAR_CENTROID,
808    SYSTEM_VALUE_BARYCENTRIC_LINEAR_SAMPLE,
809    SYSTEM_VALUE_BARYCENTRIC_PULL_MODEL,
810 
811    /**
812     * \name Ray tracing shader system values
813     */
814    /*@{*/
815    SYSTEM_VALUE_RAY_LAUNCH_ID,
816    SYSTEM_VALUE_RAY_LAUNCH_SIZE,
817    SYSTEM_VALUE_RAY_LAUNCH_SIZE_ADDR_AMD,
818    SYSTEM_VALUE_RAY_WORLD_ORIGIN,
819    SYSTEM_VALUE_RAY_WORLD_DIRECTION,
820    SYSTEM_VALUE_RAY_OBJECT_ORIGIN,
821    SYSTEM_VALUE_RAY_OBJECT_DIRECTION,
822    SYSTEM_VALUE_RAY_T_MIN,
823    SYSTEM_VALUE_RAY_T_MAX,
824    SYSTEM_VALUE_RAY_OBJECT_TO_WORLD,
825    SYSTEM_VALUE_RAY_WORLD_TO_OBJECT,
826    SYSTEM_VALUE_RAY_HIT_KIND,
827    SYSTEM_VALUE_RAY_FLAGS,
828    SYSTEM_VALUE_RAY_GEOMETRY_INDEX,
829    SYSTEM_VALUE_RAY_INSTANCE_CUSTOM_INDEX,
830    SYSTEM_VALUE_CULL_MASK,
831    /*@}*/
832 
833    /**
834     * \name Task/Mesh shader system values
835     */
836    /*@{*/
837    SYSTEM_VALUE_MESH_VIEW_COUNT,
838    SYSTEM_VALUE_MESH_VIEW_INDICES,
839    /*@}*/
840 
841    /**
842     * IR3 specific geometry shader and tesselation control shader system
843     * values that packs invocation id, thread id and vertex id.  Having this
844     * as a nir level system value lets us do the unpacking in nir.
845     */
846    SYSTEM_VALUE_GS_HEADER_IR3,
847    SYSTEM_VALUE_TCS_HEADER_IR3,
848 
849    /* IR3 specific system value that contains the patch id for the current
850     * subdraw.
851     */
852    SYSTEM_VALUE_REL_PATCH_ID_IR3,
853 
854    /**
855     * Fragment shading rate used for KHR_fragment_shading_rate (Vulkan).
856     */
857    SYSTEM_VALUE_FRAG_SHADING_RATE,
858 
859    SYSTEM_VALUE_MAX             /**< Number of values */
860 } gl_system_value;
861 
862 const char *gl_system_value_name(gl_system_value sysval);
863 
864 /**
865  * The possible interpolation qualifiers that can be applied to a fragment
866  * shader input in GLSL.
867  *
868  * Note: INTERP_MODE_NONE must be 0 so that memsetting the
869  * ir_variable data structure to 0 causes the default behavior.
870  */
871 enum glsl_interp_mode
872 {
873    INTERP_MODE_NONE = 0,
874    INTERP_MODE_SMOOTH,
875    INTERP_MODE_FLAT,
876    INTERP_MODE_NOPERSPECTIVE,
877    INTERP_MODE_EXPLICIT,
878    INTERP_MODE_COLOR, /**< glShadeModel determines the interp mode */
879    INTERP_MODE_COUNT /**< Number of interpolation qualifiers */
880 };
881 
882 enum glsl_interface_packing {
883    GLSL_INTERFACE_PACKING_STD140,
884    GLSL_INTERFACE_PACKING_SHARED,
885    GLSL_INTERFACE_PACKING_PACKED,
886    GLSL_INTERFACE_PACKING_STD430
887 };
888 
889 const char *glsl_interp_mode_name(enum glsl_interp_mode qual);
890 
891 /**
892  * Fragment program results
893  */
894 typedef enum
895 {
896    FRAG_RESULT_DEPTH = 0,
897    FRAG_RESULT_STENCIL = 1,
898    /* If a single color should be written to all render targets, this
899     * register is written.  No FRAG_RESULT_DATAn will be written.
900     */
901    FRAG_RESULT_COLOR = 2,
902    FRAG_RESULT_SAMPLE_MASK = 3,
903 
904    /* FRAG_RESULT_DATAn are the per-render-target (GLSL gl_FragData[n]
905     * or ARB_fragment_program fragment.color[n]) color results.  If
906     * any are written, FRAG_RESULT_COLOR will not be written.
907     * FRAG_RESULT_DATA1 and up are simply for the benefit of
908     * gl_frag_result_name() and not to be construed as an upper bound
909     */
910    FRAG_RESULT_DATA0 = 4,
911    FRAG_RESULT_DATA1,
912    FRAG_RESULT_DATA2,
913    FRAG_RESULT_DATA3,
914    FRAG_RESULT_DATA4,
915    FRAG_RESULT_DATA5,
916    FRAG_RESULT_DATA6,
917    FRAG_RESULT_DATA7,
918 } gl_frag_result;
919 
920 const char *gl_frag_result_name(gl_frag_result result);
921 
922 #define FRAG_RESULT_MAX		(FRAG_RESULT_DATA0 + MAX_DRAW_BUFFERS)
923 
924 /**
925  * \brief Layout qualifiers for gl_FragDepth.
926  *
927  * Extension AMD_conservative_depth allows gl_FragDepth to be redeclared with
928  * a layout qualifier.
929  *
930  * \see enum ir_depth_layout
931  */
932 enum gl_frag_depth_layout
933 {
934    FRAG_DEPTH_LAYOUT_NONE, /**< No layout is specified. */
935    FRAG_DEPTH_LAYOUT_ANY,
936    FRAG_DEPTH_LAYOUT_GREATER,
937    FRAG_DEPTH_LAYOUT_LESS,
938    FRAG_DEPTH_LAYOUT_UNCHANGED
939 };
940 
941 /**
942  * \brief Buffer access qualifiers
943  */
944 enum gl_access_qualifier
945 {
946    ACCESS_COHERENT      = (1 << 0),
947    ACCESS_RESTRICT      = (1 << 1),
948    ACCESS_VOLATILE      = (1 << 2),
949 
950    /* The memory used by the access/variable is not read. */
951    ACCESS_NON_READABLE  = (1 << 3),
952 
953    /* The memory used by the access/variable is not written. */
954    ACCESS_NON_WRITEABLE = (1 << 4),
955 
956    /**
957     * The access may use a non-uniform buffer or image index.
958     *
959     * This is not allowed in either OpenGL or OpenGL ES, or Vulkan unless
960     * VK_EXT_descriptor_indexing is supported and the appropriate capability is
961     * enabled.
962     *
963     * Some GL spec archaeology justifying this:
964     *
965     * Up through at least GLSL ES 3.20 and GLSL 4.50,  "Opaque Types" says "When
966     * aggregated into arrays within a shader, opaque types can only be indexed
967     * with a dynamically uniform integral expression (see section 3.9.3) unless
968     * otherwise noted; otherwise, results are undefined."
969     *
970     * The original GL_AB_shader_image_load_store specification for desktop GL
971     * didn't have this restriction ("Images may be aggregated into arrays within
972     * a shader (using square brackets [ ]) and can be indexed with general
973     * integer expressions.")  At the same time,
974     * GL_ARB_shader_storage_buffer_objects *did* have the uniform restriction
975     * ("A uniform or shader storage block array can only be indexed with a
976     * dynamically uniform integral expression, otherwise results are
977     * undefined"), just like ARB_gpu_shader5 did when it first introduced a
978     * non-constant indexing of an opaque type with samplers.  So, we assume that
979     * this was an oversight in the original image_load_store spec, and was
980     * considered a correction in the merge to core.
981     */
982    ACCESS_NON_UNIFORM   = (1 << 5),
983 
984    /* This has the same semantics as NIR_INTRINSIC_CAN_REORDER, only to be
985     * used with loads. In other words, it means that the load can be
986     * arbitrarily reordered, or combined with other loads to the same address.
987     * It is implied by ACCESS_NON_WRITEABLE and a lack of ACCESS_VOLATILE.
988     */
989    ACCESS_CAN_REORDER = (1 << 6),
990 
991    /** Use as little cache space as possible. */
992    ACCESS_STREAM_CACHE_POLICY = (1 << 7),
993 
994    /** Execute instruction also in helpers. */
995    ACCESS_INCLUDE_HELPERS = (1 << 8),
996 };
997 
998 /**
999  * \brief Blend support qualifiers
1000  */
1001 enum gl_advanced_blend_mode
1002 {
1003    BLEND_NONE = 0,
1004    BLEND_MULTIPLY,
1005    BLEND_SCREEN,
1006    BLEND_OVERLAY,
1007    BLEND_DARKEN,
1008    BLEND_LIGHTEN,
1009    BLEND_COLORDODGE,
1010    BLEND_COLORBURN,
1011    BLEND_HARDLIGHT,
1012    BLEND_SOFTLIGHT,
1013    BLEND_DIFFERENCE,
1014    BLEND_EXCLUSION,
1015    BLEND_HSL_HUE,
1016    BLEND_HSL_SATURATION,
1017    BLEND_HSL_COLOR,
1018    BLEND_HSL_LUMINOSITY,
1019 };
1020 
1021 enum blend_func
1022 {
1023    BLEND_FUNC_ADD,
1024    BLEND_FUNC_SUBTRACT,
1025    BLEND_FUNC_REVERSE_SUBTRACT,
1026    BLEND_FUNC_MIN,
1027    BLEND_FUNC_MAX,
1028 };
1029 
1030 enum blend_factor
1031 {
1032    BLEND_FACTOR_ZERO,
1033    BLEND_FACTOR_SRC_COLOR,
1034    BLEND_FACTOR_SRC1_COLOR,
1035    BLEND_FACTOR_DST_COLOR,
1036    BLEND_FACTOR_SRC_ALPHA,
1037    BLEND_FACTOR_SRC1_ALPHA,
1038    BLEND_FACTOR_DST_ALPHA,
1039    BLEND_FACTOR_CONSTANT_COLOR,
1040    BLEND_FACTOR_CONSTANT_ALPHA,
1041    BLEND_FACTOR_SRC_ALPHA_SATURATE,
1042 };
1043 
1044 enum gl_tess_spacing
1045 {
1046    TESS_SPACING_UNSPECIFIED,
1047    TESS_SPACING_EQUAL,
1048    TESS_SPACING_FRACTIONAL_ODD,
1049    TESS_SPACING_FRACTIONAL_EVEN,
1050 };
1051 
1052 enum tess_primitive_mode
1053 {
1054    TESS_PRIMITIVE_UNSPECIFIED,
1055    TESS_PRIMITIVE_TRIANGLES,
1056    TESS_PRIMITIVE_QUADS,
1057    TESS_PRIMITIVE_ISOLINES,
1058 };
1059 
1060 /* these also map directly to GL and gallium prim types. */
1061 enum shader_prim
1062 {
1063    SHADER_PRIM_POINTS,
1064    SHADER_PRIM_LINES,
1065    SHADER_PRIM_LINE_LOOP,
1066    SHADER_PRIM_LINE_STRIP,
1067    SHADER_PRIM_TRIANGLES,
1068    SHADER_PRIM_TRIANGLE_STRIP,
1069    SHADER_PRIM_TRIANGLE_FAN,
1070    SHADER_PRIM_QUADS,
1071    SHADER_PRIM_QUAD_STRIP,
1072    SHADER_PRIM_POLYGON,
1073    SHADER_PRIM_LINES_ADJACENCY,
1074    SHADER_PRIM_LINE_STRIP_ADJACENCY,
1075    SHADER_PRIM_TRIANGLES_ADJACENCY,
1076    SHADER_PRIM_TRIANGLE_STRIP_ADJACENCY,
1077    SHADER_PRIM_PATCHES,
1078    SHADER_PRIM_MAX = SHADER_PRIM_PATCHES,
1079    SHADER_PRIM_UNKNOWN = (SHADER_PRIM_MAX * 2),
1080 };
1081 
1082 /**
1083  * Number of vertices per mesh shader primitive.
1084  */
1085 unsigned num_mesh_vertices_per_primitive(unsigned prim);
1086 
1087 /**
1088  * A compare function enum for use in compiler lowering passes.  This is in
1089  * the same order as GL's compare functions (shifted down by GL_NEVER), and is
1090  * exactly the same as gallium's PIPE_FUNC_*.
1091  */
1092 enum compare_func
1093 {
1094    COMPARE_FUNC_NEVER,
1095    COMPARE_FUNC_LESS,
1096    COMPARE_FUNC_EQUAL,
1097    COMPARE_FUNC_LEQUAL,
1098    COMPARE_FUNC_GREATER,
1099    COMPARE_FUNC_NOTEQUAL,
1100    COMPARE_FUNC_GEQUAL,
1101    COMPARE_FUNC_ALWAYS,
1102 };
1103 
1104 /**
1105  * Arrangements for grouping invocations from NV_compute_shader_derivatives.
1106  *
1107  *   The extension provides new layout qualifiers that support two different
1108  *   arrangements of compute shader invocations for the purpose of derivative
1109  *   computation.  When specifying
1110  *
1111  *     layout(derivative_group_quadsNV) in;
1112  *
1113  *   compute shader invocations are grouped into 2x2x1 arrays whose four local
1114  *   invocation ID values follow the pattern:
1115  *
1116  *       +-----------------+------------------+
1117  *       | (2x+0, 2y+0, z) |  (2x+1, 2y+0, z) |
1118  *       +-----------------+------------------+
1119  *       | (2x+0, 2y+1, z) |  (2x+1, 2y+1, z) |
1120  *       +-----------------+------------------+
1121  *
1122  *   where Y increases from bottom to top.  When specifying
1123  *
1124  *     layout(derivative_group_linearNV) in;
1125  *
1126  *   compute shader invocations are grouped into 2x2x1 arrays whose four local
1127  *   invocation index values follow the pattern:
1128  *
1129  *       +------+------+
1130  *       | 4n+0 | 4n+1 |
1131  *       +------+------+
1132  *       | 4n+2 | 4n+3 |
1133  *       +------+------+
1134  *
1135  *   If neither layout qualifier is specified, derivatives in compute shaders
1136  *   return zero, which is consistent with the handling of built-in texture
1137  *   functions like texture() in GLSL 4.50 compute shaders.
1138  */
1139 enum gl_derivative_group {
1140    DERIVATIVE_GROUP_NONE = 0,
1141    DERIVATIVE_GROUP_QUADS,
1142    DERIVATIVE_GROUP_LINEAR,
1143 };
1144 
1145 enum float_controls
1146 {
1147    FLOAT_CONTROLS_DEFAULT_FLOAT_CONTROL_MODE        = 0x0000,
1148    FLOAT_CONTROLS_DENORM_PRESERVE_FP16              = 0x0001,
1149    FLOAT_CONTROLS_DENORM_PRESERVE_FP32              = 0x0002,
1150    FLOAT_CONTROLS_DENORM_PRESERVE_FP64              = 0x0004,
1151    FLOAT_CONTROLS_DENORM_FLUSH_TO_ZERO_FP16         = 0x0008,
1152    FLOAT_CONTROLS_DENORM_FLUSH_TO_ZERO_FP32         = 0x0010,
1153    FLOAT_CONTROLS_DENORM_FLUSH_TO_ZERO_FP64         = 0x0020,
1154    FLOAT_CONTROLS_SIGNED_ZERO_INF_NAN_PRESERVE_FP16 = 0x0040,
1155    FLOAT_CONTROLS_SIGNED_ZERO_INF_NAN_PRESERVE_FP32 = 0x0080,
1156    FLOAT_CONTROLS_SIGNED_ZERO_INF_NAN_PRESERVE_FP64 = 0x0100,
1157    FLOAT_CONTROLS_ROUNDING_MODE_RTE_FP16            = 0x0200,
1158    FLOAT_CONTROLS_ROUNDING_MODE_RTE_FP32            = 0x0400,
1159    FLOAT_CONTROLS_ROUNDING_MODE_RTE_FP64            = 0x0800,
1160    FLOAT_CONTROLS_ROUNDING_MODE_RTZ_FP16            = 0x1000,
1161    FLOAT_CONTROLS_ROUNDING_MODE_RTZ_FP32            = 0x2000,
1162    FLOAT_CONTROLS_ROUNDING_MODE_RTZ_FP64            = 0x4000,
1163 };
1164 
1165 /**
1166 * Enums to describe sampler properties used by OpenCL's inline constant samplers.
1167 * These values match the meanings described in the SPIR-V spec.
1168 */
1169 enum cl_sampler_addressing_mode {
1170    SAMPLER_ADDRESSING_MODE_NONE = 0,
1171    SAMPLER_ADDRESSING_MODE_CLAMP_TO_EDGE = 1,
1172    SAMPLER_ADDRESSING_MODE_CLAMP = 2,
1173    SAMPLER_ADDRESSING_MODE_REPEAT = 3,
1174    SAMPLER_ADDRESSING_MODE_REPEAT_MIRRORED = 4,
1175 };
1176 
1177 enum cl_sampler_filter_mode {
1178    SAMPLER_FILTER_MODE_NEAREST = 0,
1179    SAMPLER_FILTER_MODE_LINEAR = 1,
1180 };
1181 
1182 /**
1183  * \name Bit flags used for updating material values.
1184  */
1185 /*@{*/
1186 #define MAT_ATTRIB_FRONT_AMBIENT           0
1187 #define MAT_ATTRIB_BACK_AMBIENT            1
1188 #define MAT_ATTRIB_FRONT_DIFFUSE           2
1189 #define MAT_ATTRIB_BACK_DIFFUSE            3
1190 #define MAT_ATTRIB_FRONT_SPECULAR          4
1191 #define MAT_ATTRIB_BACK_SPECULAR           5
1192 #define MAT_ATTRIB_FRONT_EMISSION          6
1193 #define MAT_ATTRIB_BACK_EMISSION           7
1194 #define MAT_ATTRIB_FRONT_SHININESS         8
1195 #define MAT_ATTRIB_BACK_SHININESS          9
1196 #define MAT_ATTRIB_FRONT_INDEXES           10
1197 #define MAT_ATTRIB_BACK_INDEXES            11
1198 #define MAT_ATTRIB_MAX                     12
1199 
1200 #define MAT_ATTRIB_AMBIENT(f)  (MAT_ATTRIB_FRONT_AMBIENT+(f))
1201 #define MAT_ATTRIB_DIFFUSE(f)  (MAT_ATTRIB_FRONT_DIFFUSE+(f))
1202 #define MAT_ATTRIB_SPECULAR(f) (MAT_ATTRIB_FRONT_SPECULAR+(f))
1203 #define MAT_ATTRIB_EMISSION(f) (MAT_ATTRIB_FRONT_EMISSION+(f))
1204 #define MAT_ATTRIB_SHININESS(f)(MAT_ATTRIB_FRONT_SHININESS+(f))
1205 #define MAT_ATTRIB_INDEXES(f)  (MAT_ATTRIB_FRONT_INDEXES+(f))
1206 
1207 #define MAT_BIT_FRONT_AMBIENT         (1<<MAT_ATTRIB_FRONT_AMBIENT)
1208 #define MAT_BIT_BACK_AMBIENT          (1<<MAT_ATTRIB_BACK_AMBIENT)
1209 #define MAT_BIT_FRONT_DIFFUSE         (1<<MAT_ATTRIB_FRONT_DIFFUSE)
1210 #define MAT_BIT_BACK_DIFFUSE          (1<<MAT_ATTRIB_BACK_DIFFUSE)
1211 #define MAT_BIT_FRONT_SPECULAR        (1<<MAT_ATTRIB_FRONT_SPECULAR)
1212 #define MAT_BIT_BACK_SPECULAR         (1<<MAT_ATTRIB_BACK_SPECULAR)
1213 #define MAT_BIT_FRONT_EMISSION        (1<<MAT_ATTRIB_FRONT_EMISSION)
1214 #define MAT_BIT_BACK_EMISSION         (1<<MAT_ATTRIB_BACK_EMISSION)
1215 #define MAT_BIT_FRONT_SHININESS       (1<<MAT_ATTRIB_FRONT_SHININESS)
1216 #define MAT_BIT_BACK_SHININESS        (1<<MAT_ATTRIB_BACK_SHININESS)
1217 #define MAT_BIT_FRONT_INDEXES         (1<<MAT_ATTRIB_FRONT_INDEXES)
1218 #define MAT_BIT_BACK_INDEXES          (1<<MAT_ATTRIB_BACK_INDEXES)
1219 
1220 /** An enum representing what kind of input gl_SubgroupSize is. */
1221 enum PACKED gl_subgroup_size
1222 {
1223    /** Actual subgroup size, whatever that happens to be */
1224    SUBGROUP_SIZE_VARYING = 0,
1225 
1226    /** Subgroup size must appear to be draw or dispatch-uniform
1227     *
1228     * This is the OpenGL behavior
1229     */
1230    SUBGROUP_SIZE_UNIFORM,
1231 
1232    /** Subgroup size must appear to be the API advertised constant
1233     *
1234     * This is the default Vulkan 1.1 behavior
1235     */
1236    SUBGROUP_SIZE_API_CONSTANT,
1237 
1238    /** Subgroup size must actually be the API advertised constant
1239     *
1240     * Not only must the subgroup size match the API advertised constant as
1241     * with SUBGROUP_SIZE_API_CONSTANT but it must also be dispatched such that
1242     * all the subgroups are full if there are enough invocations.
1243     */
1244    SUBGROUP_SIZE_FULL_SUBGROUPS,
1245 
1246    /* These enums are specifically chosen so that the value of the enum is
1247     * also the subgroup size.  If any new values are added, they must respect
1248     * this invariant.
1249     */
1250    SUBGROUP_SIZE_REQUIRE_8   = 8,   /**< VK_EXT_subgroup_size_control */
1251    SUBGROUP_SIZE_REQUIRE_16  = 16,  /**< VK_EXT_subgroup_size_control */
1252    SUBGROUP_SIZE_REQUIRE_32  = 32,  /**< VK_EXT_subgroup_size_control */
1253    SUBGROUP_SIZE_REQUIRE_64  = 64,  /**< VK_EXT_subgroup_size_control */
1254    SUBGROUP_SIZE_REQUIRE_128 = 128, /**< VK_EXT_subgroup_size_control */
1255 };
1256 
1257 #ifdef __cplusplus
1258 } /* extern "C" */
1259 #endif
1260 
1261 #endif /* SHADER_ENUMS_H */
1262