2 * Copyright © 2009 Intel Corporation
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:
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
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.
28 #define GLSL_TYPE_UINT 0
29 #define GLSL_TYPE_INT 1
30 #define GLSL_TYPE_FLOAT 2
31 #define GLSL_TYPE_BOOL 3
32 #define GLSL_TYPE_SAMPLER 4
33 #define GLSL_TYPE_STRUCT 5
34 #define GLSL_TYPE_ARRAY 6
35 #define GLSL_TYPE_FUNCTION 7
36 #define GLSL_TYPE_VOID 8
37 #define GLSL_TYPE_ERROR 9
39 #define is_numeric_base_type(b) \
40 (((b) >= GLSL_TYPE_UINT) && ((b) <= GLSL_TYPE_FLOAT))
42 #define is_integer_base_type(b) \
43 (((b) == GLSL_TYPE_UINT) || ((b) == GLSL_TYPE_INT))
45 #define is_error_type(t) ((t)->base_type == GLSL_TYPE_ERROR)
47 #define GLSL_SAMPLER_DIM_1D 0
48 #define GLSL_SAMPLER_DIM_2D 1
49 #define GLSL_SAMPLER_DIM_3D 2
50 #define GLSL_SAMPLER_DIM_CUBE 3
51 #define GLSL_SAMPLER_DIM_RECT 4
52 #define GLSL_SAMPLER_DIM_BUF 5
58 unsigned sampler_dimensionality
:3;
59 unsigned sampler_shadow
:1;
60 unsigned sampler_array
:1;
61 unsigned sampler_type
:2; /**< Type of data returned using this sampler.
62 * only \c GLSL_TYPE_FLOAT, \c GLSL_TYPE_INT,
63 * and \c GLSL_TYPE_UINT are valid.
66 unsigned vector_elements
:3; /**< 0, 2, 3, or 4 vector elements. */
67 unsigned matrix_rows
:3; /**< 0, 2, 3, or 4 matrix rows. */
70 * Name of the data type
72 * This may be \c NULL for anonymous structures, for arrays, or for
78 * For \c GLSL_TYPE_ARRAY, this is the length of the array. For
79 * \c GLSL_TYPE_STRUCT, it is the number of elements in the structure and
80 * the number of values pointed to by \c fields.structure (below).
82 * For \c GLSL_TYPE_FUNCTION, it is the number of parameters to the
83 * function. The return value from a function is implicitly the first
84 * parameter. The types of the parameters are stored in
85 * \c fields.parameters (below).
90 * Subtype of composite data types.
93 const struct glsl_type
*array
; /**< Type of array elements. */
94 const struct glsl_type
*parameters
; /**< Parameters to function. */
95 const struct glsl_struct_field
*structure
;/**< List of struct fields. */
99 #define is_glsl_type_scalar(t) \
100 (((t)->vector_elements == 0) \
101 && ((t)->base_type >= GLSL_TYPE_UINT) \
102 && ((t)->base_type <= GLSL_TYPE_BOOL))
104 #define is_glsl_type_vector(t) \
105 (((t)->vector_elements > 0) \
106 && ((t)->matrix_rows == 0) \
107 && ((t)->base_type >= GLSL_TYPE_UINT) \
108 && ((t)->base_type <= GLSL_TYPE_BOOL))
110 #define is_glsl_type_matrix(t) \
111 (((t)->matrix_rows > 0) \
112 && ((t)->base_type == GLSL_TYPE_FLOAT)) /* GLSL only has float matrices. */
114 struct glsl_struct_field
{
115 const struct glsl_type
*type
;
119 struct _mesa_glsl_parse_state
;
126 _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state
*state
);
128 extern const struct glsl_type
*
129 _mesa_glsl_get_vector_type(unsigned base_type
, unsigned vector_length
);
131 extern const struct glsl_type
*const glsl_error_type
;
132 extern const struct glsl_type
*const glsl_int_type
;
133 extern const struct glsl_type
*const glsl_uint_type
;
134 extern const struct glsl_type
*const glsl_float_type
;
135 extern const struct glsl_type
*const glsl_bool_type
;
141 #endif /* GLSL_TYPES_H */