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 * This function merges both duplicate identifies within a single layout and
121 * multiple layout qualifiers on a single variable declaration. The
122 * is_single_layout_merge param is used differentiate between the two.
125 ast_type_qualifier::merge_qualifier(YYLTYPE
*loc
,
126 _mesa_glsl_parse_state
*state
,
127 const ast_type_qualifier
&q
,
128 bool is_single_layout_merge
)
130 ast_type_qualifier ubo_mat_mask
;
131 ubo_mat_mask
.flags
.i
= 0;
132 ubo_mat_mask
.flags
.q
.row_major
= 1;
133 ubo_mat_mask
.flags
.q
.column_major
= 1;
135 ast_type_qualifier ubo_layout_mask
;
136 ubo_layout_mask
.flags
.i
= 0;
137 ubo_layout_mask
.flags
.q
.std140
= 1;
138 ubo_layout_mask
.flags
.q
.packed
= 1;
139 ubo_layout_mask
.flags
.q
.shared
= 1;
140 ubo_layout_mask
.flags
.q
.std430
= 1;
142 ast_type_qualifier ubo_binding_mask
;
143 ubo_binding_mask
.flags
.i
= 0;
144 ubo_binding_mask
.flags
.q
.explicit_binding
= 1;
145 ubo_binding_mask
.flags
.q
.explicit_offset
= 1;
147 ast_type_qualifier stream_layout_mask
;
148 stream_layout_mask
.flags
.i
= 0;
149 stream_layout_mask
.flags
.q
.stream
= 1;
151 /* FIXME: We should probably do interface and function param validation
154 ast_type_qualifier input_layout_mask
;
155 input_layout_mask
.flags
.i
= 0;
156 input_layout_mask
.flags
.q
.centroid
= 1;
157 /* Function params can have constant */
158 input_layout_mask
.flags
.q
.constant
= 1;
159 input_layout_mask
.flags
.q
.explicit_component
= 1;
160 input_layout_mask
.flags
.q
.explicit_location
= 1;
161 input_layout_mask
.flags
.q
.flat
= 1;
162 input_layout_mask
.flags
.q
.in
= 1;
163 input_layout_mask
.flags
.q
.invariant
= 1;
164 input_layout_mask
.flags
.q
.noperspective
= 1;
165 input_layout_mask
.flags
.q
.origin_upper_left
= 1;
166 /* Function params 'inout' will set this */
167 input_layout_mask
.flags
.q
.out
= 1;
168 input_layout_mask
.flags
.q
.patch
= 1;
169 input_layout_mask
.flags
.q
.pixel_center_integer
= 1;
170 input_layout_mask
.flags
.q
.precise
= 1;
171 input_layout_mask
.flags
.q
.sample
= 1;
172 input_layout_mask
.flags
.q
.smooth
= 1;
174 /* Uniform block layout qualifiers get to overwrite each
175 * other (rightmost having priority), while all other
176 * qualifiers currently don't allow duplicates.
178 ast_type_qualifier allowed_duplicates_mask
;
179 allowed_duplicates_mask
.flags
.i
=
180 ubo_mat_mask
.flags
.i
|
181 ubo_layout_mask
.flags
.i
|
182 ubo_binding_mask
.flags
.i
;
184 /* Geometry shaders can have several layout qualifiers
185 * assigning different stream values.
187 if (state
->stage
== MESA_SHADER_GEOMETRY
) {
188 allowed_duplicates_mask
.flags
.i
|=
189 stream_layout_mask
.flags
.i
;
192 if (is_single_layout_merge
&& !state
->has_enhanced_layouts() &&
193 (this->flags
.i
& q
.flags
.i
& ~allowed_duplicates_mask
.flags
.i
) != 0) {
194 _mesa_glsl_error(loc
, state
, "duplicate layout qualifiers used");
198 if (q
.flags
.q
.prim_type
) {
199 if (this->flags
.q
.prim_type
&& this->prim_type
!= q
.prim_type
) {
200 _mesa_glsl_error(loc
, state
,
201 "conflicting input primitive %s specified",
202 state
->stage
== MESA_SHADER_GEOMETRY
?
206 this->flags
.q
.prim_type
= 1;
207 this->prim_type
= q
.prim_type
;
210 if (q
.flags
.q
.max_vertices
) {
211 if (this->flags
.q
.max_vertices
&& !is_single_layout_merge
) {
212 this->max_vertices
->merge_qualifier(q
.max_vertices
);
214 this->flags
.q
.max_vertices
= 1;
215 this->max_vertices
= q
.max_vertices
;
219 if (q
.flags
.q
.subroutine_def
) {
220 if (this->flags
.q
.subroutine_def
) {
221 _mesa_glsl_error(loc
, state
,
222 "conflicting subroutine qualifiers used");
224 this->subroutine_list
= q
.subroutine_list
;
228 if (q
.flags
.q
.invocations
) {
229 if (this->flags
.q
.invocations
&& !is_single_layout_merge
) {
230 this->invocations
->merge_qualifier(q
.invocations
);
232 this->flags
.q
.invocations
= 1;
233 this->invocations
= q
.invocations
;
237 if (state
->stage
== MESA_SHADER_GEOMETRY
&&
238 state
->has_explicit_attrib_stream()) {
239 if (!this->flags
.q
.explicit_stream
) {
240 if (q
.flags
.q
.stream
) {
241 this->flags
.q
.stream
= 1;
242 this->stream
= q
.stream
;
243 } else if (!this->flags
.q
.stream
&& this->flags
.q
.out
&&
245 /* Assign default global stream value */
246 this->flags
.q
.stream
= 1;
247 this->stream
= state
->out_qualifier
->stream
;
252 if (state
->has_enhanced_layouts()) {
253 if (!this->flags
.q
.explicit_xfb_buffer
) {
254 if (q
.flags
.q
.xfb_buffer
) {
255 this->flags
.q
.xfb_buffer
= 1;
256 this->xfb_buffer
= q
.xfb_buffer
;
257 } else if (!this->flags
.q
.xfb_buffer
&& this->flags
.q
.out
&&
259 /* Assign global xfb_buffer value */
260 this->flags
.q
.xfb_buffer
= 1;
261 this->xfb_buffer
= state
->out_qualifier
->xfb_buffer
;
265 if (q
.flags
.q
.explicit_xfb_stride
)
266 this->xfb_stride
= q
.xfb_stride
;
268 /* Merge all we xfb_stride qualifiers into the global out */
269 if (q
.flags
.q
.explicit_xfb_stride
|| this->flags
.q
.xfb_stride
) {
271 /* Set xfb_stride flag to 0 to avoid adding duplicates every time
274 this->flags
.q
.xfb_stride
= 0;
277 if (process_qualifier_constant(state
, loc
, "xfb_buffer",
278 this->xfb_buffer
, &buff_idx
)) {
279 if (state
->out_qualifier
->out_xfb_stride
[buff_idx
]
280 && !is_single_layout_merge
) {
281 state
->out_qualifier
->out_xfb_stride
[buff_idx
]->merge_qualifier(
282 new(state
->linalloc
) ast_layout_expression(*loc
, this->xfb_stride
));
284 state
->out_qualifier
->out_xfb_stride
[buff_idx
] =
285 new(state
->linalloc
) ast_layout_expression(*loc
, this->xfb_stride
);
291 if (q
.flags
.q
.vertices
) {
292 if (this->flags
.q
.vertices
&& !is_single_layout_merge
) {
293 this->vertices
->merge_qualifier(q
.vertices
);
295 this->flags
.q
.vertices
= 1;
296 this->vertices
= q
.vertices
;
300 if (q
.flags
.q
.vertex_spacing
) {
301 if (this->flags
.q
.vertex_spacing
&& this->vertex_spacing
!= q
.vertex_spacing
) {
302 _mesa_glsl_error(loc
, state
, "conflicting vertex spacing used");
305 this->flags
.q
.vertex_spacing
= 1;
306 this->vertex_spacing
= q
.vertex_spacing
;
309 if (q
.flags
.q
.ordering
) {
310 if (this->flags
.q
.ordering
&& this->ordering
!= q
.ordering
) {
311 _mesa_glsl_error(loc
, state
, "conflicting ordering used");
314 this->flags
.q
.ordering
= 1;
315 this->ordering
= q
.ordering
;
318 if (q
.flags
.q
.point_mode
) {
319 if (this->flags
.q
.point_mode
&& this->point_mode
!= q
.point_mode
) {
320 _mesa_glsl_error(loc
, state
, "conflicting point mode used");
323 this->flags
.q
.point_mode
= 1;
324 this->point_mode
= q
.point_mode
;
327 if (q
.flags
.q
.early_fragment_tests
)
328 this->flags
.q
.early_fragment_tests
= true;
330 if ((q
.flags
.i
& ubo_mat_mask
.flags
.i
) != 0)
331 this->flags
.i
&= ~ubo_mat_mask
.flags
.i
;
332 if ((q
.flags
.i
& ubo_layout_mask
.flags
.i
) != 0)
333 this->flags
.i
&= ~ubo_layout_mask
.flags
.i
;
335 for (int i
= 0; i
< 3; i
++) {
336 if (q
.flags
.q
.local_size
& (1 << i
)) {
337 if (this->local_size
[i
] && !is_single_layout_merge
) {
338 this->local_size
[i
]->merge_qualifier(q
.local_size
[i
]);
340 this->local_size
[i
] = q
.local_size
[i
];
345 if (q
.flags
.q
.local_size_variable
)
346 this->flags
.q
.local_size_variable
= true;
348 this->flags
.i
|= q
.flags
.i
;
350 if (this->flags
.q
.in
&&
351 (this->flags
.i
& ~input_layout_mask
.flags
.i
) != 0) {
352 _mesa_glsl_error(loc
, state
, "invalid input layout qualifier used");
356 if (q
.flags
.q
.explicit_align
)
357 this->align
= q
.align
;
359 if (q
.flags
.q
.explicit_location
)
360 this->location
= q
.location
;
362 if (q
.flags
.q
.explicit_index
)
363 this->index
= q
.index
;
365 if (q
.flags
.q
.explicit_component
)
366 this->component
= q
.component
;
368 if (q
.flags
.q
.explicit_binding
)
369 this->binding
= q
.binding
;
371 if (q
.flags
.q
.explicit_offset
|| q
.flags
.q
.explicit_xfb_offset
)
372 this->offset
= q
.offset
;
374 if (q
.precision
!= ast_precision_none
)
375 this->precision
= q
.precision
;
377 if (q
.flags
.q
.explicit_image_format
) {
378 this->image_format
= q
.image_format
;
379 this->image_base_type
= q
.image_base_type
;
386 ast_type_qualifier::validate_out_qualifier(YYLTYPE
*loc
,
387 _mesa_glsl_parse_state
*state
)
390 ast_type_qualifier valid_out_mask
;
391 valid_out_mask
.flags
.i
= 0;
393 switch (state
->stage
) {
394 case MESA_SHADER_GEOMETRY
:
395 if (this->flags
.q
.prim_type
) {
396 /* Make sure this is a valid output primitive type. */
397 switch (this->prim_type
) {
400 case GL_TRIANGLE_STRIP
:
404 _mesa_glsl_error(loc
, state
, "invalid geometry shader output "
410 valid_out_mask
.flags
.q
.stream
= 1;
411 valid_out_mask
.flags
.q
.explicit_stream
= 1;
412 valid_out_mask
.flags
.q
.explicit_xfb_buffer
= 1;
413 valid_out_mask
.flags
.q
.xfb_buffer
= 1;
414 valid_out_mask
.flags
.q
.explicit_xfb_stride
= 1;
415 valid_out_mask
.flags
.q
.xfb_stride
= 1;
416 valid_out_mask
.flags
.q
.max_vertices
= 1;
417 valid_out_mask
.flags
.q
.prim_type
= 1;
419 case MESA_SHADER_TESS_CTRL
:
420 valid_out_mask
.flags
.q
.vertices
= 1;
421 valid_out_mask
.flags
.q
.explicit_xfb_buffer
= 1;
422 valid_out_mask
.flags
.q
.xfb_buffer
= 1;
423 valid_out_mask
.flags
.q
.explicit_xfb_stride
= 1;
424 valid_out_mask
.flags
.q
.xfb_stride
= 1;
426 case MESA_SHADER_TESS_EVAL
:
427 case MESA_SHADER_VERTEX
:
428 valid_out_mask
.flags
.q
.explicit_xfb_buffer
= 1;
429 valid_out_mask
.flags
.q
.xfb_buffer
= 1;
430 valid_out_mask
.flags
.q
.explicit_xfb_stride
= 1;
431 valid_out_mask
.flags
.q
.xfb_stride
= 1;
433 case MESA_SHADER_FRAGMENT
:
434 valid_out_mask
.flags
.q
.blend_support
= 1;
438 _mesa_glsl_error(loc
, state
,
439 "out layout qualifiers only valid in "
440 "geometry, tessellation, vertex and fragment shaders");
443 /* Generate an error when invalid output layout qualifiers are used. */
444 if ((this->flags
.i
& ~valid_out_mask
.flags
.i
) != 0) {
446 _mesa_glsl_error(loc
, state
, "invalid output layout qualifiers used");
453 ast_type_qualifier::merge_into_out_qualifier(YYLTYPE
*loc
,
454 _mesa_glsl_parse_state
*state
,
455 ast_node
* &node
, bool create_node
)
457 const bool r
= state
->out_qualifier
->merge_qualifier(loc
, state
,
460 switch (state
->stage
) {
461 case MESA_SHADER_GEOMETRY
:
462 /* Allow future assignments of global out's stream id value */
463 state
->out_qualifier
->flags
.q
.explicit_stream
= 0;
465 case MESA_SHADER_TESS_CTRL
:
467 node
= new(state
->linalloc
) ast_tcs_output_layout(*loc
);
473 /* Allow future assignments of global out's */
474 state
->out_qualifier
->flags
.q
.explicit_xfb_buffer
= 0;
475 state
->out_qualifier
->flags
.q
.explicit_xfb_stride
= 0;
481 ast_type_qualifier::validate_in_qualifier(YYLTYPE
*loc
,
482 _mesa_glsl_parse_state
*state
)
485 ast_type_qualifier valid_in_mask
;
486 valid_in_mask
.flags
.i
= 0;
488 switch (state
->stage
) {
489 case MESA_SHADER_TESS_EVAL
:
490 if (this->flags
.q
.prim_type
) {
491 /* Make sure this is a valid input primitive type. */
492 switch (this->prim_type
) {
499 _mesa_glsl_error(loc
, state
,
500 "invalid tessellation evaluation "
501 "shader input primitive type");
506 valid_in_mask
.flags
.q
.prim_type
= 1;
507 valid_in_mask
.flags
.q
.vertex_spacing
= 1;
508 valid_in_mask
.flags
.q
.ordering
= 1;
509 valid_in_mask
.flags
.q
.point_mode
= 1;
511 case MESA_SHADER_GEOMETRY
:
512 if (this->flags
.q
.prim_type
) {
513 /* Make sure this is a valid input primitive type. */
514 switch (this->prim_type
) {
517 case GL_LINES_ADJACENCY
:
519 case GL_TRIANGLES_ADJACENCY
:
523 _mesa_glsl_error(loc
, state
,
524 "invalid geometry shader input primitive type");
529 valid_in_mask
.flags
.q
.prim_type
= 1;
530 valid_in_mask
.flags
.q
.invocations
= 1;
532 case MESA_SHADER_FRAGMENT
:
533 valid_in_mask
.flags
.q
.early_fragment_tests
= 1;
535 case MESA_SHADER_COMPUTE
:
536 valid_in_mask
.flags
.q
.local_size
= 7;
537 valid_in_mask
.flags
.q
.local_size_variable
= 1;
541 _mesa_glsl_error(loc
, state
,
542 "input layout qualifiers only valid in "
543 "geometry, tessellation, fragment and compute shaders");
547 /* Generate an error when invalid input layout qualifiers are used. */
548 if ((this->flags
.i
& ~valid_in_mask
.flags
.i
) != 0) {
550 _mesa_glsl_error(loc
, state
, "invalid input layout qualifiers used");
553 /* The checks below are also performed when merging but we want to spit an
554 * error against the default global input qualifier as soon as we can, with
555 * the closest error location in the shader.
558 /* Input layout qualifiers can be specified multiple
559 * times in separate declarations, as long as they match.
561 if (state
->in_qualifier
->flags
.q
.prim_type
&& this->flags
.q
.prim_type
562 && state
->in_qualifier
->prim_type
!= this->prim_type
) {
564 _mesa_glsl_error(loc
, state
,
565 "conflicting input primitive %s specified",
566 state
->stage
== MESA_SHADER_GEOMETRY
?
570 if (state
->in_qualifier
->flags
.q
.vertex_spacing
571 && this->flags
.q
.vertex_spacing
572 && state
->in_qualifier
->vertex_spacing
!= this->vertex_spacing
) {
574 _mesa_glsl_error(loc
, state
,
575 "conflicting vertex spacing specified");
578 if (state
->in_qualifier
->flags
.q
.ordering
&& this->flags
.q
.ordering
579 && state
->in_qualifier
->ordering
!= this->ordering
) {
581 _mesa_glsl_error(loc
, state
,
582 "conflicting ordering specified");
585 if (state
->in_qualifier
->flags
.q
.point_mode
&& this->flags
.q
.point_mode
586 && state
->in_qualifier
->point_mode
!= this->point_mode
) {
588 _mesa_glsl_error(loc
, state
,
589 "conflicting point mode specified");
596 ast_type_qualifier::merge_into_in_qualifier(YYLTYPE
*loc
,
597 _mesa_glsl_parse_state
*state
,
598 ast_node
* &node
, bool create_node
)
601 void *lin_ctx
= state
->linalloc
;
603 /* We create the gs_input_layout node before merging so, in the future, no
604 * more repeated nodes will be created as we will have the flag set.
606 if (state
->stage
== MESA_SHADER_GEOMETRY
607 && this->flags
.q
.prim_type
&& !state
->in_qualifier
->flags
.q
.prim_type
609 node
= new(lin_ctx
) ast_gs_input_layout(*loc
, this->prim_type
);
612 r
= state
->in_qualifier
->merge_qualifier(loc
, state
, *this, false);
614 if (state
->in_qualifier
->flags
.q
.early_fragment_tests
) {
615 state
->fs_early_fragment_tests
= true;
616 state
->in_qualifier
->flags
.q
.early_fragment_tests
= false;
619 /* We allow the creation of multiple cs_input_layout nodes. Coherence among
620 * all existing nodes is checked later, when the AST node is transformed
623 if (state
->in_qualifier
->flags
.q
.local_size
) {
625 node
= new(lin_ctx
) ast_cs_input_layout(*loc
, state
->in_qualifier
->local_size
);
626 state
->in_qualifier
->flags
.q
.local_size
= 0;
627 for (int i
= 0; i
< 3; i
++)
628 state
->in_qualifier
->local_size
[i
] = NULL
;
631 if (state
->in_qualifier
->flags
.q
.local_size_variable
) {
632 state
->cs_input_local_size_variable_specified
= true;
633 state
->in_qualifier
->flags
.q
.local_size_variable
= false;
640 * Check if the current type qualifier has any illegal flags.
642 * If so, print an error message, followed by a list of illegal flags.
644 * \param message The error message to print.
645 * \param allowed_flags A list of valid flags.
648 ast_type_qualifier::validate_flags(YYLTYPE
*loc
,
649 _mesa_glsl_parse_state
*state
,
650 const ast_type_qualifier
&allowed_flags
,
651 const char *message
, const char *name
)
653 ast_type_qualifier bad
;
654 bad
.flags
.i
= this->flags
.i
& ~allowed_flags
.flags
.i
;
655 if (bad
.flags
.i
== 0)
658 _mesa_glsl_error(loc
, state
,
660 "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s"
661 "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s"
662 "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
664 bad
.flags
.q
.invariant
? " invariant" : "",
665 bad
.flags
.q
.precise
? " precise" : "",
666 bad
.flags
.q
.constant
? " constant" : "",
667 bad
.flags
.q
.attribute
? " attribute" : "",
668 bad
.flags
.q
.varying
? " varying" : "",
669 bad
.flags
.q
.in
? " in" : "",
670 bad
.flags
.q
.out
? " out" : "",
671 bad
.flags
.q
.centroid
? " centroid" : "",
672 bad
.flags
.q
.sample
? " sample" : "",
673 bad
.flags
.q
.patch
? " patch" : "",
674 bad
.flags
.q
.uniform
? " uniform" : "",
675 bad
.flags
.q
.buffer
? " buffer" : "",
676 bad
.flags
.q
.shared_storage
? " shared_storage" : "",
677 bad
.flags
.q
.smooth
? " smooth" : "",
678 bad
.flags
.q
.flat
? " flat" : "",
679 bad
.flags
.q
.noperspective
? " noperspective" : "",
680 bad
.flags
.q
.origin_upper_left
? " origin_upper_left" : "",
681 bad
.flags
.q
.pixel_center_integer
? " pixel_center_integer" : "",
682 bad
.flags
.q
.explicit_align
? " align" : "",
683 bad
.flags
.q
.explicit_component
? " component" : "",
684 bad
.flags
.q
.explicit_location
? " location" : "",
685 bad
.flags
.q
.explicit_index
? " index" : "",
686 bad
.flags
.q
.explicit_binding
? " binding" : "",
687 bad
.flags
.q
.explicit_offset
? " offset" : "",
688 bad
.flags
.q
.depth_any
? " depth_any" : "",
689 bad
.flags
.q
.depth_greater
? " depth_greater" : "",
690 bad
.flags
.q
.depth_less
? " depth_less" : "",
691 bad
.flags
.q
.depth_unchanged
? " depth_unchanged" : "",
692 bad
.flags
.q
.std140
? " std140" : "",
693 bad
.flags
.q
.std430
? " std430" : "",
694 bad
.flags
.q
.shared
? " shared" : "",
695 bad
.flags
.q
.packed
? " packed" : "",
696 bad
.flags
.q
.column_major
? " column_major" : "",
697 bad
.flags
.q
.row_major
? " row_major" : "",
698 bad
.flags
.q
.prim_type
? " prim_type" : "",
699 bad
.flags
.q
.max_vertices
? " max_vertices" : "",
700 bad
.flags
.q
.local_size
? " local_size" : "",
701 bad
.flags
.q
.local_size_variable
? " local_size_variable" : "",
702 bad
.flags
.q
.early_fragment_tests
? " early_fragment_tests" : "",
703 bad
.flags
.q
.explicit_image_format
? " image_format" : "",
704 bad
.flags
.q
.coherent
? " coherent" : "",
705 bad
.flags
.q
._volatile
? " _volatile" : "",
706 bad
.flags
.q
.restrict_flag
? " restrict_flag" : "",
707 bad
.flags
.q
.read_only
? " read_only" : "",
708 bad
.flags
.q
.write_only
? " write_only" : "",
709 bad
.flags
.q
.invocations
? " invocations" : "",
710 bad
.flags
.q
.stream
? " stream" : "",
711 bad
.flags
.q
.explicit_stream
? " stream" : "",
712 bad
.flags
.q
.explicit_xfb_offset
? " xfb_offset" : "",
713 bad
.flags
.q
.xfb_buffer
? " xfb_buffer" : "",
714 bad
.flags
.q
.explicit_xfb_buffer
? " xfb_buffer" : "",
715 bad
.flags
.q
.xfb_stride
? " xfb_stride" : "",
716 bad
.flags
.q
.explicit_xfb_stride
? " xfb_stride" : "",
717 bad
.flags
.q
.vertex_spacing
? " vertex_spacing" : "",
718 bad
.flags
.q
.ordering
? " ordering" : "",
719 bad
.flags
.q
.point_mode
? " point_mode" : "",
720 bad
.flags
.q
.vertices
? " vertices" : "",
721 bad
.flags
.q
.subroutine
? " subroutine" : "",
722 bad
.flags
.q
.subroutine_def
? " subroutine_def" : "");
727 ast_layout_expression::process_qualifier_constant(struct _mesa_glsl_parse_state
*state
,
728 const char *qual_indentifier
,
734 bool first_pass
= true;
740 for (exec_node
*node
= layout_const_expressions
.get_head_raw();
741 !node
->is_tail_sentinel(); node
= node
->next
) {
743 exec_list dummy_instructions
;
744 ast_node
*const_expression
= exec_node_data(ast_node
, node
, link
);
746 ir_rvalue
*const ir
= const_expression
->hir(&dummy_instructions
, state
);
748 ir_constant
*const const_int
= ir
->constant_expression_value();
749 if (const_int
== NULL
|| !const_int
->type
->is_integer()) {
750 YYLTYPE loc
= const_expression
->get_location();
751 _mesa_glsl_error(&loc
, state
, "%s must be an integral constant "
752 "expression", qual_indentifier
);
756 if (const_int
->value
.i
[0] < min_value
) {
757 YYLTYPE loc
= const_expression
->get_location();
758 _mesa_glsl_error(&loc
, state
, "%s layout qualifier is invalid "
759 "(%d < %d)", qual_indentifier
,
760 const_int
->value
.i
[0], min_value
);
764 /* From section 4.4 "Layout Qualifiers" of the GLSL 4.50 spec:
765 * "When the same layout-qualifier-name occurs multiple times,
766 * in a single declaration, the last occurrence overrides the
767 * former occurrence(s)."
770 if ((must_match
|| !state
->has_420pack()) && *value
!= const_int
->value
.u
[0]) {
771 YYLTYPE loc
= const_expression
->get_location();
772 _mesa_glsl_error(&loc
, state
, "%s layout qualifier does not "
773 "match previous declaration (%d vs %d)",
774 qual_indentifier
, *value
, const_int
->value
.i
[0]);
779 *value
= const_int
->value
.u
[0];
782 /* If the location is const (and we've verified that
783 * it is) then no instructions should have been emitted
784 * when we converted it to HIR. If they were emitted,
785 * then either the location isn't const after all, or
786 * we are emitting unnecessary instructions.
788 assert(dummy_instructions
.is_empty());
795 process_qualifier_constant(struct _mesa_glsl_parse_state
*state
,
797 const char *qual_indentifier
,
798 ast_expression
*const_expression
,
801 exec_list dummy_instructions
;
803 if (const_expression
== NULL
) {
808 ir_rvalue
*const ir
= const_expression
->hir(&dummy_instructions
, state
);
810 ir_constant
*const const_int
= ir
->constant_expression_value();
811 if (const_int
== NULL
|| !const_int
->type
->is_integer()) {
812 _mesa_glsl_error(loc
, state
, "%s must be an integral constant "
813 "expression", qual_indentifier
);
817 if (const_int
->value
.i
[0] < 0) {
818 _mesa_glsl_error(loc
, state
, "%s layout qualifier is invalid (%d < 0)",
819 qual_indentifier
, const_int
->value
.u
[0]);
823 /* If the location is const (and we've verified that
824 * it is) then no instructions should have been emitted
825 * when we converted it to HIR. If they were emitted,
826 * then either the location isn't const after all, or
827 * we are emitting unnecessary instructions.
829 assert(dummy_instructions
.is_empty());
831 *value
= const_int
->value
.u
[0];