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
);
35 if (array_specifier
) {
36 array_specifier
->print();
41 ast_fully_specified_type::has_qualifiers(_mesa_glsl_parse_state
*state
) const
43 /* 'subroutine' isnt a real qualifier. */
44 ast_type_qualifier subroutine_only
;
45 subroutine_only
.flags
.i
= 0;
46 subroutine_only
.flags
.q
.subroutine
= 1;
47 subroutine_only
.flags
.q
.subroutine_def
= 1;
48 if (state
->has_explicit_uniform_location()) {
49 subroutine_only
.flags
.q
.explicit_index
= 1;
51 return (this->qualifier
.flags
.i
& ~subroutine_only
.flags
.i
) != 0;
54 bool ast_type_qualifier::has_interpolation() const
56 return this->flags
.q
.smooth
58 || this->flags
.q
.noperspective
;
62 ast_type_qualifier::has_layout() const
64 return this->flags
.q
.origin_upper_left
65 || this->flags
.q
.pixel_center_integer
66 || this->flags
.q
.depth_any
67 || this->flags
.q
.depth_greater
68 || this->flags
.q
.depth_less
69 || this->flags
.q
.depth_unchanged
70 || this->flags
.q
.std140
71 || this->flags
.q
.std430
72 || this->flags
.q
.shared
73 || this->flags
.q
.column_major
74 || this->flags
.q
.row_major
75 || this->flags
.q
.packed
76 || this->flags
.q
.explicit_align
77 || this->flags
.q
.explicit_component
78 || this->flags
.q
.explicit_location
79 || this->flags
.q
.explicit_image_format
80 || this->flags
.q
.explicit_index
81 || this->flags
.q
.explicit_binding
82 || this->flags
.q
.explicit_offset
83 || this->flags
.q
.explicit_stream
84 || this->flags
.q
.explicit_xfb_buffer
85 || this->flags
.q
.explicit_xfb_offset
86 || this->flags
.q
.explicit_xfb_stride
;
90 ast_type_qualifier::has_storage() const
92 return this->flags
.q
.constant
93 || this->flags
.q
.attribute
94 || this->flags
.q
.varying
97 || this->flags
.q
.uniform
98 || this->flags
.q
.buffer
99 || this->flags
.q
.shared_storage
;
103 ast_type_qualifier::has_auxiliary_storage() const
105 return this->flags
.q
.centroid
106 || this->flags
.q
.sample
107 || this->flags
.q
.patch
;
111 * This function merges both duplicate identifies within a single layout and
112 * multiple layout qualifiers on a single variable declaration. The
113 * is_single_layout_merge param is used differentiate between the two.
116 ast_type_qualifier::merge_qualifier(YYLTYPE
*loc
,
117 _mesa_glsl_parse_state
*state
,
118 const ast_type_qualifier
&q
,
119 bool is_single_layout_merge
)
121 ast_type_qualifier ubo_mat_mask
;
122 ubo_mat_mask
.flags
.i
= 0;
123 ubo_mat_mask
.flags
.q
.row_major
= 1;
124 ubo_mat_mask
.flags
.q
.column_major
= 1;
126 ast_type_qualifier ubo_layout_mask
;
127 ubo_layout_mask
.flags
.i
= 0;
128 ubo_layout_mask
.flags
.q
.std140
= 1;
129 ubo_layout_mask
.flags
.q
.packed
= 1;
130 ubo_layout_mask
.flags
.q
.shared
= 1;
131 ubo_layout_mask
.flags
.q
.std430
= 1;
133 ast_type_qualifier ubo_binding_mask
;
134 ubo_binding_mask
.flags
.i
= 0;
135 ubo_binding_mask
.flags
.q
.explicit_binding
= 1;
136 ubo_binding_mask
.flags
.q
.explicit_offset
= 1;
138 ast_type_qualifier stream_layout_mask
;
139 stream_layout_mask
.flags
.i
= 0;
140 stream_layout_mask
.flags
.q
.stream
= 1;
142 /* FIXME: We should probably do interface and function param validation
145 ast_type_qualifier input_layout_mask
;
146 input_layout_mask
.flags
.i
= 0;
147 input_layout_mask
.flags
.q
.centroid
= 1;
148 /* Function params can have constant */
149 input_layout_mask
.flags
.q
.constant
= 1;
150 input_layout_mask
.flags
.q
.explicit_component
= 1;
151 input_layout_mask
.flags
.q
.explicit_location
= 1;
152 input_layout_mask
.flags
.q
.flat
= 1;
153 input_layout_mask
.flags
.q
.in
= 1;
154 input_layout_mask
.flags
.q
.invariant
= 1;
155 input_layout_mask
.flags
.q
.noperspective
= 1;
156 input_layout_mask
.flags
.q
.origin_upper_left
= 1;
157 /* Function params 'inout' will set this */
158 input_layout_mask
.flags
.q
.out
= 1;
159 input_layout_mask
.flags
.q
.patch
= 1;
160 input_layout_mask
.flags
.q
.pixel_center_integer
= 1;
161 input_layout_mask
.flags
.q
.precise
= 1;
162 input_layout_mask
.flags
.q
.sample
= 1;
163 input_layout_mask
.flags
.q
.smooth
= 1;
165 /* Uniform block layout qualifiers get to overwrite each
166 * other (rightmost having priority), while all other
167 * qualifiers currently don't allow duplicates.
169 ast_type_qualifier allowed_duplicates_mask
;
170 allowed_duplicates_mask
.flags
.i
=
171 ubo_mat_mask
.flags
.i
|
172 ubo_layout_mask
.flags
.i
|
173 ubo_binding_mask
.flags
.i
;
175 /* Geometry shaders can have several layout qualifiers
176 * assigning different stream values.
178 if (state
->stage
== MESA_SHADER_GEOMETRY
) {
179 allowed_duplicates_mask
.flags
.i
|=
180 stream_layout_mask
.flags
.i
;
183 if (is_single_layout_merge
&& !state
->has_enhanced_layouts() &&
184 (this->flags
.i
& q
.flags
.i
& ~allowed_duplicates_mask
.flags
.i
) != 0) {
185 _mesa_glsl_error(loc
, state
,
186 "duplicate layout qualifiers used");
190 if (q
.flags
.q
.prim_type
) {
191 if (this->flags
.q
.prim_type
&& this->prim_type
!= q
.prim_type
) {
192 _mesa_glsl_error(loc
, state
,
193 "conflicting primitive type qualifiers used");
196 this->prim_type
= q
.prim_type
;
199 if (q
.flags
.q
.max_vertices
) {
200 if (this->max_vertices
) {
201 this->max_vertices
->merge_qualifier(q
.max_vertices
);
203 this->max_vertices
= q
.max_vertices
;
207 if (q
.flags
.q
.subroutine_def
) {
208 if (this->flags
.q
.subroutine_def
) {
209 _mesa_glsl_error(loc
, state
,
210 "conflicting subroutine qualifiers used");
212 this->subroutine_list
= q
.subroutine_list
;
216 if (q
.flags
.q
.invocations
) {
217 if (this->invocations
) {
218 this->invocations
->merge_qualifier(q
.invocations
);
220 this->invocations
= q
.invocations
;
224 if (state
->stage
== MESA_SHADER_GEOMETRY
&&
225 state
->has_explicit_attrib_stream()) {
226 if (!this->flags
.q
.explicit_stream
) {
227 if (q
.flags
.q
.stream
) {
228 this->flags
.q
.stream
= 1;
229 this->stream
= q
.stream
;
230 } else if (!this->flags
.q
.stream
&& this->flags
.q
.out
&&
232 /* Assign default global stream value */
233 this->flags
.q
.stream
= 1;
234 this->stream
= state
->out_qualifier
->stream
;
239 if (state
->has_enhanced_layouts()) {
240 if (!this->flags
.q
.explicit_xfb_buffer
) {
241 if (q
.flags
.q
.xfb_buffer
) {
242 this->flags
.q
.xfb_buffer
= 1;
243 this->xfb_buffer
= q
.xfb_buffer
;
244 } else if (!this->flags
.q
.xfb_buffer
&& this->flags
.q
.out
&&
246 /* Assign global xfb_buffer value */
247 this->flags
.q
.xfb_buffer
= 1;
248 this->xfb_buffer
= state
->out_qualifier
->xfb_buffer
;
252 if (q
.flags
.q
.explicit_xfb_stride
)
253 this->xfb_stride
= q
.xfb_stride
;
255 /* Merge all we xfb_stride qualifiers into the global out */
256 if (q
.flags
.q
.explicit_xfb_stride
|| this->flags
.q
.xfb_stride
) {
258 /* Set xfb_stride flag to 0 to avoid adding duplicates every time
261 this->flags
.q
.xfb_stride
= 0;
264 if (process_qualifier_constant(state
, loc
, "xfb_buffer",
265 this->xfb_buffer
, &buff_idx
)) {
266 if (state
->out_qualifier
->out_xfb_stride
[buff_idx
]) {
267 state
->out_qualifier
->out_xfb_stride
[buff_idx
]->merge_qualifier(
268 new(state
) ast_layout_expression(*loc
, this->xfb_stride
));
270 state
->out_qualifier
->out_xfb_stride
[buff_idx
] =
271 new(state
) ast_layout_expression(*loc
, this->xfb_stride
);
277 if (q
.flags
.q
.vertices
) {
278 if (this->vertices
) {
279 this->vertices
->merge_qualifier(q
.vertices
);
281 this->vertices
= q
.vertices
;
285 if (q
.flags
.q
.vertex_spacing
) {
286 if (this->flags
.q
.vertex_spacing
&& this->vertex_spacing
!= q
.vertex_spacing
) {
287 _mesa_glsl_error(loc
, state
,
288 "conflicting vertex spacing used");
291 this->vertex_spacing
= q
.vertex_spacing
;
294 if (q
.flags
.q
.ordering
) {
295 if (this->flags
.q
.ordering
&& this->ordering
!= q
.ordering
) {
296 _mesa_glsl_error(loc
, state
,
297 "conflicting ordering used");
300 this->ordering
= q
.ordering
;
303 if (q
.flags
.q
.point_mode
) {
304 if (this->flags
.q
.point_mode
&& this->point_mode
!= q
.point_mode
) {
305 _mesa_glsl_error(loc
, state
,
306 "conflicting point mode used");
309 this->point_mode
= q
.point_mode
;
312 if ((q
.flags
.i
& ubo_mat_mask
.flags
.i
) != 0)
313 this->flags
.i
&= ~ubo_mat_mask
.flags
.i
;
314 if ((q
.flags
.i
& ubo_layout_mask
.flags
.i
) != 0)
315 this->flags
.i
&= ~ubo_layout_mask
.flags
.i
;
317 for (int i
= 0; i
< 3; i
++) {
318 if (q
.flags
.q
.local_size
& (1 << i
)) {
319 if (this->local_size
[i
]) {
320 this->local_size
[i
]->merge_qualifier(q
.local_size
[i
]);
322 this->local_size
[i
] = q
.local_size
[i
];
327 this->flags
.i
|= q
.flags
.i
;
329 if (this->flags
.q
.in
&&
330 (this->flags
.i
& ~input_layout_mask
.flags
.i
) != 0) {
331 _mesa_glsl_error(loc
, state
,
332 "invalid input layout qualifier used");
336 if (q
.flags
.q
.explicit_align
)
337 this->align
= q
.align
;
339 if (q
.flags
.q
.explicit_location
)
340 this->location
= q
.location
;
342 if (q
.flags
.q
.explicit_index
)
343 this->index
= q
.index
;
345 if (q
.flags
.q
.explicit_component
)
346 this->component
= q
.component
;
348 if (q
.flags
.q
.explicit_binding
)
349 this->binding
= q
.binding
;
351 if (q
.flags
.q
.explicit_offset
|| q
.flags
.q
.explicit_xfb_offset
)
352 this->offset
= q
.offset
;
354 if (q
.precision
!= ast_precision_none
)
355 this->precision
= q
.precision
;
357 if (q
.flags
.q
.explicit_image_format
) {
358 this->image_format
= q
.image_format
;
359 this->image_base_type
= q
.image_base_type
;
366 ast_type_qualifier::merge_out_qualifier(YYLTYPE
*loc
,
367 _mesa_glsl_parse_state
*state
,
368 const ast_type_qualifier
&q
,
369 ast_node
* &node
, bool create_node
)
371 void *mem_ctx
= state
;
372 const bool r
= this->merge_qualifier(loc
, state
, q
, false);
373 ast_type_qualifier valid_out_mask
;
374 valid_out_mask
.flags
.i
= 0;
376 if (state
->stage
== MESA_SHADER_GEOMETRY
) {
377 if (q
.flags
.q
.prim_type
) {
378 /* Make sure this is a valid output primitive type. */
379 switch (q
.prim_type
) {
382 case GL_TRIANGLE_STRIP
:
385 _mesa_glsl_error(loc
, state
, "invalid geometry shader output "
391 /* Allow future assigments of global out's stream id value */
392 this->flags
.q
.explicit_stream
= 0;
394 valid_out_mask
.flags
.q
.stream
= 1;
395 valid_out_mask
.flags
.q
.explicit_stream
= 1;
396 valid_out_mask
.flags
.q
.explicit_xfb_buffer
= 1;
397 valid_out_mask
.flags
.q
.xfb_buffer
= 1;
398 valid_out_mask
.flags
.q
.explicit_xfb_stride
= 1;
399 valid_out_mask
.flags
.q
.xfb_stride
= 1;
400 valid_out_mask
.flags
.q
.max_vertices
= 1;
401 valid_out_mask
.flags
.q
.prim_type
= 1;
402 } else if (state
->stage
== MESA_SHADER_TESS_CTRL
) {
404 node
= new(mem_ctx
) ast_tcs_output_layout(*loc
);
406 valid_out_mask
.flags
.q
.vertices
= 1;
407 valid_out_mask
.flags
.q
.explicit_xfb_buffer
= 1;
408 valid_out_mask
.flags
.q
.xfb_buffer
= 1;
409 valid_out_mask
.flags
.q
.explicit_xfb_stride
= 1;
410 valid_out_mask
.flags
.q
.xfb_stride
= 1;
411 } else if (state
->stage
== MESA_SHADER_TESS_EVAL
||
412 state
->stage
== MESA_SHADER_VERTEX
) {
413 valid_out_mask
.flags
.q
.explicit_xfb_buffer
= 1;
414 valid_out_mask
.flags
.q
.xfb_buffer
= 1;
415 valid_out_mask
.flags
.q
.explicit_xfb_stride
= 1;
416 valid_out_mask
.flags
.q
.xfb_stride
= 1;
418 _mesa_glsl_error(loc
, state
, "out layout qualifiers only valid in "
419 "geometry, tessellation and vertex shaders");
423 /* Allow future assigments of global out's */
424 this->flags
.q
.explicit_xfb_buffer
= 0;
425 this->flags
.q
.explicit_xfb_stride
= 0;
427 /* Generate an error when invalid input layout qualifiers are used. */
428 if ((q
.flags
.i
& ~valid_out_mask
.flags
.i
) != 0) {
429 _mesa_glsl_error(loc
, state
,
430 "invalid output layout qualifiers used");
438 ast_type_qualifier::merge_in_qualifier(YYLTYPE
*loc
,
439 _mesa_glsl_parse_state
*state
,
440 const ast_type_qualifier
&q
,
441 ast_node
* &node
, bool create_node
)
443 void *mem_ctx
= state
;
444 bool create_gs_ast
= false;
445 bool create_cs_ast
= false;
446 ast_type_qualifier valid_in_mask
;
447 valid_in_mask
.flags
.i
= 0;
449 switch (state
->stage
) {
450 case MESA_SHADER_TESS_EVAL
:
451 if (q
.flags
.q
.prim_type
) {
452 /* Make sure this is a valid input primitive type. */
453 switch (q
.prim_type
) {
459 _mesa_glsl_error(loc
, state
,
460 "invalid tessellation evaluation "
461 "shader input primitive type");
466 valid_in_mask
.flags
.q
.prim_type
= 1;
467 valid_in_mask
.flags
.q
.vertex_spacing
= 1;
468 valid_in_mask
.flags
.q
.ordering
= 1;
469 valid_in_mask
.flags
.q
.point_mode
= 1;
471 case MESA_SHADER_GEOMETRY
:
472 if (q
.flags
.q
.prim_type
) {
473 /* Make sure this is a valid input primitive type. */
474 switch (q
.prim_type
) {
477 case GL_LINES_ADJACENCY
:
479 case GL_TRIANGLES_ADJACENCY
:
482 _mesa_glsl_error(loc
, state
,
483 "invalid geometry shader input primitive type");
489 q
.flags
.q
.prim_type
&&
490 !state
->in_qualifier
->flags
.q
.prim_type
;
492 valid_in_mask
.flags
.q
.prim_type
= 1;
493 valid_in_mask
.flags
.q
.invocations
= 1;
495 case MESA_SHADER_FRAGMENT
:
496 valid_in_mask
.flags
.q
.early_fragment_tests
= 1;
498 case MESA_SHADER_COMPUTE
:
500 q
.flags
.q
.local_size
!= 0 &&
501 state
->in_qualifier
->flags
.q
.local_size
== 0;
503 valid_in_mask
.flags
.q
.local_size
= 7;
506 _mesa_glsl_error(loc
, state
,
507 "input layout qualifiers only valid in "
508 "geometry, fragment and compute shaders");
512 /* Generate an error when invalid input layout qualifiers are used. */
513 if ((q
.flags
.i
& ~valid_in_mask
.flags
.i
) != 0) {
514 _mesa_glsl_error(loc
, state
,
515 "invalid input layout qualifiers used");
519 /* Input layout qualifiers can be specified multiple
520 * times in separate declarations, as long as they match.
522 if (this->flags
.q
.prim_type
) {
523 if (q
.flags
.q
.prim_type
&&
524 this->prim_type
!= q
.prim_type
) {
525 _mesa_glsl_error(loc
, state
,
526 "conflicting input primitive %s specified",
527 state
->stage
== MESA_SHADER_GEOMETRY
?
530 } else if (q
.flags
.q
.prim_type
) {
531 state
->in_qualifier
->flags
.q
.prim_type
= 1;
532 state
->in_qualifier
->prim_type
= q
.prim_type
;
535 if (q
.flags
.q
.invocations
) {
536 this->flags
.q
.invocations
= 1;
537 if (this->invocations
) {
538 this->invocations
->merge_qualifier(q
.invocations
);
540 this->invocations
= q
.invocations
;
544 if (q
.flags
.q
.early_fragment_tests
) {
545 state
->fs_early_fragment_tests
= true;
548 if (this->flags
.q
.vertex_spacing
) {
549 if (q
.flags
.q
.vertex_spacing
&&
550 this->vertex_spacing
!= q
.vertex_spacing
) {
551 _mesa_glsl_error(loc
, state
,
552 "conflicting vertex spacing specified");
554 } else if (q
.flags
.q
.vertex_spacing
) {
555 this->flags
.q
.vertex_spacing
= 1;
556 this->vertex_spacing
= q
.vertex_spacing
;
559 if (this->flags
.q
.ordering
) {
560 if (q
.flags
.q
.ordering
&&
561 this->ordering
!= q
.ordering
) {
562 _mesa_glsl_error(loc
, state
,
563 "conflicting ordering specified");
565 } else if (q
.flags
.q
.ordering
) {
566 this->flags
.q
.ordering
= 1;
567 this->ordering
= q
.ordering
;
570 if (this->flags
.q
.point_mode
) {
571 if (q
.flags
.q
.point_mode
&&
572 this->point_mode
!= q
.point_mode
) {
573 _mesa_glsl_error(loc
, state
,
574 "conflicting point mode specified");
576 } else if (q
.flags
.q
.point_mode
) {
577 this->flags
.q
.point_mode
= 1;
578 this->point_mode
= q
.point_mode
;
583 node
= new(mem_ctx
) ast_gs_input_layout(*loc
, q
.prim_type
);
584 } else if (create_cs_ast
) {
585 node
= new(mem_ctx
) ast_cs_input_layout(*loc
, q
.local_size
);
593 * Check if the current type qualifier has any illegal flags.
595 * If so, print an error message, followed by a list of illegal flags.
597 * \param message The error message to print.
598 * \param allowed_flags A list of valid flags.
601 ast_type_qualifier::validate_flags(YYLTYPE
*loc
,
602 _mesa_glsl_parse_state
*state
,
603 const ast_type_qualifier
&allowed_flags
,
604 const char *message
, const char *name
)
606 ast_type_qualifier bad
;
607 bad
.flags
.i
= this->flags
.i
& ~allowed_flags
.flags
.i
;
608 if (bad
.flags
.i
== 0)
611 _mesa_glsl_error(loc
, state
,
613 "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s"
614 "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s"
615 "%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
617 bad
.flags
.q
.invariant
? " invariant" : "",
618 bad
.flags
.q
.precise
? " precise" : "",
619 bad
.flags
.q
.constant
? " constant" : "",
620 bad
.flags
.q
.attribute
? " attribute" : "",
621 bad
.flags
.q
.varying
? " varying" : "",
622 bad
.flags
.q
.in
? " in" : "",
623 bad
.flags
.q
.out
? " out" : "",
624 bad
.flags
.q
.centroid
? " centroid" : "",
625 bad
.flags
.q
.sample
? " sample" : "",
626 bad
.flags
.q
.patch
? " patch" : "",
627 bad
.flags
.q
.uniform
? " uniform" : "",
628 bad
.flags
.q
.buffer
? " buffer" : "",
629 bad
.flags
.q
.shared_storage
? " shared_storage" : "",
630 bad
.flags
.q
.smooth
? " smooth" : "",
631 bad
.flags
.q
.flat
? " flat" : "",
632 bad
.flags
.q
.noperspective
? " noperspective" : "",
633 bad
.flags
.q
.origin_upper_left
? " origin_upper_left" : "",
634 bad
.flags
.q
.pixel_center_integer
? " pixel_center_integer" : "",
635 bad
.flags
.q
.explicit_align
? " align" : "",
636 bad
.flags
.q
.explicit_component
? " component" : "",
637 bad
.flags
.q
.explicit_location
? " location" : "",
638 bad
.flags
.q
.explicit_index
? " index" : "",
639 bad
.flags
.q
.explicit_binding
? " binding" : "",
640 bad
.flags
.q
.explicit_offset
? " offset" : "",
641 bad
.flags
.q
.depth_any
? " depth_any" : "",
642 bad
.flags
.q
.depth_greater
? " depth_greater" : "",
643 bad
.flags
.q
.depth_less
? " depth_less" : "",
644 bad
.flags
.q
.depth_unchanged
? " depth_unchanged" : "",
645 bad
.flags
.q
.std140
? " std140" : "",
646 bad
.flags
.q
.std430
? " std430" : "",
647 bad
.flags
.q
.shared
? " shared" : "",
648 bad
.flags
.q
.packed
? " packed" : "",
649 bad
.flags
.q
.column_major
? " column_major" : "",
650 bad
.flags
.q
.row_major
? " row_major" : "",
651 bad
.flags
.q
.prim_type
? " prim_type" : "",
652 bad
.flags
.q
.max_vertices
? " max_vertices" : "",
653 bad
.flags
.q
.local_size
? " local_size" : "",
654 bad
.flags
.q
.early_fragment_tests
? " early_fragment_tests" : "",
655 bad
.flags
.q
.explicit_image_format
? " image_format" : "",
656 bad
.flags
.q
.coherent
? " coherent" : "",
657 bad
.flags
.q
._volatile
? " _volatile" : "",
658 bad
.flags
.q
.restrict_flag
? " restrict_flag" : "",
659 bad
.flags
.q
.read_only
? " read_only" : "",
660 bad
.flags
.q
.write_only
? " write_only" : "",
661 bad
.flags
.q
.invocations
? " invocations" : "",
662 bad
.flags
.q
.stream
? " stream" : "",
663 bad
.flags
.q
.explicit_stream
? " stream" : "",
664 bad
.flags
.q
.explicit_xfb_offset
? " xfb_offset" : "",
665 bad
.flags
.q
.xfb_buffer
? " xfb_buffer" : "",
666 bad
.flags
.q
.explicit_xfb_buffer
? " xfb_buffer" : "",
667 bad
.flags
.q
.xfb_stride
? " xfb_stride" : "",
668 bad
.flags
.q
.explicit_xfb_stride
? " xfb_stride" : "",
669 bad
.flags
.q
.vertex_spacing
? " vertex_spacing" : "",
670 bad
.flags
.q
.ordering
? " ordering" : "",
671 bad
.flags
.q
.point_mode
? " point_mode" : "",
672 bad
.flags
.q
.vertices
? " vertices" : "",
673 bad
.flags
.q
.subroutine
? " subroutine" : "",
674 bad
.flags
.q
.subroutine_def
? " subroutine_def" : "");
679 ast_layout_expression::process_qualifier_constant(struct _mesa_glsl_parse_state
*state
,
680 const char *qual_indentifier
,
686 bool first_pass
= true;
692 for (exec_node
*node
= layout_const_expressions
.get_head_raw();
693 !node
->is_tail_sentinel(); node
= node
->next
) {
695 exec_list dummy_instructions
;
696 ast_node
*const_expression
= exec_node_data(ast_node
, node
, link
);
698 ir_rvalue
*const ir
= const_expression
->hir(&dummy_instructions
, state
);
700 ir_constant
*const const_int
= ir
->constant_expression_value();
701 if (const_int
== NULL
|| !const_int
->type
->is_integer()) {
702 YYLTYPE loc
= const_expression
->get_location();
703 _mesa_glsl_error(&loc
, state
, "%s must be an integral constant "
704 "expression", qual_indentifier
);
708 if (const_int
->value
.i
[0] < min_value
) {
709 YYLTYPE loc
= const_expression
->get_location();
710 _mesa_glsl_error(&loc
, state
, "%s layout qualifier is invalid "
711 "(%d < %d)", qual_indentifier
,
712 const_int
->value
.i
[0], min_value
);
716 /* From section 4.4 "Layout Qualifiers" of the GLSL 4.50 spec:
717 * "When the same layout-qualifier-name occurs multiple times,
718 * in a single declaration, the last occurrence overrides the
719 * former occurrence(s)."
722 if ((must_match
|| !state
->has_420pack()) && *value
!= const_int
->value
.u
[0]) {
723 YYLTYPE loc
= const_expression
->get_location();
724 _mesa_glsl_error(&loc
, state
, "%s layout qualifier does not "
725 "match previous declaration (%d vs %d)",
726 qual_indentifier
, *value
, const_int
->value
.i
[0]);
731 *value
= const_int
->value
.u
[0];
734 /* If the location is const (and we've verified that
735 * it is) then no instructions should have been emitted
736 * when we converted it to HIR. If they were emitted,
737 * then either the location isn't const after all, or
738 * we are emitting unnecessary instructions.
740 assert(dummy_instructions
.is_empty());
747 process_qualifier_constant(struct _mesa_glsl_parse_state
*state
,
749 const char *qual_indentifier
,
750 ast_expression
*const_expression
,
753 exec_list dummy_instructions
;
755 if (const_expression
== NULL
) {
760 ir_rvalue
*const ir
= const_expression
->hir(&dummy_instructions
, state
);
762 ir_constant
*const const_int
= ir
->constant_expression_value();
763 if (const_int
== NULL
|| !const_int
->type
->is_integer()) {
764 _mesa_glsl_error(loc
, state
, "%s must be an integral constant "
765 "expression", qual_indentifier
);
769 if (const_int
->value
.i
[0] < 0) {
770 _mesa_glsl_error(loc
, state
, "%s layout qualifier is invalid (%d < 0)",
771 qual_indentifier
, const_int
->value
.u
[0]);
775 /* If the location is const (and we've verified that
776 * it is) then no instructions should have been emitted
777 * when we converted it to HIR. If they were emitted,
778 * then either the location isn't const after all, or
779 * we are emitting unnecessary instructions.
781 assert(dummy_instructions
.is_empty());
783 *value
= const_int
->value
.u
[0];