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