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 * Bitflags for system values.
51 #define SYSTEM_BIT_SAMPLE_ID ((uint64_t)1 << SYSTEM_VALUE_SAMPLE_ID)
52 #define SYSTEM_BIT_SAMPLE_POS ((uint64_t)1 << SYSTEM_VALUE_SAMPLE_POS)
53 #define SYSTEM_BIT_SAMPLE_MASK_IN ((uint64_t)1 << SYSTEM_VALUE_SAMPLE_MASK_IN)
55 * If the gl_register_file is PROGRAM_SYSTEM_VALUE, the register index will be
56 * one of these values. If a NIR variable's mode is nir_var_system_value, it
57 * will be one of these values.
62 * \name Vertex shader system values
66 * OpenGL-style vertex ID.
68 * Section 2.11.7 (Shader Execution), subsection Shader Inputs, of the
69 * OpenGL 3.3 core profile spec says:
71 * "gl_VertexID holds the integer index i implicitly passed by
72 * DrawArrays or one of the other drawing commands defined in section
75 * Section 2.8.3 (Drawing Commands) of the same spec says:
77 * "The commands....are equivalent to the commands with the same base
78 * name (without the BaseVertex suffix), except that the ith element
79 * transferred by the corresponding draw call will be taken from
80 * element indices[i] + basevertex of each enabled array."
82 * Additionally, the overview in the GL_ARB_shader_draw_parameters spec
85 * "In unextended GL, vertex shaders have inputs named gl_VertexID and
86 * gl_InstanceID, which contain, respectively the index of the vertex
87 * and instance. The value of gl_VertexID is the implicitly passed
88 * index of the vertex being processed, which includes the value of
89 * baseVertex, for those commands that accept it."
91 * gl_VertexID gets basevertex added in. This differs from DirectX where
92 * SV_VertexID does \b not get basevertex added in.
95 * If all system values are available, \c SYSTEM_VALUE_VERTEX_ID will be
96 * equal to \c SYSTEM_VALUE_VERTEX_ID_ZERO_BASE plus
97 * \c SYSTEM_VALUE_BASE_VERTEX.
99 * \sa SYSTEM_VALUE_VERTEX_ID_ZERO_BASE, SYSTEM_VALUE_BASE_VERTEX
101 SYSTEM_VALUE_VERTEX_ID
,
104 * Instanced ID as supplied to gl_InstanceID
106 * Values assigned to gl_InstanceID always begin with zero, regardless of
107 * the value of baseinstance.
109 * Section 11.1.3.9 (Shader Inputs) of the OpenGL 4.4 core profile spec
112 * "gl_InstanceID holds the integer instance number of the current
113 * primitive in an instanced draw call (see section 10.5)."
115 * Through a big chain of pseudocode, section 10.5 describes that
116 * baseinstance is not counted by gl_InstanceID. In that section, notice
118 * "If an enabled vertex attribute array is instanced (it has a
119 * non-zero divisor as specified by VertexAttribDivisor), the element
120 * index that is transferred to the GL, for all vertices, is given by
122 * floor(instance/divisor) + baseinstance
124 * If an array corresponding to an attribute required by a vertex
125 * shader is not enabled, then the corresponding element is taken from
126 * the current attribute state (see section 10.2)."
128 * Note that baseinstance is \b not included in the value of instance.
130 SYSTEM_VALUE_INSTANCE_ID
,
133 * DirectX-style vertex ID.
135 * Unlike \c SYSTEM_VALUE_VERTEX_ID, this system value does \b not include
136 * the value of basevertex.
138 * \sa SYSTEM_VALUE_VERTEX_ID, SYSTEM_VALUE_BASE_VERTEX
140 SYSTEM_VALUE_VERTEX_ID_ZERO_BASE
,
143 * Value of \c basevertex passed to \c glDrawElementsBaseVertex and similar
146 * \sa SYSTEM_VALUE_VERTEX_ID, SYSTEM_VALUE_VERTEX_ID_ZERO_BASE
148 SYSTEM_VALUE_BASE_VERTEX
,
152 * \name Geometry shader system values
155 SYSTEM_VALUE_INVOCATION_ID
, /**< (Also in Tessellation Control shader) */
159 * \name Fragment shader system values
162 SYSTEM_VALUE_FRONT_FACE
, /**< (not done yet) */
163 SYSTEM_VALUE_SAMPLE_ID
,
164 SYSTEM_VALUE_SAMPLE_POS
,
165 SYSTEM_VALUE_SAMPLE_MASK_IN
,
169 * \name Tessellation Evaluation shader system values
172 SYSTEM_VALUE_TESS_COORD
,
173 SYSTEM_VALUE_VERTICES_IN
, /**< Tessellation vertices in input patch */
174 SYSTEM_VALUE_PRIMITIVE_ID
, /**< (currently not used by GS) */
175 SYSTEM_VALUE_TESS_LEVEL_OUTER
, /**< TES input */
176 SYSTEM_VALUE_TESS_LEVEL_INNER
, /**< TES input */
179 SYSTEM_VALUE_MAX
/**< Number of values */
184 * The possible interpolation qualifiers that can be applied to a fragment
185 * shader input in GLSL.
187 * Note: INTERP_QUALIFIER_NONE must be 0 so that memsetting the
188 * gl_fragment_program data structure to 0 causes the default behavior.
190 enum glsl_interp_qualifier
192 INTERP_QUALIFIER_NONE
= 0,
193 INTERP_QUALIFIER_SMOOTH
,
194 INTERP_QUALIFIER_FLAT
,
195 INTERP_QUALIFIER_NOPERSPECTIVE
,
196 INTERP_QUALIFIER_COUNT
/**< Number of interpolation qualifiers */
200 #endif /* SHADER_ENUMS_H */