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.
25 #include "glsl_symbol_table.h"
26 #include "glsl_parser_extras.h"
27 #include "glsl_types.h"
28 #include "builtin_types.h"
32 add_types_to_symbol_table(glsl_symbol_table
*symtab
,
33 const struct glsl_type
*types
,
38 for (i
= 0; i
< num_types
; i
++) {
39 symtab
->add_type(types
[i
].name
, & types
[i
]);
45 generate_110_types(glsl_symbol_table
*symtab
)
47 add_types_to_symbol_table(symtab
, builtin_core_types
,
48 Elements(builtin_core_types
));
49 add_types_to_symbol_table(symtab
, builtin_structure_types
,
50 Elements(builtin_structure_types
));
51 add_types_to_symbol_table(symtab
, builtin_110_deprecated_structure_types
,
52 Elements(builtin_110_deprecated_structure_types
));
57 generate_120_types(glsl_symbol_table
*symtab
)
59 generate_110_types(symtab
);
61 add_types_to_symbol_table(symtab
, builtin_120_types
,
62 Elements(builtin_120_types
));
67 generate_130_types(glsl_symbol_table
*symtab
)
69 generate_120_types(symtab
);
71 add_types_to_symbol_table(symtab
, builtin_130_types
,
72 Elements(builtin_130_types
));
77 _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state
*state
)
79 switch (state
->language_version
) {
81 generate_110_types(state
->symbols
);
84 generate_120_types(state
->symbols
);
87 generate_130_types(state
->symbols
);
96 const struct glsl_type
*
97 _mesa_glsl_get_vector_type(unsigned base_type
, unsigned vector_length
)
101 switch (vector_length
) {
106 return glsl_uint_type
+ (vector_length
- 1);
108 return glsl_error_type
;
111 switch (vector_length
) {
116 return glsl_int_type
+ (vector_length
- 1);
118 return glsl_error_type
;
120 case GLSL_TYPE_FLOAT
:
121 switch (vector_length
) {
126 return glsl_float_type
+ (vector_length
- 1);
128 return glsl_error_type
;
131 switch (vector_length
) {
136 return glsl_bool_type
+ (vector_length
- 1);
138 return glsl_error_type
;
141 return glsl_error_type
;