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.h 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  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. #ifndef Elements
  24. #define Elements(x) (sizeof(x)/sizeof(*(x)))
  25. #endif
  26. static const struct glsl_type _error_type =
  27. glsl_type(GLSL_TYPE_ERROR, 0, 0, "");
  28. static const struct glsl_type void_type =
  29. glsl_type(GLSL_TYPE_VOID, 0, 0, "void");
  30. const glsl_type *const glsl_type::error_type = & _error_type;
  31. /** \name Core built-in types
  32. *
  33. * These types exist in all versions of GLSL.
  34. */
  35. /*@{*/
  36. static const struct glsl_type builtin_core_types[] = {
  37. glsl_type( GLSL_TYPE_BOOL, 1, 1, "bool"),
  38. glsl_type( GLSL_TYPE_BOOL, 2, 1, "bvec2"),
  39. glsl_type( GLSL_TYPE_BOOL, 3, 1, "bvec3"),
  40. glsl_type( GLSL_TYPE_BOOL, 4, 1, "bvec4"),
  41. glsl_type( GLSL_TYPE_INT, 1, 1, "int"),
  42. glsl_type( GLSL_TYPE_INT, 2, 1, "ivec2"),
  43. glsl_type( GLSL_TYPE_INT, 3, 1, "ivec3"),
  44. glsl_type( GLSL_TYPE_INT, 4, 1, "ivec4"),
  45. glsl_type( GLSL_TYPE_FLOAT, 1, 1, "float"),
  46. glsl_type( GLSL_TYPE_FLOAT, 2, 1, "vec2"),
  47. glsl_type( GLSL_TYPE_FLOAT, 3, 1, "vec3"),
  48. glsl_type( GLSL_TYPE_FLOAT, 4, 1, "vec4"),
  49. glsl_type( GLSL_TYPE_FLOAT, 2, 2, "mat2"),
  50. glsl_type( GLSL_TYPE_FLOAT, 3, 3, "mat3"),
  51. glsl_type( GLSL_TYPE_FLOAT, 4, 4, "mat4"),
  52. glsl_type( GLSL_SAMPLER_DIM_1D, 0, 0, GLSL_TYPE_FLOAT, "sampler1D"),
  53. glsl_type( GLSL_SAMPLER_DIM_1D, 1, 0, GLSL_TYPE_FLOAT, "sampler1DShadow"),
  54. glsl_type( GLSL_SAMPLER_DIM_2D, 0, 0, GLSL_TYPE_FLOAT, "sampler2D"),
  55. glsl_type( GLSL_SAMPLER_DIM_2D, 1, 0, GLSL_TYPE_FLOAT, "sampler2DShadow"),
  56. glsl_type( GLSL_SAMPLER_DIM_3D, 0, 0, GLSL_TYPE_FLOAT, "sampler3D"),
  57. glsl_type(GLSL_SAMPLER_DIM_CUBE, 0, 0, GLSL_TYPE_FLOAT, "samplerCube"),
  58. };
  59. const glsl_type *const glsl_type::bool_type = & builtin_core_types[0];
  60. const glsl_type *const glsl_type::int_type = & builtin_core_types[4];
  61. const glsl_type *const glsl_type::ivec4_type = & builtin_core_types[7];
  62. const glsl_type *const glsl_type::float_type = & builtin_core_types[8];
  63. const glsl_type *const glsl_type::vec2_type = & builtin_core_types[9];
  64. const glsl_type *const glsl_type::vec3_type = & builtin_core_types[10];
  65. const glsl_type *const glsl_type::vec4_type = & builtin_core_types[11];
  66. const glsl_type *const glsl_type::mat2_type = & builtin_core_types[12];
  67. const glsl_type *const glsl_type::mat3_type = & builtin_core_types[13];
  68. const glsl_type *const glsl_type::mat4_type = & builtin_core_types[14];
  69. /*@}*/
  70. /** \name GLSL structures that have not been deprecated.
  71. */
  72. /*@{*/
  73. static const struct glsl_struct_field gl_DepthRangeParameters_fields[] = {
  74. { glsl_type::float_type, "near" },
  75. { glsl_type::float_type, "far" },
  76. { glsl_type::float_type, "diff" },
  77. };
  78. static const struct glsl_type builtin_structure_types[] = {
  79. glsl_type(gl_DepthRangeParameters_fields,
  80. Elements(gl_DepthRangeParameters_fields),
  81. "gl_DepthRangeParameters"),
  82. };
  83. /*@}*/
  84. /** \name GLSL 1.00 / 1.10 structures that are deprecated in GLSL 1.30
  85. */
  86. /*@{*/
  87. static const struct glsl_struct_field gl_PointParameters_fields[] = {
  88. { glsl_type::float_type, "size" },
  89. { glsl_type::float_type, "sizeMin" },
  90. { glsl_type::float_type, "sizeMax" },
  91. { glsl_type::float_type, "fadeThresholdSize" },
  92. { glsl_type::float_type, "distanceConstantAttenuation" },
  93. { glsl_type::float_type, "distanceLinearAttenuation" },
  94. { glsl_type::float_type, "distanceQuadraticAttenuation" },
  95. };
  96. static const struct glsl_struct_field gl_MaterialParameters_fields[] = {
  97. { glsl_type::vec4_type, "emission" },
  98. { glsl_type::vec4_type, "ambient" },
  99. { glsl_type::vec4_type, "diffuse" },
  100. { glsl_type::vec4_type, "specular" },
  101. { glsl_type::float_type, "shininess" },
  102. };
  103. static const struct glsl_struct_field gl_LightSourceParameters_fields[] = {
  104. { glsl_type::vec4_type, "ambient" },
  105. { glsl_type::vec4_type, "diffuse" },
  106. { glsl_type::vec4_type, "specular" },
  107. { glsl_type::vec4_type, "position" },
  108. { glsl_type::vec4_type, "halfVector" },
  109. { glsl_type::vec3_type, "spotDirection" },
  110. { glsl_type::float_type, "spotExponent" },
  111. { glsl_type::float_type, "spotCutoff" },
  112. { glsl_type::float_type, "spotCosCutoff" },
  113. { glsl_type::float_type, "constantAttenuation" },
  114. { glsl_type::float_type, "linearAttenuation" },
  115. { glsl_type::float_type, "quadraticAttenuation" },
  116. };
  117. static const struct glsl_struct_field gl_LightModelParameters_fields[] = {
  118. { glsl_type::vec4_type, "ambient" },
  119. };
  120. static const struct glsl_struct_field gl_LightModelProducts_fields[] = {
  121. { glsl_type::vec4_type, "sceneColor" },
  122. };
  123. static const struct glsl_struct_field gl_LightProducts_fields[] = {
  124. { glsl_type::vec4_type, "ambient" },
  125. { glsl_type::vec4_type, "diffuse" },
  126. { glsl_type::vec4_type, "specular" },
  127. };
  128. static const struct glsl_struct_field gl_FogParameters_fields[] = {
  129. { glsl_type::vec4_type, "color" },
  130. { glsl_type::float_type, "density" },
  131. { glsl_type::float_type, "start" },
  132. { glsl_type::float_type, "end" },
  133. { glsl_type::float_type, "scale" },
  134. };
  135. static const struct glsl_type builtin_110_deprecated_structure_types[] = {
  136. glsl_type(gl_PointParameters_fields,
  137. Elements(gl_PointParameters_fields),
  138. "gl_PointParameters"),
  139. glsl_type(gl_MaterialParameters_fields,
  140. Elements(gl_MaterialParameters_fields),
  141. "gl_MaterialParameters"),
  142. glsl_type(gl_LightSourceParameters_fields,
  143. Elements(gl_LightSourceParameters_fields),
  144. "gl_LightSourceParameters"),
  145. glsl_type(gl_LightModelParameters_fields,
  146. Elements(gl_LightModelParameters_fields),
  147. "gl_LightModelParameters"),
  148. glsl_type(gl_LightModelProducts_fields,
  149. Elements(gl_LightModelProducts_fields),
  150. "gl_LightModelProducts"),
  151. glsl_type(gl_LightProducts_fields,
  152. Elements(gl_LightProducts_fields),
  153. "gl_LightProducts"),
  154. glsl_type(gl_FogParameters_fields,
  155. Elements(gl_FogParameters_fields),
  156. "gl_FogParameters"),
  157. };
  158. /*@}*/
  159. /** \name Types added in GLSL 1.20
  160. */
  161. /*@{*/
  162. static const struct glsl_type builtin_120_types[] = {
  163. glsl_type( GLSL_TYPE_FLOAT, 3, 2, "mat2x3"),
  164. glsl_type( GLSL_TYPE_FLOAT, 4, 2, "mat2x4"),
  165. glsl_type( GLSL_TYPE_FLOAT, 2, 3, "mat3x2"),
  166. glsl_type( GLSL_TYPE_FLOAT, 4, 3, "mat3x4"),
  167. glsl_type( GLSL_TYPE_FLOAT, 2, 4, "mat4x2"),
  168. glsl_type( GLSL_TYPE_FLOAT, 3, 4, "mat4x3"),
  169. };
  170. const glsl_type *const glsl_type::mat2x3_type = & builtin_120_types[0];
  171. const glsl_type *const glsl_type::mat2x4_type = & builtin_120_types[1];
  172. const glsl_type *const glsl_type::mat3x2_type = & builtin_120_types[2];
  173. const glsl_type *const glsl_type::mat3x4_type = & builtin_120_types[3];
  174. const glsl_type *const glsl_type::mat4x2_type = & builtin_120_types[4];
  175. const glsl_type *const glsl_type::mat4x3_type = & builtin_120_types[5];
  176. /*@}*/
  177. /** \name Types added in GLSL 1.30
  178. */
  179. /*@{*/
  180. static const struct glsl_type builtin_130_types[] = {
  181. glsl_type( GLSL_TYPE_UINT, 1, 1, "uint"),
  182. glsl_type( GLSL_TYPE_UINT, 2, 1, "uvec2"),
  183. glsl_type( GLSL_TYPE_UINT, 3, 1, "uvec3"),
  184. glsl_type( GLSL_TYPE_UINT, 4, 1, "uvec4"),
  185. /* 1D and 2D texture arrays */
  186. glsl_type( GLSL_SAMPLER_DIM_1D, 0, 1, GLSL_TYPE_FLOAT, "sampler1DArray"),
  187. glsl_type( GLSL_SAMPLER_DIM_1D, 0, 1, GLSL_TYPE_INT, "isampler1DArray"),
  188. glsl_type( GLSL_SAMPLER_DIM_1D, 0, 1, GLSL_TYPE_UINT, "usampler1DArray"),
  189. glsl_type( GLSL_SAMPLER_DIM_1D, 1, 1, GLSL_TYPE_FLOAT, "sampler1DArrayShadow"),
  190. glsl_type( GLSL_SAMPLER_DIM_2D, 0, 1, GLSL_TYPE_FLOAT, "sampler2DArray"),
  191. glsl_type( GLSL_SAMPLER_DIM_2D, 0, 1, GLSL_TYPE_INT, "isampler2DArray"),
  192. glsl_type( GLSL_SAMPLER_DIM_2D, 0, 1, GLSL_TYPE_UINT, "usampler2DArray"),
  193. glsl_type( GLSL_SAMPLER_DIM_2D, 1, 1, GLSL_TYPE_FLOAT, "sampler2DArrayShadow"),
  194. /* cube shadow samplers */
  195. glsl_type(GLSL_SAMPLER_DIM_CUBE, 1, 0, GLSL_TYPE_FLOAT, "samplerCubeShadow"),
  196. /* signed and unsigned integer samplers */
  197. glsl_type( GLSL_SAMPLER_DIM_1D, 0, 0, GLSL_TYPE_INT, "isampler1D"),
  198. glsl_type( GLSL_SAMPLER_DIM_1D, 0, 0, GLSL_TYPE_UINT, "usampler1D"),
  199. glsl_type( GLSL_SAMPLER_DIM_2D, 0, 0, GLSL_TYPE_INT, "isampler2D"),
  200. glsl_type( GLSL_SAMPLER_DIM_2D, 0, 0, GLSL_TYPE_UINT, "usampler2D"),
  201. glsl_type( GLSL_SAMPLER_DIM_3D, 0, 0, GLSL_TYPE_INT, "isampler3D"),
  202. glsl_type( GLSL_SAMPLER_DIM_3D, 0, 0, GLSL_TYPE_UINT, "usampler3D"),
  203. glsl_type(GLSL_SAMPLER_DIM_CUBE, 0, 0, GLSL_TYPE_INT, "isamplerCube"),
  204. glsl_type(GLSL_SAMPLER_DIM_CUBE, 0, 0, GLSL_TYPE_UINT, "usamplerCube"),
  205. };
  206. const glsl_type *const glsl_type::uint_type = & builtin_130_types[0];
  207. const glsl_type *const glsl_type::uvec4_type = & builtin_130_types[3];
  208. /*@}*/
  209. /** \name Sampler types added by GL_ARB_texture_rectangle
  210. */
  211. /*@{*/
  212. static const struct glsl_type builtin_ARB_texture_rectangle_types[] = {
  213. glsl_type(GLSL_SAMPLER_DIM_RECT, 0, 0, GLSL_TYPE_FLOAT, "sampler2DRect"),
  214. glsl_type(GLSL_SAMPLER_DIM_RECT, 1, 0, GLSL_TYPE_FLOAT, "sampler2DRectShadow"),
  215. };
  216. /*@}*/
  217. /** \name Sampler types added by GL_EXT_texture_array
  218. */
  219. /*@{*/
  220. static const struct glsl_type builtin_EXT_texture_array_types[] = {
  221. glsl_type( GLSL_SAMPLER_DIM_1D, 0, 1, GLSL_TYPE_FLOAT, "sampler1DArray"),
  222. glsl_type( GLSL_SAMPLER_DIM_2D, 0, 1, GLSL_TYPE_FLOAT, "sampler2DArray"),
  223. glsl_type( GLSL_SAMPLER_DIM_1D, 1, 1, GLSL_TYPE_FLOAT, "sampler1DArrayShadow"),
  224. glsl_type( GLSL_SAMPLER_DIM_2D, 1, 1, GLSL_TYPE_FLOAT, "sampler2DArrayShadow"),
  225. };
  226. /*@}*/
  227. /** \name Sampler types added by GL_EXT_texture_buffer_object
  228. */
  229. /*@{*/
  230. static const struct glsl_type builtin_EXT_texture_buffer_object_types[] = {
  231. glsl_type( GLSL_SAMPLER_DIM_BUF, 0, 0, GLSL_TYPE_FLOAT, "samplerBuffer"),
  232. glsl_type( GLSL_SAMPLER_DIM_BUF, 0, 0, GLSL_TYPE_INT, "isamplerBuffer"),
  233. glsl_type( GLSL_SAMPLER_DIM_BUF, 0, 0, GLSL_TYPE_UINT, "usamplerBuffer"),
  234. };
  235. /*@}*/