• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright © 2009 Intel Corporation
3  *
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:
10  *
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
13  * Software.
14  *
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.
22  */
23 
24 const glsl_type glsl_type::_error_type =
25    glsl_type(GL_INVALID_ENUM, GLSL_TYPE_ERROR, 0, 0, "");
26 
27 const glsl_type glsl_type::_void_type =
28    glsl_type(GL_INVALID_ENUM, GLSL_TYPE_VOID, 0, 0, "void");
29 
30 const glsl_type glsl_type::_sampler3D_type =
31    glsl_type(GL_SAMPLER_3D, GLSL_SAMPLER_DIM_3D, 0, 0, GLSL_TYPE_FLOAT,
32 	     "sampler3D");
33 
34 const glsl_type *const glsl_type::error_type = & glsl_type::_error_type;
35 const glsl_type *const glsl_type::void_type = & glsl_type::_void_type;
36 
37 /** \name Core built-in types
38  *
39  * These types exist in all versions of GLSL.
40  */
41 /*@{*/
42 
43 const glsl_type glsl_type::builtin_core_types[] = {
44    glsl_type(GL_BOOL,         GLSL_TYPE_BOOL, 1, 1, "bool"),
45    glsl_type(GL_BOOL_VEC2,    GLSL_TYPE_BOOL, 2, 1, "bvec2"),
46    glsl_type(GL_BOOL_VEC3,    GLSL_TYPE_BOOL, 3, 1, "bvec3"),
47    glsl_type(GL_BOOL_VEC4,    GLSL_TYPE_BOOL, 4, 1, "bvec4"),
48    glsl_type(GL_INT,          GLSL_TYPE_INT, 1, 1, "int"),
49    glsl_type(GL_INT_VEC2,     GLSL_TYPE_INT, 2, 1, "ivec2"),
50    glsl_type(GL_INT_VEC3,     GLSL_TYPE_INT, 3, 1, "ivec3"),
51    glsl_type(GL_INT_VEC4,     GLSL_TYPE_INT, 4, 1, "ivec4"),
52    glsl_type(GL_FLOAT,        GLSL_TYPE_FLOAT, 1, 1, "float"),
53    glsl_type(GL_FLOAT_VEC2,   GLSL_TYPE_FLOAT, 2, 1, "vec2"),
54    glsl_type(GL_FLOAT_VEC3,   GLSL_TYPE_FLOAT, 3, 1, "vec3"),
55    glsl_type(GL_FLOAT_VEC4,   GLSL_TYPE_FLOAT, 4, 1, "vec4"),
56    glsl_type(GL_FLOAT_MAT2,   GLSL_TYPE_FLOAT, 2, 2, "mat2"),
57    glsl_type(GL_FLOAT_MAT3,   GLSL_TYPE_FLOAT, 3, 3, "mat3"),
58    glsl_type(GL_FLOAT_MAT4,   GLSL_TYPE_FLOAT, 4, 4, "mat4"),
59    glsl_type(GL_SAMPLER_2D,   GLSL_SAMPLER_DIM_2D, 0, 0, GLSL_TYPE_FLOAT,
60 	     "sampler2D"),
61    glsl_type(GL_SAMPLER_CUBE, GLSL_SAMPLER_DIM_CUBE, 0, 0, GLSL_TYPE_FLOAT,
62 	     "samplerCube"),
63 };
64 
65 const glsl_type *const glsl_type::bool_type  = & builtin_core_types[0];
66 const glsl_type *const glsl_type::bvec2_type = & builtin_core_types[1];
67 const glsl_type *const glsl_type::bvec3_type = & builtin_core_types[2];
68 const glsl_type *const glsl_type::bvec4_type = & builtin_core_types[3];
69 const glsl_type *const glsl_type::int_type   = & builtin_core_types[4];
70 const glsl_type *const glsl_type::ivec2_type = & builtin_core_types[5];
71 const glsl_type *const glsl_type::ivec3_type = & builtin_core_types[6];
72 const glsl_type *const glsl_type::ivec4_type = & builtin_core_types[7];
73 const glsl_type *const glsl_type::float_type = & builtin_core_types[8];
74 const glsl_type *const glsl_type::vec2_type = & builtin_core_types[9];
75 const glsl_type *const glsl_type::vec3_type = & builtin_core_types[10];
76 const glsl_type *const glsl_type::vec4_type = & builtin_core_types[11];
77 const glsl_type *const glsl_type::mat2_type = & builtin_core_types[12];
78 const glsl_type *const glsl_type::mat3_type = & builtin_core_types[13];
79 const glsl_type *const glsl_type::mat4_type = & builtin_core_types[14];
80 /*@}*/
81 
82 /** \name GLSL structures that have not been deprecated.
83  */
84 /*@{*/
85 
86 static const struct glsl_struct_field gl_DepthRangeParameters_fields[] = {
87    { glsl_type::float_type, "near" },
88    { glsl_type::float_type, "far" },
89    { glsl_type::float_type, "diff" },
90 };
91 
92 const glsl_type glsl_type::builtin_structure_types[] = {
93    glsl_type(gl_DepthRangeParameters_fields,
94              Elements(gl_DepthRangeParameters_fields),
95              "gl_DepthRangeParameters"),
96 };
97 /*@}*/
98 
99 /** \name GLSL 1.00 / 1.10 structures that are deprecated in GLSL 1.30
100  */
101 /*@{*/
102 
103 static const struct glsl_struct_field gl_PointParameters_fields[] = {
104    { glsl_type::float_type, "size" },
105    { glsl_type::float_type, "sizeMin" },
106    { glsl_type::float_type, "sizeMax" },
107    { glsl_type::float_type, "fadeThresholdSize" },
108    { glsl_type::float_type, "distanceConstantAttenuation" },
109    { glsl_type::float_type, "distanceLinearAttenuation" },
110    { glsl_type::float_type, "distanceQuadraticAttenuation" },
111 };
112 
113 static const struct glsl_struct_field gl_MaterialParameters_fields[] = {
114    { glsl_type::vec4_type, "emission" },
115    { glsl_type::vec4_type, "ambient" },
116    { glsl_type::vec4_type, "diffuse" },
117    { glsl_type::vec4_type, "specular" },
118    { glsl_type::float_type, "shininess" },
119 };
120 
121 static const struct glsl_struct_field gl_LightSourceParameters_fields[] = {
122    { glsl_type::vec4_type, "ambient" },
123    { glsl_type::vec4_type, "diffuse" },
124    { glsl_type::vec4_type, "specular" },
125    { glsl_type::vec4_type, "position" },
126    { glsl_type::vec4_type, "halfVector" },
127    { glsl_type::vec3_type, "spotDirection" },
128    { glsl_type::float_type, "spotExponent" },
129    { glsl_type::float_type, "spotCutoff" },
130    { glsl_type::float_type, "spotCosCutoff" },
131    { glsl_type::float_type, "constantAttenuation" },
132    { glsl_type::float_type, "linearAttenuation" },
133    { glsl_type::float_type, "quadraticAttenuation" },
134 };
135 
136 static const struct glsl_struct_field gl_LightModelParameters_fields[] = {
137    { glsl_type::vec4_type, "ambient" },
138 };
139 
140 static const struct glsl_struct_field gl_LightModelProducts_fields[] = {
141    { glsl_type::vec4_type, "sceneColor" },
142 };
143 
144 static const struct glsl_struct_field gl_LightProducts_fields[] = {
145    { glsl_type::vec4_type, "ambient" },
146    { glsl_type::vec4_type, "diffuse" },
147    { glsl_type::vec4_type, "specular" },
148 };
149 
150 static const struct glsl_struct_field gl_FogParameters_fields[] = {
151    { glsl_type::vec4_type, "color" },
152    { glsl_type::float_type, "density" },
153    { glsl_type::float_type, "start" },
154    { glsl_type::float_type, "end" },
155    { glsl_type::float_type, "scale" },
156 };
157 
158 const glsl_type glsl_type::builtin_110_deprecated_structure_types[] = {
159    glsl_type(gl_PointParameters_fields,
160              Elements(gl_PointParameters_fields),
161              "gl_PointParameters"),
162    glsl_type(gl_MaterialParameters_fields,
163              Elements(gl_MaterialParameters_fields),
164              "gl_MaterialParameters"),
165    glsl_type(gl_LightSourceParameters_fields,
166              Elements(gl_LightSourceParameters_fields),
167              "gl_LightSourceParameters"),
168    glsl_type(gl_LightModelParameters_fields,
169              Elements(gl_LightModelParameters_fields),
170              "gl_LightModelParameters"),
171    glsl_type(gl_LightModelProducts_fields,
172              Elements(gl_LightModelProducts_fields),
173              "gl_LightModelProducts"),
174    glsl_type(gl_LightProducts_fields,
175              Elements(gl_LightProducts_fields),
176              "gl_LightProducts"),
177    glsl_type(gl_FogParameters_fields,
178              Elements(gl_FogParameters_fields),
179              "gl_FogParameters"),
180 };
181 /*@}*/
182 
183 /** \name Types in GLSL 1.10 (but not GLSL ES 1.00)
184  */
185 /*@{*/
186 const glsl_type glsl_type::builtin_110_types[] = {
187    glsl_type(GL_SAMPLER_1D,   GLSL_SAMPLER_DIM_1D, 0, 0, GLSL_TYPE_FLOAT,
188 	     "sampler1D"),
189    glsl_type(GL_SAMPLER_1D_SHADOW, GLSL_SAMPLER_DIM_1D, 1, 0, GLSL_TYPE_FLOAT,
190 	     "sampler1DShadow"),
191    glsl_type(GL_SAMPLER_2D_SHADOW, GLSL_SAMPLER_DIM_2D, 1, 0, GLSL_TYPE_FLOAT,
192 	     "sampler2DShadow"),
193 };
194 /*@}*/
195 
196 /** \name Types added in GLSL 1.20
197  */
198 /*@{*/
199 
200 const glsl_type glsl_type::builtin_120_types[] = {
201    glsl_type(GL_FLOAT_MAT2x3, GLSL_TYPE_FLOAT, 3, 2, "mat2x3"),
202    glsl_type(GL_FLOAT_MAT2x4, GLSL_TYPE_FLOAT, 4, 2, "mat2x4"),
203    glsl_type(GL_FLOAT_MAT3x2, GLSL_TYPE_FLOAT, 2, 3, "mat3x2"),
204    glsl_type(GL_FLOAT_MAT3x4, GLSL_TYPE_FLOAT, 4, 3, "mat3x4"),
205    glsl_type(GL_FLOAT_MAT4x2, GLSL_TYPE_FLOAT, 2, 4, "mat4x2"),
206    glsl_type(GL_FLOAT_MAT4x3, GLSL_TYPE_FLOAT, 3, 4, "mat4x3"),
207 };
208 const glsl_type *const glsl_type::mat2x3_type = & builtin_120_types[0];
209 const glsl_type *const glsl_type::mat2x4_type = & builtin_120_types[1];
210 const glsl_type *const glsl_type::mat3x2_type = & builtin_120_types[2];
211 const glsl_type *const glsl_type::mat3x4_type = & builtin_120_types[3];
212 const glsl_type *const glsl_type::mat4x2_type = & builtin_120_types[4];
213 const glsl_type *const glsl_type::mat4x3_type = & builtin_120_types[5];
214 /*@}*/
215 
216 /** \name Types added in GLSL 1.30
217  */
218 /*@{*/
219 
220 const glsl_type glsl_type::builtin_130_types[] = {
221    glsl_type(GL_UNSIGNED_INT,      GLSL_TYPE_UINT, 1, 1, "uint"),
222    glsl_type(GL_UNSIGNED_INT_VEC2, GLSL_TYPE_UINT, 2, 1, "uvec2"),
223    glsl_type(GL_UNSIGNED_INT_VEC3, GLSL_TYPE_UINT, 3, 1, "uvec3"),
224    glsl_type(GL_UNSIGNED_INT_VEC4, GLSL_TYPE_UINT, 4, 1, "uvec4"),
225 
226    /* 1D and 2D texture arrays - several of these are included only in
227     * builtin_EXT_texture_array_types.
228     */
229    glsl_type(GL_INT_SAMPLER_1D_ARRAY,
230 	     GLSL_SAMPLER_DIM_1D, 0, 1,   GLSL_TYPE_INT, "isampler1DArray"),
231    glsl_type(GL_UNSIGNED_INT_SAMPLER_1D_ARRAY,
232 	     GLSL_SAMPLER_DIM_1D, 0, 1,  GLSL_TYPE_UINT, "usampler1DArray"),
233    glsl_type(GL_INT_SAMPLER_2D_ARRAY,
234 	     GLSL_SAMPLER_DIM_2D, 0, 1,   GLSL_TYPE_INT, "isampler2DArray"),
235    glsl_type(GL_UNSIGNED_INT_SAMPLER_2D_ARRAY,
236 	     GLSL_SAMPLER_DIM_2D, 0, 1,  GLSL_TYPE_UINT, "usampler2DArray"),
237 
238    /* cube shadow samplers */
239    glsl_type(GL_SAMPLER_CUBE_SHADOW,
240 	     GLSL_SAMPLER_DIM_CUBE, 1, 0, GLSL_TYPE_FLOAT, "samplerCubeShadow"),
241 
242    /* signed and unsigned integer samplers */
243    glsl_type(GL_INT_SAMPLER_1D,
244 	     GLSL_SAMPLER_DIM_1D, 0, 0,   GLSL_TYPE_INT, "isampler1D"),
245    glsl_type(GL_UNSIGNED_INT_SAMPLER_1D,
246 	     GLSL_SAMPLER_DIM_1D, 0, 0,  GLSL_TYPE_UINT, "usampler1D"),
247    glsl_type(GL_INT_SAMPLER_2D,
248 	     GLSL_SAMPLER_DIM_2D, 0, 0,   GLSL_TYPE_INT, "isampler2D"),
249    glsl_type(GL_UNSIGNED_INT_SAMPLER_2D,
250 	     GLSL_SAMPLER_DIM_2D, 0, 0,  GLSL_TYPE_UINT, "usampler2D"),
251    glsl_type(GL_INT_SAMPLER_3D,
252 	     GLSL_SAMPLER_DIM_3D, 0, 0,   GLSL_TYPE_INT, "isampler3D"),
253    glsl_type(GL_UNSIGNED_INT_SAMPLER_3D,
254 	     GLSL_SAMPLER_DIM_3D, 0, 0,  GLSL_TYPE_UINT, "usampler3D"),
255    glsl_type(GL_INT_SAMPLER_CUBE,
256 	     GLSL_SAMPLER_DIM_CUBE, 0, 0,   GLSL_TYPE_INT, "isamplerCube"),
257    glsl_type(GL_INT_SAMPLER_CUBE,
258 	     GLSL_SAMPLER_DIM_CUBE, 0, 0,  GLSL_TYPE_UINT, "usamplerCube"),
259 };
260 
261 const glsl_type *const glsl_type::uint_type = & builtin_130_types[0];
262 const glsl_type *const glsl_type::uvec2_type = & builtin_130_types[1];
263 const glsl_type *const glsl_type::uvec3_type = & builtin_130_types[2];
264 const glsl_type *const glsl_type::uvec4_type = & builtin_130_types[3];
265 /*@}*/
266 
267 
268 /** \name Types added in GLSL 1.40
269  */
270 /*@{*/
271 const glsl_type glsl_type::builtin_140_types[] = {
272    glsl_type(GL_INT_SAMPLER_2D_RECT,
273 	     GLSL_SAMPLER_DIM_RECT, 0, 0, GLSL_TYPE_INT, "isampler2DRect"),
274    glsl_type(GL_UNSIGNED_INT_SAMPLER_2D_RECT,
275 	     GLSL_SAMPLER_DIM_RECT, 0, 0, GLSL_TYPE_UINT, "usampler2DRect"),
276 };
277 /*@}*/
278 
279 /** \name Sampler types added by GL_ARB_texture_rectangle
280  */
281 /*@{*/
282 
283 const glsl_type glsl_type::builtin_ARB_texture_rectangle_types[] = {
284    glsl_type(GL_SAMPLER_2D_RECT,
285 	     GLSL_SAMPLER_DIM_RECT, 0, 0, GLSL_TYPE_FLOAT, "sampler2DRect"),
286    glsl_type(GL_SAMPLER_2D_RECT_SHADOW,
287 	     GLSL_SAMPLER_DIM_RECT, 1, 0, GLSL_TYPE_FLOAT, "sampler2DRectShadow"),
288 };
289 /*@}*/
290 
291 /** \name Sampler types added by GL_EXT_texture_array
292  */
293 /*@{*/
294 
295 const glsl_type glsl_type::builtin_EXT_texture_array_types[] = {
296    glsl_type(GL_SAMPLER_1D_ARRAY,
297 	     GLSL_SAMPLER_DIM_1D, 0, 1, GLSL_TYPE_FLOAT, "sampler1DArray"),
298    glsl_type(GL_SAMPLER_2D_ARRAY,
299 	     GLSL_SAMPLER_DIM_2D, 0, 1, GLSL_TYPE_FLOAT, "sampler2DArray"),
300    glsl_type(GL_SAMPLER_1D_ARRAY_SHADOW,
301 	     GLSL_SAMPLER_DIM_1D, 1, 1, GLSL_TYPE_FLOAT, "sampler1DArrayShadow"),
302    glsl_type(GL_SAMPLER_2D_ARRAY_SHADOW,
303 	     GLSL_SAMPLER_DIM_2D, 1, 1, GLSL_TYPE_FLOAT, "sampler2DArrayShadow"),
304 };
305 /*@}*/
306 
307 /** \name Sampler types added by GL_EXT_texture_buffer_object
308  */
309 /*@{*/
310 
311 const glsl_type glsl_type::builtin_EXT_texture_buffer_object_types[] = {
312    glsl_type(GL_SAMPLER_BUFFER,
313 	     GLSL_SAMPLER_DIM_BUF, 0, 0, GLSL_TYPE_FLOAT, "samplerBuffer"),
314    glsl_type(GL_INT_SAMPLER_BUFFER,
315 	     GLSL_SAMPLER_DIM_BUF, 0, 0,   GLSL_TYPE_INT, "isamplerBuffer"),
316    glsl_type(GL_UNSIGNED_INT_SAMPLER_BUFFER,
317 	     GLSL_SAMPLER_DIM_BUF, 0, 0,  GLSL_TYPE_UINT, "usamplerBuffer"),
318 };
319 /*@}*/
320 
321 /** \name Sampler types added by GL_OES_EGL_image_external
322  */
323 /*@{*/
324 
325 const glsl_type glsl_type::builtin_OES_EGL_image_external_types[] = {
326    glsl_type(GL_SAMPLER_EXTERNAL_OES,
327 	     GLSL_SAMPLER_DIM_EXTERNAL, 0, 0, GLSL_TYPE_FLOAT, "samplerExternalOES"),
328 };
329 /*@}*/
330