Merge branch 'draw-instanced'
[mesa.git] / src / glsl / builtin_types.h
index bd8f8b583a55985ef06dd2305fbd28827d0b20fe..8ccbf6e312f7b61b7cbcd1af8aca7bc7e4d6ae31 100644 (file)
  * DEALINGS IN THE SOFTWARE.
  */
 
-#ifndef Elements
-#define Elements(x) (sizeof(x)/sizeof(*(x)))
-#endif
-
 const glsl_type glsl_type::_error_type =
    glsl_type(GL_INVALID_ENUM, GLSL_TYPE_ERROR, 0, 0, "");
 
-const glsl_type glsl_type::void_type =
+const glsl_type glsl_type::_void_type =
    glsl_type(GL_INVALID_ENUM, GLSL_TYPE_VOID, 0, 0, "void");
 
 const glsl_type *const glsl_type::error_type = & glsl_type::_error_type;
+const glsl_type *const glsl_type::void_type = & glsl_type::_void_type;
 
 /** \name Core built-in types
  *
@@ -55,16 +52,8 @@ const glsl_type glsl_type::builtin_core_types[] = {
    glsl_type(GL_FLOAT_MAT2,   GLSL_TYPE_FLOAT, 2, 2, "mat2"),
    glsl_type(GL_FLOAT_MAT3,   GLSL_TYPE_FLOAT, 3, 3, "mat3"),
    glsl_type(GL_FLOAT_MAT4,   GLSL_TYPE_FLOAT, 4, 4, "mat4"),
-   glsl_type(GL_SAMPLER_1D,   GLSL_SAMPLER_DIM_1D, 0, 0, GLSL_TYPE_FLOAT,
-            "sampler1D"),
-   glsl_type(GL_SAMPLER_1D_SHADOW, GLSL_SAMPLER_DIM_1D, 1, 0, GLSL_TYPE_FLOAT,
-            "sampler1DShadow"),
    glsl_type(GL_SAMPLER_2D,   GLSL_SAMPLER_DIM_2D, 0, 0, GLSL_TYPE_FLOAT,
             "sampler2D"),
-   glsl_type(GL_SAMPLER_2D_SHADOW, GLSL_SAMPLER_DIM_2D, 1, 0, GLSL_TYPE_FLOAT,
-            "sampler2DShadow"),
-   glsl_type(GL_SAMPLER_3D,   GLSL_SAMPLER_DIM_3D, 0, 0, GLSL_TYPE_FLOAT,
-            "sampler3D"),
    glsl_type(GL_SAMPLER_CUBE, GLSL_SAMPLER_DIM_CUBE, 0, 0, GLSL_TYPE_FLOAT,
             "samplerCube"),
 };
@@ -182,6 +171,21 @@ const glsl_type glsl_type::builtin_110_deprecated_structure_types[] = {
 };
 /*@}*/
 
+/** \name Types in GLSL 1.10 (but not GLSL ES 1.00)
+ */
+/*@{*/
+const glsl_type glsl_type::builtin_110_types[] = {
+   glsl_type(GL_SAMPLER_1D,   GLSL_SAMPLER_DIM_1D, 0, 0, GLSL_TYPE_FLOAT,
+            "sampler1D"),
+   glsl_type(GL_SAMPLER_1D_SHADOW, GLSL_SAMPLER_DIM_1D, 1, 0, GLSL_TYPE_FLOAT,
+            "sampler1DShadow"),
+   glsl_type(GL_SAMPLER_2D_SHADOW, GLSL_SAMPLER_DIM_2D, 1, 0, GLSL_TYPE_FLOAT,
+            "sampler2DShadow"),
+   glsl_type(GL_SAMPLER_3D,   GLSL_SAMPLER_DIM_3D, 0, 0, GLSL_TYPE_FLOAT,
+            "sampler3D"),
+};
+/*@}*/
+
 /** \name Types added in GLSL 1.20
  */
 /*@{*/
@@ -212,23 +216,17 @@ const glsl_type glsl_type::builtin_130_types[] = {
    glsl_type(GL_UNSIGNED_INT_VEC3, GLSL_TYPE_UINT, 3, 1, "uvec3"),
    glsl_type(GL_UNSIGNED_INT_VEC4, GLSL_TYPE_UINT, 4, 1, "uvec4"),
 
-   /* 1D and 2D texture arrays */
-   glsl_type(GL_SAMPLER_1D_ARRAY,
-            GLSL_SAMPLER_DIM_1D, 0, 1, GLSL_TYPE_FLOAT, "sampler1DArray"),
+   /* 1D and 2D texture arrays - several of these are included only in
+    * builtin_EXT_texture_array_types.
+    */
    glsl_type(GL_INT_SAMPLER_1D_ARRAY,
             GLSL_SAMPLER_DIM_1D, 0, 1,   GLSL_TYPE_INT, "isampler1DArray"),
    glsl_type(GL_UNSIGNED_INT_SAMPLER_1D_ARRAY,
             GLSL_SAMPLER_DIM_1D, 0, 1,  GLSL_TYPE_UINT, "usampler1DArray"),
-   glsl_type(GL_SAMPLER_1D_ARRAY_SHADOW,
-            GLSL_SAMPLER_DIM_1D, 1, 1, GLSL_TYPE_FLOAT, "sampler1DArrayShadow"),
-   glsl_type(GL_SAMPLER_2D_ARRAY,
-            GLSL_SAMPLER_DIM_2D, 0, 1, GLSL_TYPE_FLOAT, "sampler2DArray"),
    glsl_type(GL_INT_SAMPLER_2D_ARRAY,
             GLSL_SAMPLER_DIM_2D, 0, 1,   GLSL_TYPE_INT, "isampler2DArray"),
    glsl_type(GL_UNSIGNED_INT_SAMPLER_2D_ARRAY,
             GLSL_SAMPLER_DIM_2D, 0, 1,  GLSL_TYPE_UINT, "usampler2DArray"),
-   glsl_type(GL_SAMPLER_2D_ARRAY_SHADOW,
-            GLSL_SAMPLER_DIM_2D, 1, 1, GLSL_TYPE_FLOAT, "sampler2DArrayShadow"),
 
    /* cube shadow samplers */
    glsl_type(GL_SAMPLER_CUBE_SHADOW,
@@ -254,6 +252,8 @@ const glsl_type glsl_type::builtin_130_types[] = {
 };
 
 const glsl_type *const glsl_type::uint_type = & builtin_130_types[0];
+const glsl_type *const glsl_type::uvec2_type = & builtin_130_types[1];
+const glsl_type *const glsl_type::uvec3_type = & builtin_130_types[2];
 const glsl_type *const glsl_type::uvec4_type = & builtin_130_types[3];
 /*@}*/
 
@@ -276,9 +276,9 @@ const glsl_type glsl_type::builtin_ARB_texture_rectangle_types[] = {
 const glsl_type glsl_type::builtin_EXT_texture_array_types[] = {
    glsl_type(GL_SAMPLER_1D_ARRAY,
             GLSL_SAMPLER_DIM_1D, 0, 1, GLSL_TYPE_FLOAT, "sampler1DArray"),
-   glsl_type(GL_SAMPLER_1D_ARRAY_SHADOW,
-            GLSL_SAMPLER_DIM_2D, 0, 1, GLSL_TYPE_FLOAT, "sampler2DArray"),
    glsl_type(GL_SAMPLER_2D_ARRAY,
+            GLSL_SAMPLER_DIM_2D, 0, 1, GLSL_TYPE_FLOAT, "sampler2DArray"),
+   glsl_type(GL_SAMPLER_1D_ARRAY_SHADOW,
             GLSL_SAMPLER_DIM_1D, 1, 1, GLSL_TYPE_FLOAT, "sampler1DArrayShadow"),
    glsl_type(GL_SAMPLER_2D_ARRAY_SHADOW,
             GLSL_SAMPLER_DIM_2D, 1, 1, GLSL_TYPE_FLOAT, "sampler2DArrayShadow"),