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
;
110 bool ast_type_qualifier::has_memory() const
112 return this->flags
.q
.coherent
113 || this->flags
.q
._volatile
114 || this->flags
.q
.restrict_flag
115 || this->flags
.q
.read_only
116 || this->flags
.q
.write_only
;
120 validate_prim_type(YYLTYPE
*loc
,
121 _mesa_glsl_parse_state
*state
,
122 const ast_type_qualifier
&qualifier
,
123 const ast_type_qualifier
&new_qualifier
)
125 /* Input layout qualifiers can be specified multiple
126 * times in separate declarations, as long as they match.
128 if (qualifier
.flags
.q
.prim_type
&& new_qualifier
.flags
.q
.prim_type
129 && qualifier
.prim_type
!= new_qualifier
.prim_type
) {
130 _mesa_glsl_error(loc
, state
,
131 "conflicting input primitive %s specified",
132 state
->stage
== MESA_SHADER_GEOMETRY
?
141 validate_vertex_spacing(YYLTYPE
*loc
,
142 _mesa_glsl_parse_state
*state
,
143 const ast_type_qualifier
&qualifier
,
144 const ast_type_qualifier
&new_qualifier
)
146 if (qualifier
.flags
.q
.vertex_spacing
&& new_qualifier
.flags
.q
.vertex_spacing
147 && qualifier
.vertex_spacing
!= new_qualifier
.vertex_spacing
) {
148 _mesa_glsl_error(loc
, state
,
149 "conflicting vertex spacing specified");
157 validate_ordering(YYLTYPE
*loc
,
158 _mesa_glsl_parse_state
*state
,
159 const ast_type_qualifier
&qualifier
,
160 const ast_type_qualifier
&new_qualifier
)
162 if (qualifier
.flags
.q
.ordering
&& new_qualifier
.flags
.q
.ordering
163 && qualifier
.ordering
!= new_qualifier
.ordering
) {
164 _mesa_glsl_error(loc
, state
,
165 "conflicting ordering specified");
173 validate_point_mode(YYLTYPE
*loc
,
174 _mesa_glsl_parse_state
*state
,
175 const ast_type_qualifier
&qualifier
,
176 const ast_type_qualifier
&new_qualifier
)
178 /* Point mode can only be true if the flag is set. */
179 assert (!qualifier
.flags
.q
.point_mode
|| !new_qualifier
.flags
.q
.point_mode
180 || (qualifier
.point_mode
&& new_qualifier
.point_mode
));
186 * This function merges duplicate layout identifiers.
188 * It deals with duplicates within a single layout qualifier, among multiple
189 * layout qualifiers on a single declaration and on several declarations for
192 * The is_single_layout_merge and is_multiple_layouts_merge parameters are
193 * used to differentiate among them.
196 ast_type_qualifier::merge_qualifier(YYLTYPE
*loc
,
197 _mesa_glsl_parse_state
*state
,
198 const ast_type_qualifier
&q
,
199 bool is_single_layout_merge
,
200 bool is_multiple_layouts_merge
)
203 ast_type_qualifier ubo_mat_mask
;
204 ubo_mat_mask
.flags
.i
= 0;
205 ubo_mat_mask
.flags
.q
.row_major
= 1;
206 ubo_mat_mask
.flags
.q
.column_major
= 1;
208 ast_type_qualifier ubo_layout_mask
;
209 ubo_layout_mask
.flags
.i
= 0;
210 ubo_layout_mask
.flags
.q
.std140
= 1;
211 ubo_layout_mask
.flags
.q
.packed
= 1;
212 ubo_layout_mask
.flags
.q
.shared
= 1;
213 ubo_layout_mask
.flags
.q
.std430
= 1;
215 ast_type_qualifier ubo_binding_mask
;
216 ubo_binding_mask
.flags
.i
= 0;
217 ubo_binding_mask
.flags
.q
.explicit_binding
= 1;
218 ubo_binding_mask
.flags
.q
.explicit_offset
= 1;
220 ast_type_qualifier stream_layout_mask
;
221 stream_layout_mask
.flags
.i
= 0;
222 stream_layout_mask
.flags
.q
.stream
= 1;
224 /* FIXME: We should probably do interface and function param validation
227 ast_type_qualifier input_layout_mask
;
228 input_layout_mask
.flags
.i
= 0;
229 input_layout_mask
.flags
.q
.centroid
= 1;
230 /* Function params can have constant */
231 input_layout_mask
.flags
.q
.constant
= 1;
232 input_layout_mask
.flags
.q
.explicit_component
= 1;
233 input_layout_mask
.flags
.q
.explicit_location
= 1;
234 input_layout_mask
.flags
.q
.flat
= 1;
235 input_layout_mask
.flags
.q
.in
= 1;
236 input_layout_mask
.flags
.q
.invariant
= 1;
237 input_layout_mask
.flags
.q
.noperspective
= 1;
238 input_layout_mask
.flags
.q
.origin_upper_left
= 1;
239 /* Function params 'inout' will set this */
240 input_layout_mask
.flags
.q
.out
= 1;
241 input_layout_mask
.flags
.q
.patch
= 1;
242 input_layout_mask
.flags
.q
.pixel_center_integer
= 1;
243 input_layout_mask
.flags
.q
.precise
= 1;
244 input_layout_mask
.flags
.q
.sample
= 1;
245 input_layout_mask
.flags
.q
.smooth
= 1;
247 /* Uniform block layout qualifiers get to overwrite each
248 * other (rightmost having priority), while all other
249 * qualifiers currently don't allow duplicates.
251 ast_type_qualifier allowed_duplicates_mask
;
252 allowed_duplicates_mask
.flags
.i
=
253 ubo_mat_mask
.flags
.i
|
254 ubo_layout_mask
.flags
.i
|
255 ubo_binding_mask
.flags
.i
;
257 /* Geometry shaders can have several layout qualifiers
258 * assigning different stream values.
260 if (state
->stage
== MESA_SHADER_GEOMETRY
) {
261 allowed_duplicates_mask
.flags
.i
|=
262 stream_layout_mask
.flags
.i
;
265 if (is_single_layout_merge
&& !state
->has_enhanced_layouts() &&
266 (this->flags
.i
& q
.flags
.i
& ~allowed_duplicates_mask
.flags
.i
) != 0) {
267 _mesa_glsl_error(loc
, state
, "duplicate layout qualifiers used");
271 if (is_multiple_layouts_merge
&& !state
->has_420pack_or_es31()) {
272 _mesa_glsl_error(loc
, state
,
273 "duplicate layout(...) qualifiers");
277 if (q
.flags
.q
.prim_type
) {
278 r
&= validate_prim_type(loc
, state
, *this, q
);
279 this->flags
.q
.prim_type
= 1;
280 this->prim_type
= q
.prim_type
;
283 if (q
.flags
.q
.max_vertices
) {
284 if (this->flags
.q
.max_vertices
285 && !is_single_layout_merge
&& !is_multiple_layouts_merge
) {
286 this->max_vertices
->merge_qualifier(q
.max_vertices
);
288 this->flags
.q
.max_vertices
= 1;
289 this->max_vertices
= q
.max_vertices
;
293 if (q
.flags
.q
.subroutine_def
) {
294 if (this->flags
.q
.subroutine_def
) {
295 _mesa_glsl_error(loc
, state
,
296 "conflicting subroutine qualifiers used");
298 this->subroutine_list
= q
.subroutine_list
;
302 if (q
.flags
.q
.invocations
) {
303 if (this->flags
.q
.invocations
304 && !is_single_layout_merge
&& !is_multiple_layouts_merge
) {
305 this->invocations
->merge_qualifier(q
.invocations
);
307 this->flags
.q
.invocations
= 1;
308 this->invocations
= q
.invocations
;
312 if (state
->stage
== MESA_SHADER_GEOMETRY
&&
313 state
->has_explicit_attrib_stream()) {
314 if (!this->flags
.q
.explicit_stream
) {
315 if (q
.flags
.q
.stream
) {
316 this->flags
.q
.stream
= 1;
317 this->stream
= q
.stream
;
318 } else if (!this->flags
.q
.stream
&& this->flags
.q
.out
&&
320 /* Assign default global stream value */
321 this->flags
.q
.stream
= 1;
322 this->stream
= state
->out_qualifier
->stream
;
327 if (state
->has_enhanced_layouts()) {
328 if (!this->flags
.q
.explicit_xfb_buffer
) {
329 if (q
.flags
.q
.xfb_buffer
) {
330 this->flags
.q
.xfb_buffer
= 1;
331 this->xfb_buffer
= q
.xfb_buffer
;
332 } else if (!this->flags
.q
.xfb_buffer
&& this->flags
.q
.out
&&
334 /* Assign global xfb_buffer value */
335 this->flags
.q
.xfb_buffer
= 1;
336 this->xfb_buffer
= state
->out_qualifier
->xfb_buffer
;
340 if (q
.flags
.q
.explicit_xfb_stride
) {
341 this->flags
.q
.xfb_stride
= 1;
342 this->flags
.q
.explicit_xfb_stride
= 1;
343 this->xfb_stride
= q
.xfb_stride
;
347 if (q
.flags
.q
.vertices
) {
348 if (this->flags
.q
.vertices
349 && !is_single_layout_merge
&& !is_multiple_layouts_merge
) {
350 this->vertices
->merge_qualifier(q
.vertices
);
352 this->flags
.q
.vertices
= 1;
353 this->vertices
= q
.vertices
;
357 if (q
.flags
.q
.vertex_spacing
) {
358 r
&= validate_vertex_spacing(loc
, state
, *this, q
);
359 this->flags
.q
.vertex_spacing
= 1;
360 this->vertex_spacing
= q
.vertex_spacing
;
363 if (q
.flags
.q
.ordering
) {
364 r
&= validate_ordering(loc
, state
, *this, q
);
365 this->flags
.q
.ordering
= 1;
366 this->ordering
= q
.ordering
;
369 if (q
.flags
.q
.point_mode
) {
370 r
&= validate_point_mode(loc
, state
, *this, q
);
371 this->flags
.q
.point_mode
= 1;
372 this->point_mode
= q
.point_mode
;
375 if (q
.flags
.q
.early_fragment_tests
)
376 this->flags
.q
.early_fragment_tests
= true;
378 if ((q
.flags
.i
& ubo_mat_mask
.flags
.i
) != 0)
379 this->flags
.i
&= ~ubo_mat_mask
.flags
.i
;
380 if ((q
.flags
.i
& ubo_layout_mask
.flags
.i
) != 0)
381 this->flags
.i
&= ~ubo_layout_mask
.flags
.i
;
383 for (int i
= 0; i
< 3; i
++) {
384 if (q
.flags
.q
.local_size
& (1 << i
)) {
385 if (this->local_size
[i
]
386 && !is_single_layout_merge
&& !is_multiple_layouts_merge
) {
387 this->local_size
[i
]->merge_qualifier(q
.local_size
[i
]);
389 this->local_size
[i
] = q
.local_size
[i
];
394 if (q
.flags
.q
.local_size_variable
)
395 this->flags
.q
.local_size_variable
= true;
397 this->flags
.i
|= q
.flags
.i
;
399 if (this->flags
.q
.in
&&
400 (this->flags
.i
& ~input_layout_mask
.flags
.i
) != 0) {
401 _mesa_glsl_error(loc
, state
, "invalid input layout qualifier used");
405 if (q
.flags
.q
.explicit_align
)
406 this->align
= q
.align
;
408 if (q
.flags
.q
.explicit_location
)
409 this->location
= q
.location
;
411 if (q
.flags
.q
.explicit_index
)
412 this->index
= q
.index
;
414 if (q
.flags
.q
.explicit_component
)
415 this->component
= q
.component
;
417 if (q
.flags
.q
.explicit_binding
)
418 this->binding
= q
.binding
;
420 if (q
.flags
.q
.explicit_offset
|| q
.flags
.q
.explicit_xfb_offset
)
421 this->offset
= q
.offset
;
423 if (q
.precision
!= ast_precision_none
)
424 this->precision
= q
.precision
;
426 if (q
.flags
.q
.explicit_image_format
) {
427 this->image_format
= q
.image_format
;
428 this->image_base_type
= q
.image_base_type
;
435 ast_type_qualifier::validate_out_qualifier(YYLTYPE
*loc
,
436 _mesa_glsl_parse_state
*state
)
439 ast_type_qualifier valid_out_mask
;
440 valid_out_mask
.flags
.i
= 0;
442 switch (state
->stage
) {
443 case MESA_SHADER_GEOMETRY
:
444 if (this->flags
.q
.prim_type
) {
445 /* Make sure this is a valid output primitive type. */
446 switch (this->prim_type
) {
449 case GL_TRIANGLE_STRIP
:
453 _mesa_glsl_error(loc
, state
, "invalid geometry shader output "
459 valid_out_mask
.flags
.q
.stream
= 1;
460 valid_out_mask
.flags
.q
.explicit_stream
= 1;
461 valid_out_mask
.flags
.q
.explicit_xfb_buffer
= 1;
462 valid_out_mask
.flags
.q
.xfb_buffer
= 1;
463 valid_out_mask
.flags
.q
.explicit_xfb_stride
= 1;
464 valid_out_mask
.flags
.q
.xfb_stride
= 1;
465 valid_out_mask
.flags
.q
.max_vertices
= 1;
466 valid_out_mask
.flags
.q
.prim_type
= 1;
468 case MESA_SHADER_TESS_CTRL
:
469 valid_out_mask
.flags
.q
.vertices
= 1;
470 valid_out_mask
.flags
.q
.explicit_xfb_buffer
= 1;
471 valid_out_mask
.flags
.q
.xfb_buffer
= 1;
472 valid_out_mask
.flags
.q
.explicit_xfb_stride
= 1;
473 valid_out_mask
.flags
.q
.xfb_stride
= 1;
475 case MESA_SHADER_TESS_EVAL
:
476 case MESA_SHADER_VERTEX
:
477 valid_out_mask
.flags
.q
.explicit_xfb_buffer
= 1;
478 valid_out_mask
.flags
.q
.xfb_buffer
= 1;
479 valid_out_mask
.flags
.q
.explicit_xfb_stride
= 1;
480 valid_out_mask
.flags
.q
.xfb_stride
= 1;
482 case MESA_SHADER_FRAGMENT
:
483 valid_out_mask
.flags
.q
.blend_support
= 1;
487 _mesa_glsl_error(loc
, state
,
488 "out layout qualifiers only valid in "
489 "geometry, tessellation, vertex and fragment shaders");
492 /* Generate an error when invalid output layout qualifiers are used. */
493 if ((this->flags
.i
& ~valid_out_mask
.flags
.i
) != 0) {
495 _mesa_glsl_error(loc
, state
, "invalid output layout qualifiers used");
502 ast_type_qualifier::merge_into_out_qualifier(YYLTYPE
*loc
,
503 _mesa_glsl_parse_state
*state
,
506 const bool r
= state
->out_qualifier
->merge_qualifier(loc
, state
,
509 switch (state
->stage
) {
510 case MESA_SHADER_GEOMETRY
:
511 /* Allow future assignments of global out's stream id value */
512 state
->out_qualifier
->flags
.q
.explicit_stream
= 0;
514 case MESA_SHADER_TESS_CTRL
:
515 node
= new(state
->linalloc
) ast_tcs_output_layout(*loc
);
521 /* Allow future assignments of global out's */
522 state
->out_qualifier
->flags
.q
.explicit_xfb_buffer
= 0;
523 state
->out_qualifier
->flags
.q
.explicit_xfb_stride
= 0;
529 ast_type_qualifier::validate_in_qualifier(YYLTYPE
*loc
,
530 _mesa_glsl_parse_state
*state
)
533 ast_type_qualifier valid_in_mask
;
534 valid_in_mask
.flags
.i
= 0;
536 switch (state
->stage
) {
537 case MESA_SHADER_TESS_EVAL
:
538 if (this->flags
.q
.prim_type
) {
539 /* Make sure this is a valid input primitive type. */
540 switch (this->prim_type
) {
547 _mesa_glsl_error(loc
, state
,
548 "invalid tessellation evaluation "
549 "shader input primitive type");
554 valid_in_mask
.flags
.q
.prim_type
= 1;
555 valid_in_mask
.flags
.q
.vertex_spacing
= 1;
556 valid_in_mask
.flags
.q
.ordering
= 1;
557 valid_in_mask
.flags
.q
.point_mode
= 1;
559 case MESA_SHADER_GEOMETRY
:
560 if (this->flags
.q
.prim_type
) {
561 /* Make sure this is a valid input primitive type. */
562 switch (this->prim_type
) {
565 case GL_LINES_ADJACENCY
:
567 case GL_TRIANGLES_ADJACENCY
:
571 _mesa_glsl_error(loc
, state
,
572 "invalid geometry shader input primitive type");
577 valid_in_mask
.flags
.q
.prim_type
= 1;
578 valid_in_mask
.flags
.q
.invocations
= 1;
580 case MESA_SHADER_FRAGMENT
:
581 valid_in_mask
.flags
.q
.early_fragment_tests
= 1;
583 case MESA_SHADER_COMPUTE
:
584 valid_in_mask
.flags
.q
.local_size
= 7;
585 valid_in_mask
.flags
.q
.local_size_variable
= 1;
589 _mesa_glsl_error(loc
, state
,
590 "input layout qualifiers only valid in "
591 "geometry, tessellation, fragment and compute shaders");
595 /* Generate an error when invalid input layout qualifiers are used. */
596 if ((this->flags
.i
& ~valid_in_mask
.flags
.i
) != 0) {
598 _mesa_glsl_error(loc
, state
, "invalid input layout qualifiers used");
601 /* The checks below are also performed when merging but we want to spit an
602 * error against the default global input qualifier as soon as we can, with
603 * the closest error location in the shader.
605 r
&= validate_prim_type(loc
, state
, *state
->in_qualifier
, *this);
606 r
&= validate_vertex_spacing(loc
, state
, *state
->in_qualifier
, *this);
607 r
&= validate_ordering(loc
, state
, *state
->in_qualifier
, *this);
608 r
&= validate_point_mode(loc
, state
, *state
->in_qualifier
, *this);
614 ast_type_qualifier::merge_into_in_qualifier(YYLTYPE
*loc
,
615 _mesa_glsl_parse_state
*state
,
619 void *lin_ctx
= state
->linalloc
;
621 /* We create the gs_input_layout node before merging so, in the future, no
622 * more repeated nodes will be created as we will have the flag set.
624 if (state
->stage
== MESA_SHADER_GEOMETRY
625 && this->flags
.q
.prim_type
&& !state
->in_qualifier
->flags
.q
.prim_type
) {
626 node
= new(lin_ctx
) ast_gs_input_layout(*loc
, this->prim_type
);
629 r
= state
->in_qualifier
->merge_qualifier(loc
, state
, *this, false);
631 if (state
->in_qualifier
->flags
.q
.early_fragment_tests
) {
632 state
->fs_early_fragment_tests
= true;
633 state
->in_qualifier
->flags
.q
.early_fragment_tests
= false;
636 /* We allow the creation of multiple cs_input_layout nodes. Coherence among
637 * all existing nodes is checked later, when the AST node is transformed
640 if (state
->in_qualifier
->flags
.q
.local_size
) {
641 node
= new(lin_ctx
) ast_cs_input_layout(*loc
,
642 state
->in_qualifier
->local_size
);
643 state
->in_qualifier
->flags
.q
.local_size
= 0;
644 for (int i
= 0; i
< 3; i
++)
645 state
->in_qualifier
->local_size
[i
] = NULL
;
648 if (state
->in_qualifier
->flags
.q
.local_size_variable
) {
649 state
->cs_input_local_size_variable_specified
= true;
650 state
->in_qualifier
->flags
.q
.local_size_variable
= false;
657 ast_type_qualifier::push_to_global(YYLTYPE
*loc
,
658 _mesa_glsl_parse_state
*state
)
660 if (this->flags
.q
.xfb_stride
) {
661 this->flags
.q
.xfb_stride
= 0;
664 if (process_qualifier_constant(state
, loc
, "xfb_buffer",
665 this->xfb_buffer
, &buff_idx
)) {
666 if (state
->out_qualifier
->out_xfb_stride
[buff_idx
]) {
667 state
->out_qualifier
->out_xfb_stride
[buff_idx
]->merge_qualifier(
668 new(state
->linalloc
) ast_layout_expression(*loc
,
671 state
->out_qualifier
->out_xfb_stride
[buff_idx
] =
672 new(state
->linalloc
) ast_layout_expression(*loc
,
682 * Check if the current type qualifier has any illegal flags.
684 * If so, print an error message, followed by a list of illegal flags.
686 * \param message The error message to print.
687 * \param allowed_flags A list of valid flags.
690 ast_type_qualifier::validate_flags(YYLTYPE
*loc
,
691 _mesa_glsl_parse_state
*state
,
692 const ast_type_qualifier
&allowed_flags
,
693 const char *message
, const char *name
)
695 ast_type_qualifier bad
;
696 bad
.flags
.i
= this->flags
.i
& ~allowed_flags
.flags
.i
;
697 if (bad
.flags
.i
== 0)
700 _mesa_glsl_error(loc
, state
,
702 "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s"
703 "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s"
704 "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
706 bad
.flags
.q
.invariant
? " invariant" : "",
707 bad
.flags
.q
.precise
? " precise" : "",
708 bad
.flags
.q
.constant
? " constant" : "",
709 bad
.flags
.q
.attribute
? " attribute" : "",
710 bad
.flags
.q
.varying
? " varying" : "",
711 bad
.flags
.q
.in
? " in" : "",
712 bad
.flags
.q
.out
? " out" : "",
713 bad
.flags
.q
.centroid
? " centroid" : "",
714 bad
.flags
.q
.sample
? " sample" : "",
715 bad
.flags
.q
.patch
? " patch" : "",
716 bad
.flags
.q
.uniform
? " uniform" : "",
717 bad
.flags
.q
.buffer
? " buffer" : "",
718 bad
.flags
.q
.shared_storage
? " shared_storage" : "",
719 bad
.flags
.q
.smooth
? " smooth" : "",
720 bad
.flags
.q
.flat
? " flat" : "",
721 bad
.flags
.q
.noperspective
? " noperspective" : "",
722 bad
.flags
.q
.origin_upper_left
? " origin_upper_left" : "",
723 bad
.flags
.q
.pixel_center_integer
? " pixel_center_integer" : "",
724 bad
.flags
.q
.explicit_align
? " align" : "",
725 bad
.flags
.q
.explicit_component
? " component" : "",
726 bad
.flags
.q
.explicit_location
? " location" : "",
727 bad
.flags
.q
.explicit_index
? " index" : "",
728 bad
.flags
.q
.explicit_binding
? " binding" : "",
729 bad
.flags
.q
.explicit_offset
? " offset" : "",
730 bad
.flags
.q
.depth_any
? " depth_any" : "",
731 bad
.flags
.q
.depth_greater
? " depth_greater" : "",
732 bad
.flags
.q
.depth_less
? " depth_less" : "",
733 bad
.flags
.q
.depth_unchanged
? " depth_unchanged" : "",
734 bad
.flags
.q
.std140
? " std140" : "",
735 bad
.flags
.q
.std430
? " std430" : "",
736 bad
.flags
.q
.shared
? " shared" : "",
737 bad
.flags
.q
.packed
? " packed" : "",
738 bad
.flags
.q
.column_major
? " column_major" : "",
739 bad
.flags
.q
.row_major
? " row_major" : "",
740 bad
.flags
.q
.prim_type
? " prim_type" : "",
741 bad
.flags
.q
.max_vertices
? " max_vertices" : "",
742 bad
.flags
.q
.local_size
? " local_size" : "",
743 bad
.flags
.q
.local_size_variable
? " local_size_variable" : "",
744 bad
.flags
.q
.early_fragment_tests
? " early_fragment_tests" : "",
745 bad
.flags
.q
.explicit_image_format
? " image_format" : "",
746 bad
.flags
.q
.coherent
? " coherent" : "",
747 bad
.flags
.q
._volatile
? " _volatile" : "",
748 bad
.flags
.q
.restrict_flag
? " restrict_flag" : "",
749 bad
.flags
.q
.read_only
? " read_only" : "",
750 bad
.flags
.q
.write_only
? " write_only" : "",
751 bad
.flags
.q
.invocations
? " invocations" : "",
752 bad
.flags
.q
.stream
? " stream" : "",
753 bad
.flags
.q
.explicit_stream
? " stream" : "",
754 bad
.flags
.q
.explicit_xfb_offset
? " xfb_offset" : "",
755 bad
.flags
.q
.xfb_buffer
? " xfb_buffer" : "",
756 bad
.flags
.q
.explicit_xfb_buffer
? " xfb_buffer" : "",
757 bad
.flags
.q
.xfb_stride
? " xfb_stride" : "",
758 bad
.flags
.q
.explicit_xfb_stride
? " xfb_stride" : "",
759 bad
.flags
.q
.vertex_spacing
? " vertex_spacing" : "",
760 bad
.flags
.q
.ordering
? " ordering" : "",
761 bad
.flags
.q
.point_mode
? " point_mode" : "",
762 bad
.flags
.q
.vertices
? " vertices" : "",
763 bad
.flags
.q
.subroutine
? " subroutine" : "",
764 bad
.flags
.q
.subroutine_def
? " subroutine_def" : "");
769 ast_layout_expression::process_qualifier_constant(struct _mesa_glsl_parse_state
*state
,
770 const char *qual_indentifier
,
775 bool first_pass
= true;
781 for (exec_node
*node
= layout_const_expressions
.get_head_raw();
782 !node
->is_tail_sentinel(); node
= node
->next
) {
784 exec_list dummy_instructions
;
785 ast_node
*const_expression
= exec_node_data(ast_node
, node
, link
);
787 ir_rvalue
*const ir
= const_expression
->hir(&dummy_instructions
, state
);
789 ir_constant
*const const_int
= ir
->constant_expression_value();
790 if (const_int
== NULL
|| !const_int
->type
->is_integer()) {
791 YYLTYPE loc
= const_expression
->get_location();
792 _mesa_glsl_error(&loc
, state
, "%s must be an integral constant "
793 "expression", qual_indentifier
);
797 if (const_int
->value
.i
[0] < min_value
) {
798 YYLTYPE loc
= const_expression
->get_location();
799 _mesa_glsl_error(&loc
, state
, "%s layout qualifier is invalid "
800 "(%d < %d)", qual_indentifier
,
801 const_int
->value
.i
[0], min_value
);
805 if (!first_pass
&& *value
!= const_int
->value
.u
[0]) {
806 YYLTYPE loc
= const_expression
->get_location();
807 _mesa_glsl_error(&loc
, state
, "%s layout qualifier does not "
808 "match previous declaration (%d vs %d)",
809 qual_indentifier
, *value
, const_int
->value
.i
[0]);
813 *value
= const_int
->value
.u
[0];
816 /* If the location is const (and we've verified that
817 * it is) then no instructions should have been emitted
818 * when we converted it to HIR. If they were emitted,
819 * then either the location isn't const after all, or
820 * we are emitting unnecessary instructions.
822 assert(dummy_instructions
.is_empty());
829 process_qualifier_constant(struct _mesa_glsl_parse_state
*state
,
831 const char *qual_indentifier
,
832 ast_expression
*const_expression
,
835 exec_list dummy_instructions
;
837 if (const_expression
== NULL
) {
842 ir_rvalue
*const ir
= const_expression
->hir(&dummy_instructions
, state
);
844 ir_constant
*const const_int
= ir
->constant_expression_value();
845 if (const_int
== NULL
|| !const_int
->type
->is_integer()) {
846 _mesa_glsl_error(loc
, state
, "%s must be an integral constant "
847 "expression", qual_indentifier
);
851 if (const_int
->value
.i
[0] < 0) {
852 _mesa_glsl_error(loc
, state
, "%s layout qualifier is invalid (%d < 0)",
853 qual_indentifier
, const_int
->value
.u
[0]);
857 /* If the location is const (and we've verified that
858 * it is) then no instructions should have been emitted
859 * when we converted it to HIR. If they were emitted,
860 * then either the location isn't const after all, or
861 * we are emitting unnecessary instructions.
863 assert(dummy_instructions
.is_empty());
865 *value
= const_int
->value
.u
[0];