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 #ifndef SHADER_ENUMS_H
27 #define SHADER_ENUMS_H
30 * Shader stages. Note that these will become 5 with tessellation.
32 * The order must match how shaders are ordered in the pipeline.
33 * The GLSL linker assumes that if i<j, then the j-th shader is
34 * executed later than the i-th shader.
38 MESA_SHADER_VERTEX
= 0,
39 MESA_SHADER_TESS_CTRL
= 1,
40 MESA_SHADER_TESS_EVAL
= 2,
41 MESA_SHADER_GEOMETRY
= 3,
42 MESA_SHADER_FRAGMENT
= 4,
43 MESA_SHADER_COMPUTE
= 5,
46 #define MESA_SHADER_STAGES (MESA_SHADER_COMPUTE + 1)
49 * Indexes for vertex shader outputs, geometry shader inputs/outputs, and
50 * fragment shader inputs.
52 * Note that some of these values are not available to all pipeline stages.
54 * When this enum is updated, the following code must be updated too:
55 * - vertResults (in prog_print.c's arb_output_attrib_string())
56 * - fragAttribs (in prog_print.c's arb_input_attrib_string())
57 * - _mesa_varying_slot_in_fs()
62 VARYING_SLOT_COL0
, /* COL0 and COL1 must be contiguous */
65 VARYING_SLOT_TEX0
, /* TEX0-TEX7 must be contiguous */
73 VARYING_SLOT_PSIZ
, /* Does not appear in FS */
74 VARYING_SLOT_BFC0
, /* Does not appear in FS */
75 VARYING_SLOT_BFC1
, /* Does not appear in FS */
76 VARYING_SLOT_EDGE
, /* Does not appear in FS */
77 VARYING_SLOT_CLIP_VERTEX
, /* Does not appear in FS */
78 VARYING_SLOT_CLIP_DIST0
,
79 VARYING_SLOT_CLIP_DIST1
,
80 VARYING_SLOT_PRIMITIVE_ID
, /* Does not appear in VS */
81 VARYING_SLOT_LAYER
, /* Appears as VS or GS output */
82 VARYING_SLOT_VIEWPORT
, /* Appears as VS or GS output */
83 VARYING_SLOT_FACE
, /* FS only */
84 VARYING_SLOT_PNTC
, /* FS only */
85 VARYING_SLOT_TESS_LEVEL_OUTER
, /* Only appears as TCS output. */
86 VARYING_SLOT_TESS_LEVEL_INNER
, /* Only appears as TCS output. */
87 VARYING_SLOT_VAR0
, /* First generic varying slot */
92 * Bitflags for varying slots.
95 #define VARYING_BIT_POS BITFIELD64_BIT(VARYING_SLOT_POS)
96 #define VARYING_BIT_COL0 BITFIELD64_BIT(VARYING_SLOT_COL0)
97 #define VARYING_BIT_COL1 BITFIELD64_BIT(VARYING_SLOT_COL1)
98 #define VARYING_BIT_FOGC BITFIELD64_BIT(VARYING_SLOT_FOGC)
99 #define VARYING_BIT_TEX0 BITFIELD64_BIT(VARYING_SLOT_TEX0)
100 #define VARYING_BIT_TEX1 BITFIELD64_BIT(VARYING_SLOT_TEX1)
101 #define VARYING_BIT_TEX2 BITFIELD64_BIT(VARYING_SLOT_TEX2)
102 #define VARYING_BIT_TEX3 BITFIELD64_BIT(VARYING_SLOT_TEX3)
103 #define VARYING_BIT_TEX4 BITFIELD64_BIT(VARYING_SLOT_TEX4)
104 #define VARYING_BIT_TEX5 BITFIELD64_BIT(VARYING_SLOT_TEX5)
105 #define VARYING_BIT_TEX6 BITFIELD64_BIT(VARYING_SLOT_TEX6)
106 #define VARYING_BIT_TEX7 BITFIELD64_BIT(VARYING_SLOT_TEX7)
107 #define VARYING_BIT_TEX(U) BITFIELD64_BIT(VARYING_SLOT_TEX0 + (U))
108 #define VARYING_BITS_TEX_ANY BITFIELD64_RANGE(VARYING_SLOT_TEX0, \
109 MAX_TEXTURE_COORD_UNITS)
110 #define VARYING_BIT_PSIZ BITFIELD64_BIT(VARYING_SLOT_PSIZ)
111 #define VARYING_BIT_BFC0 BITFIELD64_BIT(VARYING_SLOT_BFC0)
112 #define VARYING_BIT_BFC1 BITFIELD64_BIT(VARYING_SLOT_BFC1)
113 #define VARYING_BIT_EDGE BITFIELD64_BIT(VARYING_SLOT_EDGE)
114 #define VARYING_BIT_CLIP_VERTEX BITFIELD64_BIT(VARYING_SLOT_CLIP_VERTEX)
115 #define VARYING_BIT_CLIP_DIST0 BITFIELD64_BIT(VARYING_SLOT_CLIP_DIST0)
116 #define VARYING_BIT_CLIP_DIST1 BITFIELD64_BIT(VARYING_SLOT_CLIP_DIST1)
117 #define VARYING_BIT_PRIMITIVE_ID BITFIELD64_BIT(VARYING_SLOT_PRIMITIVE_ID)
118 #define VARYING_BIT_LAYER BITFIELD64_BIT(VARYING_SLOT_LAYER)
119 #define VARYING_BIT_VIEWPORT BITFIELD64_BIT(VARYING_SLOT_VIEWPORT)
120 #define VARYING_BIT_FACE BITFIELD64_BIT(VARYING_SLOT_FACE)
121 #define VARYING_BIT_PNTC BITFIELD64_BIT(VARYING_SLOT_PNTC)
122 #define VARYING_BIT_TESS_LEVEL_OUTER BITFIELD64_BIT(VARYING_SLOT_TESS_LEVEL_OUTER)
123 #define VARYING_BIT_TESS_LEVEL_INNER BITFIELD64_BIT(VARYING_SLOT_TESS_LEVEL_INNER)
124 #define VARYING_BIT_VAR(V) BITFIELD64_BIT(VARYING_SLOT_VAR0 + (V))
128 * Bitflags for system values.
130 #define SYSTEM_BIT_SAMPLE_ID ((uint64_t)1 << SYSTEM_VALUE_SAMPLE_ID)
131 #define SYSTEM_BIT_SAMPLE_POS ((uint64_t)1 << SYSTEM_VALUE_SAMPLE_POS)
132 #define SYSTEM_BIT_SAMPLE_MASK_IN ((uint64_t)1 << SYSTEM_VALUE_SAMPLE_MASK_IN)
134 * If the gl_register_file is PROGRAM_SYSTEM_VALUE, the register index will be
135 * one of these values. If a NIR variable's mode is nir_var_system_value, it
136 * will be one of these values.
141 * \name Vertex shader system values
145 * OpenGL-style vertex ID.
147 * Section 2.11.7 (Shader Execution), subsection Shader Inputs, of the
148 * OpenGL 3.3 core profile spec says:
150 * "gl_VertexID holds the integer index i implicitly passed by
151 * DrawArrays or one of the other drawing commands defined in section
154 * Section 2.8.3 (Drawing Commands) of the same spec says:
156 * "The commands....are equivalent to the commands with the same base
157 * name (without the BaseVertex suffix), except that the ith element
158 * transferred by the corresponding draw call will be taken from
159 * element indices[i] + basevertex of each enabled array."
161 * Additionally, the overview in the GL_ARB_shader_draw_parameters spec
164 * "In unextended GL, vertex shaders have inputs named gl_VertexID and
165 * gl_InstanceID, which contain, respectively the index of the vertex
166 * and instance. The value of gl_VertexID is the implicitly passed
167 * index of the vertex being processed, which includes the value of
168 * baseVertex, for those commands that accept it."
170 * gl_VertexID gets basevertex added in. This differs from DirectX where
171 * SV_VertexID does \b not get basevertex added in.
174 * If all system values are available, \c SYSTEM_VALUE_VERTEX_ID will be
175 * equal to \c SYSTEM_VALUE_VERTEX_ID_ZERO_BASE plus
176 * \c SYSTEM_VALUE_BASE_VERTEX.
178 * \sa SYSTEM_VALUE_VERTEX_ID_ZERO_BASE, SYSTEM_VALUE_BASE_VERTEX
180 SYSTEM_VALUE_VERTEX_ID
,
183 * Instanced ID as supplied to gl_InstanceID
185 * Values assigned to gl_InstanceID always begin with zero, regardless of
186 * the value of baseinstance.
188 * Section 11.1.3.9 (Shader Inputs) of the OpenGL 4.4 core profile spec
191 * "gl_InstanceID holds the integer instance number of the current
192 * primitive in an instanced draw call (see section 10.5)."
194 * Through a big chain of pseudocode, section 10.5 describes that
195 * baseinstance is not counted by gl_InstanceID. In that section, notice
197 * "If an enabled vertex attribute array is instanced (it has a
198 * non-zero divisor as specified by VertexAttribDivisor), the element
199 * index that is transferred to the GL, for all vertices, is given by
201 * floor(instance/divisor) + baseinstance
203 * If an array corresponding to an attribute required by a vertex
204 * shader is not enabled, then the corresponding element is taken from
205 * the current attribute state (see section 10.2)."
207 * Note that baseinstance is \b not included in the value of instance.
209 SYSTEM_VALUE_INSTANCE_ID
,
212 * DirectX-style vertex ID.
214 * Unlike \c SYSTEM_VALUE_VERTEX_ID, this system value does \b not include
215 * the value of basevertex.
217 * \sa SYSTEM_VALUE_VERTEX_ID, SYSTEM_VALUE_BASE_VERTEX
219 SYSTEM_VALUE_VERTEX_ID_ZERO_BASE
,
222 * Value of \c basevertex passed to \c glDrawElementsBaseVertex and similar
225 * \sa SYSTEM_VALUE_VERTEX_ID, SYSTEM_VALUE_VERTEX_ID_ZERO_BASE
227 SYSTEM_VALUE_BASE_VERTEX
,
231 * \name Geometry shader system values
234 SYSTEM_VALUE_INVOCATION_ID
, /**< (Also in Tessellation Control shader) */
238 * \name Fragment shader system values
241 SYSTEM_VALUE_FRONT_FACE
, /**< (not done yet) */
242 SYSTEM_VALUE_SAMPLE_ID
,
243 SYSTEM_VALUE_SAMPLE_POS
,
244 SYSTEM_VALUE_SAMPLE_MASK_IN
,
248 * \name Tessellation Evaluation shader system values
251 SYSTEM_VALUE_TESS_COORD
,
252 SYSTEM_VALUE_VERTICES_IN
, /**< Tessellation vertices in input patch */
253 SYSTEM_VALUE_PRIMITIVE_ID
, /**< (currently not used by GS) */
254 SYSTEM_VALUE_TESS_LEVEL_OUTER
, /**< TES input */
255 SYSTEM_VALUE_TESS_LEVEL_INNER
, /**< TES input */
258 SYSTEM_VALUE_MAX
/**< Number of values */
263 * The possible interpolation qualifiers that can be applied to a fragment
264 * shader input in GLSL.
266 * Note: INTERP_QUALIFIER_NONE must be 0 so that memsetting the
267 * gl_fragment_program data structure to 0 causes the default behavior.
269 enum glsl_interp_qualifier
271 INTERP_QUALIFIER_NONE
= 0,
272 INTERP_QUALIFIER_SMOOTH
,
273 INTERP_QUALIFIER_FLAT
,
274 INTERP_QUALIFIER_NOPERSPECTIVE
,
275 INTERP_QUALIFIER_COUNT
/**< Number of interpolation qualifiers */
279 * Fragment program results
283 FRAG_RESULT_DEPTH
= 0,
284 FRAG_RESULT_STENCIL
= 1,
285 /* If a single color should be written to all render targets, this
286 * register is written. No FRAG_RESULT_DATAn will be written.
288 FRAG_RESULT_COLOR
= 2,
289 FRAG_RESULT_SAMPLE_MASK
= 3,
291 /* FRAG_RESULT_DATAn are the per-render-target (GLSL gl_FragData[n]
292 * or ARB_fragment_program fragment.color[n]) color results. If
293 * any are written, FRAG_RESULT_COLOR will not be written.
295 FRAG_RESULT_DATA0
= 4,
298 #endif /* SHADER_ENUMS_H */