2 * Copyright © 2009 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
24 const glsl_type
glsl_type::_error_type
=
25 glsl_type(GL_INVALID_ENUM
, GLSL_TYPE_ERROR
, 0, 0, "");
27 const glsl_type
glsl_type::void_type
=
28 glsl_type(GL_INVALID_ENUM
, GLSL_TYPE_VOID
, 0, 0, "void");
30 const glsl_type
*const glsl_type::error_type
= & glsl_type::_error_type
;
32 /** \name Core built-in types
34 * These types exist in all versions of GLSL.
38 const glsl_type
glsl_type::builtin_core_types
[] = {
39 glsl_type(GL_BOOL
, GLSL_TYPE_BOOL
, 1, 1, "bool"),
40 glsl_type(GL_BOOL_VEC2
, GLSL_TYPE_BOOL
, 2, 1, "bvec2"),
41 glsl_type(GL_BOOL_VEC3
, GLSL_TYPE_BOOL
, 3, 1, "bvec3"),
42 glsl_type(GL_BOOL_VEC4
, GLSL_TYPE_BOOL
, 4, 1, "bvec4"),
43 glsl_type(GL_INT
, GLSL_TYPE_INT
, 1, 1, "int"),
44 glsl_type(GL_INT_VEC2
, GLSL_TYPE_INT
, 2, 1, "ivec2"),
45 glsl_type(GL_INT_VEC3
, GLSL_TYPE_INT
, 3, 1, "ivec3"),
46 glsl_type(GL_INT_VEC4
, GLSL_TYPE_INT
, 4, 1, "ivec4"),
47 glsl_type(GL_FLOAT
, GLSL_TYPE_FLOAT
, 1, 1, "float"),
48 glsl_type(GL_FLOAT_VEC2
, GLSL_TYPE_FLOAT
, 2, 1, "vec2"),
49 glsl_type(GL_FLOAT_VEC3
, GLSL_TYPE_FLOAT
, 3, 1, "vec3"),
50 glsl_type(GL_FLOAT_VEC4
, GLSL_TYPE_FLOAT
, 4, 1, "vec4"),
51 glsl_type(GL_FLOAT_MAT2
, GLSL_TYPE_FLOAT
, 2, 2, "mat2"),
52 glsl_type(GL_FLOAT_MAT3
, GLSL_TYPE_FLOAT
, 3, 3, "mat3"),
53 glsl_type(GL_FLOAT_MAT4
, GLSL_TYPE_FLOAT
, 4, 4, "mat4"),
54 glsl_type(GL_SAMPLER_1D
, GLSL_SAMPLER_DIM_1D
, 0, 0, GLSL_TYPE_FLOAT
,
56 glsl_type(GL_SAMPLER_1D_SHADOW
, GLSL_SAMPLER_DIM_1D
, 1, 0, GLSL_TYPE_FLOAT
,
58 glsl_type(GL_SAMPLER_2D
, GLSL_SAMPLER_DIM_2D
, 0, 0, GLSL_TYPE_FLOAT
,
60 glsl_type(GL_SAMPLER_2D_SHADOW
, GLSL_SAMPLER_DIM_2D
, 1, 0, GLSL_TYPE_FLOAT
,
62 glsl_type(GL_SAMPLER_3D
, GLSL_SAMPLER_DIM_3D
, 0, 0, GLSL_TYPE_FLOAT
,
64 glsl_type(GL_SAMPLER_CUBE
, GLSL_SAMPLER_DIM_CUBE
, 0, 0, GLSL_TYPE_FLOAT
,
68 const glsl_type
*const glsl_type::bool_type
= & builtin_core_types
[0];
69 const glsl_type
*const glsl_type::int_type
= & builtin_core_types
[4];
70 const glsl_type
*const glsl_type::ivec4_type
= & builtin_core_types
[7];
71 const glsl_type
*const glsl_type::float_type
= & builtin_core_types
[8];
72 const glsl_type
*const glsl_type::vec2_type
= & builtin_core_types
[9];
73 const glsl_type
*const glsl_type::vec3_type
= & builtin_core_types
[10];
74 const glsl_type
*const glsl_type::vec4_type
= & builtin_core_types
[11];
75 const glsl_type
*const glsl_type::mat2_type
= & builtin_core_types
[12];
76 const glsl_type
*const glsl_type::mat3_type
= & builtin_core_types
[13];
77 const glsl_type
*const glsl_type::mat4_type
= & builtin_core_types
[14];
80 /** \name GLSL structures that have not been deprecated.
84 static const struct glsl_struct_field gl_DepthRangeParameters_fields
[] = {
85 { glsl_type::float_type
, "near" },
86 { glsl_type::float_type
, "far" },
87 { glsl_type::float_type
, "diff" },
90 const glsl_type
glsl_type::builtin_structure_types
[] = {
91 glsl_type(gl_DepthRangeParameters_fields
,
92 Elements(gl_DepthRangeParameters_fields
),
93 "gl_DepthRangeParameters"),
97 /** \name GLSL 1.00 / 1.10 structures that are deprecated in GLSL 1.30
101 static const struct glsl_struct_field gl_PointParameters_fields
[] = {
102 { glsl_type::float_type
, "size" },
103 { glsl_type::float_type
, "sizeMin" },
104 { glsl_type::float_type
, "sizeMax" },
105 { glsl_type::float_type
, "fadeThresholdSize" },
106 { glsl_type::float_type
, "distanceConstantAttenuation" },
107 { glsl_type::float_type
, "distanceLinearAttenuation" },
108 { glsl_type::float_type
, "distanceQuadraticAttenuation" },
111 static const struct glsl_struct_field gl_MaterialParameters_fields
[] = {
112 { glsl_type::vec4_type
, "emission" },
113 { glsl_type::vec4_type
, "ambient" },
114 { glsl_type::vec4_type
, "diffuse" },
115 { glsl_type::vec4_type
, "specular" },
116 { glsl_type::float_type
, "shininess" },
119 static const struct glsl_struct_field gl_LightSourceParameters_fields
[] = {
120 { glsl_type::vec4_type
, "ambient" },
121 { glsl_type::vec4_type
, "diffuse" },
122 { glsl_type::vec4_type
, "specular" },
123 { glsl_type::vec4_type
, "position" },
124 { glsl_type::vec4_type
, "halfVector" },
125 { glsl_type::vec3_type
, "spotDirection" },
126 { glsl_type::float_type
, "spotExponent" },
127 { glsl_type::float_type
, "spotCutoff" },
128 { glsl_type::float_type
, "spotCosCutoff" },
129 { glsl_type::float_type
, "constantAttenuation" },
130 { glsl_type::float_type
, "linearAttenuation" },
131 { glsl_type::float_type
, "quadraticAttenuation" },
134 static const struct glsl_struct_field gl_LightModelParameters_fields
[] = {
135 { glsl_type::vec4_type
, "ambient" },
138 static const struct glsl_struct_field gl_LightModelProducts_fields
[] = {
139 { glsl_type::vec4_type
, "sceneColor" },
142 static const struct glsl_struct_field gl_LightProducts_fields
[] = {
143 { glsl_type::vec4_type
, "ambient" },
144 { glsl_type::vec4_type
, "diffuse" },
145 { glsl_type::vec4_type
, "specular" },
148 static const struct glsl_struct_field gl_FogParameters_fields
[] = {
149 { glsl_type::vec4_type
, "color" },
150 { glsl_type::float_type
, "density" },
151 { glsl_type::float_type
, "start" },
152 { glsl_type::float_type
, "end" },
153 { glsl_type::float_type
, "scale" },
156 const glsl_type
glsl_type::builtin_110_deprecated_structure_types
[] = {
157 glsl_type(gl_PointParameters_fields
,
158 Elements(gl_PointParameters_fields
),
159 "gl_PointParameters"),
160 glsl_type(gl_MaterialParameters_fields
,
161 Elements(gl_MaterialParameters_fields
),
162 "gl_MaterialParameters"),
163 glsl_type(gl_LightSourceParameters_fields
,
164 Elements(gl_LightSourceParameters_fields
),
165 "gl_LightSourceParameters"),
166 glsl_type(gl_LightModelParameters_fields
,
167 Elements(gl_LightModelParameters_fields
),
168 "gl_LightModelParameters"),
169 glsl_type(gl_LightModelProducts_fields
,
170 Elements(gl_LightModelProducts_fields
),
171 "gl_LightModelProducts"),
172 glsl_type(gl_LightProducts_fields
,
173 Elements(gl_LightProducts_fields
),
175 glsl_type(gl_FogParameters_fields
,
176 Elements(gl_FogParameters_fields
),
181 /** \name Types added in GLSL 1.20
185 const glsl_type
glsl_type::builtin_120_types
[] = {
186 glsl_type(GL_FLOAT_MAT2x3
, GLSL_TYPE_FLOAT
, 3, 2, "mat2x3"),
187 glsl_type(GL_FLOAT_MAT2x4
, GLSL_TYPE_FLOAT
, 4, 2, "mat2x4"),
188 glsl_type(GL_FLOAT_MAT3x2
, GLSL_TYPE_FLOAT
, 2, 3, "mat3x2"),
189 glsl_type(GL_FLOAT_MAT3x4
, GLSL_TYPE_FLOAT
, 4, 3, "mat3x4"),
190 glsl_type(GL_FLOAT_MAT4x2
, GLSL_TYPE_FLOAT
, 2, 4, "mat4x2"),
191 glsl_type(GL_FLOAT_MAT4x3
, GLSL_TYPE_FLOAT
, 3, 4, "mat4x3"),
193 const glsl_type
*const glsl_type::mat2x3_type
= & builtin_120_types
[0];
194 const glsl_type
*const glsl_type::mat2x4_type
= & builtin_120_types
[1];
195 const glsl_type
*const glsl_type::mat3x2_type
= & builtin_120_types
[2];
196 const glsl_type
*const glsl_type::mat3x4_type
= & builtin_120_types
[3];
197 const glsl_type
*const glsl_type::mat4x2_type
= & builtin_120_types
[4];
198 const glsl_type
*const glsl_type::mat4x3_type
= & builtin_120_types
[5];
201 /** \name Types added in GLSL 1.30
205 const glsl_type
glsl_type::builtin_130_types
[] = {
206 glsl_type(GL_UNSIGNED_INT
, GLSL_TYPE_UINT
, 1, 1, "uint"),
207 glsl_type(GL_UNSIGNED_INT_VEC2
, GLSL_TYPE_UINT
, 2, 1, "uvec2"),
208 glsl_type(GL_UNSIGNED_INT_VEC3
, GLSL_TYPE_UINT
, 3, 1, "uvec3"),
209 glsl_type(GL_UNSIGNED_INT_VEC4
, GLSL_TYPE_UINT
, 4, 1, "uvec4"),
211 /* 1D and 2D texture arrays - several of these are included only in
212 * builtin_EXT_texture_array_types.
214 glsl_type(GL_INT_SAMPLER_1D_ARRAY
,
215 GLSL_SAMPLER_DIM_1D
, 0, 1, GLSL_TYPE_INT
, "isampler1DArray"),
216 glsl_type(GL_UNSIGNED_INT_SAMPLER_1D_ARRAY
,
217 GLSL_SAMPLER_DIM_1D
, 0, 1, GLSL_TYPE_UINT
, "usampler1DArray"),
218 glsl_type(GL_INT_SAMPLER_2D_ARRAY
,
219 GLSL_SAMPLER_DIM_2D
, 0, 1, GLSL_TYPE_INT
, "isampler2DArray"),
220 glsl_type(GL_UNSIGNED_INT_SAMPLER_2D_ARRAY
,
221 GLSL_SAMPLER_DIM_2D
, 0, 1, GLSL_TYPE_UINT
, "usampler2DArray"),
223 /* cube shadow samplers */
224 glsl_type(GL_SAMPLER_CUBE_SHADOW
,
225 GLSL_SAMPLER_DIM_CUBE
, 1, 0, GLSL_TYPE_FLOAT
, "samplerCubeShadow"),
227 /* signed and unsigned integer samplers */
228 glsl_type(GL_INT_SAMPLER_1D
,
229 GLSL_SAMPLER_DIM_1D
, 0, 0, GLSL_TYPE_INT
, "isampler1D"),
230 glsl_type(GL_UNSIGNED_INT_SAMPLER_1D
,
231 GLSL_SAMPLER_DIM_1D
, 0, 0, GLSL_TYPE_UINT
, "usampler1D"),
232 glsl_type(GL_INT_SAMPLER_2D
,
233 GLSL_SAMPLER_DIM_2D
, 0, 0, GLSL_TYPE_INT
, "isampler2D"),
234 glsl_type(GL_UNSIGNED_INT_SAMPLER_2D
,
235 GLSL_SAMPLER_DIM_2D
, 0, 0, GLSL_TYPE_UINT
, "usampler2D"),
236 glsl_type(GL_INT_SAMPLER_3D
,
237 GLSL_SAMPLER_DIM_3D
, 0, 0, GLSL_TYPE_INT
, "isampler3D"),
238 glsl_type(GL_UNSIGNED_INT_SAMPLER_3D
,
239 GLSL_SAMPLER_DIM_3D
, 0, 0, GLSL_TYPE_UINT
, "usampler3D"),
240 glsl_type(GL_INT_SAMPLER_CUBE
,
241 GLSL_SAMPLER_DIM_CUBE
, 0, 0, GLSL_TYPE_INT
, "isamplerCube"),
242 glsl_type(GL_INT_SAMPLER_CUBE
,
243 GLSL_SAMPLER_DIM_CUBE
, 0, 0, GLSL_TYPE_UINT
, "usamplerCube"),
246 const glsl_type
*const glsl_type::uint_type
= & builtin_130_types
[0];
247 const glsl_type
*const glsl_type::uvec4_type
= & builtin_130_types
[3];
250 /** \name Sampler types added by GL_ARB_texture_rectangle
254 const glsl_type
glsl_type::builtin_ARB_texture_rectangle_types
[] = {
255 glsl_type(GL_SAMPLER_2D_RECT
,
256 GLSL_SAMPLER_DIM_RECT
, 0, 0, GLSL_TYPE_FLOAT
, "sampler2DRect"),
257 glsl_type(GL_SAMPLER_2D_RECT_SHADOW
,
258 GLSL_SAMPLER_DIM_RECT
, 1, 0, GLSL_TYPE_FLOAT
, "sampler2DRectShadow"),
262 /** \name Sampler types added by GL_EXT_texture_array
266 const glsl_type
glsl_type::builtin_EXT_texture_array_types
[] = {
267 glsl_type(GL_SAMPLER_1D_ARRAY
,
268 GLSL_SAMPLER_DIM_1D
, 0, 1, GLSL_TYPE_FLOAT
, "sampler1DArray"),
269 glsl_type(GL_SAMPLER_1D_ARRAY_SHADOW
,
270 GLSL_SAMPLER_DIM_2D
, 0, 1, GLSL_TYPE_FLOAT
, "sampler2DArray"),
271 glsl_type(GL_SAMPLER_2D_ARRAY
,
272 GLSL_SAMPLER_DIM_1D
, 1, 1, GLSL_TYPE_FLOAT
, "sampler1DArrayShadow"),
273 glsl_type(GL_SAMPLER_2D_ARRAY_SHADOW
,
274 GLSL_SAMPLER_DIM_2D
, 1, 1, GLSL_TYPE_FLOAT
, "sampler2DArrayShadow"),
278 /** \name Sampler types added by GL_EXT_texture_buffer_object
282 const glsl_type
glsl_type::builtin_EXT_texture_buffer_object_types
[] = {
283 glsl_type(GL_SAMPLER_BUFFER
,
284 GLSL_SAMPLER_DIM_BUF
, 0, 0, GLSL_TYPE_FLOAT
, "samplerBuffer"),
285 glsl_type(GL_INT_SAMPLER_BUFFER
,
286 GLSL_SAMPLER_DIM_BUF
, 0, 0, GLSL_TYPE_INT
, "isamplerBuffer"),
287 glsl_type(GL_UNSIGNED_INT_SAMPLER_BUFFER
,
288 GLSL_SAMPLER_DIM_BUF
, 0, 0, GLSL_TYPE_UINT
, "usamplerBuffer"),