3 * Copyright © 2009 Intel Corporation
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:
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
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.
31 #include "shader_enums.h"
33 #include "c11/threads.h"
36 #include "main/config.h"
45 struct _mesa_glsl_parse_state
;
46 struct glsl_symbol_table
;
49 _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state
*state
);
52 _mesa_glsl_release_types(void);
54 void encode_type_to_blob(struct blob
*blob
, const struct glsl_type
*type
);
56 const struct glsl_type
*decode_type_from_blob(struct blob_reader
*blob
);
63 /* Note: GLSL_TYPE_UINT, GLSL_TYPE_INT, and GLSL_TYPE_FLOAT must be 0, 1,
64 * and 2 so that they will fit in the 2 bits of glsl_type::sampled_type.
80 GLSL_TYPE_ATOMIC_UINT
,
90 static inline bool glsl_base_type_is_16bit(enum glsl_base_type type
)
92 return type
== GLSL_TYPE_FLOAT16
||
93 type
== GLSL_TYPE_UINT16
||
94 type
== GLSL_TYPE_INT16
;
97 static inline bool glsl_base_type_is_64bit(enum glsl_base_type type
)
99 return type
== GLSL_TYPE_DOUBLE
||
100 type
== GLSL_TYPE_UINT64
||
101 type
== GLSL_TYPE_INT64
||
102 type
== GLSL_TYPE_IMAGE
||
103 type
== GLSL_TYPE_SAMPLER
;
106 static inline bool glsl_base_type_is_integer(enum glsl_base_type type
)
108 return type
== GLSL_TYPE_UINT
||
109 type
== GLSL_TYPE_INT
||
110 type
== GLSL_TYPE_UINT64
||
111 type
== GLSL_TYPE_INT64
||
112 type
== GLSL_TYPE_BOOL
||
113 type
== GLSL_TYPE_SAMPLER
||
114 type
== GLSL_TYPE_IMAGE
;
117 enum glsl_sampler_dim
{
118 GLSL_SAMPLER_DIM_1D
= 0,
121 GLSL_SAMPLER_DIM_CUBE
,
122 GLSL_SAMPLER_DIM_RECT
,
123 GLSL_SAMPLER_DIM_BUF
,
124 GLSL_SAMPLER_DIM_EXTERNAL
,
126 GLSL_SAMPLER_DIM_SUBPASS
, /* for vulkan input attachments */
127 GLSL_SAMPLER_DIM_SUBPASS_MS
, /* for multisampled vulkan input attachments */
130 enum glsl_matrix_layout
{
132 * The layout of the matrix is inherited from the object containing the
133 * matrix (the top level structure or the uniform block).
135 GLSL_MATRIX_LAYOUT_INHERITED
,
138 * Explicit column-major layout
140 * If a uniform block doesn't have an explicit layout set, it will default
143 GLSL_MATRIX_LAYOUT_COLUMN_MAJOR
,
148 GLSL_MATRIX_LAYOUT_ROW_MAJOR
152 GLSL_PRECISION_NONE
= 0,
154 GLSL_PRECISION_MEDIUM
,
160 #include "util/ralloc.h"
161 #include "main/menums.h" /* for gl_texture_index, C++'s enum rules are broken */
165 glsl_base_type base_type
:8;
167 glsl_base_type sampled_type
:8; /**< Type of data returned using this
168 * sampler or image. Only \c
169 * GLSL_TYPE_FLOAT, \c GLSL_TYPE_INT,
170 * and \c GLSL_TYPE_UINT are valid.
173 unsigned sampler_dimensionality
:4; /**< \see glsl_sampler_dim */
174 unsigned sampler_shadow
:1;
175 unsigned sampler_array
:1;
176 unsigned interface_packing
:2;
177 unsigned interface_row_major
:1;
180 glsl_type() : mem_ctx(NULL
)
182 // Dummy constructor, just for the sake of ASSERT_BITFIELD_SIZE.
187 * \name Vector and matrix element counts
189 * For scalars, each of these values will be 1. For non-numeric types
193 uint8_t vector_elements
; /**< 1, 2, 3, or 4 vector elements. */
194 uint8_t matrix_columns
; /**< 1, 2, 3, or 4 matrix columns. */
198 * For \c GLSL_TYPE_ARRAY, this is the length of the array. For
199 * \c GLSL_TYPE_STRUCT or \c GLSL_TYPE_INTERFACE, it is the number of
200 * elements in the structure and the number of values pointed to by
201 * \c fields.structure (below).
206 * Name of the data type
208 * Will never be \c NULL.
213 * Explicit array, matrix, or vector stride. This is used to communicate
214 * explicit array layouts from SPIR-V. Should be 0 if the type has no
217 unsigned explicit_stride
;
220 * Subtype of composite data types.
223 const struct glsl_type
*array
; /**< Type of array elements. */
224 struct glsl_function_param
*parameters
; /**< Parameters to function. */
225 struct glsl_struct_field
*structure
; /**< List of struct fields. */
229 * \name Pointers to various public type singletons
233 #define DECL_TYPE(NAME, ...) \
234 static const glsl_type *const NAME##_type;
236 #define STRUCT_TYPE(NAME) \
237 static const glsl_type *const struct_##NAME##_type;
238 #include "compiler/builtin_type_macros.h"
242 * Convenience accessors for vector types (shorter than get_instance()).
245 static const glsl_type
*vec(unsigned components
, const glsl_type
*const ts
[]);
246 static const glsl_type
*vec(unsigned components
);
247 static const glsl_type
*f16vec(unsigned components
);
248 static const glsl_type
*dvec(unsigned components
);
249 static const glsl_type
*ivec(unsigned components
);
250 static const glsl_type
*uvec(unsigned components
);
251 static const glsl_type
*bvec(unsigned components
);
252 static const glsl_type
*i64vec(unsigned components
);
253 static const glsl_type
*u64vec(unsigned components
);
254 static const glsl_type
*i16vec(unsigned components
);
255 static const glsl_type
*u16vec(unsigned components
);
256 static const glsl_type
*i8vec(unsigned components
);
257 static const glsl_type
*u8vec(unsigned components
);
261 * For numeric and boolean derived types returns the basic scalar type
263 * If the type is a numeric or boolean scalar, vector, or matrix type,
264 * this function gets the scalar type of the individual components. For
265 * all other types, including arrays of numeric or boolean types, the
266 * error type is returned.
268 const glsl_type
*get_base_type() const;
271 * Get the basic scalar type which this type aggregates.
273 * If the type is a numeric or boolean scalar, vector, or matrix, or an
274 * array of any of those, this function gets the scalar type of the
275 * individual components. For structs and arrays of structs, this function
276 * returns the struct type. For samplers and arrays of samplers, this
277 * function returns the sampler type.
279 const glsl_type
*get_scalar_type() const;
282 * Gets the "bare" type without any decorations or layout information.
284 const glsl_type
*get_bare_type() const;
287 * Get the instance of a built-in scalar, vector, or matrix type
289 static const glsl_type
*get_instance(unsigned base_type
, unsigned rows
,
291 unsigned explicit_stride
= 0,
292 bool row_major
= false);
295 * Get the instance of a sampler type
297 static const glsl_type
*get_sampler_instance(enum glsl_sampler_dim dim
,
300 glsl_base_type type
);
302 static const glsl_type
*get_image_instance(enum glsl_sampler_dim dim
,
303 bool array
, glsl_base_type type
);
306 * Get the instance of an array type
308 static const glsl_type
*get_array_instance(const glsl_type
*base
,
310 unsigned explicit_stride
= 0);
313 * Get the instance of a record type
315 static const glsl_type
*get_record_instance(const glsl_struct_field
*fields
,
320 * Get the instance of an interface block type
322 static const glsl_type
*get_interface_instance(const glsl_struct_field
*fields
,
324 enum glsl_interface_packing packing
,
326 const char *block_name
);
329 * Get the instance of an subroutine type
331 static const glsl_type
*get_subroutine_instance(const char *subroutine_name
);
334 * Get the instance of a function type
336 static const glsl_type
*get_function_instance(const struct glsl_type
*return_type
,
337 const glsl_function_param
*parameters
,
338 unsigned num_params
);
341 * Get the type resulting from a multiplication of \p type_a * \p type_b
343 static const glsl_type
*get_mul_type(const glsl_type
*type_a
,
344 const glsl_type
*type_b
);
347 * Query the total number of scalars that make up a scalar, vector or matrix
349 unsigned components() const
351 return vector_elements
* matrix_columns
;
355 * Calculate the number of components slots required to hold this type
357 * This is used to determine how many uniform or varying locations a type
360 unsigned component_slots() const;
363 * Calculate offset between the base location of the struct in
364 * uniform storage and a struct member.
365 * For the initial call, length is the index of the member to find the
368 unsigned record_location_offset(unsigned length
) const;
371 * Calculate the number of unique values from glGetUniformLocation for the
372 * elements of the type.
374 * This is used to allocate slots in the UniformRemapTable, the amount of
375 * locations may not match with actual used storage space by the driver.
377 unsigned uniform_locations() const;
380 * Used to count the number of varyings contained in the type ignoring
381 * innermost array elements.
383 unsigned varying_count() const;
386 * Calculate the number of attribute slots required to hold this type
388 * This implements the language rules of GLSL 1.50 for counting the number
389 * of slots used by a vertex attribute. It also determines the number of
390 * varying slots the type will use up in the absence of varying packing
391 * (and thus, it can be used to measure the number of varying slots used by
392 * the varyings that are generated by lower_packed_varyings).
394 * For vertex shader attributes - doubles only take one slot.
395 * For inter-shader varyings - dvec3/dvec4 take two slots.
397 unsigned count_attribute_slots(bool is_vertex_input
) const;
400 * Alignment in bytes of the start of this type in a std140 uniform
403 unsigned std140_base_alignment(bool row_major
) const;
405 /** Size in bytes of this type in a std140 uniform block.
407 * Note that this is not GL_UNIFORM_SIZE (which is the number of
408 * elements in the array)
410 unsigned std140_size(bool row_major
) const;
413 * Alignment in bytes of the start of this type in a std430 shader
416 unsigned std430_base_alignment(bool row_major
) const;
419 * Calculate array stride in bytes of this type in a std430 shader storage
422 unsigned std430_array_stride(bool row_major
) const;
425 * Size in bytes of this type in a std430 shader storage block.
427 * Note that this is not GL_BUFFER_SIZE
429 unsigned std430_size(bool row_major
) const;
432 * \brief Can this type be implicitly converted to another?
434 * \return True if the types are identical or if this type can be converted
435 * to \c desired according to Section 4.1.10 of the GLSL spec.
438 * From page 25 (31 of the pdf) of the GLSL 1.50 spec, Section 4.1.10
439 * Implicit Conversions:
441 * In some situations, an expression and its type will be implicitly
442 * converted to a different type. The following table shows all allowed
443 * implicit conversions:
445 * Type of expression | Can be implicitly converted to
446 * --------------------------------------------------
459 * There are no implicit array or structure conversions. For example,
460 * an array of int cannot be implicitly converted to an array of float.
461 * There are no implicit conversions between signed and unsigned
465 bool can_implicitly_convert_to(const glsl_type
*desired
,
466 _mesa_glsl_parse_state
*state
) const;
469 * Query whether or not a type is a scalar (non-vector and non-matrix).
471 bool is_scalar() const
473 return (vector_elements
== 1)
474 && (base_type
>= GLSL_TYPE_UINT
)
475 && (base_type
<= GLSL_TYPE_IMAGE
);
479 * Query whether or not a type is a vector
481 bool is_vector() const
483 return (vector_elements
> 1)
484 && (matrix_columns
== 1)
485 && (base_type
>= GLSL_TYPE_UINT
)
486 && (base_type
<= GLSL_TYPE_BOOL
);
490 * Query whether or not a type is a matrix
492 bool is_matrix() const
494 /* GLSL only has float matrices. */
495 return (matrix_columns
> 1) && (base_type
== GLSL_TYPE_FLOAT
||
496 base_type
== GLSL_TYPE_DOUBLE
||
497 base_type
== GLSL_TYPE_FLOAT16
);
501 * Query whether or not a type is a non-array numeric type
503 bool is_numeric() const
505 return (base_type
>= GLSL_TYPE_UINT
) && (base_type
<= GLSL_TYPE_INT64
);
509 * Query whether or not a type is an integral type
511 bool is_integer() const
513 return (base_type
== GLSL_TYPE_UINT
) || (base_type
== GLSL_TYPE_INT
);
517 * Query whether or not a type is a 64-bit integer.
519 bool is_integer_64() const
521 return base_type
== GLSL_TYPE_UINT64
|| base_type
== GLSL_TYPE_INT64
;
525 * Query whether or not a type is a 32-bit or 64-bit integer
527 bool is_integer_32_64() const
529 return is_integer() || is_integer_64();
533 * Query whether or not type is an integral type, or for struct and array
534 * types, contains an integral type.
536 bool contains_integer() const;
539 * Query whether or not type is a double type, or for struct, interface and
540 * array types, contains a double type.
542 bool contains_double() const;
545 * Query whether or not a type is a float type
547 bool is_float() const
549 return base_type
== GLSL_TYPE_FLOAT
;
553 * Query whether or not a type is a double type
555 bool is_double() const
557 return base_type
== GLSL_TYPE_DOUBLE
;
561 * Query whether a 64-bit type takes two slots.
563 bool is_dual_slot() const
565 return is_64bit() && vector_elements
> 2;
569 * Query whether or not a type is 64-bit
571 bool is_64bit() const
573 return glsl_base_type_is_64bit(base_type
);
577 * Query whether or not a type is 16-bit
579 bool is_16bit() const
581 return glsl_base_type_is_16bit(base_type
);
585 * Query whether or not a type is a non-array boolean type
587 bool is_boolean() const
589 return base_type
== GLSL_TYPE_BOOL
;
593 * Query whether or not a type is a sampler
595 bool is_sampler() const
597 return base_type
== GLSL_TYPE_SAMPLER
;
601 * Query whether or not type is a sampler, or for struct, interface and
602 * array types, contains a sampler.
604 bool contains_sampler() const;
607 * Query whether or not type is an array or for struct, interface and
608 * array types, contains an array.
610 bool contains_array() const;
613 * Get the Mesa texture target index for a sampler type.
615 gl_texture_index
sampler_index() const;
618 * Query whether or not type is an image, or for struct, interface and
619 * array types, contains an image.
621 bool contains_image() const;
624 * Query whether or not a type is an image
626 bool is_image() const
628 return base_type
== GLSL_TYPE_IMAGE
;
632 * Query whether or not a type is an array
634 bool is_array() const
636 return base_type
== GLSL_TYPE_ARRAY
;
639 bool is_array_of_arrays() const
641 return is_array() && fields
.array
->is_array();
645 * Query whether or not a type is a record
647 bool is_record() const
649 return base_type
== GLSL_TYPE_STRUCT
;
653 * Query whether or not a type is an interface
655 bool is_interface() const
657 return base_type
== GLSL_TYPE_INTERFACE
;
661 * Query whether or not a type is the void type singleton.
665 return base_type
== GLSL_TYPE_VOID
;
669 * Query whether or not a type is the error type singleton.
671 bool is_error() const
673 return base_type
== GLSL_TYPE_ERROR
;
677 * Query if a type is unnamed/anonymous (named by the parser)
680 bool is_subroutine() const
682 return base_type
== GLSL_TYPE_SUBROUTINE
;
684 bool contains_subroutine() const;
686 bool is_anonymous() const
688 return !strncmp(name
, "#anon", 5);
692 * Get the type stripped of any arrays
695 * Pointer to the type of elements of the first non-array type for array
696 * types, or pointer to itself for non-array types.
698 const glsl_type
*without_array() const
700 const glsl_type
*t
= this;
702 while (t
->is_array())
709 * Return the total number of elements in an array including the elements
710 * in arrays of arrays.
712 unsigned arrays_of_arrays_size() const
717 unsigned size
= length
;
718 const glsl_type
*base_type
= fields
.array
;
720 while (base_type
->is_array()) {
721 size
= size
* base_type
->length
;
722 base_type
= base_type
->fields
.array
;
728 * Query whether or not a type is an atomic_uint.
730 bool is_atomic_uint() const
732 return base_type
== GLSL_TYPE_ATOMIC_UINT
;
736 * Return the amount of atomic counter storage required for a type.
738 unsigned atomic_size() const
740 if (is_atomic_uint())
741 return ATOMIC_COUNTER_SIZE
;
743 return length
* fields
.array
->atomic_size();
749 * Return whether a type contains any atomic counters.
751 bool contains_atomic() const
753 return atomic_size() > 0;
757 * Return whether a type contains any opaque types.
759 bool contains_opaque() const;
762 * Query the full type of a matrix row
765 * If the type is not a matrix, \c glsl_type::error_type is returned.
766 * Otherwise a type matching the rows of the matrix is returned.
768 const glsl_type
*row_type() const
773 if (explicit_stride
&& !interface_row_major
)
774 return get_instance(base_type
, matrix_columns
, 1, explicit_stride
);
776 return get_instance(base_type
, matrix_columns
, 1);
780 * Query the full type of a matrix column
783 * If the type is not a matrix, \c glsl_type::error_type is returned.
784 * Otherwise a type matching the columns of the matrix is returned.
786 const glsl_type
*column_type() const
791 if (explicit_stride
&& interface_row_major
)
792 return get_instance(base_type
, vector_elements
, 1, explicit_stride
);
794 return get_instance(base_type
, vector_elements
, 1);
798 * Get the type of a structure field
801 * Pointer to the type of the named field. If the type is not a structure
802 * or the named field does not exist, \c glsl_type::error_type is returned.
804 const glsl_type
*field_type(const char *name
) const;
807 * Get the location of a field within a record type
809 int field_index(const char *name
) const;
812 * Query the number of elements in an array type
815 * The number of elements in the array for array types or -1 for non-array
816 * types. If the number of elements in the array has not yet been declared,
819 int array_size() const
821 return is_array() ? length
: -1;
825 * Query whether the array size for all dimensions has been declared.
827 bool is_unsized_array() const
829 return is_array() && length
== 0;
833 * Return the number of coordinate components needed for this
834 * sampler or image type.
836 * This is based purely on the sampler's dimensionality. For example, this
837 * returns 1 for sampler1D, and 3 for sampler2DArray.
839 * Note that this is often different than actual coordinate type used in
840 * a texturing built-in function, since those pack additional values (such
841 * as the shadow comparator or projector) into the coordinate type.
843 int coordinate_components() const;
846 * Compare a record type against another record type.
848 * This is useful for matching record types declared across shader stages.
849 * The option to not match locations is to deal with places where the
850 * same struct is defined in a block which has a location set on it.
852 bool record_compare(const glsl_type
*b
, bool match_locations
= true) const;
855 * Get the type interface packing.
857 enum glsl_interface_packing
get_interface_packing() const
859 return (enum glsl_interface_packing
)interface_packing
;
863 * Get the type interface packing used internally. For shared and packing
864 * layouts this is implementation defined.
866 enum glsl_interface_packing
get_internal_ifc_packing(bool std430_supported
) const
868 enum glsl_interface_packing packing
= this->get_interface_packing();
869 if (packing
== GLSL_INTERFACE_PACKING_STD140
||
870 (!std430_supported
&&
871 (packing
== GLSL_INTERFACE_PACKING_SHARED
||
872 packing
== GLSL_INTERFACE_PACKING_PACKED
))) {
873 return GLSL_INTERFACE_PACKING_STD140
;
875 assert(packing
== GLSL_INTERFACE_PACKING_STD430
||
877 (packing
== GLSL_INTERFACE_PACKING_SHARED
||
878 packing
== GLSL_INTERFACE_PACKING_PACKED
)));
879 return GLSL_INTERFACE_PACKING_STD430
;
884 * Check if the type interface is row major
886 bool get_interface_row_major() const
888 return (bool) interface_row_major
;
895 static mtx_t hash_mutex
;
898 * ralloc context for the type itself.
902 /** Constructor for vector and matrix types */
903 glsl_type(GLenum gl_type
,
904 glsl_base_type base_type
, unsigned vector_elements
,
905 unsigned matrix_columns
, const char *name
,
906 unsigned explicit_stride
= 0, bool row_major
= false);
908 /** Constructor for sampler or image types */
909 glsl_type(GLenum gl_type
, glsl_base_type base_type
,
910 enum glsl_sampler_dim dim
, bool shadow
, bool array
,
911 glsl_base_type type
, const char *name
);
913 /** Constructor for record types */
914 glsl_type(const glsl_struct_field
*fields
, unsigned num_fields
,
917 /** Constructor for interface types */
918 glsl_type(const glsl_struct_field
*fields
, unsigned num_fields
,
919 enum glsl_interface_packing packing
,
920 bool row_major
, const char *name
);
922 /** Constructor for interface types */
923 glsl_type(const glsl_type
*return_type
,
924 const glsl_function_param
*params
, unsigned num_params
);
926 /** Constructors for array types */
927 glsl_type(const glsl_type
*array
, unsigned length
, unsigned explicit_stride
);
929 /** Constructor for subroutine types */
930 glsl_type(const char *name
);
932 /** Hash table containing the known explicit matrix and vector types. */
933 static struct hash_table
*explicit_matrix_types
;
935 /** Hash table containing the known array types. */
936 static struct hash_table
*array_types
;
938 /** Hash table containing the known record types. */
939 static struct hash_table
*record_types
;
941 /** Hash table containing the known interface types. */
942 static struct hash_table
*interface_types
;
944 /** Hash table containing the known subroutine types. */
945 static struct hash_table
*subroutine_types
;
947 /** Hash table containing the known function types. */
948 static struct hash_table
*function_types
;
950 static bool record_key_compare(const void *a
, const void *b
);
951 static unsigned record_key_hash(const void *key
);
954 * \name Built-in type flyweights
958 #define DECL_TYPE(NAME, ...) static const glsl_type _##NAME##_type;
960 #define STRUCT_TYPE(NAME) static const glsl_type _struct_##NAME##_type;
961 #include "compiler/builtin_type_macros.h"
965 * \name Friend functions.
967 * These functions are friends because they must have C linkage and the
968 * need to call various private methods or access various private static
972 friend void _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state
*);
973 friend void _mesa_glsl_release_types(void);
979 #endif /* __cplusplus */
981 struct glsl_struct_field
{
982 const struct glsl_type
*type
;
986 * For interface blocks, gl_varying_slot corresponding to the input/output
987 * if this is a built-in input/output (i.e. a member of the built-in
988 * gl_PerVertex interface block); -1 otherwise.
990 * Ignored for structs.
995 * For interface blocks, members may have an explicit byte offset
996 * specified; -1 otherwise. Also used for xfb_offset layout qualifier.
998 * Unless used for xfb_offset this field is ignored for structs.
1003 * For interface blocks, members may define a transform feedback buffer;
1009 * For interface blocks, members may define a transform feedback stride;
1015 * For interface blocks, the interpolation mode (as in
1016 * ir_variable::interpolation). 0 otherwise.
1018 unsigned interpolation
:2;
1021 * For interface blocks, 1 if this variable uses centroid interpolation (as
1022 * in ir_variable::centroid). 0 otherwise.
1024 unsigned centroid
:1;
1027 * For interface blocks, 1 if this variable uses sample interpolation (as
1028 * in ir_variable::sample). 0 otherwise.
1033 * Layout of the matrix. Uses glsl_matrix_layout values.
1035 unsigned matrix_layout
:2;
1038 * For interface blocks, 1 if this variable is a per-patch input or output
1039 * (as in ir_variable::patch). 0 otherwise.
1044 * Precision qualifier
1046 unsigned precision
:2;
1049 * Memory qualifiers, applicable to buffer variables defined in shader
1050 * storage buffer objects (SSBOs)
1052 unsigned memory_read_only
:1;
1053 unsigned memory_write_only
:1;
1054 unsigned memory_coherent
:1;
1055 unsigned memory_volatile
:1;
1056 unsigned memory_restrict
:1;
1059 * Layout format, applicable to image variables only.
1061 unsigned image_format
:16;
1064 * Any of the xfb_* qualifiers trigger the shader to be in transform
1065 * feedback mode so we need to keep track of whether the buffer was
1066 * explicitly set or if its just been assigned the default global value.
1068 unsigned explicit_xfb_buffer
:1;
1070 unsigned implicit_sized_array
:1;
1072 glsl_struct_field(const struct glsl_type
*_type
, const char *_name
)
1073 : type(_type
), name(_name
), location(-1), offset(0), xfb_buffer(0),
1074 xfb_stride(0), interpolation(0), centroid(0),
1075 sample(0), matrix_layout(GLSL_MATRIX_LAYOUT_INHERITED
), patch(0),
1076 precision(GLSL_PRECISION_NONE
), memory_read_only(0),
1077 memory_write_only(0), memory_coherent(0), memory_volatile(0),
1078 memory_restrict(0), image_format(0), explicit_xfb_buffer(0),
1079 implicit_sized_array(0)
1085 : type(NULL
), name(NULL
), location(0), offset(0), xfb_buffer(0),
1086 xfb_stride(0), interpolation(0), centroid(0),
1087 sample(0), matrix_layout(0), patch(0),
1088 precision(0), memory_read_only(0),
1089 memory_write_only(0), memory_coherent(0), memory_volatile(0),
1090 memory_restrict(0), image_format(0), explicit_xfb_buffer(0),
1091 implicit_sized_array(0)
1098 struct glsl_function_param
{
1099 const struct glsl_type
*type
;
1105 static inline unsigned int
1106 glsl_align(unsigned int a
, unsigned int align
)
1108 return (a
+ align
- 1) / align
* align
;
1111 #endif /* GLSL_TYPES_H */