Clone of mesa.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

builtin_types.sh 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. #!/bin/sh
  2. #
  3. # Copyright © 2009 Intel Corporation
  4. #
  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:
  11. #
  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
  14. # Software.
  15. #
  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.
  23. # gen_integral_type <name> <base_type> <vector elements> <matrix rows>
  24. function gen_integral_type
  25. {
  26. printf ' glsl_type( %17s, %u, %u, "%s"),\n' $2 $3 $4 $1
  27. index=$((index + 1))
  28. }
  29. # gen_struct_type <name>
  30. function gen_struct_type
  31. {
  32. elements=$(printf "%s_fields" $1)
  33. printf ' glsl_type(%s,\n Elements(%s),\n "%s"),\n' \
  34. $elements $elements $1
  35. }
  36. # gen_sampler_type <name> <dimensions> <shadow> <array> <type>
  37. function gen_sampler_type
  38. {
  39. name=$(printf "sampler%s" $1)
  40. if [ $4 -eq 1 ]; then
  41. name=$(printf "%sArray" $name)
  42. fi
  43. if [ $3 -eq 1 ]; then
  44. name=$(printf "%sShadow" $name)
  45. fi
  46. if [ $5 == GLSL_TYPE_INT ]; then
  47. name=$(printf "i%s" $name)
  48. elif [ $5 == GLSL_TYPE_UINT ]; then
  49. name=$(printf "u%s" $name)
  50. fi
  51. printf ' glsl_type(%21s, %u, %u, %15s, "%s"),\n' \
  52. $2 $3 $4 $5 $name
  53. }
  54. function gen_header
  55. {
  56. if [ x$1 == x ]; then
  57. name="builtin_types"
  58. else
  59. name="builtin_${1}_types"
  60. fi
  61. printf "\nstatic const struct glsl_type %s[] = {\n" $name
  62. }
  63. function gen_footer
  64. {
  65. printf "};\n"
  66. }
  67. function gen_struct_field_header
  68. {
  69. printf "\nstatic const struct glsl_struct_field %s_fields[] = {\n" $1
  70. }
  71. function gen_struct_field_footer
  72. {
  73. printf "};\n"
  74. }
  75. function gen_struct_field
  76. {
  77. printf ' { & %s[%2u], "%s" },\n' $1 $2 "$3"
  78. }
  79. cat <<EOF
  80. /* THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT! See builtin_types.sh. */
  81. /*
  82. * Copyright © 2009 Intel Corporation
  83. *
  84. * Permission is hereby granted, free of charge, to any person obtaining a
  85. * copy of this software and associated documentation files (the "Software"),
  86. * to deal in the Software without restriction, including without limitation
  87. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  88. * and/or sell copies of the Software, and to permit persons to whom the
  89. * Software is furnished to do so, subject to the following conditions:
  90. *
  91. * The above copyright notice and this permission notice (including the next
  92. * paragraph) shall be included in all copies or substantial portions of the
  93. * Software.
  94. *
  95. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  96. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  97. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  98. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  99. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  100. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  101. * DEALINGS IN THE SOFTWARE.
  102. */
  103. #ifndef Elements
  104. #define Elements(x) (sizeof(x)/sizeof(*(x)))
  105. #endif
  106. static const struct glsl_type error_type =
  107. glsl_type(GLSL_TYPE_ERROR, 0, 0, "");
  108. const struct glsl_type *const glsl_error_type = & error_type;
  109. EOF
  110. echo '/** \name Core built-in types'
  111. echo ' *'
  112. echo ' * These types exist in all versions of GLSL.'
  113. echo ' */'
  114. echo '/*@{*/'
  115. gen_header "core"
  116. index=0;
  117. bool_index=$index
  118. gen_integral_type "bool" "GLSL_TYPE_BOOL" 0 0
  119. for i in 2 3 4; do
  120. gen_integral_type "bvec$i" "GLSL_TYPE_BOOL" $i 0
  121. done
  122. int_index=$index
  123. gen_integral_type "int" "GLSL_TYPE_INT" 0 0
  124. for i in 2 3 4; do
  125. gen_integral_type "ivec$i" "GLSL_TYPE_INT" $i 0
  126. done
  127. float_index=$index
  128. gen_integral_type "float" "GLSL_TYPE_FLOAT" 0 0
  129. for i in 2 3 4; do
  130. gen_integral_type "vec$i" "GLSL_TYPE_FLOAT" $i 0
  131. done
  132. for i in 2 3 4; do
  133. gen_integral_type "mat$i" "GLSL_TYPE_FLOAT" $i $i
  134. done
  135. for i in "1D" "2D"; do
  136. gen_sampler_type $i "GLSL_SAMPLER_DIM_$i" 0 0 "GLSL_TYPE_FLOAT"
  137. gen_sampler_type $i "GLSL_SAMPLER_DIM_$i" 1 0 "GLSL_TYPE_FLOAT"
  138. done
  139. gen_sampler_type "3D" "GLSL_SAMPLER_DIM_3D" 0 0 "GLSL_TYPE_FLOAT"
  140. gen_sampler_type "Cube" "GLSL_SAMPLER_DIM_CUBE" 0 0 "GLSL_TYPE_FLOAT"
  141. gen_sampler_type "2DRect" "GLSL_SAMPLER_DIM_RECT" 0 0 "GLSL_TYPE_FLOAT"
  142. gen_sampler_type "2DRect" "GLSL_SAMPLER_DIM_RECT" 1 0 "GLSL_TYPE_FLOAT"
  143. gen_footer
  144. echo
  145. echo 'const struct glsl_type *const glsl_bool_type = & builtin_core_types['$bool_index'];'
  146. echo 'const struct glsl_type *const glsl_int_type = & builtin_core_types['$int_index'];'
  147. echo 'const struct glsl_type *const glsl_float_type = & builtin_core_types['$float_index'];'
  148. echo '/*@}*/'
  149. echo
  150. echo '/** \name GLSL structures that have not been deprecated.'
  151. echo ' */'
  152. echo '/*@{*/'
  153. gen_struct_field_header gl_DepthRangeParameters
  154. gen_struct_field builtin_core_types 8 "near"
  155. gen_struct_field builtin_core_types 8 "far"
  156. gen_struct_field builtin_core_types 8 "diff"
  157. gen_struct_field_footer
  158. gen_header "structure"
  159. gen_struct_type gl_DepthRangeParameters
  160. gen_footer
  161. echo '/*@}*/'
  162. echo
  163. echo '/** \name GLSL 1.00 / 1.10 structures that are deprecated in GLSL 1.30'
  164. echo ' */'
  165. echo '/*@{*/'
  166. gen_struct_field_header gl_PointParameters
  167. gen_struct_field builtin_core_types 8 "size"
  168. gen_struct_field builtin_core_types 8 "sizeMin"
  169. gen_struct_field builtin_core_types 8 "sizeMax"
  170. gen_struct_field builtin_core_types 8 "fadeThresholdSize"
  171. gen_struct_field builtin_core_types 8 "distanceConstantAttenuation"
  172. gen_struct_field builtin_core_types 8 "distanceLinearAttenuation"
  173. gen_struct_field builtin_core_types 8 "distanceQuadraticAttenuation"
  174. gen_struct_field_footer
  175. gen_struct_field_header gl_MaterialParameters
  176. gen_struct_field builtin_core_types 11 "emission"
  177. gen_struct_field builtin_core_types 11 "ambient"
  178. gen_struct_field builtin_core_types 11 "diffuse"
  179. gen_struct_field builtin_core_types 11 "specular"
  180. gen_struct_field builtin_core_types 8 "shininess"
  181. gen_struct_field_footer
  182. gen_struct_field_header gl_LightSourceParameters
  183. gen_struct_field builtin_core_types 11 "ambient"
  184. gen_struct_field builtin_core_types 11 "diffuse"
  185. gen_struct_field builtin_core_types 11 "specular"
  186. gen_struct_field builtin_core_types 11 "position"
  187. gen_struct_field builtin_core_types 11 "halfVector"
  188. gen_struct_field builtin_core_types 10 "spotDirection"
  189. gen_struct_field builtin_core_types 8 "spotExponent"
  190. gen_struct_field builtin_core_types 8 "spotCutoff"
  191. gen_struct_field builtin_core_types 8 "spotCosCutoff"
  192. gen_struct_field builtin_core_types 8 "constantAttenuation"
  193. gen_struct_field builtin_core_types 8 "linearAttenuation"
  194. gen_struct_field builtin_core_types 8 "quadraticAttenuation"
  195. gen_struct_field_footer
  196. gen_struct_field_header gl_LightModelParameters
  197. gen_struct_field builtin_core_types 11 "ambient"
  198. gen_struct_field_footer
  199. gen_struct_field_header gl_LightModelProducts
  200. gen_struct_field builtin_core_types 11 "sceneColor"
  201. gen_struct_field_footer
  202. gen_struct_field_header gl_LightProducts
  203. gen_struct_field builtin_core_types 11 "ambient"
  204. gen_struct_field builtin_core_types 11 "diffuse"
  205. gen_struct_field builtin_core_types 11 "specular"
  206. gen_struct_field_footer
  207. gen_struct_field_header gl_FogParameters
  208. gen_struct_field builtin_core_types 11 "color"
  209. gen_struct_field builtin_core_types 8 "density"
  210. gen_struct_field builtin_core_types 8 "start"
  211. gen_struct_field builtin_core_types 8 "end"
  212. gen_struct_field builtin_core_types 8 "scale"
  213. gen_struct_field_footer
  214. gen_header "110_deprecated_structure"
  215. gen_struct_type gl_PointParameters
  216. gen_struct_type gl_MaterialParameters
  217. gen_struct_type gl_LightSourceParameters
  218. gen_struct_type gl_LightModelParameters
  219. gen_struct_type gl_LightModelProducts
  220. gen_struct_type gl_LightProducts
  221. gen_struct_type gl_FogParameters
  222. gen_footer
  223. echo '/*@}*/'
  224. echo
  225. echo '/** \name Types added in GLSL 1.20'
  226. echo ' */'
  227. echo '/*@{*/'
  228. gen_header "120"
  229. for i in 2 3 4; do
  230. for j in 2 3 4; do
  231. if [ $i -ne $j ]; then
  232. gen_integral_type "mat${i}x${j}" "GLSL_TYPE_FLOAT" $i $j
  233. fi
  234. done
  235. done
  236. gen_footer
  237. echo '/*@}*/'
  238. echo
  239. echo '/** \name Types added in GLSL 1.30'
  240. echo ' */'
  241. echo '/*@{*/'
  242. gen_header "130"
  243. index=0;
  244. uint_index=$index
  245. gen_integral_type "uint" "GLSL_TYPE_UINT" 0 0
  246. for i in 2 3 4; do
  247. gen_integral_type "uvec$i" "GLSL_TYPE_UINT" $i 0
  248. done
  249. echo
  250. echo " /* 1D and 2D texture arrays */"
  251. for i in "1D" "2D"; do
  252. gen_sampler_type $i "GLSL_SAMPLER_DIM_$i" 0 1 "GLSL_TYPE_FLOAT"
  253. gen_sampler_type $i "GLSL_SAMPLER_DIM_$i" 0 1 "GLSL_TYPE_INT"
  254. gen_sampler_type $i "GLSL_SAMPLER_DIM_$i" 0 1 "GLSL_TYPE_UINT"
  255. gen_sampler_type $i "GLSL_SAMPLER_DIM_$i" 1 1 "GLSL_TYPE_FLOAT"
  256. done
  257. echo
  258. echo " /* cube shadow samplers */"
  259. gen_sampler_type "Cube" "GLSL_SAMPLER_DIM_CUBE" 1 0 "GLSL_TYPE_FLOAT"
  260. echo
  261. echo " /* signed and unsigned integer samplers */"
  262. for i in "1D" "2D" "3D"; do
  263. gen_sampler_type $i "GLSL_SAMPLER_DIM_$i" 0 0 "GLSL_TYPE_INT"
  264. gen_sampler_type $i "GLSL_SAMPLER_DIM_$i" 0 0 "GLSL_TYPE_UINT"
  265. done
  266. gen_sampler_type "Cube" "GLSL_SAMPLER_DIM_CUBE" 0 0 "GLSL_TYPE_INT"
  267. gen_sampler_type "Cube" "GLSL_SAMPLER_DIM_CUBE" 0 0 "GLSL_TYPE_UINT"
  268. gen_footer
  269. echo ''
  270. echo 'const struct glsl_type *const glsl_uint_type = & builtin_130_types['$uint_index'];'
  271. echo '/*@}*/'
  272. echo
  273. echo '/** \name Sampler types added by GL_EXT_texture_buffer_object'
  274. echo ' */'
  275. echo '/*@{*/'
  276. gen_header "EXT_texture_buffer_object"
  277. gen_sampler_type "Buffer" "GLSL_SAMPLER_DIM_BUF" 0 0 "GLSL_TYPE_FLOAT"
  278. gen_sampler_type "Buffer" "GLSL_SAMPLER_DIM_BUF" 0 0 "GLSL_TYPE_INT"
  279. gen_sampler_type "Buffer" "GLSL_SAMPLER_DIM_BUF" 0 0 "GLSL_TYPE_UINT"
  280. gen_footer
  281. echo '/*@}*/'