2 * Mesa 3-D graphics library
4 * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
5 * Copyright (C) 2009 VMware, Inc. All Rights Reserved.
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:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
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.
26 #include "main/config.h"
28 #ifndef SHADER_ENUMS_H
29 #define SHADER_ENUMS_H
32 * Shader stages. Note that these will become 5 with tessellation.
34 * The order must match how shaders are ordered in the pipeline.
35 * The GLSL linker assumes that if i<j, then the j-th shader is
36 * executed later than the i-th shader.
40 MESA_SHADER_VERTEX
= 0,
41 MESA_SHADER_TESS_CTRL
= 1,
42 MESA_SHADER_TESS_EVAL
= 2,
43 MESA_SHADER_GEOMETRY
= 3,
44 MESA_SHADER_FRAGMENT
= 4,
45 MESA_SHADER_COMPUTE
= 5,
48 #define MESA_SHADER_STAGES (MESA_SHADER_COMPUTE + 1)
51 * Indexes for vertex program attributes.
52 * GL_NV_vertex_program aliases generic attributes over the conventional
53 * attributes. In GL_ARB_vertex_program shader the aliasing is optional.
54 * In GL_ARB_vertex_shader / OpenGL 2.0 the aliasing is disallowed (the
55 * generic attributes are distinct/separate).
60 VERT_ATTRIB_WEIGHT
= 1,
61 VERT_ATTRIB_NORMAL
= 2,
62 VERT_ATTRIB_COLOR0
= 3,
63 VERT_ATTRIB_COLOR1
= 4,
65 VERT_ATTRIB_COLOR_INDEX
= 6,
66 VERT_ATTRIB_EDGEFLAG
= 7,
69 VERT_ATTRIB_TEX2
= 10,
70 VERT_ATTRIB_TEX3
= 11,
71 VERT_ATTRIB_TEX4
= 12,
72 VERT_ATTRIB_TEX5
= 13,
73 VERT_ATTRIB_TEX6
= 14,
74 VERT_ATTRIB_TEX7
= 15,
75 VERT_ATTRIB_POINT_SIZE
= 16,
76 VERT_ATTRIB_GENERIC0
= 17,
77 VERT_ATTRIB_GENERIC1
= 18,
78 VERT_ATTRIB_GENERIC2
= 19,
79 VERT_ATTRIB_GENERIC3
= 20,
80 VERT_ATTRIB_GENERIC4
= 21,
81 VERT_ATTRIB_GENERIC5
= 22,
82 VERT_ATTRIB_GENERIC6
= 23,
83 VERT_ATTRIB_GENERIC7
= 24,
84 VERT_ATTRIB_GENERIC8
= 25,
85 VERT_ATTRIB_GENERIC9
= 26,
86 VERT_ATTRIB_GENERIC10
= 27,
87 VERT_ATTRIB_GENERIC11
= 28,
88 VERT_ATTRIB_GENERIC12
= 29,
89 VERT_ATTRIB_GENERIC13
= 30,
90 VERT_ATTRIB_GENERIC14
= 31,
91 VERT_ATTRIB_GENERIC15
= 32,
96 * Symbolic constats to help iterating over
97 * specific blocks of vertex attributes.
100 * includes all fixed function attributes as well as
101 * the aliased GL_NV_vertex_program shader attributes.
103 * include the classic texture coordinate attributes.
104 * Is a subset of VERT_ATTRIB_FF.
105 * VERT_ATTRIB_GENERIC
106 * include the OpenGL 2.0+ GLSL generic shader attributes.
107 * These alias the generic GL_ARB_vertex_shader attributes.
109 #define VERT_ATTRIB_FF(i) (VERT_ATTRIB_POS + (i))
110 #define VERT_ATTRIB_FF_MAX VERT_ATTRIB_GENERIC0
112 #define VERT_ATTRIB_TEX(i) (VERT_ATTRIB_TEX0 + (i))
113 #define VERT_ATTRIB_TEX_MAX MAX_TEXTURE_COORD_UNITS
115 #define VERT_ATTRIB_GENERIC(i) (VERT_ATTRIB_GENERIC0 + (i))
116 #define VERT_ATTRIB_GENERIC_MAX MAX_VERTEX_GENERIC_ATTRIBS
119 * Bitflags for vertex attributes.
120 * These are used in bitfields in many places.
123 #define VERT_BIT_POS BITFIELD64_BIT(VERT_ATTRIB_POS)
124 #define VERT_BIT_WEIGHT BITFIELD64_BIT(VERT_ATTRIB_WEIGHT)
125 #define VERT_BIT_NORMAL BITFIELD64_BIT(VERT_ATTRIB_NORMAL)
126 #define VERT_BIT_COLOR0 BITFIELD64_BIT(VERT_ATTRIB_COLOR0)
127 #define VERT_BIT_COLOR1 BITFIELD64_BIT(VERT_ATTRIB_COLOR1)
128 #define VERT_BIT_FOG BITFIELD64_BIT(VERT_ATTRIB_FOG)
129 #define VERT_BIT_COLOR_INDEX BITFIELD64_BIT(VERT_ATTRIB_COLOR_INDEX)
130 #define VERT_BIT_EDGEFLAG BITFIELD64_BIT(VERT_ATTRIB_EDGEFLAG)
131 #define VERT_BIT_TEX0 BITFIELD64_BIT(VERT_ATTRIB_TEX0)
132 #define VERT_BIT_TEX1 BITFIELD64_BIT(VERT_ATTRIB_TEX1)
133 #define VERT_BIT_TEX2 BITFIELD64_BIT(VERT_ATTRIB_TEX2)
134 #define VERT_BIT_TEX3 BITFIELD64_BIT(VERT_ATTRIB_TEX3)
135 #define VERT_BIT_TEX4 BITFIELD64_BIT(VERT_ATTRIB_TEX4)
136 #define VERT_BIT_TEX5 BITFIELD64_BIT(VERT_ATTRIB_TEX5)
137 #define VERT_BIT_TEX6 BITFIELD64_BIT(VERT_ATTRIB_TEX6)
138 #define VERT_BIT_TEX7 BITFIELD64_BIT(VERT_ATTRIB_TEX7)
139 #define VERT_BIT_POINT_SIZE BITFIELD64_BIT(VERT_ATTRIB_POINT_SIZE)
140 #define VERT_BIT_GENERIC0 BITFIELD64_BIT(VERT_ATTRIB_GENERIC0)
142 #define VERT_BIT(i) BITFIELD64_BIT(i)
143 #define VERT_BIT_ALL BITFIELD64_RANGE(0, VERT_ATTRIB_MAX)
145 #define VERT_BIT_FF(i) VERT_BIT(i)
146 #define VERT_BIT_FF_ALL BITFIELD64_RANGE(0, VERT_ATTRIB_FF_MAX)
147 #define VERT_BIT_TEX(i) VERT_BIT(VERT_ATTRIB_TEX(i))
148 #define VERT_BIT_TEX_ALL \
149 BITFIELD64_RANGE(VERT_ATTRIB_TEX(0), VERT_ATTRIB_TEX_MAX)
151 #define VERT_BIT_GENERIC(i) VERT_BIT(VERT_ATTRIB_GENERIC(i))
152 #define VERT_BIT_GENERIC_ALL \
153 BITFIELD64_RANGE(VERT_ATTRIB_GENERIC(0), VERT_ATTRIB_GENERIC_MAX)
157 * Indexes for vertex shader outputs, geometry shader inputs/outputs, and
158 * fragment shader inputs.
160 * Note that some of these values are not available to all pipeline stages.
162 * When this enum is updated, the following code must be updated too:
163 * - vertResults (in prog_print.c's arb_output_attrib_string())
164 * - fragAttribs (in prog_print.c's arb_input_attrib_string())
165 * - _mesa_varying_slot_in_fs()
170 VARYING_SLOT_COL0
, /* COL0 and COL1 must be contiguous */
173 VARYING_SLOT_TEX0
, /* TEX0-TEX7 must be contiguous */
181 VARYING_SLOT_PSIZ
, /* Does not appear in FS */
182 VARYING_SLOT_BFC0
, /* Does not appear in FS */
183 VARYING_SLOT_BFC1
, /* Does not appear in FS */
184 VARYING_SLOT_EDGE
, /* Does not appear in FS */
185 VARYING_SLOT_CLIP_VERTEX
, /* Does not appear in FS */
186 VARYING_SLOT_CLIP_DIST0
,
187 VARYING_SLOT_CLIP_DIST1
,
188 VARYING_SLOT_PRIMITIVE_ID
, /* Does not appear in VS */
189 VARYING_SLOT_LAYER
, /* Appears as VS or GS output */
190 VARYING_SLOT_VIEWPORT
, /* Appears as VS or GS output */
191 VARYING_SLOT_FACE
, /* FS only */
192 VARYING_SLOT_PNTC
, /* FS only */
193 VARYING_SLOT_TESS_LEVEL_OUTER
, /* Only appears as TCS output. */
194 VARYING_SLOT_TESS_LEVEL_INNER
, /* Only appears as TCS output. */
195 VARYING_SLOT_VAR0
, /* First generic varying slot */
200 * Bitflags for varying slots.
203 #define VARYING_BIT_POS BITFIELD64_BIT(VARYING_SLOT_POS)
204 #define VARYING_BIT_COL0 BITFIELD64_BIT(VARYING_SLOT_COL0)
205 #define VARYING_BIT_COL1 BITFIELD64_BIT(VARYING_SLOT_COL1)
206 #define VARYING_BIT_FOGC BITFIELD64_BIT(VARYING_SLOT_FOGC)
207 #define VARYING_BIT_TEX0 BITFIELD64_BIT(VARYING_SLOT_TEX0)
208 #define VARYING_BIT_TEX1 BITFIELD64_BIT(VARYING_SLOT_TEX1)
209 #define VARYING_BIT_TEX2 BITFIELD64_BIT(VARYING_SLOT_TEX2)
210 #define VARYING_BIT_TEX3 BITFIELD64_BIT(VARYING_SLOT_TEX3)
211 #define VARYING_BIT_TEX4 BITFIELD64_BIT(VARYING_SLOT_TEX4)
212 #define VARYING_BIT_TEX5 BITFIELD64_BIT(VARYING_SLOT_TEX5)
213 #define VARYING_BIT_TEX6 BITFIELD64_BIT(VARYING_SLOT_TEX6)
214 #define VARYING_BIT_TEX7 BITFIELD64_BIT(VARYING_SLOT_TEX7)
215 #define VARYING_BIT_TEX(U) BITFIELD64_BIT(VARYING_SLOT_TEX0 + (U))
216 #define VARYING_BITS_TEX_ANY BITFIELD64_RANGE(VARYING_SLOT_TEX0, \
217 MAX_TEXTURE_COORD_UNITS)
218 #define VARYING_BIT_PSIZ BITFIELD64_BIT(VARYING_SLOT_PSIZ)
219 #define VARYING_BIT_BFC0 BITFIELD64_BIT(VARYING_SLOT_BFC0)
220 #define VARYING_BIT_BFC1 BITFIELD64_BIT(VARYING_SLOT_BFC1)
221 #define VARYING_BIT_EDGE BITFIELD64_BIT(VARYING_SLOT_EDGE)
222 #define VARYING_BIT_CLIP_VERTEX BITFIELD64_BIT(VARYING_SLOT_CLIP_VERTEX)
223 #define VARYING_BIT_CLIP_DIST0 BITFIELD64_BIT(VARYING_SLOT_CLIP_DIST0)
224 #define VARYING_BIT_CLIP_DIST1 BITFIELD64_BIT(VARYING_SLOT_CLIP_DIST1)
225 #define VARYING_BIT_PRIMITIVE_ID BITFIELD64_BIT(VARYING_SLOT_PRIMITIVE_ID)
226 #define VARYING_BIT_LAYER BITFIELD64_BIT(VARYING_SLOT_LAYER)
227 #define VARYING_BIT_VIEWPORT BITFIELD64_BIT(VARYING_SLOT_VIEWPORT)
228 #define VARYING_BIT_FACE BITFIELD64_BIT(VARYING_SLOT_FACE)
229 #define VARYING_BIT_PNTC BITFIELD64_BIT(VARYING_SLOT_PNTC)
230 #define VARYING_BIT_TESS_LEVEL_OUTER BITFIELD64_BIT(VARYING_SLOT_TESS_LEVEL_OUTER)
231 #define VARYING_BIT_TESS_LEVEL_INNER BITFIELD64_BIT(VARYING_SLOT_TESS_LEVEL_INNER)
232 #define VARYING_BIT_VAR(V) BITFIELD64_BIT(VARYING_SLOT_VAR0 + (V))
236 * Bitflags for system values.
238 #define SYSTEM_BIT_SAMPLE_ID ((uint64_t)1 << SYSTEM_VALUE_SAMPLE_ID)
239 #define SYSTEM_BIT_SAMPLE_POS ((uint64_t)1 << SYSTEM_VALUE_SAMPLE_POS)
240 #define SYSTEM_BIT_SAMPLE_MASK_IN ((uint64_t)1 << SYSTEM_VALUE_SAMPLE_MASK_IN)
242 * If the gl_register_file is PROGRAM_SYSTEM_VALUE, the register index will be
243 * one of these values. If a NIR variable's mode is nir_var_system_value, it
244 * will be one of these values.
249 * \name Vertex shader system values
253 * OpenGL-style vertex ID.
255 * Section 2.11.7 (Shader Execution), subsection Shader Inputs, of the
256 * OpenGL 3.3 core profile spec says:
258 * "gl_VertexID holds the integer index i implicitly passed by
259 * DrawArrays or one of the other drawing commands defined in section
262 * Section 2.8.3 (Drawing Commands) of the same spec says:
264 * "The commands....are equivalent to the commands with the same base
265 * name (without the BaseVertex suffix), except that the ith element
266 * transferred by the corresponding draw call will be taken from
267 * element indices[i] + basevertex of each enabled array."
269 * Additionally, the overview in the GL_ARB_shader_draw_parameters spec
272 * "In unextended GL, vertex shaders have inputs named gl_VertexID and
273 * gl_InstanceID, which contain, respectively the index of the vertex
274 * and instance. The value of gl_VertexID is the implicitly passed
275 * index of the vertex being processed, which includes the value of
276 * baseVertex, for those commands that accept it."
278 * gl_VertexID gets basevertex added in. This differs from DirectX where
279 * SV_VertexID does \b not get basevertex added in.
282 * If all system values are available, \c SYSTEM_VALUE_VERTEX_ID will be
283 * equal to \c SYSTEM_VALUE_VERTEX_ID_ZERO_BASE plus
284 * \c SYSTEM_VALUE_BASE_VERTEX.
286 * \sa SYSTEM_VALUE_VERTEX_ID_ZERO_BASE, SYSTEM_VALUE_BASE_VERTEX
288 SYSTEM_VALUE_VERTEX_ID
,
291 * Instanced ID as supplied to gl_InstanceID
293 * Values assigned to gl_InstanceID always begin with zero, regardless of
294 * the value of baseinstance.
296 * Section 11.1.3.9 (Shader Inputs) of the OpenGL 4.4 core profile spec
299 * "gl_InstanceID holds the integer instance number of the current
300 * primitive in an instanced draw call (see section 10.5)."
302 * Through a big chain of pseudocode, section 10.5 describes that
303 * baseinstance is not counted by gl_InstanceID. In that section, notice
305 * "If an enabled vertex attribute array is instanced (it has a
306 * non-zero divisor as specified by VertexAttribDivisor), the element
307 * index that is transferred to the GL, for all vertices, is given by
309 * floor(instance/divisor) + baseinstance
311 * If an array corresponding to an attribute required by a vertex
312 * shader is not enabled, then the corresponding element is taken from
313 * the current attribute state (see section 10.2)."
315 * Note that baseinstance is \b not included in the value of instance.
317 SYSTEM_VALUE_INSTANCE_ID
,
320 * DirectX-style vertex ID.
322 * Unlike \c SYSTEM_VALUE_VERTEX_ID, this system value does \b not include
323 * the value of basevertex.
325 * \sa SYSTEM_VALUE_VERTEX_ID, SYSTEM_VALUE_BASE_VERTEX
327 SYSTEM_VALUE_VERTEX_ID_ZERO_BASE
,
330 * Value of \c basevertex passed to \c glDrawElementsBaseVertex and similar
333 * \sa SYSTEM_VALUE_VERTEX_ID, SYSTEM_VALUE_VERTEX_ID_ZERO_BASE
335 SYSTEM_VALUE_BASE_VERTEX
,
339 * \name Geometry shader system values
342 SYSTEM_VALUE_INVOCATION_ID
, /**< (Also in Tessellation Control shader) */
346 * \name Fragment shader system values
349 SYSTEM_VALUE_FRONT_FACE
, /**< (not done yet) */
350 SYSTEM_VALUE_SAMPLE_ID
,
351 SYSTEM_VALUE_SAMPLE_POS
,
352 SYSTEM_VALUE_SAMPLE_MASK_IN
,
356 * \name Tessellation Evaluation shader system values
359 SYSTEM_VALUE_TESS_COORD
,
360 SYSTEM_VALUE_VERTICES_IN
, /**< Tessellation vertices in input patch */
361 SYSTEM_VALUE_PRIMITIVE_ID
, /**< (currently not used by GS) */
362 SYSTEM_VALUE_TESS_LEVEL_OUTER
, /**< TES input */
363 SYSTEM_VALUE_TESS_LEVEL_INNER
, /**< TES input */
366 SYSTEM_VALUE_MAX
/**< Number of values */
371 * The possible interpolation qualifiers that can be applied to a fragment
372 * shader input in GLSL.
374 * Note: INTERP_QUALIFIER_NONE must be 0 so that memsetting the
375 * gl_fragment_program data structure to 0 causes the default behavior.
377 enum glsl_interp_qualifier
379 INTERP_QUALIFIER_NONE
= 0,
380 INTERP_QUALIFIER_SMOOTH
,
381 INTERP_QUALIFIER_FLAT
,
382 INTERP_QUALIFIER_NOPERSPECTIVE
,
383 INTERP_QUALIFIER_COUNT
/**< Number of interpolation qualifiers */
387 * Fragment program results
391 FRAG_RESULT_DEPTH
= 0,
392 FRAG_RESULT_STENCIL
= 1,
393 /* If a single color should be written to all render targets, this
394 * register is written. No FRAG_RESULT_DATAn will be written.
396 FRAG_RESULT_COLOR
= 2,
397 FRAG_RESULT_SAMPLE_MASK
= 3,
399 /* FRAG_RESULT_DATAn are the per-render-target (GLSL gl_FragData[n]
400 * or ARB_fragment_program fragment.color[n]) color results. If
401 * any are written, FRAG_RESULT_COLOR will not be written.
403 FRAG_RESULT_DATA0
= 4,
406 #endif /* SHADER_ENUMS_H */