Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4358 | Serge | 1 | /* |
2 | * Copyright © 2010 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 | |||
24 | #include "ast.h" |
||
25 | |||
26 | void |
||
27 | ast_type_specifier::print(void) const |
||
28 | { |
||
29 | if (structure) { |
||
30 | structure->print(); |
||
31 | } else { |
||
32 | printf("%s ", type_name); |
||
33 | } |
||
34 | |||
35 | if (is_array) { |
||
36 | printf("[ "); |
||
37 | |||
38 | if (array_size) { |
||
39 | array_size->print(); |
||
40 | } |
||
41 | |||
42 | printf("] "); |
||
43 | } |
||
44 | } |
||
45 | |||
46 | bool |
||
47 | ast_fully_specified_type::has_qualifiers() const |
||
48 | { |
||
49 | return this->qualifier.flags.i != 0; |
||
50 | } |
||
51 | |||
52 | bool ast_type_qualifier::has_interpolation() const |
||
53 | { |
||
54 | return this->flags.q.smooth |
||
55 | || this->flags.q.flat |
||
56 | || this->flags.q.noperspective; |
||
57 | } |
||
58 | |||
59 | bool |
||
60 | ast_type_qualifier::has_layout() const |
||
61 | { |
||
62 | return this->flags.q.origin_upper_left |
||
63 | || this->flags.q.pixel_center_integer |
||
64 | || this->flags.q.depth_any |
||
65 | || this->flags.q.depth_greater |
||
66 | || this->flags.q.depth_less |
||
67 | || this->flags.q.depth_unchanged |
||
68 | || this->flags.q.std140 |
||
69 | || this->flags.q.shared |
||
70 | || this->flags.q.column_major |
||
71 | || this->flags.q.row_major |
||
72 | || this->flags.q.packed |
||
73 | || this->flags.q.explicit_location |
||
74 | || this->flags.q.explicit_index |
||
75 | || this->flags.q.explicit_binding; |
||
76 | } |
||
77 | |||
78 | bool |
||
79 | ast_type_qualifier::has_storage() const |
||
80 | { |
||
81 | return this->flags.q.constant |
||
82 | || this->flags.q.attribute |
||
83 | || this->flags.q.varying |
||
84 | || this->flags.q.in |
||
85 | || this->flags.q.out |
||
86 | || this->flags.q.uniform; |
||
87 | } |
||
88 | |||
89 | bool |
||
90 | ast_type_qualifier::has_auxiliary_storage() const |
||
91 | { |
||
92 | return this->flags.q.centroid; |
||
93 | } |
||
94 | |||
95 | const char* |
||
96 | ast_type_qualifier::interpolation_string() const |
||
97 | { |
||
98 | if (this->flags.q.smooth) |
||
99 | return "smooth"; |
||
100 | else if (this->flags.q.flat) |
||
101 | return "flat"; |
||
102 | else if (this->flags.q.noperspective) |
||
103 | return "noperspective"; |
||
104 | else |
||
105 | return NULL; |
||
106 | } |
||
107 | |||
108 | bool |
||
109 | ast_type_qualifier::merge_qualifier(YYLTYPE *loc, |
||
110 | _mesa_glsl_parse_state *state, |
||
111 | ast_type_qualifier q) |
||
112 | { |
||
113 | ast_type_qualifier ubo_mat_mask; |
||
114 | ubo_mat_mask.flags.i = 0; |
||
115 | ubo_mat_mask.flags.q.row_major = 1; |
||
116 | ubo_mat_mask.flags.q.column_major = 1; |
||
117 | |||
118 | ast_type_qualifier ubo_layout_mask; |
||
119 | ubo_layout_mask.flags.i = 0; |
||
120 | ubo_layout_mask.flags.q.std140 = 1; |
||
121 | ubo_layout_mask.flags.q.packed = 1; |
||
122 | ubo_layout_mask.flags.q.shared = 1; |
||
123 | |||
124 | /* Uniform block layout qualifiers get to overwrite each |
||
125 | * other (rightmost having priority), while all other |
||
126 | * qualifiers currently don't allow duplicates. |
||
127 | */ |
||
128 | |||
129 | if ((this->flags.i & q.flags.i & ~(ubo_mat_mask.flags.i | |
||
130 | ubo_layout_mask.flags.i)) != 0) { |
||
131 | _mesa_glsl_error(loc, state, |
||
132 | "duplicate layout qualifiers used\n"); |
||
133 | return false; |
||
134 | } |
||
135 | |||
136 | if ((q.flags.i & ubo_mat_mask.flags.i) != 0) |
||
137 | this->flags.i &= ~ubo_mat_mask.flags.i; |
||
138 | if ((q.flags.i & ubo_layout_mask.flags.i) != 0) |
||
139 | this->flags.i &= ~ubo_layout_mask.flags.i; |
||
140 | |||
141 | this->flags.i |= q.flags.i; |
||
142 | |||
143 | if (q.flags.q.explicit_location) |
||
144 | this->location = q.location; |
||
145 | |||
146 | if (q.flags.q.explicit_index) |
||
147 | this->index = q.index; |
||
148 | |||
149 | if (q.flags.q.explicit_binding) |
||
150 | this->binding = q.binding; |
||
151 | |||
152 | if (q.precision != ast_precision_none) |
||
153 | this->precision = q.precision; |
||
154 | |||
155 | return true; |
||
156 | } |
||
157 |