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
glsl_type::_sampler3D_type
=
31 glsl_type(GL_SAMPLER_3D
, GLSL_SAMPLER_DIM_3D
, 0, 0, GLSL_TYPE_FLOAT
,
34 const glsl_type
glsl_type::_samplerCubeShadow_type
=
35 glsl_type(GL_SAMPLER_CUBE_SHADOW
,
36 GLSL_SAMPLER_DIM_CUBE
, 1, 0, GLSL_TYPE_FLOAT
,
39 const glsl_type
*const glsl_type::error_type
= & glsl_type::_error_type
;
40 const glsl_type
*const glsl_type::void_type
= & glsl_type::_void_type
;
42 /** \name Core built-in types
44 * These types exist in all versions of GLSL.
48 const glsl_type
glsl_type::builtin_core_types
[] = {
49 glsl_type(GL_BOOL
, GLSL_TYPE_BOOL
, 1, 1, "bool"),
50 glsl_type(GL_BOOL_VEC2
, GLSL_TYPE_BOOL
, 2, 1, "bvec2"),
51 glsl_type(GL_BOOL_VEC3
, GLSL_TYPE_BOOL
, 3, 1, "bvec3"),
52 glsl_type(GL_BOOL_VEC4
, GLSL_TYPE_BOOL
, 4, 1, "bvec4"),
53 glsl_type(GL_INT
, GLSL_TYPE_INT
, 1, 1, "int"),
54 glsl_type(GL_INT_VEC2
, GLSL_TYPE_INT
, 2, 1, "ivec2"),
55 glsl_type(GL_INT_VEC3
, GLSL_TYPE_INT
, 3, 1, "ivec3"),
56 glsl_type(GL_INT_VEC4
, GLSL_TYPE_INT
, 4, 1, "ivec4"),
57 glsl_type(GL_FLOAT
, GLSL_TYPE_FLOAT
, 1, 1, "float"),
58 glsl_type(GL_FLOAT_VEC2
, GLSL_TYPE_FLOAT
, 2, 1, "vec2"),
59 glsl_type(GL_FLOAT_VEC3
, GLSL_TYPE_FLOAT
, 3, 1, "vec3"),
60 glsl_type(GL_FLOAT_VEC4
, GLSL_TYPE_FLOAT
, 4, 1, "vec4"),
61 glsl_type(GL_FLOAT_MAT2
, GLSL_TYPE_FLOAT
, 2, 2, "mat2"),
62 glsl_type(GL_FLOAT_MAT3
, GLSL_TYPE_FLOAT
, 3, 3, "mat3"),
63 glsl_type(GL_FLOAT_MAT4
, GLSL_TYPE_FLOAT
, 4, 4, "mat4"),
64 glsl_type(GL_SAMPLER_2D
, GLSL_SAMPLER_DIM_2D
, 0, 0, GLSL_TYPE_FLOAT
,
66 glsl_type(GL_SAMPLER_CUBE
, GLSL_SAMPLER_DIM_CUBE
, 0, 0, GLSL_TYPE_FLOAT
,
70 const glsl_type
*const glsl_type::bool_type
= & builtin_core_types
[0];
71 const glsl_type
*const glsl_type::bvec2_type
= & builtin_core_types
[1];
72 const glsl_type
*const glsl_type::bvec3_type
= & builtin_core_types
[2];
73 const glsl_type
*const glsl_type::bvec4_type
= & builtin_core_types
[3];
74 const glsl_type
*const glsl_type::int_type
= & builtin_core_types
[4];
75 const glsl_type
*const glsl_type::ivec2_type
= & builtin_core_types
[5];
76 const glsl_type
*const glsl_type::ivec3_type
= & builtin_core_types
[6];
77 const glsl_type
*const glsl_type::ivec4_type
= & builtin_core_types
[7];
78 const glsl_type
*const glsl_type::float_type
= & builtin_core_types
[8];
79 const glsl_type
*const glsl_type::vec2_type
= & builtin_core_types
[9];
80 const glsl_type
*const glsl_type::vec3_type
= & builtin_core_types
[10];
81 const glsl_type
*const glsl_type::vec4_type
= & builtin_core_types
[11];
82 const glsl_type
*const glsl_type::mat2_type
= & builtin_core_types
[12];
83 const glsl_type
*const glsl_type::mat3_type
= & builtin_core_types
[13];
84 const glsl_type
*const glsl_type::mat4_type
= & builtin_core_types
[14];
87 /** \name GLSL structures that have not been deprecated.
91 static const struct glsl_struct_field gl_DepthRangeParameters_fields
[] = {
92 { glsl_type::float_type
, "near" },
93 { glsl_type::float_type
, "far" },
94 { glsl_type::float_type
, "diff" },
97 const glsl_type
glsl_type::builtin_structure_types
[] = {
98 glsl_type(gl_DepthRangeParameters_fields
,
99 Elements(gl_DepthRangeParameters_fields
),
100 "gl_DepthRangeParameters"),
104 /** \name GLSL 1.00 / 1.10 structures that are deprecated in GLSL 1.30
108 static const struct glsl_struct_field gl_PointParameters_fields
[] = {
109 { glsl_type::float_type
, "size" },
110 { glsl_type::float_type
, "sizeMin" },
111 { glsl_type::float_type
, "sizeMax" },
112 { glsl_type::float_type
, "fadeThresholdSize" },
113 { glsl_type::float_type
, "distanceConstantAttenuation" },
114 { glsl_type::float_type
, "distanceLinearAttenuation" },
115 { glsl_type::float_type
, "distanceQuadraticAttenuation" },
118 static const struct glsl_struct_field gl_MaterialParameters_fields
[] = {
119 { glsl_type::vec4_type
, "emission" },
120 { glsl_type::vec4_type
, "ambient" },
121 { glsl_type::vec4_type
, "diffuse" },
122 { glsl_type::vec4_type
, "specular" },
123 { glsl_type::float_type
, "shininess" },
126 static const struct glsl_struct_field gl_LightSourceParameters_fields
[] = {
127 { glsl_type::vec4_type
, "ambient" },
128 { glsl_type::vec4_type
, "diffuse" },
129 { glsl_type::vec4_type
, "specular" },
130 { glsl_type::vec4_type
, "position" },
131 { glsl_type::vec4_type
, "halfVector" },
132 { glsl_type::vec3_type
, "spotDirection" },
133 { glsl_type::float_type
, "spotExponent" },
134 { glsl_type::float_type
, "spotCutoff" },
135 { glsl_type::float_type
, "spotCosCutoff" },
136 { glsl_type::float_type
, "constantAttenuation" },
137 { glsl_type::float_type
, "linearAttenuation" },
138 { glsl_type::float_type
, "quadraticAttenuation" },
141 static const struct glsl_struct_field gl_LightModelParameters_fields
[] = {
142 { glsl_type::vec4_type
, "ambient" },
145 static const struct glsl_struct_field gl_LightModelProducts_fields
[] = {
146 { glsl_type::vec4_type
, "sceneColor" },
149 static const struct glsl_struct_field gl_LightProducts_fields
[] = {
150 { glsl_type::vec4_type
, "ambient" },
151 { glsl_type::vec4_type
, "diffuse" },
152 { glsl_type::vec4_type
, "specular" },
155 static const struct glsl_struct_field gl_FogParameters_fields
[] = {
156 { glsl_type::vec4_type
, "color" },
157 { glsl_type::float_type
, "density" },
158 { glsl_type::float_type
, "start" },
159 { glsl_type::float_type
, "end" },
160 { glsl_type::float_type
, "scale" },
163 const glsl_type
glsl_type::builtin_110_deprecated_structure_types
[] = {
164 glsl_type(gl_PointParameters_fields
,
165 Elements(gl_PointParameters_fields
),
166 "gl_PointParameters"),
167 glsl_type(gl_MaterialParameters_fields
,
168 Elements(gl_MaterialParameters_fields
),
169 "gl_MaterialParameters"),
170 glsl_type(gl_LightSourceParameters_fields
,
171 Elements(gl_LightSourceParameters_fields
),
172 "gl_LightSourceParameters"),
173 glsl_type(gl_LightModelParameters_fields
,
174 Elements(gl_LightModelParameters_fields
),
175 "gl_LightModelParameters"),
176 glsl_type(gl_LightModelProducts_fields
,
177 Elements(gl_LightModelProducts_fields
),
178 "gl_LightModelProducts"),
179 glsl_type(gl_LightProducts_fields
,
180 Elements(gl_LightProducts_fields
),
182 glsl_type(gl_FogParameters_fields
,
183 Elements(gl_FogParameters_fields
),
188 /** \name Types in GLSL 1.10 (but not GLSL ES 1.00)
191 const glsl_type
glsl_type::builtin_110_types
[] = {
192 glsl_type(GL_SAMPLER_1D
, GLSL_SAMPLER_DIM_1D
, 0, 0, GLSL_TYPE_FLOAT
,
194 glsl_type(GL_SAMPLER_1D_SHADOW
, GLSL_SAMPLER_DIM_1D
, 1, 0, GLSL_TYPE_FLOAT
,
196 glsl_type(GL_SAMPLER_2D_SHADOW
, GLSL_SAMPLER_DIM_2D
, 1, 0, GLSL_TYPE_FLOAT
,
201 /** \name Types added in GLSL 1.20
205 const glsl_type
glsl_type::builtin_120_types
[] = {
206 glsl_type(GL_FLOAT_MAT2x3
, GLSL_TYPE_FLOAT
, 3, 2, "mat2x3"),
207 glsl_type(GL_FLOAT_MAT2x4
, GLSL_TYPE_FLOAT
, 4, 2, "mat2x4"),
208 glsl_type(GL_FLOAT_MAT3x2
, GLSL_TYPE_FLOAT
, 2, 3, "mat3x2"),
209 glsl_type(GL_FLOAT_MAT3x4
, GLSL_TYPE_FLOAT
, 4, 3, "mat3x4"),
210 glsl_type(GL_FLOAT_MAT4x2
, GLSL_TYPE_FLOAT
, 2, 4, "mat4x2"),
211 glsl_type(GL_FLOAT_MAT4x3
, GLSL_TYPE_FLOAT
, 3, 4, "mat4x3"),
213 const glsl_type
*const glsl_type::mat2x3_type
= & builtin_120_types
[0];
214 const glsl_type
*const glsl_type::mat2x4_type
= & builtin_120_types
[1];
215 const glsl_type
*const glsl_type::mat3x2_type
= & builtin_120_types
[2];
216 const glsl_type
*const glsl_type::mat3x4_type
= & builtin_120_types
[3];
217 const glsl_type
*const glsl_type::mat4x2_type
= & builtin_120_types
[4];
218 const glsl_type
*const glsl_type::mat4x3_type
= & builtin_120_types
[5];
221 /** \name Types added in GLSL 1.30
225 const glsl_type
glsl_type::builtin_130_types
[] = {
226 glsl_type(GL_UNSIGNED_INT
, GLSL_TYPE_UINT
, 1, 1, "uint"),
227 glsl_type(GL_UNSIGNED_INT_VEC2
, GLSL_TYPE_UINT
, 2, 1, "uvec2"),
228 glsl_type(GL_UNSIGNED_INT_VEC3
, GLSL_TYPE_UINT
, 3, 1, "uvec3"),
229 glsl_type(GL_UNSIGNED_INT_VEC4
, GLSL_TYPE_UINT
, 4, 1, "uvec4"),
231 /* 1D and 2D texture arrays - several of these are included only in
232 * builtin_EXT_texture_array_types.
234 glsl_type(GL_INT_SAMPLER_1D_ARRAY
,
235 GLSL_SAMPLER_DIM_1D
, 0, 1, GLSL_TYPE_INT
, "isampler1DArray"),
236 glsl_type(GL_UNSIGNED_INT_SAMPLER_1D_ARRAY
,
237 GLSL_SAMPLER_DIM_1D
, 0, 1, GLSL_TYPE_UINT
, "usampler1DArray"),
238 glsl_type(GL_INT_SAMPLER_2D_ARRAY
,
239 GLSL_SAMPLER_DIM_2D
, 0, 1, GLSL_TYPE_INT
, "isampler2DArray"),
240 glsl_type(GL_UNSIGNED_INT_SAMPLER_2D_ARRAY
,
241 GLSL_SAMPLER_DIM_2D
, 0, 1, GLSL_TYPE_UINT
, "usampler2DArray"),
243 /* cube shadow samplers */
244 glsl_type(GL_SAMPLER_CUBE_SHADOW
,
245 GLSL_SAMPLER_DIM_CUBE
, 1, 0, GLSL_TYPE_FLOAT
, "samplerCubeShadow"),
247 /* signed and unsigned integer samplers */
248 glsl_type(GL_INT_SAMPLER_1D
,
249 GLSL_SAMPLER_DIM_1D
, 0, 0, GLSL_TYPE_INT
, "isampler1D"),
250 glsl_type(GL_UNSIGNED_INT_SAMPLER_1D
,
251 GLSL_SAMPLER_DIM_1D
, 0, 0, GLSL_TYPE_UINT
, "usampler1D"),
252 glsl_type(GL_INT_SAMPLER_2D
,
253 GLSL_SAMPLER_DIM_2D
, 0, 0, GLSL_TYPE_INT
, "isampler2D"),
254 glsl_type(GL_UNSIGNED_INT_SAMPLER_2D
,
255 GLSL_SAMPLER_DIM_2D
, 0, 0, GLSL_TYPE_UINT
, "usampler2D"),
256 glsl_type(GL_INT_SAMPLER_3D
,
257 GLSL_SAMPLER_DIM_3D
, 0, 0, GLSL_TYPE_INT
, "isampler3D"),
258 glsl_type(GL_UNSIGNED_INT_SAMPLER_3D
,
259 GLSL_SAMPLER_DIM_3D
, 0, 0, GLSL_TYPE_UINT
, "usampler3D"),
260 glsl_type(GL_INT_SAMPLER_CUBE
,
261 GLSL_SAMPLER_DIM_CUBE
, 0, 0, GLSL_TYPE_INT
, "isamplerCube"),
262 glsl_type(GL_INT_SAMPLER_CUBE
,
263 GLSL_SAMPLER_DIM_CUBE
, 0, 0, GLSL_TYPE_UINT
, "usamplerCube"),
266 const glsl_type
*const glsl_type::uint_type
= & builtin_130_types
[0];
267 const glsl_type
*const glsl_type::uvec2_type
= & builtin_130_types
[1];
268 const glsl_type
*const glsl_type::uvec3_type
= & builtin_130_types
[2];
269 const glsl_type
*const glsl_type::uvec4_type
= & builtin_130_types
[3];
273 /** \name Types added in GLSL 1.40
276 const glsl_type
glsl_type::builtin_140_types
[] = {
277 glsl_type(GL_INT_SAMPLER_2D_RECT
,
278 GLSL_SAMPLER_DIM_RECT
, 0, 0, GLSL_TYPE_INT
, "isampler2DRect"),
279 glsl_type(GL_UNSIGNED_INT_SAMPLER_2D_RECT
,
280 GLSL_SAMPLER_DIM_RECT
, 0, 0, GLSL_TYPE_UINT
, "usampler2DRect"),
284 /** \name Sampler types added by GL_ARB_texture_rectangle
288 const glsl_type
glsl_type::builtin_ARB_texture_rectangle_types
[] = {
289 glsl_type(GL_SAMPLER_2D_RECT
,
290 GLSL_SAMPLER_DIM_RECT
, 0, 0, GLSL_TYPE_FLOAT
, "sampler2DRect"),
291 glsl_type(GL_SAMPLER_2D_RECT_SHADOW
,
292 GLSL_SAMPLER_DIM_RECT
, 1, 0, GLSL_TYPE_FLOAT
, "sampler2DRectShadow"),
296 /** \name Sampler types added by GL_EXT_texture_array
300 const glsl_type
glsl_type::builtin_EXT_texture_array_types
[] = {
301 glsl_type(GL_SAMPLER_1D_ARRAY
,
302 GLSL_SAMPLER_DIM_1D
, 0, 1, GLSL_TYPE_FLOAT
, "sampler1DArray"),
303 glsl_type(GL_SAMPLER_2D_ARRAY
,
304 GLSL_SAMPLER_DIM_2D
, 0, 1, GLSL_TYPE_FLOAT
, "sampler2DArray"),
305 glsl_type(GL_SAMPLER_1D_ARRAY_SHADOW
,
306 GLSL_SAMPLER_DIM_1D
, 1, 1, GLSL_TYPE_FLOAT
, "sampler1DArrayShadow"),
307 glsl_type(GL_SAMPLER_2D_ARRAY_SHADOW
,
308 GLSL_SAMPLER_DIM_2D
, 1, 1, GLSL_TYPE_FLOAT
, "sampler2DArrayShadow"),
312 /** \name Sampler types added by GL_EXT_texture_buffer_object
316 const glsl_type
glsl_type::builtin_EXT_texture_buffer_object_types
[] = {
317 glsl_type(GL_SAMPLER_BUFFER
,
318 GLSL_SAMPLER_DIM_BUF
, 0, 0, GLSL_TYPE_FLOAT
, "samplerBuffer"),
319 glsl_type(GL_INT_SAMPLER_BUFFER
,
320 GLSL_SAMPLER_DIM_BUF
, 0, 0, GLSL_TYPE_INT
, "isamplerBuffer"),
321 glsl_type(GL_UNSIGNED_INT_SAMPLER_BUFFER
,
322 GLSL_SAMPLER_DIM_BUF
, 0, 0, GLSL_TYPE_UINT
, "usamplerBuffer"),
326 /** \name Sampler types added by GL_OES_EGL_image_external
330 const glsl_type
glsl_type::builtin_OES_EGL_image_external_types
[] = {
331 glsl_type(GL_SAMPLER_EXTERNAL_OES
,
332 GLSL_SAMPLER_DIM_EXTERNAL
, 0, 0, GLSL_TYPE_FLOAT
, "samplerExternalOES"),
336 /** \name Sampler types added by GL_ARB_texture_cube_map_array
339 const glsl_type
glsl_type::builtin_ARB_texture_cube_map_array_types
[] = {
340 glsl_type(GL_SAMPLER_CUBE_MAP_ARRAY
,
341 GLSL_SAMPLER_DIM_CUBE
, 0, 1, GLSL_TYPE_FLOAT
, "samplerCubeArray"),
342 glsl_type(GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW
,
343 GLSL_SAMPLER_DIM_CUBE
, 1, 1, GLSL_TYPE_FLOAT
, "samplerCubeArrayShadow"),
344 glsl_type(GL_INT_SAMPLER_CUBE_MAP_ARRAY
,
345 GLSL_SAMPLER_DIM_CUBE
, 0, 1, GLSL_TYPE_INT
, "isamplerCubeArray"),
346 glsl_type(GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY
,
347 GLSL_SAMPLER_DIM_CUBE
, 0, 1, GLSL_TYPE_UINT
, "usamplerCubeArray"),