aa296adb5a1c0b64fd786f06b483591b8af9ac57
[mesa.git] / src / compiler / shader_enums.h
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 #ifdef __cplusplus
30 extern "C" {
31 #endif
32
33 /**
34 * Shader stages.
35 *
36 * The order must match how shaders are ordered in the pipeline.
37 * The GLSL linker assumes that if i<j, then the j-th shader is
38 * executed later than the i-th shader.
39 */
40 typedef enum
41 {
42 MESA_SHADER_NONE = -1,
43 MESA_SHADER_VERTEX = 0,
44 MESA_SHADER_TESS_CTRL = 1,
45 MESA_SHADER_TESS_EVAL = 2,
46 MESA_SHADER_GEOMETRY = 3,
47 MESA_SHADER_FRAGMENT = 4,
48 MESA_SHADER_COMPUTE = 5,
49 } gl_shader_stage;
50
51 const char *gl_shader_stage_name(gl_shader_stage stage);
52
53 /**
54 * Translate a gl_shader_stage to a short shader stage name for debug
55 * printouts and error messages.
56 */
57 const char *_mesa_shader_stage_to_string(unsigned stage);
58
59 /**
60 * Translate a gl_shader_stage to a shader stage abbreviation (VS, GS, FS)
61 * for debug printouts and error messages.
62 */
63 const char *_mesa_shader_stage_to_abbrev(unsigned stage);
64
65 #define MESA_SHADER_STAGES (MESA_SHADER_COMPUTE + 1)
66
67
68 /**
69 * Indexes for vertex program attributes.
70 * GL_NV_vertex_program aliases generic attributes over the conventional
71 * attributes. In GL_ARB_vertex_program shader the aliasing is optional.
72 * In GL_ARB_vertex_shader / OpenGL 2.0 the aliasing is disallowed (the
73 * generic attributes are distinct/separate).
74 */
75 typedef enum
76 {
77 VERT_ATTRIB_POS,
78 VERT_ATTRIB_NORMAL,
79 VERT_ATTRIB_COLOR0,
80 VERT_ATTRIB_COLOR1,
81 VERT_ATTRIB_FOG,
82 VERT_ATTRIB_COLOR_INDEX,
83 VERT_ATTRIB_EDGEFLAG,
84 VERT_ATTRIB_TEX0,
85 VERT_ATTRIB_TEX1,
86 VERT_ATTRIB_TEX2,
87 VERT_ATTRIB_TEX3,
88 VERT_ATTRIB_TEX4,
89 VERT_ATTRIB_TEX5,
90 VERT_ATTRIB_TEX6,
91 VERT_ATTRIB_TEX7,
92 VERT_ATTRIB_POINT_SIZE,
93 VERT_ATTRIB_GENERIC0,
94 VERT_ATTRIB_GENERIC1,
95 VERT_ATTRIB_GENERIC2,
96 VERT_ATTRIB_GENERIC3,
97 VERT_ATTRIB_GENERIC4,
98 VERT_ATTRIB_GENERIC5,
99 VERT_ATTRIB_GENERIC6,
100 VERT_ATTRIB_GENERIC7,
101 VERT_ATTRIB_GENERIC8,
102 VERT_ATTRIB_GENERIC9,
103 VERT_ATTRIB_GENERIC10,
104 VERT_ATTRIB_GENERIC11,
105 VERT_ATTRIB_GENERIC12,
106 VERT_ATTRIB_GENERIC13,
107 VERT_ATTRIB_GENERIC14,
108 VERT_ATTRIB_GENERIC15,
109 VERT_ATTRIB_MAX
110 } gl_vert_attrib;
111
112 const char *gl_vert_attrib_name(gl_vert_attrib attrib);
113
114 /**
115 * Symbolic constats to help iterating over
116 * specific blocks of vertex attributes.
117 *
118 * VERT_ATTRIB_FF
119 * includes all fixed function attributes as well as
120 * the aliased GL_NV_vertex_program shader attributes.
121 * VERT_ATTRIB_TEX
122 * include the classic texture coordinate attributes.
123 * Is a subset of VERT_ATTRIB_FF.
124 * VERT_ATTRIB_GENERIC
125 * include the OpenGL 2.0+ GLSL generic shader attributes.
126 * These alias the generic GL_ARB_vertex_shader attributes.
127 * VERT_ATTRIB_MAT
128 * include the generic shader attributes used to alias
129 * varying material values for the TNL shader programs.
130 */
131 #define VERT_ATTRIB_FF(i) (VERT_ATTRIB_POS + (i))
132 #define VERT_ATTRIB_FF_MAX VERT_ATTRIB_GENERIC0
133
134 #define VERT_ATTRIB_TEX(i) (VERT_ATTRIB_TEX0 + (i))
135 #define VERT_ATTRIB_TEX_MAX MAX_TEXTURE_COORD_UNITS
136
137 #define VERT_ATTRIB_GENERIC(i) (VERT_ATTRIB_GENERIC0 + (i))
138 #define VERT_ATTRIB_GENERIC_MAX MAX_VERTEX_GENERIC_ATTRIBS
139
140 #define VERT_ATTRIB_MAT(i) VERT_ATTRIB_GENERIC(i)
141 #define VERT_ATTRIB_MAT_MAX MAT_ATTRIB_MAX
142
143 /**
144 * Bitflags for vertex attributes.
145 * These are used in bitfields in many places.
146 */
147 /*@{*/
148 #define VERT_BIT_POS BITFIELD_BIT(VERT_ATTRIB_POS)
149 #define VERT_BIT_NORMAL BITFIELD_BIT(VERT_ATTRIB_NORMAL)
150 #define VERT_BIT_COLOR0 BITFIELD_BIT(VERT_ATTRIB_COLOR0)
151 #define VERT_BIT_COLOR1 BITFIELD_BIT(VERT_ATTRIB_COLOR1)
152 #define VERT_BIT_FOG BITFIELD_BIT(VERT_ATTRIB_FOG)
153 #define VERT_BIT_COLOR_INDEX BITFIELD_BIT(VERT_ATTRIB_COLOR_INDEX)
154 #define VERT_BIT_EDGEFLAG BITFIELD_BIT(VERT_ATTRIB_EDGEFLAG)
155 #define VERT_BIT_TEX0 BITFIELD_BIT(VERT_ATTRIB_TEX0)
156 #define VERT_BIT_TEX1 BITFIELD_BIT(VERT_ATTRIB_TEX1)
157 #define VERT_BIT_TEX2 BITFIELD_BIT(VERT_ATTRIB_TEX2)
158 #define VERT_BIT_TEX3 BITFIELD_BIT(VERT_ATTRIB_TEX3)
159 #define VERT_BIT_TEX4 BITFIELD_BIT(VERT_ATTRIB_TEX4)
160 #define VERT_BIT_TEX5 BITFIELD_BIT(VERT_ATTRIB_TEX5)
161 #define VERT_BIT_TEX6 BITFIELD_BIT(VERT_ATTRIB_TEX6)
162 #define VERT_BIT_TEX7 BITFIELD_BIT(VERT_ATTRIB_TEX7)
163 #define VERT_BIT_POINT_SIZE BITFIELD_BIT(VERT_ATTRIB_POINT_SIZE)
164 #define VERT_BIT_GENERIC0 BITFIELD_BIT(VERT_ATTRIB_GENERIC0)
165
166 #define VERT_BIT(i) BITFIELD_BIT(i)
167 #define VERT_BIT_ALL BITFIELD_RANGE(0, VERT_ATTRIB_MAX)
168
169 #define VERT_BIT_FF(i) VERT_BIT(i)
170 #define VERT_BIT_FF_ALL BITFIELD_RANGE(0, VERT_ATTRIB_FF_MAX)
171 #define VERT_BIT_TEX(i) VERT_BIT(VERT_ATTRIB_TEX(i))
172 #define VERT_BIT_TEX_ALL \
173 BITFIELD_RANGE(VERT_ATTRIB_TEX(0), VERT_ATTRIB_TEX_MAX)
174
175 #define VERT_BIT_GENERIC(i) VERT_BIT(VERT_ATTRIB_GENERIC(i))
176 #define VERT_BIT_GENERIC_ALL \
177 BITFIELD_RANGE(VERT_ATTRIB_GENERIC(0), VERT_ATTRIB_GENERIC_MAX)
178
179 #define VERT_BIT_MAT(i) VERT_BIT(VERT_ATTRIB_MAT(i))
180 #define VERT_BIT_MAT_ALL \
181 BITFIELD_RANGE(VERT_ATTRIB_MAT(0), VERT_ATTRIB_MAT_MAX)
182 /*@}*/
183
184 #define MAX_VARYING 32 /**< number of float[4] vectors */
185
186 /**
187 * Indexes for vertex shader outputs, geometry shader inputs/outputs, and
188 * fragment shader inputs.
189 *
190 * Note that some of these values are not available to all pipeline stages.
191 *
192 * When this enum is updated, the following code must be updated too:
193 * - vertResults (in prog_print.c's arb_output_attrib_string())
194 * - fragAttribs (in prog_print.c's arb_input_attrib_string())
195 * - _mesa_varying_slot_in_fs()
196 */
197 typedef enum
198 {
199 VARYING_SLOT_POS,
200 VARYING_SLOT_COL0, /* COL0 and COL1 must be contiguous */
201 VARYING_SLOT_COL1,
202 VARYING_SLOT_FOGC,
203 VARYING_SLOT_TEX0, /* TEX0-TEX7 must be contiguous */
204 VARYING_SLOT_TEX1,
205 VARYING_SLOT_TEX2,
206 VARYING_SLOT_TEX3,
207 VARYING_SLOT_TEX4,
208 VARYING_SLOT_TEX5,
209 VARYING_SLOT_TEX6,
210 VARYING_SLOT_TEX7,
211 VARYING_SLOT_PSIZ, /* Does not appear in FS */
212 VARYING_SLOT_BFC0, /* Does not appear in FS */
213 VARYING_SLOT_BFC1, /* Does not appear in FS */
214 VARYING_SLOT_EDGE, /* Does not appear in FS */
215 VARYING_SLOT_CLIP_VERTEX, /* Does not appear in FS */
216 VARYING_SLOT_CLIP_DIST0,
217 VARYING_SLOT_CLIP_DIST1,
218 VARYING_SLOT_CULL_DIST0,
219 VARYING_SLOT_CULL_DIST1,
220 VARYING_SLOT_PRIMITIVE_ID, /* Does not appear in VS */
221 VARYING_SLOT_LAYER, /* Appears as VS or GS output */
222 VARYING_SLOT_VIEWPORT, /* Appears as VS or GS output */
223 VARYING_SLOT_FACE, /* FS only */
224 VARYING_SLOT_PNTC, /* FS only */
225 VARYING_SLOT_TESS_LEVEL_OUTER, /* Only appears as TCS output. */
226 VARYING_SLOT_TESS_LEVEL_INNER, /* Only appears as TCS output. */
227 VARYING_SLOT_BOUNDING_BOX0, /* Only appears as TCS output. */
228 VARYING_SLOT_BOUNDING_BOX1, /* Only appears as TCS output. */
229 VARYING_SLOT_VIEW_INDEX,
230 VARYING_SLOT_VAR0, /* First generic varying slot */
231 /* the remaining are simply for the benefit of gl_varying_slot_name()
232 * and not to be construed as an upper bound:
233 */
234 VARYING_SLOT_VAR1,
235 VARYING_SLOT_VAR2,
236 VARYING_SLOT_VAR3,
237 VARYING_SLOT_VAR4,
238 VARYING_SLOT_VAR5,
239 VARYING_SLOT_VAR6,
240 VARYING_SLOT_VAR7,
241 VARYING_SLOT_VAR8,
242 VARYING_SLOT_VAR9,
243 VARYING_SLOT_VAR10,
244 VARYING_SLOT_VAR11,
245 VARYING_SLOT_VAR12,
246 VARYING_SLOT_VAR13,
247 VARYING_SLOT_VAR14,
248 VARYING_SLOT_VAR15,
249 VARYING_SLOT_VAR16,
250 VARYING_SLOT_VAR17,
251 VARYING_SLOT_VAR18,
252 VARYING_SLOT_VAR19,
253 VARYING_SLOT_VAR20,
254 VARYING_SLOT_VAR21,
255 VARYING_SLOT_VAR22,
256 VARYING_SLOT_VAR23,
257 VARYING_SLOT_VAR24,
258 VARYING_SLOT_VAR25,
259 VARYING_SLOT_VAR26,
260 VARYING_SLOT_VAR27,
261 VARYING_SLOT_VAR28,
262 VARYING_SLOT_VAR29,
263 VARYING_SLOT_VAR30,
264 VARYING_SLOT_VAR31,
265 } gl_varying_slot;
266
267
268 #define VARYING_SLOT_MAX (VARYING_SLOT_VAR0 + MAX_VARYING)
269 #define VARYING_SLOT_PATCH0 (VARYING_SLOT_MAX)
270 #define VARYING_SLOT_TESS_MAX (VARYING_SLOT_PATCH0 + MAX_VARYING)
271 #define MAX_VARYINGS_INCL_PATCH (VARYING_SLOT_TESS_MAX - VARYING_SLOT_VAR0)
272
273 const char *gl_varying_slot_name(gl_varying_slot slot);
274
275 /**
276 * Bitflags for varying slots.
277 */
278 /*@{*/
279 #define VARYING_BIT_POS BITFIELD64_BIT(VARYING_SLOT_POS)
280 #define VARYING_BIT_COL0 BITFIELD64_BIT(VARYING_SLOT_COL0)
281 #define VARYING_BIT_COL1 BITFIELD64_BIT(VARYING_SLOT_COL1)
282 #define VARYING_BIT_FOGC BITFIELD64_BIT(VARYING_SLOT_FOGC)
283 #define VARYING_BIT_TEX0 BITFIELD64_BIT(VARYING_SLOT_TEX0)
284 #define VARYING_BIT_TEX1 BITFIELD64_BIT(VARYING_SLOT_TEX1)
285 #define VARYING_BIT_TEX2 BITFIELD64_BIT(VARYING_SLOT_TEX2)
286 #define VARYING_BIT_TEX3 BITFIELD64_BIT(VARYING_SLOT_TEX3)
287 #define VARYING_BIT_TEX4 BITFIELD64_BIT(VARYING_SLOT_TEX4)
288 #define VARYING_BIT_TEX5 BITFIELD64_BIT(VARYING_SLOT_TEX5)
289 #define VARYING_BIT_TEX6 BITFIELD64_BIT(VARYING_SLOT_TEX6)
290 #define VARYING_BIT_TEX7 BITFIELD64_BIT(VARYING_SLOT_TEX7)
291 #define VARYING_BIT_TEX(U) BITFIELD64_BIT(VARYING_SLOT_TEX0 + (U))
292 #define VARYING_BITS_TEX_ANY BITFIELD64_RANGE(VARYING_SLOT_TEX0, \
293 MAX_TEXTURE_COORD_UNITS)
294 #define VARYING_BIT_PSIZ BITFIELD64_BIT(VARYING_SLOT_PSIZ)
295 #define VARYING_BIT_BFC0 BITFIELD64_BIT(VARYING_SLOT_BFC0)
296 #define VARYING_BIT_BFC1 BITFIELD64_BIT(VARYING_SLOT_BFC1)
297 #define VARYING_BIT_EDGE BITFIELD64_BIT(VARYING_SLOT_EDGE)
298 #define VARYING_BIT_CLIP_VERTEX BITFIELD64_BIT(VARYING_SLOT_CLIP_VERTEX)
299 #define VARYING_BIT_CLIP_DIST0 BITFIELD64_BIT(VARYING_SLOT_CLIP_DIST0)
300 #define VARYING_BIT_CLIP_DIST1 BITFIELD64_BIT(VARYING_SLOT_CLIP_DIST1)
301 #define VARYING_BIT_CULL_DIST0 BITFIELD64_BIT(VARYING_SLOT_CULL_DIST0)
302 #define VARYING_BIT_CULL_DIST1 BITFIELD64_BIT(VARYING_SLOT_CULL_DIST1)
303 #define VARYING_BIT_PRIMITIVE_ID BITFIELD64_BIT(VARYING_SLOT_PRIMITIVE_ID)
304 #define VARYING_BIT_LAYER BITFIELD64_BIT(VARYING_SLOT_LAYER)
305 #define VARYING_BIT_VIEWPORT BITFIELD64_BIT(VARYING_SLOT_VIEWPORT)
306 #define VARYING_BIT_FACE BITFIELD64_BIT(VARYING_SLOT_FACE)
307 #define VARYING_BIT_PNTC BITFIELD64_BIT(VARYING_SLOT_PNTC)
308 #define VARYING_BIT_TESS_LEVEL_OUTER BITFIELD64_BIT(VARYING_SLOT_TESS_LEVEL_OUTER)
309 #define VARYING_BIT_TESS_LEVEL_INNER BITFIELD64_BIT(VARYING_SLOT_TESS_LEVEL_INNER)
310 #define VARYING_BIT_BOUNDING_BOX0 BITFIELD64_BIT(VARYING_SLOT_BOUNDING_BOX0)
311 #define VARYING_BIT_BOUNDING_BOX1 BITFIELD64_BIT(VARYING_SLOT_BOUNDING_BOX1)
312 #define VARYING_BIT_VAR(V) BITFIELD64_BIT(VARYING_SLOT_VAR0 + (V))
313 /*@}*/
314
315 /**
316 * Bitflags for system values.
317 */
318 #define SYSTEM_BIT_SAMPLE_ID ((uint64_t)1 << SYSTEM_VALUE_SAMPLE_ID)
319 #define SYSTEM_BIT_SAMPLE_POS ((uint64_t)1 << SYSTEM_VALUE_SAMPLE_POS)
320 #define SYSTEM_BIT_SAMPLE_MASK_IN ((uint64_t)1 << SYSTEM_VALUE_SAMPLE_MASK_IN)
321 #define SYSTEM_BIT_LOCAL_INVOCATION_ID ((uint64_t)1 << SYSTEM_VALUE_LOCAL_INVOCATION_ID)
322
323 /**
324 * If the gl_register_file is PROGRAM_SYSTEM_VALUE, the register index will be
325 * one of these values. If a NIR variable's mode is nir_var_system_value, it
326 * will be one of these values.
327 */
328 typedef enum
329 {
330 /**
331 * \name System values applicable to all shaders
332 */
333 /*@{*/
334
335 /**
336 * Builtin variables added by GL_ARB_shader_ballot.
337 */
338 /*@{*/
339
340 /**
341 * From the GL_ARB_shader-ballot spec:
342 *
343 * "A sub-group is a collection of invocations which execute in lockstep.
344 * The variable <gl_SubGroupSizeARB> is the maximum number of
345 * invocations in a sub-group. The maximum <gl_SubGroupSizeARB>
346 * supported in this extension is 64."
347 *
348 * The spec defines this as a uniform. However, it's highly unlikely that
349 * implementations actually treat it as a uniform (which is loaded from a
350 * constant buffer). Most likely, this is an implementation-wide constant,
351 * or perhaps something that depends on the shader stage.
352 */
353 SYSTEM_VALUE_SUBGROUP_SIZE,
354
355 /**
356 * From the GL_ARB_shader_ballot spec:
357 *
358 * "The variable <gl_SubGroupInvocationARB> holds the index of the
359 * invocation within sub-group. This variable is in the range 0 to
360 * <gl_SubGroupSizeARB>-1, where <gl_SubGroupSizeARB> is the total
361 * number of invocations in a sub-group."
362 */
363 SYSTEM_VALUE_SUBGROUP_INVOCATION,
364
365 /**
366 * From the GL_ARB_shader_ballot spec:
367 *
368 * "The <gl_SubGroup??MaskARB> variables provide a bitmask for all
369 * invocations, with one bit per invocation starting with the least
370 * significant bit, according to the following table,
371 *
372 * variable equation for bit values
373 * -------------------- ------------------------------------
374 * gl_SubGroupEqMaskARB bit index == gl_SubGroupInvocationARB
375 * gl_SubGroupGeMaskARB bit index >= gl_SubGroupInvocationARB
376 * gl_SubGroupGtMaskARB bit index > gl_SubGroupInvocationARB
377 * gl_SubGroupLeMaskARB bit index <= gl_SubGroupInvocationARB
378 * gl_SubGroupLtMaskARB bit index < gl_SubGroupInvocationARB
379 */
380 SYSTEM_VALUE_SUBGROUP_EQ_MASK,
381 SYSTEM_VALUE_SUBGROUP_GE_MASK,
382 SYSTEM_VALUE_SUBGROUP_GT_MASK,
383 SYSTEM_VALUE_SUBGROUP_LE_MASK,
384 SYSTEM_VALUE_SUBGROUP_LT_MASK,
385 /*@}*/
386
387 /*@}*/
388
389 /**
390 * \name Vertex shader system values
391 */
392 /*@{*/
393 /**
394 * OpenGL-style vertex ID.
395 *
396 * Section 2.11.7 (Shader Execution), subsection Shader Inputs, of the
397 * OpenGL 3.3 core profile spec says:
398 *
399 * "gl_VertexID holds the integer index i implicitly passed by
400 * DrawArrays or one of the other drawing commands defined in section
401 * 2.8.3."
402 *
403 * Section 2.8.3 (Drawing Commands) of the same spec says:
404 *
405 * "The commands....are equivalent to the commands with the same base
406 * name (without the BaseVertex suffix), except that the ith element
407 * transferred by the corresponding draw call will be taken from
408 * element indices[i] + basevertex of each enabled array."
409 *
410 * Additionally, the overview in the GL_ARB_shader_draw_parameters spec
411 * says:
412 *
413 * "In unextended GL, vertex shaders have inputs named gl_VertexID and
414 * gl_InstanceID, which contain, respectively the index of the vertex
415 * and instance. The value of gl_VertexID is the implicitly passed
416 * index of the vertex being processed, which includes the value of
417 * baseVertex, for those commands that accept it."
418 *
419 * gl_VertexID gets basevertex added in. This differs from DirectX where
420 * SV_VertexID does \b not get basevertex added in.
421 *
422 * \note
423 * If all system values are available, \c SYSTEM_VALUE_VERTEX_ID will be
424 * equal to \c SYSTEM_VALUE_VERTEX_ID_ZERO_BASE plus
425 * \c SYSTEM_VALUE_BASE_VERTEX.
426 *
427 * \sa SYSTEM_VALUE_VERTEX_ID_ZERO_BASE, SYSTEM_VALUE_BASE_VERTEX
428 */
429 SYSTEM_VALUE_VERTEX_ID,
430
431 /**
432 * Instanced ID as supplied to gl_InstanceID
433 *
434 * Values assigned to gl_InstanceID always begin with zero, regardless of
435 * the value of baseinstance.
436 *
437 * Section 11.1.3.9 (Shader Inputs) of the OpenGL 4.4 core profile spec
438 * says:
439 *
440 * "gl_InstanceID holds the integer instance number of the current
441 * primitive in an instanced draw call (see section 10.5)."
442 *
443 * Through a big chain of pseudocode, section 10.5 describes that
444 * baseinstance is not counted by gl_InstanceID. In that section, notice
445 *
446 * "If an enabled vertex attribute array is instanced (it has a
447 * non-zero divisor as specified by VertexAttribDivisor), the element
448 * index that is transferred to the GL, for all vertices, is given by
449 *
450 * floor(instance/divisor) + baseinstance
451 *
452 * If an array corresponding to an attribute required by a vertex
453 * shader is not enabled, then the corresponding element is taken from
454 * the current attribute state (see section 10.2)."
455 *
456 * Note that baseinstance is \b not included in the value of instance.
457 */
458 SYSTEM_VALUE_INSTANCE_ID,
459
460 /**
461 * Vulkan InstanceIndex.
462 *
463 * InstanceIndex = gl_InstanceID + gl_BaseInstance
464 */
465 SYSTEM_VALUE_INSTANCE_INDEX,
466
467 /**
468 * DirectX-style vertex ID.
469 *
470 * Unlike \c SYSTEM_VALUE_VERTEX_ID, this system value does \b not include
471 * the value of basevertex.
472 *
473 * \sa SYSTEM_VALUE_VERTEX_ID, SYSTEM_VALUE_BASE_VERTEX
474 */
475 SYSTEM_VALUE_VERTEX_ID_ZERO_BASE,
476
477 /**
478 * Value of \c basevertex passed to \c glDrawElementsBaseVertex and similar
479 * functions.
480 *
481 * \sa SYSTEM_VALUE_VERTEX_ID, SYSTEM_VALUE_VERTEX_ID_ZERO_BASE
482 */
483 SYSTEM_VALUE_BASE_VERTEX,
484
485 /**
486 * Value of \c baseinstance passed to instanced draw entry points
487 *
488 * \sa SYSTEM_VALUE_INSTANCE_ID
489 */
490 SYSTEM_VALUE_BASE_INSTANCE,
491
492 /**
493 * From _ARB_shader_draw_parameters:
494 *
495 * "Additionally, this extension adds a further built-in variable,
496 * gl_DrawID to the shading language. This variable contains the index
497 * of the draw currently being processed by a Multi* variant of a
498 * drawing command (such as MultiDrawElements or
499 * MultiDrawArraysIndirect)."
500 *
501 * If GL_ARB_multi_draw_indirect is not supported, this is always 0.
502 */
503 SYSTEM_VALUE_DRAW_ID,
504 /*@}*/
505
506 /**
507 * \name Geometry shader system values
508 */
509 /*@{*/
510 SYSTEM_VALUE_INVOCATION_ID, /**< (Also in Tessellation Control shader) */
511 /*@}*/
512
513 /**
514 * \name Fragment shader system values
515 */
516 /*@{*/
517 SYSTEM_VALUE_FRAG_COORD,
518 SYSTEM_VALUE_FRONT_FACE,
519 SYSTEM_VALUE_SAMPLE_ID,
520 SYSTEM_VALUE_SAMPLE_POS,
521 SYSTEM_VALUE_SAMPLE_MASK_IN,
522 SYSTEM_VALUE_HELPER_INVOCATION,
523 /*@}*/
524
525 /**
526 * \name Tessellation Evaluation shader system values
527 */
528 /*@{*/
529 SYSTEM_VALUE_TESS_COORD,
530 SYSTEM_VALUE_VERTICES_IN, /**< Tessellation vertices in input patch */
531 SYSTEM_VALUE_PRIMITIVE_ID,
532 SYSTEM_VALUE_TESS_LEVEL_OUTER, /**< TES input */
533 SYSTEM_VALUE_TESS_LEVEL_INNER, /**< TES input */
534 /*@}*/
535
536 /**
537 * \name Compute shader system values
538 */
539 /*@{*/
540 SYSTEM_VALUE_LOCAL_INVOCATION_ID,
541 SYSTEM_VALUE_LOCAL_INVOCATION_INDEX,
542 SYSTEM_VALUE_GLOBAL_INVOCATION_ID,
543 SYSTEM_VALUE_WORK_GROUP_ID,
544 SYSTEM_VALUE_NUM_WORK_GROUPS,
545 SYSTEM_VALUE_LOCAL_GROUP_SIZE,
546 /*@}*/
547
548 /** Required for VK_KHX_multiview */
549 SYSTEM_VALUE_VIEW_INDEX,
550
551 /**
552 * Driver internal vertex-count, used (for example) for drivers to
553 * calculate stride for stream-out outputs. Not externally visible.
554 */
555 SYSTEM_VALUE_VERTEX_CNT,
556
557 SYSTEM_VALUE_MAX /**< Number of values */
558 } gl_system_value;
559
560 const char *gl_system_value_name(gl_system_value sysval);
561
562 /**
563 * The possible interpolation qualifiers that can be applied to a fragment
564 * shader input in GLSL.
565 *
566 * Note: INTERP_MODE_NONE must be 0 so that memsetting the
567 * ir_variable data structure to 0 causes the default behavior.
568 */
569 enum glsl_interp_mode
570 {
571 INTERP_MODE_NONE = 0,
572 INTERP_MODE_SMOOTH,
573 INTERP_MODE_FLAT,
574 INTERP_MODE_NOPERSPECTIVE,
575 INTERP_MODE_COUNT /**< Number of interpolation qualifiers */
576 };
577
578 enum glsl_interface_packing {
579 GLSL_INTERFACE_PACKING_STD140,
580 GLSL_INTERFACE_PACKING_SHARED,
581 GLSL_INTERFACE_PACKING_PACKED,
582 GLSL_INTERFACE_PACKING_STD430
583 };
584
585 const char *glsl_interp_mode_name(enum glsl_interp_mode qual);
586
587 /**
588 * Fragment program results
589 */
590 typedef enum
591 {
592 FRAG_RESULT_DEPTH = 0,
593 FRAG_RESULT_STENCIL = 1,
594 /* If a single color should be written to all render targets, this
595 * register is written. No FRAG_RESULT_DATAn will be written.
596 */
597 FRAG_RESULT_COLOR = 2,
598 FRAG_RESULT_SAMPLE_MASK = 3,
599
600 /* FRAG_RESULT_DATAn are the per-render-target (GLSL gl_FragData[n]
601 * or ARB_fragment_program fragment.color[n]) color results. If
602 * any are written, FRAG_RESULT_COLOR will not be written.
603 * FRAG_RESULT_DATA1 and up are simply for the benefit of
604 * gl_frag_result_name() and not to be construed as an upper bound
605 */
606 FRAG_RESULT_DATA0 = 4,
607 FRAG_RESULT_DATA1,
608 FRAG_RESULT_DATA2,
609 FRAG_RESULT_DATA3,
610 FRAG_RESULT_DATA4,
611 FRAG_RESULT_DATA5,
612 FRAG_RESULT_DATA6,
613 FRAG_RESULT_DATA7,
614 } gl_frag_result;
615
616 const char *gl_frag_result_name(gl_frag_result result);
617
618 #define FRAG_RESULT_MAX (FRAG_RESULT_DATA0 + MAX_DRAW_BUFFERS)
619
620 /**
621 * \brief Layout qualifiers for gl_FragDepth.
622 *
623 * Extension AMD_conservative_depth allows gl_FragDepth to be redeclared with
624 * a layout qualifier.
625 *
626 * \see enum ir_depth_layout
627 */
628 enum gl_frag_depth_layout
629 {
630 FRAG_DEPTH_LAYOUT_NONE, /**< No layout is specified. */
631 FRAG_DEPTH_LAYOUT_ANY,
632 FRAG_DEPTH_LAYOUT_GREATER,
633 FRAG_DEPTH_LAYOUT_LESS,
634 FRAG_DEPTH_LAYOUT_UNCHANGED
635 };
636
637 /**
638 * \brief Buffer access qualifiers
639 */
640 enum gl_buffer_access_qualifier
641 {
642 ACCESS_COHERENT = 1,
643 ACCESS_RESTRICT = 2,
644 ACCESS_VOLATILE = 4,
645 };
646
647 /**
648 * \brief Blend support qualifiers
649 */
650 enum gl_advanced_blend_mode
651 {
652 BLEND_NONE = 0x0000,
653
654 BLEND_MULTIPLY = 0x0001,
655 BLEND_SCREEN = 0x0002,
656 BLEND_OVERLAY = 0x0004,
657 BLEND_DARKEN = 0x0008,
658 BLEND_LIGHTEN = 0x0010,
659 BLEND_COLORDODGE = 0x0020,
660 BLEND_COLORBURN = 0x0040,
661 BLEND_HARDLIGHT = 0x0080,
662 BLEND_SOFTLIGHT = 0x0100,
663 BLEND_DIFFERENCE = 0x0200,
664 BLEND_EXCLUSION = 0x0400,
665 BLEND_HSL_HUE = 0x0800,
666 BLEND_HSL_SATURATION = 0x1000,
667 BLEND_HSL_COLOR = 0x2000,
668 BLEND_HSL_LUMINOSITY = 0x4000,
669
670 BLEND_ALL = 0x7fff,
671 };
672
673 enum gl_tess_spacing
674 {
675 TESS_SPACING_UNSPECIFIED,
676 TESS_SPACING_EQUAL,
677 TESS_SPACING_FRACTIONAL_ODD,
678 TESS_SPACING_FRACTIONAL_EVEN,
679 };
680
681 /**
682 * A compare function enum for use in compiler lowering passes. This is in
683 * the same order as GL's compare functions (shifted down by GL_NEVER), and is
684 * exactly the same as gallium's PIPE_FUNC_*.
685 */
686 enum compare_func
687 {
688 COMPARE_FUNC_NEVER,
689 COMPARE_FUNC_LESS,
690 COMPARE_FUNC_EQUAL,
691 COMPARE_FUNC_LEQUAL,
692 COMPARE_FUNC_GREATER,
693 COMPARE_FUNC_NOTEQUAL,
694 COMPARE_FUNC_GEQUAL,
695 COMPARE_FUNC_ALWAYS,
696 };
697
698 #ifdef __cplusplus
699 } /* extern "C" */
700 #endif
701
702 #endif /* SHADER_ENUMS_H */