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 * For \c GLSL_TYPE_STRUCT this specifies if the struct is packed or not.
182 * Only used for Compute kernels
187 glsl_type() : mem_ctx(NULL
)
189 // Dummy constructor, just for the sake of ASSERT_BITFIELD_SIZE.
194 * \name Vector and matrix element counts
196 * For scalars, each of these values will be 1. For non-numeric types
200 uint8_t vector_elements
; /**< 1, 2, 3, or 4 vector elements. */
201 uint8_t matrix_columns
; /**< 1, 2, 3, or 4 matrix columns. */
205 * For \c GLSL_TYPE_ARRAY, this is the length of the array. For
206 * \c GLSL_TYPE_STRUCT or \c GLSL_TYPE_INTERFACE, it is the number of
207 * elements in the structure and the number of values pointed to by
208 * \c fields.structure (below).
213 * Name of the data type
215 * Will never be \c NULL.
220 * Explicit array, matrix, or vector stride. This is used to communicate
221 * explicit array layouts from SPIR-V. Should be 0 if the type has no
224 unsigned explicit_stride
;
227 * Subtype of composite data types.
230 const struct glsl_type
*array
; /**< Type of array elements. */
231 struct glsl_function_param
*parameters
; /**< Parameters to function. */
232 struct glsl_struct_field
*structure
; /**< List of struct fields. */
236 * \name Pointers to various public type singletons
240 #define DECL_TYPE(NAME, ...) \
241 static const glsl_type *const NAME##_type;
243 #define STRUCT_TYPE(NAME) \
244 static const glsl_type *const struct_##NAME##_type;
245 #include "compiler/builtin_type_macros.h"
249 * Convenience accessors for vector types (shorter than get_instance()).
252 static const glsl_type
*vec(unsigned components
, const glsl_type
*const ts
[]);
253 static const glsl_type
*vec(unsigned components
);
254 static const glsl_type
*f16vec(unsigned components
);
255 static const glsl_type
*dvec(unsigned components
);
256 static const glsl_type
*ivec(unsigned components
);
257 static const glsl_type
*uvec(unsigned components
);
258 static const glsl_type
*bvec(unsigned components
);
259 static const glsl_type
*i64vec(unsigned components
);
260 static const glsl_type
*u64vec(unsigned components
);
261 static const glsl_type
*i16vec(unsigned components
);
262 static const glsl_type
*u16vec(unsigned components
);
263 static const glsl_type
*i8vec(unsigned components
);
264 static const glsl_type
*u8vec(unsigned components
);
268 * For numeric and boolean derived types returns the basic scalar type
270 * If the type is a numeric or boolean scalar, vector, or matrix type,
271 * this function gets the scalar type of the individual components. For
272 * all other types, including arrays of numeric or boolean types, the
273 * error type is returned.
275 const glsl_type
*get_base_type() const;
278 * Get the basic scalar type which this type aggregates.
280 * If the type is a numeric or boolean scalar, vector, or matrix, or an
281 * array of any of those, this function gets the scalar type of the
282 * individual components. For structs and arrays of structs, this function
283 * returns the struct type. For samplers and arrays of samplers, this
284 * function returns the sampler type.
286 const glsl_type
*get_scalar_type() const;
289 * Gets the "bare" type without any decorations or layout information.
291 const glsl_type
*get_bare_type() const;
294 * Get the instance of a built-in scalar, vector, or matrix type
296 static const glsl_type
*get_instance(unsigned base_type
, unsigned rows
,
298 unsigned explicit_stride
= 0,
299 bool row_major
= false);
302 * Get the instance of a sampler type
304 static const glsl_type
*get_sampler_instance(enum glsl_sampler_dim dim
,
307 glsl_base_type type
);
309 static const glsl_type
*get_image_instance(enum glsl_sampler_dim dim
,
310 bool array
, glsl_base_type type
);
313 * Get the instance of an array type
315 static const glsl_type
*get_array_instance(const glsl_type
*base
,
317 unsigned explicit_stride
= 0);
320 * Get the instance of a record type
322 static const glsl_type
*get_struct_instance(const glsl_struct_field
*fields
,
325 bool packed
= false);
328 * Get the instance of an interface block type
330 static const glsl_type
*get_interface_instance(const glsl_struct_field
*fields
,
332 enum glsl_interface_packing packing
,
334 const char *block_name
);
337 * Get the instance of an subroutine type
339 static const glsl_type
*get_subroutine_instance(const char *subroutine_name
);
342 * Get the instance of a function type
344 static const glsl_type
*get_function_instance(const struct glsl_type
*return_type
,
345 const glsl_function_param
*parameters
,
346 unsigned num_params
);
349 * Get the type resulting from a multiplication of \p type_a * \p type_b
351 static const glsl_type
*get_mul_type(const glsl_type
*type_a
,
352 const glsl_type
*type_b
);
355 * Query the total number of scalars that make up a scalar, vector or matrix
357 unsigned components() const
359 return vector_elements
* matrix_columns
;
363 * Calculate the number of components slots required to hold this type
365 * This is used to determine how many uniform or varying locations a type
368 unsigned component_slots() const;
371 * Calculate offset between the base location of the struct in
372 * uniform storage and a struct member.
373 * For the initial call, length is the index of the member to find the
376 unsigned struct_location_offset(unsigned length
) const;
379 * Calculate the number of unique values from glGetUniformLocation for the
380 * elements of the type.
382 * This is used to allocate slots in the UniformRemapTable, the amount of
383 * locations may not match with actual used storage space by the driver.
385 unsigned uniform_locations() const;
388 * Used to count the number of varyings contained in the type ignoring
389 * innermost array elements.
391 unsigned varying_count() const;
394 * Calculate the number of attribute slots required to hold this type
396 * This implements the language rules of GLSL 1.50 for counting the number
397 * of slots used by a vertex attribute. It also determines the number of
398 * varying slots the type will use up in the absence of varying packing
399 * (and thus, it can be used to measure the number of varying slots used by
400 * the varyings that are generated by lower_packed_varyings).
402 * For vertex shader attributes - doubles only take one slot.
403 * For inter-shader varyings - dvec3/dvec4 take two slots.
405 * Vulkan doesn’t make this distinction so the argument should always be
408 unsigned count_attribute_slots(bool is_gl_vertex_input
) const;
411 * Alignment in bytes of the start of this type in a std140 uniform
414 unsigned std140_base_alignment(bool row_major
) const;
416 /** Size in bytes of this type in a std140 uniform block.
418 * Note that this is not GL_UNIFORM_SIZE (which is the number of
419 * elements in the array)
421 unsigned std140_size(bool row_major
) const;
424 * Gets an explicitly laid out type with the std140 layout.
426 const glsl_type
*get_explicit_std140_type(bool row_major
) const;
429 * Alignment in bytes of the start of this type in a std430 shader
432 unsigned std430_base_alignment(bool row_major
) const;
435 * Calculate array stride in bytes of this type in a std430 shader storage
438 unsigned std430_array_stride(bool row_major
) const;
441 * Size in bytes of this type in a std430 shader storage block.
443 * Note that this is not GL_BUFFER_SIZE
445 unsigned std430_size(bool row_major
) const;
448 * Gets an explicitly laid out type with the std430 layout.
450 const glsl_type
*get_explicit_std430_type(bool row_major
) const;
453 * Gets an explicitly laid out interface type.
455 const glsl_type
*get_explicit_interface_type(bool supports_std430
) const;
458 * \brief Can this type be implicitly converted to another?
460 * \return True if the types are identical or if this type can be converted
461 * to \c desired according to Section 4.1.10 of the GLSL spec.
464 * From page 25 (31 of the pdf) of the GLSL 1.50 spec, Section 4.1.10
465 * Implicit Conversions:
467 * In some situations, an expression and its type will be implicitly
468 * converted to a different type. The following table shows all allowed
469 * implicit conversions:
471 * Type of expression | Can be implicitly converted to
472 * --------------------------------------------------
485 * There are no implicit array or structure conversions. For example,
486 * an array of int cannot be implicitly converted to an array of float.
487 * There are no implicit conversions between signed and unsigned
491 bool can_implicitly_convert_to(const glsl_type
*desired
,
492 _mesa_glsl_parse_state
*state
) const;
495 * Query whether or not a type is a scalar (non-vector and non-matrix).
497 bool is_scalar() const
499 return (vector_elements
== 1)
500 && (base_type
>= GLSL_TYPE_UINT
)
501 && (base_type
<= GLSL_TYPE_IMAGE
);
505 * Query whether or not a type is a vector
507 bool is_vector() const
509 return (vector_elements
> 1)
510 && (matrix_columns
== 1)
511 && (base_type
>= GLSL_TYPE_UINT
)
512 && (base_type
<= GLSL_TYPE_BOOL
);
516 * Query whether or not a type is a matrix
518 bool is_matrix() const
520 /* GLSL only has float matrices. */
521 return (matrix_columns
> 1) && (base_type
== GLSL_TYPE_FLOAT
||
522 base_type
== GLSL_TYPE_DOUBLE
||
523 base_type
== GLSL_TYPE_FLOAT16
);
527 * Query whether or not a type is a non-array numeric type
529 bool is_numeric() const
531 return (base_type
>= GLSL_TYPE_UINT
) && (base_type
<= GLSL_TYPE_INT64
);
535 * Query whether or not a type is an integral type
537 bool is_integer() const
539 return (base_type
== GLSL_TYPE_UINT
) || (base_type
== GLSL_TYPE_INT
);
543 * Query whether or not a type is a 64-bit integer.
545 bool is_integer_64() const
547 return base_type
== GLSL_TYPE_UINT64
|| base_type
== GLSL_TYPE_INT64
;
551 * Query whether or not a type is a 32-bit or 64-bit integer
553 bool is_integer_32_64() const
555 return is_integer() || is_integer_64();
559 * Query whether or not type is an integral type, or for struct and array
560 * types, contains an integral type.
562 bool contains_integer() const;
565 * Query whether or not type is a double type, or for struct, interface and
566 * array types, contains a double type.
568 bool contains_double() const;
571 * Query whether or not type is a 64-bit type, or for struct, interface and
572 * array types, contains a double type.
574 bool contains_64bit() const;
577 * Query whether or not a type is a float type
579 bool is_float() const
581 return base_type
== GLSL_TYPE_FLOAT
;
585 * Query whether or not a type is a double type
587 bool is_double() const
589 return base_type
== GLSL_TYPE_DOUBLE
;
593 * Query whether a 64-bit type takes two slots.
595 bool is_dual_slot() const
597 return is_64bit() && vector_elements
> 2;
601 * Query whether or not a type is 64-bit
603 bool is_64bit() const
605 return glsl_base_type_is_64bit(base_type
);
609 * Query whether or not a type is 16-bit
611 bool is_16bit() const
613 return glsl_base_type_is_16bit(base_type
);
617 * Query whether or not a type is 32-bit
619 bool is_32bit() const
621 return base_type
== GLSL_TYPE_UINT
||
622 base_type
== GLSL_TYPE_INT
||
623 base_type
== GLSL_TYPE_FLOAT
;
627 * Query whether or not a type is a non-array boolean type
629 bool is_boolean() const
631 return base_type
== GLSL_TYPE_BOOL
;
635 * Query whether or not a type is a sampler
637 bool is_sampler() const
639 return base_type
== GLSL_TYPE_SAMPLER
;
643 * Query whether or not type is a sampler, or for struct, interface and
644 * array types, contains a sampler.
646 bool contains_sampler() const;
649 * Query whether or not type is an array or for struct, interface and
650 * array types, contains an array.
652 bool contains_array() const;
655 * Get the Mesa texture target index for a sampler type.
657 gl_texture_index
sampler_index() const;
660 * Query whether or not type is an image, or for struct, interface and
661 * array types, contains an image.
663 bool contains_image() const;
666 * Query whether or not a type is an image
668 bool is_image() const
670 return base_type
== GLSL_TYPE_IMAGE
;
674 * Query whether or not a type is an array
676 bool is_array() const
678 return base_type
== GLSL_TYPE_ARRAY
;
681 bool is_array_of_arrays() const
683 return is_array() && fields
.array
->is_array();
687 * Query whether or not a type is a record
689 bool is_struct() const
691 return base_type
== GLSL_TYPE_STRUCT
;
695 * Query whether or not a type is an interface
697 bool is_interface() const
699 return base_type
== GLSL_TYPE_INTERFACE
;
703 * Query whether or not a type is the void type singleton.
707 return base_type
== GLSL_TYPE_VOID
;
711 * Query whether or not a type is the error type singleton.
713 bool is_error() const
715 return base_type
== GLSL_TYPE_ERROR
;
719 * Query if a type is unnamed/anonymous (named by the parser)
722 bool is_subroutine() const
724 return base_type
== GLSL_TYPE_SUBROUTINE
;
726 bool contains_subroutine() const;
728 bool is_anonymous() const
730 return !strncmp(name
, "#anon", 5);
734 * Get the type stripped of any arrays
737 * Pointer to the type of elements of the first non-array type for array
738 * types, or pointer to itself for non-array types.
740 const glsl_type
*without_array() const
742 const glsl_type
*t
= this;
744 while (t
->is_array())
751 * Return the total number of elements in an array including the elements
752 * in arrays of arrays.
754 unsigned arrays_of_arrays_size() const
759 unsigned size
= length
;
760 const glsl_type
*base_type
= fields
.array
;
762 while (base_type
->is_array()) {
763 size
= size
* base_type
->length
;
764 base_type
= base_type
->fields
.array
;
770 * Query whether or not a type is an atomic_uint.
772 bool is_atomic_uint() const
774 return base_type
== GLSL_TYPE_ATOMIC_UINT
;
778 * Return the amount of atomic counter storage required for a type.
780 unsigned atomic_size() const
782 if (is_atomic_uint())
783 return ATOMIC_COUNTER_SIZE
;
785 return length
* fields
.array
->atomic_size();
791 * Return whether a type contains any atomic counters.
793 bool contains_atomic() const
795 return atomic_size() > 0;
799 * Return whether a type contains any opaque types.
801 bool contains_opaque() const;
804 * Query the full type of a matrix row
807 * If the type is not a matrix, \c glsl_type::error_type is returned.
808 * Otherwise a type matching the rows of the matrix is returned.
810 const glsl_type
*row_type() const
815 if (explicit_stride
&& !interface_row_major
)
816 return get_instance(base_type
, matrix_columns
, 1, explicit_stride
);
818 return get_instance(base_type
, matrix_columns
, 1);
822 * Query the full type of a matrix column
825 * If the type is not a matrix, \c glsl_type::error_type is returned.
826 * Otherwise a type matching the columns of the matrix is returned.
828 const glsl_type
*column_type() const
833 if (explicit_stride
&& interface_row_major
)
834 return get_instance(base_type
, vector_elements
, 1, explicit_stride
);
836 return get_instance(base_type
, vector_elements
, 1);
840 * Get the type of a structure field
843 * Pointer to the type of the named field. If the type is not a structure
844 * or the named field does not exist, \c glsl_type::error_type is returned.
846 const glsl_type
*field_type(const char *name
) const;
849 * Get the location of a field within a record type
851 int field_index(const char *name
) const;
854 * Query the number of elements in an array type
857 * The number of elements in the array for array types or -1 for non-array
858 * types. If the number of elements in the array has not yet been declared,
861 int array_size() const
863 return is_array() ? length
: -1;
867 * Query whether the array size for all dimensions has been declared.
869 bool is_unsized_array() const
871 return is_array() && length
== 0;
875 * Return the number of coordinate components needed for this
876 * sampler or image type.
878 * This is based purely on the sampler's dimensionality. For example, this
879 * returns 1 for sampler1D, and 3 for sampler2DArray.
881 * Note that this is often different than actual coordinate type used in
882 * a texturing built-in function, since those pack additional values (such
883 * as the shadow comparator or projector) into the coordinate type.
885 int coordinate_components() const;
888 * Compare a record type against another record type.
890 * This is useful for matching record types declared across shader stages.
891 * The option to not match locations is to deal with places where the
892 * same struct is defined in a block which has a location set on it.
894 bool record_compare(const glsl_type
*b
, bool match_locations
= true) const;
897 * Get the type interface packing.
899 enum glsl_interface_packing
get_interface_packing() const
901 return (enum glsl_interface_packing
)interface_packing
;
905 * Get the type interface packing used internally. For shared and packing
906 * layouts this is implementation defined.
908 enum glsl_interface_packing
get_internal_ifc_packing(bool std430_supported
) const
910 enum glsl_interface_packing packing
= this->get_interface_packing();
911 if (packing
== GLSL_INTERFACE_PACKING_STD140
||
912 (!std430_supported
&&
913 (packing
== GLSL_INTERFACE_PACKING_SHARED
||
914 packing
== GLSL_INTERFACE_PACKING_PACKED
))) {
915 return GLSL_INTERFACE_PACKING_STD140
;
917 assert(packing
== GLSL_INTERFACE_PACKING_STD430
||
919 (packing
== GLSL_INTERFACE_PACKING_SHARED
||
920 packing
== GLSL_INTERFACE_PACKING_PACKED
)));
921 return GLSL_INTERFACE_PACKING_STD430
;
926 * Check if the type interface is row major
928 bool get_interface_row_major() const
930 return (bool) interface_row_major
;
937 static mtx_t hash_mutex
;
940 * ralloc context for the type itself.
944 /** Constructor for vector and matrix types */
945 glsl_type(GLenum gl_type
,
946 glsl_base_type base_type
, unsigned vector_elements
,
947 unsigned matrix_columns
, const char *name
,
948 unsigned explicit_stride
= 0, bool row_major
= false);
950 /** Constructor for sampler or image types */
951 glsl_type(GLenum gl_type
, glsl_base_type base_type
,
952 enum glsl_sampler_dim dim
, bool shadow
, bool array
,
953 glsl_base_type type
, const char *name
);
955 /** Constructor for record types */
956 glsl_type(const glsl_struct_field
*fields
, unsigned num_fields
,
957 const char *name
, bool packed
= false);
959 /** Constructor for interface types */
960 glsl_type(const glsl_struct_field
*fields
, unsigned num_fields
,
961 enum glsl_interface_packing packing
,
962 bool row_major
, const char *name
);
964 /** Constructor for interface types */
965 glsl_type(const glsl_type
*return_type
,
966 const glsl_function_param
*params
, unsigned num_params
);
968 /** Constructors for array types */
969 glsl_type(const glsl_type
*array
, unsigned length
, unsigned explicit_stride
);
971 /** Constructor for subroutine types */
972 glsl_type(const char *name
);
974 /** Hash table containing the known explicit matrix and vector types. */
975 static struct hash_table
*explicit_matrix_types
;
977 /** Hash table containing the known array types. */
978 static struct hash_table
*array_types
;
980 /** Hash table containing the known struct types. */
981 static struct hash_table
*struct_types
;
983 /** Hash table containing the known interface types. */
984 static struct hash_table
*interface_types
;
986 /** Hash table containing the known subroutine types. */
987 static struct hash_table
*subroutine_types
;
989 /** Hash table containing the known function types. */
990 static struct hash_table
*function_types
;
992 static bool record_key_compare(const void *a
, const void *b
);
993 static unsigned record_key_hash(const void *key
);
996 * \name Built-in type flyweights
1000 #define DECL_TYPE(NAME, ...) static const glsl_type _##NAME##_type;
1002 #define STRUCT_TYPE(NAME) static const glsl_type _struct_##NAME##_type;
1003 #include "compiler/builtin_type_macros.h"
1007 * \name Friend functions.
1009 * These functions are friends because they must have C linkage and the
1010 * need to call various private methods or access various private static
1014 friend void _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state
*);
1015 friend void _mesa_glsl_release_types(void);
1021 #endif /* __cplusplus */
1023 struct glsl_struct_field
{
1024 const struct glsl_type
*type
;
1028 * For interface blocks, gl_varying_slot corresponding to the input/output
1029 * if this is a built-in input/output (i.e. a member of the built-in
1030 * gl_PerVertex interface block); -1 otherwise.
1032 * Ignored for structs.
1037 * For interface blocks, members may have an explicit byte offset
1038 * specified; -1 otherwise. Also used for xfb_offset layout qualifier.
1040 * Unless used for xfb_offset this field is ignored for structs.
1045 * For interface blocks, members may define a transform feedback buffer;
1051 * For interface blocks, members may define a transform feedback stride;
1057 * For interface blocks, the interpolation mode (as in
1058 * ir_variable::interpolation). 0 otherwise.
1060 unsigned interpolation
:2;
1063 * For interface blocks, 1 if this variable uses centroid interpolation (as
1064 * in ir_variable::centroid). 0 otherwise.
1066 unsigned centroid
:1;
1069 * For interface blocks, 1 if this variable uses sample interpolation (as
1070 * in ir_variable::sample). 0 otherwise.
1075 * Layout of the matrix. Uses glsl_matrix_layout values.
1077 unsigned matrix_layout
:2;
1080 * For interface blocks, 1 if this variable is a per-patch input or output
1081 * (as in ir_variable::patch). 0 otherwise.
1086 * Precision qualifier
1088 unsigned precision
:2;
1091 * Memory qualifiers, applicable to buffer variables defined in shader
1092 * storage buffer objects (SSBOs)
1094 unsigned memory_read_only
:1;
1095 unsigned memory_write_only
:1;
1096 unsigned memory_coherent
:1;
1097 unsigned memory_volatile
:1;
1098 unsigned memory_restrict
:1;
1101 * Layout format, applicable to image variables only.
1103 unsigned image_format
:16;
1106 * Any of the xfb_* qualifiers trigger the shader to be in transform
1107 * feedback mode so we need to keep track of whether the buffer was
1108 * explicitly set or if its just been assigned the default global value.
1110 unsigned explicit_xfb_buffer
:1;
1112 unsigned implicit_sized_array
:1;
1114 glsl_struct_field(const struct glsl_type
*_type
, const char *_name
)
1115 : type(_type
), name(_name
), location(-1), offset(-1), xfb_buffer(0),
1116 xfb_stride(0), interpolation(0), centroid(0),
1117 sample(0), matrix_layout(GLSL_MATRIX_LAYOUT_INHERITED
), patch(0),
1118 precision(GLSL_PRECISION_NONE
), memory_read_only(0),
1119 memory_write_only(0), memory_coherent(0), memory_volatile(0),
1120 memory_restrict(0), image_format(0), explicit_xfb_buffer(0),
1121 implicit_sized_array(0)
1127 : type(NULL
), name(NULL
), location(-1), offset(-1), xfb_buffer(0),
1128 xfb_stride(0), interpolation(0), centroid(0),
1129 sample(0), matrix_layout(0), patch(0),
1130 precision(0), memory_read_only(0),
1131 memory_write_only(0), memory_coherent(0), memory_volatile(0),
1132 memory_restrict(0), image_format(0), explicit_xfb_buffer(0),
1133 implicit_sized_array(0)
1140 struct glsl_function_param
{
1141 const struct glsl_type
*type
;
1147 static inline unsigned int
1148 glsl_align(unsigned int a
, unsigned int align
)
1150 return (a
+ align
- 1) / align
* align
;
1153 #endif /* GLSL_TYPES_H */