2 * Copyright © 2010 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.
27 ast_type_specifier::print(void) const
32 printf("%s ", type_name
);
47 ast_fully_specified_type::has_qualifiers() const
49 return this->qualifier
.flags
.i
!= 0;
52 bool ast_type_qualifier::has_interpolation() const
54 return this->flags
.q
.smooth
56 || this->flags
.q
.noperspective
;
60 ast_type_qualifier::has_layout() const
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 || this->flags
.q
.explicit_offset
;
80 ast_type_qualifier::has_storage() const
82 return this->flags
.q
.constant
83 || this->flags
.q
.attribute
84 || this->flags
.q
.varying
87 || this->flags
.q
.uniform
;
91 ast_type_qualifier::has_auxiliary_storage() const
93 return this->flags
.q
.centroid
94 || this->flags
.q
.sample
;
98 ast_type_qualifier::interpolation_string() const
100 if (this->flags
.q
.smooth
)
102 else if (this->flags
.q
.flat
)
104 else if (this->flags
.q
.noperspective
)
105 return "noperspective";
111 ast_type_qualifier::merge_qualifier(YYLTYPE
*loc
,
112 _mesa_glsl_parse_state
*state
,
113 ast_type_qualifier q
)
115 ast_type_qualifier ubo_mat_mask
;
116 ubo_mat_mask
.flags
.i
= 0;
117 ubo_mat_mask
.flags
.q
.row_major
= 1;
118 ubo_mat_mask
.flags
.q
.column_major
= 1;
120 ast_type_qualifier ubo_layout_mask
;
121 ubo_layout_mask
.flags
.i
= 0;
122 ubo_layout_mask
.flags
.q
.std140
= 1;
123 ubo_layout_mask
.flags
.q
.packed
= 1;
124 ubo_layout_mask
.flags
.q
.shared
= 1;
126 ast_type_qualifier ubo_binding_mask
;
127 ubo_binding_mask
.flags
.q
.explicit_binding
= 1;
128 ubo_binding_mask
.flags
.q
.explicit_offset
= 1;
130 /* Uniform block layout qualifiers get to overwrite each
131 * other (rightmost having priority), while all other
132 * qualifiers currently don't allow duplicates.
135 if ((this->flags
.i
& q
.flags
.i
& ~(ubo_mat_mask
.flags
.i
|
136 ubo_layout_mask
.flags
.i
|
137 ubo_binding_mask
.flags
.i
)) != 0) {
138 _mesa_glsl_error(loc
, state
,
139 "duplicate layout qualifiers used");
143 if (q
.flags
.q
.prim_type
) {
144 if (this->flags
.q
.prim_type
&& this->prim_type
!= q
.prim_type
) {
145 _mesa_glsl_error(loc
, state
,
146 "conflicting primitive type qualifiers used");
149 this->prim_type
= q
.prim_type
;
152 if (q
.flags
.q
.max_vertices
) {
153 if (this->flags
.q
.max_vertices
&& this->max_vertices
!= q
.max_vertices
) {
154 _mesa_glsl_error(loc
, state
,
155 "geometry shader set conflicting max_vertices "
156 "(%d and %d)", this->max_vertices
, q
.max_vertices
);
159 this->max_vertices
= q
.max_vertices
;
162 if ((q
.flags
.i
& ubo_mat_mask
.flags
.i
) != 0)
163 this->flags
.i
&= ~ubo_mat_mask
.flags
.i
;
164 if ((q
.flags
.i
& ubo_layout_mask
.flags
.i
) != 0)
165 this->flags
.i
&= ~ubo_layout_mask
.flags
.i
;
167 this->flags
.i
|= q
.flags
.i
;
169 if (q
.flags
.q
.explicit_location
)
170 this->location
= q
.location
;
172 if (q
.flags
.q
.explicit_index
)
173 this->index
= q
.index
;
175 if (q
.flags
.q
.explicit_binding
)
176 this->binding
= q
.binding
;
178 if (q
.flags
.q
.explicit_offset
)
179 this->offset
= q
.offset
;
181 if (q
.precision
!= ast_precision_none
)
182 this->precision
= q
.precision
;