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