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_GEOMETRY
= 1,
40 MESA_SHADER_FRAGMENT
= 2,
41 MESA_SHADER_COMPUTE
= 3,
44 #define MESA_SHADER_STAGES (MESA_SHADER_COMPUTE + 1)
47 * Bitflags for system values.
49 #define SYSTEM_BIT_SAMPLE_ID ((uint64_t)1 << SYSTEM_VALUE_SAMPLE_ID)
50 #define SYSTEM_BIT_SAMPLE_POS ((uint64_t)1 << SYSTEM_VALUE_SAMPLE_POS)
51 #define SYSTEM_BIT_SAMPLE_MASK_IN ((uint64_t)1 << SYSTEM_VALUE_SAMPLE_MASK_IN)
53 * If the gl_register_file is PROGRAM_SYSTEM_VALUE, the register index will be
54 * one of these values. If a NIR variable's mode is nir_var_system_value, it
55 * will be one of these values.
60 * \name Vertex shader system values
64 * OpenGL-style vertex ID.
66 * Section 2.11.7 (Shader Execution), subsection Shader Inputs, of the
67 * OpenGL 3.3 core profile spec says:
69 * "gl_VertexID holds the integer index i implicitly passed by
70 * DrawArrays or one of the other drawing commands defined in section
73 * Section 2.8.3 (Drawing Commands) of the same spec says:
75 * "The commands....are equivalent to the commands with the same base
76 * name (without the BaseVertex suffix), except that the ith element
77 * transferred by the corresponding draw call will be taken from
78 * element indices[i] + basevertex of each enabled array."
80 * Additionally, the overview in the GL_ARB_shader_draw_parameters spec
83 * "In unextended GL, vertex shaders have inputs named gl_VertexID and
84 * gl_InstanceID, which contain, respectively the index of the vertex
85 * and instance. The value of gl_VertexID is the implicitly passed
86 * index of the vertex being processed, which includes the value of
87 * baseVertex, for those commands that accept it."
89 * gl_VertexID gets basevertex added in. This differs from DirectX where
90 * SV_VertexID does \b not get basevertex added in.
93 * If all system values are available, \c SYSTEM_VALUE_VERTEX_ID will be
94 * equal to \c SYSTEM_VALUE_VERTEX_ID_ZERO_BASE plus
95 * \c SYSTEM_VALUE_BASE_VERTEX.
97 * \sa SYSTEM_VALUE_VERTEX_ID_ZERO_BASE, SYSTEM_VALUE_BASE_VERTEX
99 SYSTEM_VALUE_VERTEX_ID
,
102 * Instanced ID as supplied to gl_InstanceID
104 * Values assigned to gl_InstanceID always begin with zero, regardless of
105 * the value of baseinstance.
107 * Section 11.1.3.9 (Shader Inputs) of the OpenGL 4.4 core profile spec
110 * "gl_InstanceID holds the integer instance number of the current
111 * primitive in an instanced draw call (see section 10.5)."
113 * Through a big chain of pseudocode, section 10.5 describes that
114 * baseinstance is not counted by gl_InstanceID. In that section, notice
116 * "If an enabled vertex attribute array is instanced (it has a
117 * non-zero divisor as specified by VertexAttribDivisor), the element
118 * index that is transferred to the GL, for all vertices, is given by
120 * floor(instance/divisor) + baseinstance
122 * If an array corresponding to an attribute required by a vertex
123 * shader is not enabled, then the corresponding element is taken from
124 * the current attribute state (see section 10.2)."
126 * Note that baseinstance is \b not included in the value of instance.
128 SYSTEM_VALUE_INSTANCE_ID
,
131 * DirectX-style vertex ID.
133 * Unlike \c SYSTEM_VALUE_VERTEX_ID, this system value does \b not include
134 * the value of basevertex.
136 * \sa SYSTEM_VALUE_VERTEX_ID, SYSTEM_VALUE_BASE_VERTEX
138 SYSTEM_VALUE_VERTEX_ID_ZERO_BASE
,
141 * Value of \c basevertex passed to \c glDrawElementsBaseVertex and similar
144 * \sa SYSTEM_VALUE_VERTEX_ID, SYSTEM_VALUE_VERTEX_ID_ZERO_BASE
146 SYSTEM_VALUE_BASE_VERTEX
,
150 * \name Geometry shader system values
153 SYSTEM_VALUE_INVOCATION_ID
,
157 * \name Fragment shader system values
160 SYSTEM_VALUE_FRONT_FACE
, /**< (not done yet) */
161 SYSTEM_VALUE_SAMPLE_ID
,
162 SYSTEM_VALUE_SAMPLE_POS
,
163 SYSTEM_VALUE_SAMPLE_MASK_IN
,
166 SYSTEM_VALUE_MAX
/**< Number of values */
171 * The possible interpolation qualifiers that can be applied to a fragment
172 * shader input in GLSL.
174 * Note: INTERP_QUALIFIER_NONE must be 0 so that memsetting the
175 * gl_fragment_program data structure to 0 causes the default behavior.
177 enum glsl_interp_qualifier
179 INTERP_QUALIFIER_NONE
= 0,
180 INTERP_QUALIFIER_SMOOTH
,
181 INTERP_QUALIFIER_FLAT
,
182 INTERP_QUALIFIER_NOPERSPECTIVE
,
183 INTERP_QUALIFIER_COUNT
/**< Number of interpolation qualifiers */
187 #endif /* SHADER_ENUMS_H */