glsl: add helper for calculating size of AoA
[mesa.git] / src / glsl / glsl_types.h
1 /* -*- c++ -*- */
2 /*
3 * Copyright © 2009 Intel Corporation
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
14 * Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 */
24
25 #pragma once
26 #ifndef GLSL_TYPES_H
27 #define GLSL_TYPES_H
28
29 #include <string.h>
30 #include <assert.h>
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35
36 struct _mesa_glsl_parse_state;
37 struct glsl_symbol_table;
38
39 extern void
40 _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state);
41
42 extern void
43 _mesa_glsl_release_types(void);
44
45 #ifdef __cplusplus
46 }
47 #endif
48
49 enum glsl_base_type {
50 GLSL_TYPE_UINT = 0,
51 GLSL_TYPE_INT,
52 GLSL_TYPE_FLOAT,
53 GLSL_TYPE_DOUBLE,
54 GLSL_TYPE_BOOL,
55 GLSL_TYPE_SAMPLER,
56 GLSL_TYPE_IMAGE,
57 GLSL_TYPE_ATOMIC_UINT,
58 GLSL_TYPE_STRUCT,
59 GLSL_TYPE_INTERFACE,
60 GLSL_TYPE_ARRAY,
61 GLSL_TYPE_VOID,
62 GLSL_TYPE_SUBROUTINE,
63 GLSL_TYPE_ERROR
64 };
65
66 enum glsl_sampler_dim {
67 GLSL_SAMPLER_DIM_1D = 0,
68 GLSL_SAMPLER_DIM_2D,
69 GLSL_SAMPLER_DIM_3D,
70 GLSL_SAMPLER_DIM_CUBE,
71 GLSL_SAMPLER_DIM_RECT,
72 GLSL_SAMPLER_DIM_BUF,
73 GLSL_SAMPLER_DIM_EXTERNAL,
74 GLSL_SAMPLER_DIM_MS
75 };
76
77 enum glsl_interface_packing {
78 GLSL_INTERFACE_PACKING_STD140,
79 GLSL_INTERFACE_PACKING_SHARED,
80 GLSL_INTERFACE_PACKING_PACKED,
81 GLSL_INTERFACE_PACKING_STD430
82 };
83
84 enum glsl_matrix_layout {
85 /**
86 * The layout of the matrix is inherited from the object containing the
87 * matrix (the top level structure or the uniform block).
88 */
89 GLSL_MATRIX_LAYOUT_INHERITED,
90
91 /**
92 * Explicit column-major layout
93 *
94 * If a uniform block doesn't have an explicit layout set, it will default
95 * to this layout.
96 */
97 GLSL_MATRIX_LAYOUT_COLUMN_MAJOR,
98
99 /**
100 * Row-major layout
101 */
102 GLSL_MATRIX_LAYOUT_ROW_MAJOR
103 };
104
105 #ifdef __cplusplus
106 #include "GL/gl.h"
107 #include "util/ralloc.h"
108 #include "main/mtypes.h" /* for gl_texture_index, C++'s enum rules are broken */
109
110 struct glsl_type {
111 GLenum gl_type;
112 glsl_base_type base_type;
113
114 unsigned sampler_dimensionality:3; /**< \see glsl_sampler_dim */
115 unsigned sampler_shadow:1;
116 unsigned sampler_array:1;
117 unsigned sampler_type:2; /**< Type of data returned using this
118 * sampler or image. Only \c
119 * GLSL_TYPE_FLOAT, \c GLSL_TYPE_INT,
120 * and \c GLSL_TYPE_UINT are valid.
121 */
122 unsigned interface_packing:2;
123
124 /* Callers of this ralloc-based new need not call delete. It's
125 * easier to just ralloc_free 'mem_ctx' (or any of its ancestors). */
126 static void* operator new(size_t size)
127 {
128 mtx_lock(&glsl_type::mutex);
129
130 /* mem_ctx should have been created by the static members */
131 assert(glsl_type::mem_ctx != NULL);
132
133 void *type;
134
135 type = ralloc_size(glsl_type::mem_ctx, size);
136 assert(type != NULL);
137
138 mtx_unlock(&glsl_type::mutex);
139
140 return type;
141 }
142
143 /* If the user *does* call delete, that's OK, we will just
144 * ralloc_free in that case. */
145 static void operator delete(void *type)
146 {
147 mtx_lock(&glsl_type::mutex);
148 ralloc_free(type);
149 mtx_unlock(&glsl_type::mutex);
150 }
151
152 /**
153 * \name Vector and matrix element counts
154 *
155 * For scalars, each of these values will be 1. For non-numeric types
156 * these will be 0.
157 */
158 /*@{*/
159 uint8_t vector_elements; /**< 1, 2, 3, or 4 vector elements. */
160 uint8_t matrix_columns; /**< 1, 2, 3, or 4 matrix columns. */
161 /*@}*/
162
163 /**
164 * For \c GLSL_TYPE_ARRAY, this is the length of the array. For
165 * \c GLSL_TYPE_STRUCT or \c GLSL_TYPE_INTERFACE, it is the number of
166 * elements in the structure and the number of values pointed to by
167 * \c fields.structure (below).
168 */
169 unsigned length;
170
171 /**
172 * Name of the data type
173 *
174 * Will never be \c NULL.
175 */
176 const char *name;
177
178 /**
179 * Subtype of composite data types.
180 */
181 union {
182 const struct glsl_type *array; /**< Type of array elements. */
183 const struct glsl_type *parameters; /**< Parameters to function. */
184 struct glsl_struct_field *structure; /**< List of struct fields. */
185 } fields;
186
187 /**
188 * \name Pointers to various public type singletons
189 */
190 /*@{*/
191 #undef DECL_TYPE
192 #define DECL_TYPE(NAME, ...) \
193 static const glsl_type *const NAME##_type;
194 #undef STRUCT_TYPE
195 #define STRUCT_TYPE(NAME) \
196 static const glsl_type *const struct_##NAME##_type;
197 #include "builtin_type_macros.h"
198 /*@}*/
199
200 /**
201 * Convenience accessors for vector types (shorter than get_instance()).
202 * @{
203 */
204 static const glsl_type *vec(unsigned components);
205 static const glsl_type *dvec(unsigned components);
206 static const glsl_type *ivec(unsigned components);
207 static const glsl_type *uvec(unsigned components);
208 static const glsl_type *bvec(unsigned components);
209 /**@}*/
210
211 /**
212 * For numeric and boolean derived types returns the basic scalar type
213 *
214 * If the type is a numeric or boolean scalar, vector, or matrix type,
215 * this function gets the scalar type of the individual components. For
216 * all other types, including arrays of numeric or boolean types, the
217 * error type is returned.
218 */
219 const glsl_type *get_base_type() const;
220
221 /**
222 * Get the basic scalar type which this type aggregates.
223 *
224 * If the type is a numeric or boolean scalar, vector, or matrix, or an
225 * array of any of those, this function gets the scalar type of the
226 * individual components. For structs and arrays of structs, this function
227 * returns the struct type. For samplers and arrays of samplers, this
228 * function returns the sampler type.
229 */
230 const glsl_type *get_scalar_type() const;
231
232 /**
233 * Get the instance of a built-in scalar, vector, or matrix type
234 */
235 static const glsl_type *get_instance(unsigned base_type, unsigned rows,
236 unsigned columns);
237
238 /**
239 * Get the instance of a sampler type
240 */
241 static const glsl_type *get_sampler_instance(enum glsl_sampler_dim dim,
242 bool shadow,
243 bool array,
244 glsl_base_type type);
245
246
247 /**
248 * Get the instance of an array type
249 */
250 static const glsl_type *get_array_instance(const glsl_type *base,
251 unsigned elements);
252
253 /**
254 * Get the instance of a record type
255 */
256 static const glsl_type *get_record_instance(const glsl_struct_field *fields,
257 unsigned num_fields,
258 const char *name);
259
260 /**
261 * Get the instance of an interface block type
262 */
263 static const glsl_type *get_interface_instance(const glsl_struct_field *fields,
264 unsigned num_fields,
265 enum glsl_interface_packing packing,
266 const char *block_name);
267
268 /**
269 * Get the instance of an subroutine type
270 */
271 static const glsl_type *get_subroutine_instance(const char *subroutine_name);
272
273 /**
274 * Get the type resulting from a multiplication of \p type_a * \p type_b
275 */
276 static const glsl_type *get_mul_type(const glsl_type *type_a,
277 const glsl_type *type_b);
278
279 /**
280 * Query the total number of scalars that make up a scalar, vector or matrix
281 */
282 unsigned components() const
283 {
284 return vector_elements * matrix_columns;
285 }
286
287 /**
288 * Calculate the number of components slots required to hold this type
289 *
290 * This is used to determine how many uniform or varying locations a type
291 * might occupy.
292 */
293 unsigned component_slots() const;
294
295 /**
296 * Calculate offset between the base location of the struct in
297 * uniform storage and a struct member.
298 * For the initial call, length is the index of the member to find the
299 * offset for.
300 */
301 unsigned record_location_offset(unsigned length) const;
302
303 /**
304 * Calculate the number of unique values from glGetUniformLocation for the
305 * elements of the type.
306 *
307 * This is used to allocate slots in the UniformRemapTable, the amount of
308 * locations may not match with actual used storage space by the driver.
309 */
310 unsigned uniform_locations() const;
311
312 /**
313 * Calculate the number of attribute slots required to hold this type
314 *
315 * This implements the language rules of GLSL 1.50 for counting the number
316 * of slots used by a vertex attribute. It also determines the number of
317 * varying slots the type will use up in the absence of varying packing
318 * (and thus, it can be used to measure the number of varying slots used by
319 * the varyings that are generated by lower_packed_varyings).
320 */
321 unsigned count_attribute_slots() const;
322
323
324 /**
325 * Alignment in bytes of the start of this type in a std140 uniform
326 * block.
327 */
328 unsigned std140_base_alignment(bool row_major) const;
329
330 /** Size in bytes of this type in a std140 uniform block.
331 *
332 * Note that this is not GL_UNIFORM_SIZE (which is the number of
333 * elements in the array)
334 */
335 unsigned std140_size(bool row_major) const;
336
337 /**
338 * Alignment in bytes of the start of this type in a std430 shader
339 * storage block.
340 */
341 unsigned std430_base_alignment(bool row_major) const;
342
343 /**
344 * Calculate array stride in bytes of this type in a std430 shader storage
345 * block.
346 */
347 unsigned std430_array_stride(bool row_major) const;
348
349 /**
350 * Size in bytes of this type in a std430 shader storage block.
351 *
352 * Note that this is not GL_BUFFER_SIZE
353 */
354 unsigned std430_size(bool row_major) const;
355
356 /**
357 * \brief Can this type be implicitly converted to another?
358 *
359 * \return True if the types are identical or if this type can be converted
360 * to \c desired according to Section 4.1.10 of the GLSL spec.
361 *
362 * \verbatim
363 * From page 25 (31 of the pdf) of the GLSL 1.50 spec, Section 4.1.10
364 * Implicit Conversions:
365 *
366 * In some situations, an expression and its type will be implicitly
367 * converted to a different type. The following table shows all allowed
368 * implicit conversions:
369 *
370 * Type of expression | Can be implicitly converted to
371 * --------------------------------------------------
372 * int float
373 * uint
374 *
375 * ivec2 vec2
376 * uvec2
377 *
378 * ivec3 vec3
379 * uvec3
380 *
381 * ivec4 vec4
382 * uvec4
383 *
384 * There are no implicit array or structure conversions. For example,
385 * an array of int cannot be implicitly converted to an array of float.
386 * There are no implicit conversions between signed and unsigned
387 * integers.
388 * \endverbatim
389 */
390 bool can_implicitly_convert_to(const glsl_type *desired,
391 _mesa_glsl_parse_state *state) const;
392
393 /**
394 * Query whether or not a type is a scalar (non-vector and non-matrix).
395 */
396 bool is_scalar() const
397 {
398 return (vector_elements == 1)
399 && (base_type >= GLSL_TYPE_UINT)
400 && (base_type <= GLSL_TYPE_BOOL);
401 }
402
403 /**
404 * Query whether or not a type is a vector
405 */
406 bool is_vector() const
407 {
408 return (vector_elements > 1)
409 && (matrix_columns == 1)
410 && (base_type >= GLSL_TYPE_UINT)
411 && (base_type <= GLSL_TYPE_BOOL);
412 }
413
414 /**
415 * Query whether or not a type is a matrix
416 */
417 bool is_matrix() const
418 {
419 /* GLSL only has float matrices. */
420 return (matrix_columns > 1) && (base_type == GLSL_TYPE_FLOAT || base_type == GLSL_TYPE_DOUBLE);
421 }
422
423 /**
424 * Query whether or not a type is a non-array numeric type
425 */
426 bool is_numeric() const
427 {
428 return (base_type >= GLSL_TYPE_UINT) && (base_type <= GLSL_TYPE_DOUBLE);
429 }
430
431 /**
432 * Query whether or not a type is an integral type
433 */
434 bool is_integer() const
435 {
436 return (base_type == GLSL_TYPE_UINT) || (base_type == GLSL_TYPE_INT);
437 }
438
439 /**
440 * Query whether or not type is an integral type, or for struct and array
441 * types, contains an integral type.
442 */
443 bool contains_integer() const;
444
445 /**
446 * Query whether or not type is a double type, or for struct and array
447 * types, contains a double type.
448 */
449 bool contains_double() const;
450
451 /**
452 * Query whether or not a type is a float type
453 */
454 bool is_float() const
455 {
456 return base_type == GLSL_TYPE_FLOAT;
457 }
458
459 /**
460 * Query whether or not a type is a double type
461 */
462 bool is_double() const
463 {
464 return base_type == GLSL_TYPE_DOUBLE;
465 }
466
467 /**
468 * Query whether or not a type is a non-array boolean type
469 */
470 bool is_boolean() const
471 {
472 return base_type == GLSL_TYPE_BOOL;
473 }
474
475 /**
476 * Query whether or not a type is a sampler
477 */
478 bool is_sampler() const
479 {
480 return base_type == GLSL_TYPE_SAMPLER;
481 }
482
483 /**
484 * Query whether or not type is a sampler, or for struct and array
485 * types, contains a sampler.
486 */
487 bool contains_sampler() const;
488
489 /**
490 * Get the Mesa texture target index for a sampler type.
491 */
492 gl_texture_index sampler_index() const;
493
494 /**
495 * Query whether or not type is an image, or for struct and array
496 * types, contains an image.
497 */
498 bool contains_image() const;
499
500 /**
501 * Query whether or not a type is an image
502 */
503 bool is_image() const
504 {
505 return base_type == GLSL_TYPE_IMAGE;
506 }
507
508 /**
509 * Query whether or not a type is an array
510 */
511 bool is_array() const
512 {
513 return base_type == GLSL_TYPE_ARRAY;
514 }
515
516 /**
517 * Query whether or not a type is a record
518 */
519 bool is_record() const
520 {
521 return base_type == GLSL_TYPE_STRUCT;
522 }
523
524 /**
525 * Query whether or not a type is an interface
526 */
527 bool is_interface() const
528 {
529 return base_type == GLSL_TYPE_INTERFACE;
530 }
531
532 /**
533 * Query whether or not a type is the void type singleton.
534 */
535 bool is_void() const
536 {
537 return base_type == GLSL_TYPE_VOID;
538 }
539
540 /**
541 * Query whether or not a type is the error type singleton.
542 */
543 bool is_error() const
544 {
545 return base_type == GLSL_TYPE_ERROR;
546 }
547
548 /**
549 * Query if a type is unnamed/anonymous (named by the parser)
550 */
551
552 bool is_subroutine() const
553 {
554 return base_type == GLSL_TYPE_SUBROUTINE;
555 }
556 bool contains_subroutine() const;
557
558 bool is_anonymous() const
559 {
560 return !strncmp(name, "#anon", 5);
561 }
562
563 /**
564 * Get the type stripped of any arrays
565 *
566 * \return
567 * Pointer to the type of elements of the first non-array type for array
568 * types, or pointer to itself for non-array types.
569 */
570 const glsl_type *without_array() const
571 {
572 const glsl_type *t = this;
573
574 while (t->is_array())
575 t = t->fields.array;
576
577 return t;
578 }
579
580 /**
581 * Return the total number of elements in an array including the elements
582 * in arrays of arrays.
583 */
584 unsigned arrays_of_arrays_size() const
585 {
586 if (!is_array())
587 return 0;
588
589 unsigned size = length;
590 const glsl_type *base_type = fields.array;
591
592 while (base_type->is_array()) {
593 size = size * base_type->length;
594 base_type = base_type->fields.array;
595 }
596 return size;
597 }
598
599 /**
600 * Return the amount of atomic counter storage required for a type.
601 */
602 unsigned atomic_size() const
603 {
604 if (base_type == GLSL_TYPE_ATOMIC_UINT)
605 return ATOMIC_COUNTER_SIZE;
606 else if (is_array())
607 return length * fields.array->atomic_size();
608 else
609 return 0;
610 }
611
612 /**
613 * Return whether a type contains any atomic counters.
614 */
615 bool contains_atomic() const
616 {
617 return atomic_size() > 0;
618 }
619
620 /**
621 * Return whether a type contains any opaque types.
622 */
623 bool contains_opaque() const;
624
625 /**
626 * Query the full type of a matrix row
627 *
628 * \return
629 * If the type is not a matrix, \c glsl_type::error_type is returned.
630 * Otherwise a type matching the rows of the matrix is returned.
631 */
632 const glsl_type *row_type() const
633 {
634 return is_matrix()
635 ? get_instance(base_type, matrix_columns, 1)
636 : error_type;
637 }
638
639 /**
640 * Query the full type of a matrix column
641 *
642 * \return
643 * If the type is not a matrix, \c glsl_type::error_type is returned.
644 * Otherwise a type matching the columns of the matrix is returned.
645 */
646 const glsl_type *column_type() const
647 {
648 return is_matrix()
649 ? get_instance(base_type, vector_elements, 1)
650 : error_type;
651 }
652
653 /**
654 * Get the type of a structure field
655 *
656 * \return
657 * Pointer to the type of the named field. If the type is not a structure
658 * or the named field does not exist, \c glsl_type::error_type is returned.
659 */
660 const glsl_type *field_type(const char *name) const;
661
662 /**
663 * Get the location of a field within a record type
664 */
665 int field_index(const char *name) const;
666
667 /**
668 * Query the number of elements in an array type
669 *
670 * \return
671 * The number of elements in the array for array types or -1 for non-array
672 * types. If the number of elements in the array has not yet been declared,
673 * zero is returned.
674 */
675 int array_size() const
676 {
677 return is_array() ? length : -1;
678 }
679
680 /**
681 * Query whether the array size for all dimensions has been declared.
682 */
683 bool is_unsized_array() const
684 {
685 return is_array() && length == 0;
686 }
687
688 /**
689 * Return the number of coordinate components needed for this
690 * sampler or image type.
691 *
692 * This is based purely on the sampler's dimensionality. For example, this
693 * returns 1 for sampler1D, and 3 for sampler2DArray.
694 *
695 * Note that this is often different than actual coordinate type used in
696 * a texturing built-in function, since those pack additional values (such
697 * as the shadow comparitor or projector) into the coordinate type.
698 */
699 int coordinate_components() const;
700
701 /**
702 * Compare a record type against another record type.
703 *
704 * This is useful for matching record types declared across shader stages.
705 */
706 bool record_compare(const glsl_type *b) const;
707
708 private:
709
710 static mtx_t mutex;
711
712 /**
713 * ralloc context for all glsl_type allocations
714 *
715 * Set on the first call to \c glsl_type::new.
716 */
717 static void *mem_ctx;
718
719 void init_ralloc_type_ctx(void);
720
721 /** Constructor for vector and matrix types */
722 glsl_type(GLenum gl_type,
723 glsl_base_type base_type, unsigned vector_elements,
724 unsigned matrix_columns, const char *name);
725
726 /** Constructor for sampler or image types */
727 glsl_type(GLenum gl_type, glsl_base_type base_type,
728 enum glsl_sampler_dim dim, bool shadow, bool array,
729 unsigned type, const char *name);
730
731 /** Constructor for record types */
732 glsl_type(const glsl_struct_field *fields, unsigned num_fields,
733 const char *name);
734
735 /** Constructor for interface types */
736 glsl_type(const glsl_struct_field *fields, unsigned num_fields,
737 enum glsl_interface_packing packing, const char *name);
738
739 /** Constructor for array types */
740 glsl_type(const glsl_type *array, unsigned length);
741
742 /** Constructor for subroutine types */
743 glsl_type(const char *name);
744
745 /** Hash table containing the known array types. */
746 static struct hash_table *array_types;
747
748 /** Hash table containing the known record types. */
749 static struct hash_table *record_types;
750
751 /** Hash table containing the known interface types. */
752 static struct hash_table *interface_types;
753
754 /** Hash table containing the known subroutine types. */
755 static struct hash_table *subroutine_types;
756
757 static bool record_key_compare(const void *a, const void *b);
758 static unsigned record_key_hash(const void *key);
759
760 /**
761 * \name Built-in type flyweights
762 */
763 /*@{*/
764 #undef DECL_TYPE
765 #define DECL_TYPE(NAME, ...) static const glsl_type _##NAME##_type;
766 #undef STRUCT_TYPE
767 #define STRUCT_TYPE(NAME) static const glsl_type _struct_##NAME##_type;
768 #include "builtin_type_macros.h"
769 /*@}*/
770
771 /**
772 * \name Friend functions.
773 *
774 * These functions are friends because they must have C linkage and the
775 * need to call various private methods or access various private static
776 * data.
777 */
778 /*@{*/
779 friend void _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *);
780 friend void _mesa_glsl_release_types(void);
781 /*@}*/
782 };
783
784 struct glsl_struct_field {
785 const struct glsl_type *type;
786 const char *name;
787
788 /**
789 * For interface blocks, gl_varying_slot corresponding to the input/output
790 * if this is a built-in input/output (i.e. a member of the built-in
791 * gl_PerVertex interface block); -1 otherwise.
792 *
793 * Ignored for structs.
794 */
795 int location;
796
797 /**
798 * For interface blocks, the interpolation mode (as in
799 * ir_variable::interpolation). 0 otherwise.
800 */
801 unsigned interpolation:2;
802
803 /**
804 * For interface blocks, 1 if this variable uses centroid interpolation (as
805 * in ir_variable::centroid). 0 otherwise.
806 */
807 unsigned centroid:1;
808
809 /**
810 * For interface blocks, 1 if this variable uses sample interpolation (as
811 * in ir_variable::sample). 0 otherwise.
812 */
813 unsigned sample:1;
814
815 /**
816 * Layout of the matrix. Uses glsl_matrix_layout values.
817 */
818 unsigned matrix_layout:2;
819
820 /**
821 * For interface blocks, 1 if this variable is a per-patch input or output
822 * (as in ir_variable::patch). 0 otherwise.
823 */
824 unsigned patch:1;
825
826 /**
827 * For interface blocks, it has a value if this variable uses multiple vertex
828 * streams (as in ir_variable::stream). -1 otherwise.
829 */
830 int stream;
831
832
833 /**
834 * Image qualifiers, applicable to buffer variables defined in shader
835 * storage buffer objects (SSBOs)
836 */
837 unsigned image_read_only:1;
838 unsigned image_write_only:1;
839 unsigned image_coherent:1;
840 unsigned image_volatile:1;
841 unsigned image_restrict:1;
842
843 glsl_struct_field(const struct glsl_type *_type, const char *_name)
844 : type(_type), name(_name), location(-1), interpolation(0), centroid(0),
845 sample(0), matrix_layout(GLSL_MATRIX_LAYOUT_INHERITED), patch(0),
846 stream(-1)
847 {
848 /* empty */
849 }
850
851 glsl_struct_field()
852 {
853 /* empty */
854 }
855 };
856
857 static inline unsigned int
858 glsl_align(unsigned int a, unsigned int align)
859 {
860 return (a + align - 1) / align * align;
861 }
862
863 #undef DECL_TYPE
864 #undef STRUCT_TYPE
865 #endif /* __cplusplus */
866
867 #endif /* GLSL_TYPES_H */