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_location
78 || this->flags
.q
.explicit_image_format
79 || this->flags
.q
.explicit_index
80 || this->flags
.q
.explicit_binding
81 || this->flags
.q
.explicit_offset
82 || this->flags
.q
.explicit_stream
83 || this->flags
.q
.explicit_xfb_buffer
84 || this->flags
.q
.explicit_xfb_offset
85 || this->flags
.q
.explicit_xfb_stride
;
89 ast_type_qualifier::has_storage() const
91 return this->flags
.q
.constant
92 || this->flags
.q
.attribute
93 || this->flags
.q
.varying
96 || this->flags
.q
.uniform
97 || this->flags
.q
.buffer
98 || this->flags
.q
.shared_storage
;
102 ast_type_qualifier::has_auxiliary_storage() const
104 return this->flags
.q
.centroid
105 || this->flags
.q
.sample
106 || this->flags
.q
.patch
;
110 * This function merges both duplicate identifies within a single layout and
111 * multiple layout qualifiers on a single variable declaration. The
112 * is_single_layout_merge param is used differentiate between the two.
115 ast_type_qualifier::merge_qualifier(YYLTYPE
*loc
,
116 _mesa_glsl_parse_state
*state
,
117 const ast_type_qualifier
&q
,
118 bool is_single_layout_merge
)
120 ast_type_qualifier ubo_mat_mask
;
121 ubo_mat_mask
.flags
.i
= 0;
122 ubo_mat_mask
.flags
.q
.row_major
= 1;
123 ubo_mat_mask
.flags
.q
.column_major
= 1;
125 ast_type_qualifier ubo_layout_mask
;
126 ubo_layout_mask
.flags
.i
= 0;
127 ubo_layout_mask
.flags
.q
.std140
= 1;
128 ubo_layout_mask
.flags
.q
.packed
= 1;
129 ubo_layout_mask
.flags
.q
.shared
= 1;
130 ubo_layout_mask
.flags
.q
.std430
= 1;
132 ast_type_qualifier ubo_binding_mask
;
133 ubo_binding_mask
.flags
.i
= 0;
134 ubo_binding_mask
.flags
.q
.explicit_binding
= 1;
135 ubo_binding_mask
.flags
.q
.explicit_offset
= 1;
137 ast_type_qualifier stream_layout_mask
;
138 stream_layout_mask
.flags
.i
= 0;
139 stream_layout_mask
.flags
.q
.stream
= 1;
141 /* FIXME: We should probably do interface and function param validation
144 ast_type_qualifier input_layout_mask
;
145 input_layout_mask
.flags
.i
= 0;
146 input_layout_mask
.flags
.q
.centroid
= 1;
147 /* Function params can have constant */
148 input_layout_mask
.flags
.q
.constant
= 1;
149 input_layout_mask
.flags
.q
.explicit_location
= 1;
150 input_layout_mask
.flags
.q
.flat
= 1;
151 input_layout_mask
.flags
.q
.in
= 1;
152 input_layout_mask
.flags
.q
.invariant
= 1;
153 input_layout_mask
.flags
.q
.noperspective
= 1;
154 input_layout_mask
.flags
.q
.origin_upper_left
= 1;
155 /* Function params 'inout' will set this */
156 input_layout_mask
.flags
.q
.out
= 1;
157 input_layout_mask
.flags
.q
.patch
= 1;
158 input_layout_mask
.flags
.q
.pixel_center_integer
= 1;
159 input_layout_mask
.flags
.q
.precise
= 1;
160 input_layout_mask
.flags
.q
.sample
= 1;
161 input_layout_mask
.flags
.q
.smooth
= 1;
163 /* Uniform block layout qualifiers get to overwrite each
164 * other (rightmost having priority), while all other
165 * qualifiers currently don't allow duplicates.
167 ast_type_qualifier allowed_duplicates_mask
;
168 allowed_duplicates_mask
.flags
.i
=
169 ubo_mat_mask
.flags
.i
|
170 ubo_layout_mask
.flags
.i
|
171 ubo_binding_mask
.flags
.i
;
173 /* Geometry shaders can have several layout qualifiers
174 * assigning different stream values.
176 if (state
->stage
== MESA_SHADER_GEOMETRY
)
177 allowed_duplicates_mask
.flags
.i
|=
178 stream_layout_mask
.flags
.i
;
180 if (is_single_layout_merge
&& !state
->has_enhanced_layouts() &&
181 (this->flags
.i
& q
.flags
.i
& ~allowed_duplicates_mask
.flags
.i
) != 0) {
182 _mesa_glsl_error(loc
, state
,
183 "duplicate layout qualifiers used");
187 if (q
.flags
.q
.prim_type
) {
188 if (this->flags
.q
.prim_type
&& this->prim_type
!= q
.prim_type
) {
189 _mesa_glsl_error(loc
, state
,
190 "conflicting primitive type qualifiers used");
193 this->prim_type
= q
.prim_type
;
196 if (q
.flags
.q
.max_vertices
) {
197 if (this->max_vertices
) {
198 this->max_vertices
->merge_qualifier(q
.max_vertices
);
200 this->max_vertices
= q
.max_vertices
;
204 if (q
.flags
.q
.subroutine_def
) {
205 if (this->flags
.q
.subroutine_def
) {
206 _mesa_glsl_error(loc
, state
,
207 "conflicting subroutine qualifiers used");
209 this->subroutine_list
= q
.subroutine_list
;
213 if (q
.flags
.q
.invocations
) {
214 if (this->invocations
) {
215 this->invocations
->merge_qualifier(q
.invocations
);
217 this->invocations
= q
.invocations
;
221 if (state
->stage
== MESA_SHADER_GEOMETRY
&&
222 state
->has_explicit_attrib_stream()) {
223 if (!this->flags
.q
.explicit_stream
) {
224 if (q
.flags
.q
.stream
) {
225 this->flags
.q
.stream
= 1;
226 this->stream
= q
.stream
;
227 } else if (!this->flags
.q
.stream
&& this->flags
.q
.out
) {
228 /* Assign default global stream value */
229 this->flags
.q
.stream
= 1;
230 this->stream
= state
->out_qualifier
->stream
;
235 if (state
->has_enhanced_layouts()) {
236 if (!this->flags
.q
.explicit_xfb_buffer
) {
237 if (q
.flags
.q
.xfb_buffer
) {
238 this->flags
.q
.xfb_buffer
= 1;
239 this->xfb_buffer
= q
.xfb_buffer
;
240 } else if (!this->flags
.q
.xfb_buffer
&& this->flags
.q
.out
) {
241 /* Assign global xfb_buffer value */
242 this->flags
.q
.xfb_buffer
= 1;
243 this->xfb_buffer
= state
->out_qualifier
->xfb_buffer
;
247 if (q
.flags
.q
.explicit_xfb_stride
)
248 this->xfb_stride
= q
.xfb_stride
;
250 /* Merge all we xfb_stride qualifiers into the global out */
251 if (q
.flags
.q
.explicit_xfb_stride
|| this->flags
.q
.xfb_stride
) {
253 /* Set xfb_stride flag to 0 to avoid adding duplicates every time
256 this->flags
.q
.xfb_stride
= 0;
259 if (process_qualifier_constant(state
, loc
, "xfb_buffer",
260 this->xfb_buffer
, &buff_idx
)) {
261 if (state
->out_qualifier
->out_xfb_stride
[buff_idx
]) {
262 state
->out_qualifier
->out_xfb_stride
[buff_idx
]->merge_qualifier(
263 new(state
) ast_layout_expression(*loc
, this->xfb_stride
));
265 state
->out_qualifier
->out_xfb_stride
[buff_idx
] =
266 new(state
) ast_layout_expression(*loc
, this->xfb_stride
);
272 if (q
.flags
.q
.vertices
) {
273 if (this->vertices
) {
274 this->vertices
->merge_qualifier(q
.vertices
);
276 this->vertices
= q
.vertices
;
280 if (q
.flags
.q
.vertex_spacing
) {
281 if (this->flags
.q
.vertex_spacing
&& this->vertex_spacing
!= q
.vertex_spacing
) {
282 _mesa_glsl_error(loc
, state
,
283 "conflicting vertex spacing used");
286 this->vertex_spacing
= q
.vertex_spacing
;
289 if (q
.flags
.q
.ordering
) {
290 if (this->flags
.q
.ordering
&& this->ordering
!= q
.ordering
) {
291 _mesa_glsl_error(loc
, state
,
292 "conflicting ordering used");
295 this->ordering
= q
.ordering
;
298 if (q
.flags
.q
.point_mode
) {
299 if (this->flags
.q
.point_mode
&& this->point_mode
!= q
.point_mode
) {
300 _mesa_glsl_error(loc
, state
,
301 "conflicting point mode used");
304 this->point_mode
= q
.point_mode
;
307 if ((q
.flags
.i
& ubo_mat_mask
.flags
.i
) != 0)
308 this->flags
.i
&= ~ubo_mat_mask
.flags
.i
;
309 if ((q
.flags
.i
& ubo_layout_mask
.flags
.i
) != 0)
310 this->flags
.i
&= ~ubo_layout_mask
.flags
.i
;
312 for (int i
= 0; i
< 3; i
++) {
313 if (q
.flags
.q
.local_size
& (1 << i
)) {
314 if (this->local_size
[i
]) {
315 this->local_size
[i
]->merge_qualifier(q
.local_size
[i
]);
317 this->local_size
[i
] = q
.local_size
[i
];
322 this->flags
.i
|= q
.flags
.i
;
324 if (this->flags
.q
.in
&&
325 (this->flags
.i
& ~input_layout_mask
.flags
.i
) != 0) {
326 _mesa_glsl_error(loc
, state
,
327 "invalid input layout qualifier used");
331 if (q
.flags
.q
.explicit_align
)
332 this->align
= q
.align
;
334 if (q
.flags
.q
.explicit_location
)
335 this->location
= q
.location
;
337 if (q
.flags
.q
.explicit_index
)
338 this->index
= q
.index
;
340 if (q
.flags
.q
.explicit_binding
)
341 this->binding
= q
.binding
;
343 if (q
.flags
.q
.explicit_offset
|| q
.flags
.q
.explicit_xfb_offset
)
344 this->offset
= q
.offset
;
346 if (q
.precision
!= ast_precision_none
)
347 this->precision
= q
.precision
;
349 if (q
.flags
.q
.explicit_image_format
) {
350 this->image_format
= q
.image_format
;
351 this->image_base_type
= q
.image_base_type
;
358 ast_type_qualifier::merge_out_qualifier(YYLTYPE
*loc
,
359 _mesa_glsl_parse_state
*state
,
360 const ast_type_qualifier
&q
,
361 ast_node
* &node
, bool create_node
)
363 void *mem_ctx
= state
;
364 const bool r
= this->merge_qualifier(loc
, state
, q
, false);
365 ast_type_qualifier valid_out_mask
;
366 valid_out_mask
.flags
.i
= 0;
368 if (state
->stage
== MESA_SHADER_GEOMETRY
) {
369 if (q
.flags
.q
.prim_type
) {
370 /* Make sure this is a valid output primitive type. */
371 switch (q
.prim_type
) {
374 case GL_TRIANGLE_STRIP
:
377 _mesa_glsl_error(loc
, state
, "invalid geometry shader output "
383 /* Allow future assigments of global out's stream id value */
384 this->flags
.q
.explicit_stream
= 0;
386 valid_out_mask
.flags
.q
.stream
= 1;
387 valid_out_mask
.flags
.q
.explicit_stream
= 1;
388 valid_out_mask
.flags
.q
.explicit_xfb_buffer
= 1;
389 valid_out_mask
.flags
.q
.xfb_buffer
= 1;
390 valid_out_mask
.flags
.q
.explicit_xfb_stride
= 1;
391 valid_out_mask
.flags
.q
.xfb_stride
= 1;
392 valid_out_mask
.flags
.q
.max_vertices
= 1;
393 valid_out_mask
.flags
.q
.prim_type
= 1;
394 } else if (state
->stage
== MESA_SHADER_TESS_CTRL
) {
396 node
= new(mem_ctx
) ast_tcs_output_layout(*loc
);
398 valid_out_mask
.flags
.q
.vertices
= 1;
399 valid_out_mask
.flags
.q
.explicit_xfb_buffer
= 1;
400 valid_out_mask
.flags
.q
.xfb_buffer
= 1;
401 valid_out_mask
.flags
.q
.explicit_xfb_stride
= 1;
402 valid_out_mask
.flags
.q
.xfb_stride
= 1;
403 } else if (state
->stage
== MESA_SHADER_TESS_EVAL
||
404 state
->stage
== MESA_SHADER_VERTEX
) {
405 valid_out_mask
.flags
.q
.explicit_xfb_buffer
= 1;
406 valid_out_mask
.flags
.q
.xfb_buffer
= 1;
407 valid_out_mask
.flags
.q
.explicit_xfb_stride
= 1;
408 valid_out_mask
.flags
.q
.xfb_stride
= 1;
410 _mesa_glsl_error(loc
, state
, "out layout qualifiers only valid in "
411 "geometry, tessellation and vertex shaders");
415 /* Allow future assigments of global out's */
416 this->flags
.q
.explicit_xfb_buffer
= 0;
417 this->flags
.q
.explicit_xfb_stride
= 0;
419 /* Generate an error when invalid input layout qualifiers are used. */
420 if ((q
.flags
.i
& ~valid_out_mask
.flags
.i
) != 0) {
421 _mesa_glsl_error(loc
, state
,
422 "invalid output layout qualifiers used");
430 ast_type_qualifier::merge_in_qualifier(YYLTYPE
*loc
,
431 _mesa_glsl_parse_state
*state
,
432 const ast_type_qualifier
&q
,
433 ast_node
* &node
, bool create_node
)
435 void *mem_ctx
= state
;
436 bool create_gs_ast
= false;
437 bool create_cs_ast
= false;
438 ast_type_qualifier valid_in_mask
;
439 valid_in_mask
.flags
.i
= 0;
441 switch (state
->stage
) {
442 case MESA_SHADER_TESS_EVAL
:
443 if (q
.flags
.q
.prim_type
) {
444 /* Make sure this is a valid input primitive type. */
445 switch (q
.prim_type
) {
451 _mesa_glsl_error(loc
, state
,
452 "invalid tessellation evaluation "
453 "shader input primitive type");
458 valid_in_mask
.flags
.q
.prim_type
= 1;
459 valid_in_mask
.flags
.q
.vertex_spacing
= 1;
460 valid_in_mask
.flags
.q
.ordering
= 1;
461 valid_in_mask
.flags
.q
.point_mode
= 1;
463 case MESA_SHADER_GEOMETRY
:
464 if (q
.flags
.q
.prim_type
) {
465 /* Make sure this is a valid input primitive type. */
466 switch (q
.prim_type
) {
469 case GL_LINES_ADJACENCY
:
471 case GL_TRIANGLES_ADJACENCY
:
474 _mesa_glsl_error(loc
, state
,
475 "invalid geometry shader input primitive type");
481 q
.flags
.q
.prim_type
&&
482 !state
->in_qualifier
->flags
.q
.prim_type
;
484 valid_in_mask
.flags
.q
.prim_type
= 1;
485 valid_in_mask
.flags
.q
.invocations
= 1;
487 case MESA_SHADER_FRAGMENT
:
488 valid_in_mask
.flags
.q
.early_fragment_tests
= 1;
490 case MESA_SHADER_COMPUTE
:
492 q
.flags
.q
.local_size
!= 0 &&
493 state
->in_qualifier
->flags
.q
.local_size
== 0;
495 valid_in_mask
.flags
.q
.local_size
= 7;
498 _mesa_glsl_error(loc
, state
,
499 "input layout qualifiers only valid in "
500 "geometry, fragment and compute shaders");
504 /* Generate an error when invalid input layout qualifiers are used. */
505 if ((q
.flags
.i
& ~valid_in_mask
.flags
.i
) != 0) {
506 _mesa_glsl_error(loc
, state
,
507 "invalid input layout qualifiers used");
511 /* Input layout qualifiers can be specified multiple
512 * times in separate declarations, as long as they match.
514 if (this->flags
.q
.prim_type
) {
515 if (q
.flags
.q
.prim_type
&&
516 this->prim_type
!= q
.prim_type
) {
517 _mesa_glsl_error(loc
, state
,
518 "conflicting input primitive %s specified",
519 state
->stage
== MESA_SHADER_GEOMETRY
?
522 } else if (q
.flags
.q
.prim_type
) {
523 state
->in_qualifier
->flags
.q
.prim_type
= 1;
524 state
->in_qualifier
->prim_type
= q
.prim_type
;
527 if (q
.flags
.q
.invocations
) {
528 this->flags
.q
.invocations
= 1;
529 if (this->invocations
) {
530 this->invocations
->merge_qualifier(q
.invocations
);
532 this->invocations
= q
.invocations
;
536 if (q
.flags
.q
.early_fragment_tests
) {
537 state
->fs_early_fragment_tests
= true;
540 if (this->flags
.q
.vertex_spacing
) {
541 if (q
.flags
.q
.vertex_spacing
&&
542 this->vertex_spacing
!= q
.vertex_spacing
) {
543 _mesa_glsl_error(loc
, state
,
544 "conflicting vertex spacing specified");
546 } else if (q
.flags
.q
.vertex_spacing
) {
547 this->flags
.q
.vertex_spacing
= 1;
548 this->vertex_spacing
= q
.vertex_spacing
;
551 if (this->flags
.q
.ordering
) {
552 if (q
.flags
.q
.ordering
&&
553 this->ordering
!= q
.ordering
) {
554 _mesa_glsl_error(loc
, state
,
555 "conflicting ordering specified");
557 } else if (q
.flags
.q
.ordering
) {
558 this->flags
.q
.ordering
= 1;
559 this->ordering
= q
.ordering
;
562 if (this->flags
.q
.point_mode
) {
563 if (q
.flags
.q
.point_mode
&&
564 this->point_mode
!= q
.point_mode
) {
565 _mesa_glsl_error(loc
, state
,
566 "conflicting point mode specified");
568 } else if (q
.flags
.q
.point_mode
) {
569 this->flags
.q
.point_mode
= 1;
570 this->point_mode
= q
.point_mode
;
575 node
= new(mem_ctx
) ast_gs_input_layout(*loc
, q
.prim_type
);
576 } else if (create_cs_ast
) {
577 node
= new(mem_ctx
) ast_cs_input_layout(*loc
, q
.local_size
);
585 * Check if the current type qualifier has any illegal flags.
587 * If so, print an error message, followed by a list of illegal flags.
589 * \param message The error message to print.
590 * \param allowed_flags A list of valid flags.
593 ast_type_qualifier::validate_flags(YYLTYPE
*loc
,
594 _mesa_glsl_parse_state
*state
,
596 const ast_type_qualifier
&allowed_flags
)
598 ast_type_qualifier bad
;
599 bad
.flags
.i
= this->flags
.i
& ~allowed_flags
.flags
.i
;
600 if (bad
.flags
.i
== 0)
603 _mesa_glsl_error(loc
, state
,
605 "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s"
606 "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s"
607 "%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
609 bad
.flags
.q
.invariant
? " invariant" : "",
610 bad
.flags
.q
.precise
? " precise" : "",
611 bad
.flags
.q
.constant
? " constant" : "",
612 bad
.flags
.q
.attribute
? " attribute" : "",
613 bad
.flags
.q
.varying
? " varying" : "",
614 bad
.flags
.q
.in
? " in" : "",
615 bad
.flags
.q
.out
? " out" : "",
616 bad
.flags
.q
.centroid
? " centroid" : "",
617 bad
.flags
.q
.sample
? " sample" : "",
618 bad
.flags
.q
.patch
? " patch" : "",
619 bad
.flags
.q
.uniform
? " uniform" : "",
620 bad
.flags
.q
.buffer
? " buffer" : "",
621 bad
.flags
.q
.shared_storage
? " shared_storage" : "",
622 bad
.flags
.q
.smooth
? " smooth" : "",
623 bad
.flags
.q
.flat
? " flat" : "",
624 bad
.flags
.q
.noperspective
? " noperspective" : "",
625 bad
.flags
.q
.origin_upper_left
? " origin_upper_left" : "",
626 bad
.flags
.q
.pixel_center_integer
? " pixel_center_integer" : "",
627 bad
.flags
.q
.explicit_align
? " align" : "",
628 bad
.flags
.q
.explicit_location
? " location" : "",
629 bad
.flags
.q
.explicit_index
? " index" : "",
630 bad
.flags
.q
.explicit_binding
? " binding" : "",
631 bad
.flags
.q
.explicit_offset
? " offset" : "",
632 bad
.flags
.q
.depth_any
? " depth_any" : "",
633 bad
.flags
.q
.depth_greater
? " depth_greater" : "",
634 bad
.flags
.q
.depth_less
? " depth_less" : "",
635 bad
.flags
.q
.depth_unchanged
? " depth_unchanged" : "",
636 bad
.flags
.q
.std140
? " std140" : "",
637 bad
.flags
.q
.std430
? " std430" : "",
638 bad
.flags
.q
.shared
? " shared" : "",
639 bad
.flags
.q
.packed
? " packed" : "",
640 bad
.flags
.q
.column_major
? " column_major" : "",
641 bad
.flags
.q
.row_major
? " row_major" : "",
642 bad
.flags
.q
.prim_type
? " prim_type" : "",
643 bad
.flags
.q
.max_vertices
? " max_vertices" : "",
644 bad
.flags
.q
.local_size
? " local_size" : "",
645 bad
.flags
.q
.early_fragment_tests
? " early_fragment_tests" : "",
646 bad
.flags
.q
.explicit_image_format
? " image_format" : "",
647 bad
.flags
.q
.coherent
? " coherent" : "",
648 bad
.flags
.q
._volatile
? " _volatile" : "",
649 bad
.flags
.q
.restrict_flag
? " restrict_flag" : "",
650 bad
.flags
.q
.read_only
? " read_only" : "",
651 bad
.flags
.q
.write_only
? " write_only" : "",
652 bad
.flags
.q
.invocations
? " invocations" : "",
653 bad
.flags
.q
.stream
? " stream" : "",
654 bad
.flags
.q
.explicit_stream
? " stream" : "",
655 bad
.flags
.q
.explicit_xfb_offset
? " xfb_offset" : "",
656 bad
.flags
.q
.xfb_buffer
? " xfb_buffer" : "",
657 bad
.flags
.q
.explicit_xfb_buffer
? " xfb_buffer" : "",
658 bad
.flags
.q
.xfb_stride
? " xfb_stride" : "",
659 bad
.flags
.q
.explicit_xfb_stride
? " xfb_stride" : "",
660 bad
.flags
.q
.vertex_spacing
? " vertex_spacing" : "",
661 bad
.flags
.q
.ordering
? " ordering" : "",
662 bad
.flags
.q
.point_mode
? " point_mode" : "",
663 bad
.flags
.q
.vertices
? " vertices" : "",
664 bad
.flags
.q
.subroutine
? " subroutine" : "",
665 bad
.flags
.q
.subroutine_def
? " subroutine_def" : "");
670 ast_layout_expression::process_qualifier_constant(struct _mesa_glsl_parse_state
*state
,
671 const char *qual_indentifier
,
676 bool first_pass
= true;
682 for (exec_node
*node
= layout_const_expressions
.head
;
683 !node
->is_tail_sentinel(); node
= node
->next
) {
685 exec_list dummy_instructions
;
686 ast_node
*const_expression
= exec_node_data(ast_node
, node
, link
);
688 ir_rvalue
*const ir
= const_expression
->hir(&dummy_instructions
, state
);
690 ir_constant
*const const_int
= ir
->constant_expression_value();
691 if (const_int
== NULL
|| !const_int
->type
->is_integer()) {
692 YYLTYPE loc
= const_expression
->get_location();
693 _mesa_glsl_error(&loc
, state
, "%s must be an integral constant "
694 "expression", qual_indentifier
);
698 if (const_int
->value
.i
[0] < min_value
) {
699 YYLTYPE loc
= const_expression
->get_location();
700 _mesa_glsl_error(&loc
, state
, "%s layout qualifier is invalid "
701 "(%d < %d)", qual_indentifier
,
702 const_int
->value
.i
[0], min_value
);
706 if (!first_pass
&& *value
!= const_int
->value
.u
[0]) {
707 YYLTYPE loc
= const_expression
->get_location();
708 _mesa_glsl_error(&loc
, state
, "%s layout qualifier does not "
709 "match previous declaration (%d vs %d)",
710 qual_indentifier
, *value
, const_int
->value
.i
[0]);
714 *value
= const_int
->value
.u
[0];
717 /* If the location is const (and we've verified that
718 * it is) then no instructions should have been emitted
719 * when we converted it to HIR. If they were emitted,
720 * then either the location isn't const after all, or
721 * we are emitting unnecessary instructions.
723 assert(dummy_instructions
.is_empty());
730 process_qualifier_constant(struct _mesa_glsl_parse_state
*state
,
732 const char *qual_indentifier
,
733 ast_expression
*const_expression
,
736 exec_list dummy_instructions
;
738 if (const_expression
== NULL
) {
743 ir_rvalue
*const ir
= const_expression
->hir(&dummy_instructions
, state
);
745 ir_constant
*const const_int
= ir
->constant_expression_value();
746 if (const_int
== NULL
|| !const_int
->type
->is_integer()) {
747 _mesa_glsl_error(loc
, state
, "%s must be an integral constant "
748 "expression", qual_indentifier
);
752 if (const_int
->value
.i
[0] < 0) {
753 _mesa_glsl_error(loc
, state
, "%s layout qualifier is invalid (%d < 0)",
754 qual_indentifier
, const_int
->value
.u
[0]);
758 /* If the location is const (and we've verified that
759 * it is) then no instructions should have been emitted
760 * when we converted it to HIR. If they were emitted,
761 * then either the location isn't const after all, or
762 * we are emitting unnecessary instructions.
764 assert(dummy_instructions
.is_empty());
766 *value
= const_int
->value
.u
[0];