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