3 # Copyright © 2009 Intel Corporation
5 # Permission is hereby granted, free of charge, to any person obtaining a
6 # copy of this software and associated documentation files (the "Software"),
7 # to deal in the Software without restriction, including without limitation
8 # the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 # and/or sell copies of the Software, and to permit persons to whom the
10 # Software is furnished to do so, subject to the following conditions:
12 # The above copyright notice and this permission notice (including the next
13 # paragraph) shall be included in all copies or substantial portions of the
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 # DEALINGS IN THE SOFTWARE.
24 # gen_integral_type <name> <base_type> <vector elements> <matrix rows>
25 function gen_integral_type
27 printf ' glsl_type( %17s, %u, %u, "%s"),\n' $2 $3 $4 $1
31 # gen_struct_type <name>
32 function gen_struct_type
34 elements
=$
(printf "%s_fields" $1)
35 printf ' glsl_type(%s,\n Elements(%s),\n "%s"),\n' \
36 $elements $elements $1
39 # gen_sampler_type <name> <dimensions> <shadow> <array> <type>
40 function gen_sampler_type
42 name
=$
(printf "sampler%s" $1)
45 name
=$
(printf "%sArray" $name)
49 name
=$
(printf "%sShadow" $name)
52 if [ $5 == GLSL_TYPE_INT
]; then
53 name
=$
(printf "i%s" $name)
54 elif [ $5 == GLSL_TYPE_UINT
]; then
55 name
=$
(printf "u%s" $name)
58 printf ' glsl_type(%21s, %u, %u, %15s, "%s"),\n' \
67 name
="builtin_${1}_types"
70 printf "\nstatic const struct glsl_type %s[] = {\n" $name
78 function gen_struct_field_header
80 printf "\nstatic const struct glsl_struct_field %s_fields[] = {\n" $1
83 function gen_struct_field_footer
88 function gen_struct_field
90 printf ' { & %s[%2u], "%s" },\n' $1 $2 "$3"
94 /* THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT! See builtin_types.sh. */
96 * Copyright © 2009 Intel Corporation
98 * Permission is hereby granted, free of charge, to any person obtaining a
99 * copy of this software and associated documentation files (the "Software"),
100 * to deal in the Software without restriction, including without limitation
101 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
102 * and/or sell copies of the Software, and to permit persons to whom the
103 * Software is furnished to do so, subject to the following conditions:
105 * The above copyright notice and this permission notice (including the next
106 * paragraph) shall be included in all copies or substantial portions of the
109 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
110 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
111 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
112 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
113 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
114 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
115 * DEALINGS IN THE SOFTWARE.
119 #define Elements(x) (sizeof(x)/sizeof(*(x)))
122 static const struct glsl_type _error_type =
123 glsl_type(GLSL_TYPE_ERROR, 0, 0, "");
125 static const struct glsl_type void_type =
126 glsl_type(GLSL_TYPE_VOID, 0, 0, "void");
128 const glsl_type *const glsl_type::error_type = & _error_type;
132 echo '/** \name Core built-in types'
134 echo ' * These types exist in all versions of GLSL.'
141 gen_integral_type
"bool" "GLSL_TYPE_BOOL" 1 1
143 gen_integral_type
"bvec$i" "GLSL_TYPE_BOOL" $i 1
147 gen_integral_type
"int" "GLSL_TYPE_INT" 1 1
149 gen_integral_type
"ivec$i" "GLSL_TYPE_INT" $i 1
153 gen_integral_type
"float" "GLSL_TYPE_FLOAT" 1 1
155 gen_integral_type
"vec$i" "GLSL_TYPE_FLOAT" $i 1
160 gen_integral_type
"mat$i" "GLSL_TYPE_FLOAT" $i $i
163 for i
in "1D" "2D"; do
164 gen_sampler_type
$i "GLSL_SAMPLER_DIM_$i" 0 0 "GLSL_TYPE_FLOAT"
165 gen_sampler_type
$i "GLSL_SAMPLER_DIM_$i" 1 0 "GLSL_TYPE_FLOAT"
168 gen_sampler_type
"3D" "GLSL_SAMPLER_DIM_3D" 0 0 "GLSL_TYPE_FLOAT"
169 gen_sampler_type
"Cube" "GLSL_SAMPLER_DIM_CUBE" 0 0 "GLSL_TYPE_FLOAT"
170 gen_sampler_type
"2DRect" "GLSL_SAMPLER_DIM_RECT" 0 0 "GLSL_TYPE_FLOAT"
171 gen_sampler_type
"2DRect" "GLSL_SAMPLER_DIM_RECT" 1 0 "GLSL_TYPE_FLOAT"
176 echo 'const glsl_type *const glsl_type::bool_type = & builtin_core_types['$bool_index'];'
177 echo 'const glsl_type *const glsl_type::int_type = & builtin_core_types['$int_index'];'
178 echo 'const glsl_type *const glsl_type::float_type = & builtin_core_types['$float_index'];'
179 echo 'const glsl_type *const glsl_type::mat2_type = & builtin_core_types['$
(($matX_index + 0))'];'
180 echo 'const glsl_type *const glsl_type::mat3_type = & builtin_core_types['$
(($matX_index + 1))'];'
181 echo 'const glsl_type *const glsl_type::mat4_type = & builtin_core_types['$
(($matX_index + 2))'];'
185 echo '/** \name GLSL structures that have not been deprecated.'
188 gen_struct_field_header gl_DepthRangeParameters
189 gen_struct_field builtin_core_types
8 "near"
190 gen_struct_field builtin_core_types
8 "far"
191 gen_struct_field builtin_core_types
8 "diff"
192 gen_struct_field_footer
194 gen_header
"structure"
195 gen_struct_type gl_DepthRangeParameters
200 echo '/** \name GLSL 1.00 / 1.10 structures that are deprecated in GLSL 1.30'
203 gen_struct_field_header gl_PointParameters
204 gen_struct_field builtin_core_types
8 "size"
205 gen_struct_field builtin_core_types
8 "sizeMin"
206 gen_struct_field builtin_core_types
8 "sizeMax"
207 gen_struct_field builtin_core_types
8 "fadeThresholdSize"
208 gen_struct_field builtin_core_types
8 "distanceConstantAttenuation"
209 gen_struct_field builtin_core_types
8 "distanceLinearAttenuation"
210 gen_struct_field builtin_core_types
8 "distanceQuadraticAttenuation"
211 gen_struct_field_footer
213 gen_struct_field_header gl_MaterialParameters
214 gen_struct_field builtin_core_types
11 "emission"
215 gen_struct_field builtin_core_types
11 "ambient"
216 gen_struct_field builtin_core_types
11 "diffuse"
217 gen_struct_field builtin_core_types
11 "specular"
218 gen_struct_field builtin_core_types
8 "shininess"
219 gen_struct_field_footer
221 gen_struct_field_header gl_LightSourceParameters
222 gen_struct_field builtin_core_types
11 "ambient"
223 gen_struct_field builtin_core_types
11 "diffuse"
224 gen_struct_field builtin_core_types
11 "specular"
225 gen_struct_field builtin_core_types
11 "position"
226 gen_struct_field builtin_core_types
11 "halfVector"
227 gen_struct_field builtin_core_types
10 "spotDirection"
228 gen_struct_field builtin_core_types
8 "spotExponent"
229 gen_struct_field builtin_core_types
8 "spotCutoff"
230 gen_struct_field builtin_core_types
8 "spotCosCutoff"
231 gen_struct_field builtin_core_types
8 "constantAttenuation"
232 gen_struct_field builtin_core_types
8 "linearAttenuation"
233 gen_struct_field builtin_core_types
8 "quadraticAttenuation"
234 gen_struct_field_footer
236 gen_struct_field_header gl_LightModelParameters
237 gen_struct_field builtin_core_types
11 "ambient"
238 gen_struct_field_footer
240 gen_struct_field_header gl_LightModelProducts
241 gen_struct_field builtin_core_types
11 "sceneColor"
242 gen_struct_field_footer
244 gen_struct_field_header gl_LightProducts
245 gen_struct_field builtin_core_types
11 "ambient"
246 gen_struct_field builtin_core_types
11 "diffuse"
247 gen_struct_field builtin_core_types
11 "specular"
248 gen_struct_field_footer
250 gen_struct_field_header gl_FogParameters
251 gen_struct_field builtin_core_types
11 "color"
252 gen_struct_field builtin_core_types
8 "density"
253 gen_struct_field builtin_core_types
8 "start"
254 gen_struct_field builtin_core_types
8 "end"
255 gen_struct_field builtin_core_types
8 "scale"
256 gen_struct_field_footer
258 gen_header
"110_deprecated_structure"
259 gen_struct_type gl_PointParameters
260 gen_struct_type gl_MaterialParameters
261 gen_struct_type gl_LightSourceParameters
262 gen_struct_type gl_LightModelParameters
263 gen_struct_type gl_LightModelProducts
264 gen_struct_type gl_LightProducts
265 gen_struct_type gl_FogParameters
271 echo '/** \name Types added in GLSL 1.20'
277 if [ $c -ne $r ]; then
278 gen_integral_type
"mat${c}x${r}" "GLSL_TYPE_FLOAT" $r $c
284 echo 'const glsl_type *const glsl_type::mat2x3_type = & builtin_120_types[0];'
285 echo 'const glsl_type *const glsl_type::mat2x4_type = & builtin_120_types[1];'
286 echo 'const glsl_type *const glsl_type::mat3x2_type = & builtin_120_types[2];'
287 echo 'const glsl_type *const glsl_type::mat3x4_type = & builtin_120_types[3];'
288 echo 'const glsl_type *const glsl_type::mat4x2_type = & builtin_120_types[4];'
289 echo 'const glsl_type *const glsl_type::mat4x3_type = & builtin_120_types[5];'
292 echo '/** \name Types added in GLSL 1.30'
298 gen_integral_type
"uint" "GLSL_TYPE_UINT" 1 1
300 gen_integral_type
"uvec$i" "GLSL_TYPE_UINT" $i 1
304 echo " /* 1D and 2D texture arrays */"
305 for i
in "1D" "2D"; do
306 gen_sampler_type
$i "GLSL_SAMPLER_DIM_$i" 0 1 "GLSL_TYPE_FLOAT"
307 gen_sampler_type
$i "GLSL_SAMPLER_DIM_$i" 0 1 "GLSL_TYPE_INT"
308 gen_sampler_type
$i "GLSL_SAMPLER_DIM_$i" 0 1 "GLSL_TYPE_UINT"
309 gen_sampler_type
$i "GLSL_SAMPLER_DIM_$i" 1 1 "GLSL_TYPE_FLOAT"
313 echo " /* cube shadow samplers */"
314 gen_sampler_type
"Cube" "GLSL_SAMPLER_DIM_CUBE" 1 0 "GLSL_TYPE_FLOAT"
317 echo " /* signed and unsigned integer samplers */"
318 for i
in "1D" "2D" "3D"; do
319 gen_sampler_type
$i "GLSL_SAMPLER_DIM_$i" 0 0 "GLSL_TYPE_INT"
320 gen_sampler_type
$i "GLSL_SAMPLER_DIM_$i" 0 0 "GLSL_TYPE_UINT"
323 gen_sampler_type
"Cube" "GLSL_SAMPLER_DIM_CUBE" 0 0 "GLSL_TYPE_INT"
324 gen_sampler_type
"Cube" "GLSL_SAMPLER_DIM_CUBE" 0 0 "GLSL_TYPE_UINT"
328 echo 'const glsl_type *const glsl_type::uint_type = & builtin_130_types['$uint_index'];'
332 echo '/** \name Sampler types added by GL_EXT_texture_buffer_object'
335 gen_header
"EXT_texture_buffer_object"
336 gen_sampler_type
"Buffer" "GLSL_SAMPLER_DIM_BUF" 0 0 "GLSL_TYPE_FLOAT"
337 gen_sampler_type
"Buffer" "GLSL_SAMPLER_DIM_BUF" 0 0 "GLSL_TYPE_INT"
338 gen_sampler_type
"Buffer" "GLSL_SAMPLER_DIM_BUF" 0 0 "GLSL_TYPE_UINT"