X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fglsl%2Fglsl_types.h;h=92578ff47ac13bd06e9ab4bb0da3c6701fcfa0c3;hb=6305caea521fb2c7f82100db490f03d279185c43;hp=e60c19132d60415c21e9a493581e18dfa5a3eddb;hpb=8cf35c3d2f8f40215f9fe00bdec6329aca2afc78;p=mesa.git diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h index e60c19132d6..92578ff47ac 100644 --- a/src/glsl/glsl_types.h +++ b/src/glsl/glsl_types.h @@ -53,6 +53,8 @@ enum glsl_base_type { GLSL_TYPE_FLOAT, GLSL_TYPE_BOOL, GLSL_TYPE_SAMPLER, + GLSL_TYPE_IMAGE, + GLSL_TYPE_ATOMIC_UINT, GLSL_TYPE_STRUCT, GLSL_TYPE_INTERFACE, GLSL_TYPE_ARRAY, @@ -79,7 +81,7 @@ enum glsl_interface_packing { #ifdef __cplusplus #include "GL/gl.h" -#include "ralloc.h" +#include "util/ralloc.h" struct glsl_type { GLenum gl_type; @@ -88,8 +90,9 @@ struct glsl_type { unsigned sampler_dimensionality:3; /**< \see glsl_sampler_dim */ unsigned sampler_shadow:1; unsigned sampler_array:1; - unsigned sampler_type:2; /**< Type of data returned using this sampler. - * only \c GLSL_TYPE_FLOAT, \c GLSL_TYPE_INT, + unsigned sampler_type:2; /**< Type of data returned using this + * sampler or image. Only \c + * GLSL_TYPE_FLOAT, \c GLSL_TYPE_INT, * and \c GLSL_TYPE_UINT are valid. */ unsigned interface_packing:2; @@ -177,7 +180,7 @@ struct glsl_type { /**@}*/ /** - * For numeric and boolean derrived types returns the basic scalar type + * For numeric and boolean derived types returns the basic scalar type * * If the type is a numeric or boolean scalar, vector, or matrix type, * this function gets the scalar type of the individual components. For @@ -252,6 +255,12 @@ struct glsl_type { */ unsigned component_slots() const; + /** + * Calculate the number of unique values from glGetUniformLocation for the + * elements of the type. + */ + unsigned uniform_locations() const; + /** * Calculate the number of attribute slots required to hold this type * @@ -311,7 +320,8 @@ struct glsl_type { * integers. * \endverbatim */ - bool can_implicitly_convert_to(const glsl_type *desired) const; + bool can_implicitly_convert_to(const glsl_type *desired, + _mesa_glsl_parse_state *state) const; /** * Query whether or not a type is a scalar (non-vector and non-matrix). @@ -400,6 +410,20 @@ struct glsl_type { */ gl_texture_index sampler_index() const; + /** + * Query whether or not type is an image, or for struct and array + * types, contains an image. + */ + bool contains_image() const; + + /** + * Query whether or not a type is an image + */ + bool is_image() const + { + return base_type == GLSL_TYPE_IMAGE; + } + /** * Query whether or not a type is an array */ @@ -440,6 +464,44 @@ struct glsl_type { return base_type == GLSL_TYPE_ERROR; } + /** + * Get the type stripped of any arrays + * + * \return + * Pointer to the type of elements of the first non-array type for array + * types, or pointer to itself for non-array types. + */ + const glsl_type *without_array() const + { + return this->is_array() ? this->fields.array : this; + } + + /** + * Return the amount of atomic counter storage required for a type. + */ + unsigned atomic_size() const + { + if (base_type == GLSL_TYPE_ATOMIC_UINT) + return ATOMIC_COUNTER_SIZE; + else if (is_array()) + return length * element_type()->atomic_size(); + else + return 0; + } + + /** + * Return whether a type contains any atomic counters. + */ + bool contains_atomic() const + { + return atomic_size() > 0; + } + + /** + * Return whether a type contains any opaque types. + */ + bool contains_opaque() const; + /** * Query the full type of a matrix row * @@ -468,7 +530,6 @@ struct glsl_type { : error_type; } - /** * Get the type of a structure field * @@ -478,13 +539,11 @@ struct glsl_type { */ const glsl_type *field_type(const char *name) const; - /** * Get the location of a filed within a record type */ int field_index(const char *name) const; - /** * Query the number of elements in an array type * @@ -499,7 +558,16 @@ struct glsl_type { } /** - * Return the number of coordinate components needed for this sampler type. + * Query whether the array size for all dimensions has been declared. + */ + bool is_unsized_array() const + { + return is_array() && length == 0; + } + + /** + * Return the number of coordinate components needed for this + * sampler or image type. * * This is based purely on the sampler's dimensionality. For example, this * returns 1 for sampler1D, and 3 for sampler2DArray. @@ -508,7 +576,14 @@ struct glsl_type { * a texturing built-in function, since those pack additional values (such * as the shadow comparitor or projector) into the coordinate type. */ - int sampler_coordinate_components() const; + int coordinate_components() const; + + /** + * Compare a record type against another record type. + * + * This is useful for matching record types declared across shader stages. + */ + bool record_compare(const glsl_type *b) const; private: /** @@ -525,8 +600,8 @@ private: glsl_base_type base_type, unsigned vector_elements, unsigned matrix_columns, const char *name); - /** Constructor for sampler types */ - glsl_type(GLenum gl_type, + /** Constructor for sampler or image types */ + glsl_type(GLenum gl_type, glsl_base_type base_type, enum glsl_sampler_dim dim, bool shadow, bool array, unsigned type, const char *name); @@ -590,6 +665,30 @@ struct glsl_struct_field { * Ignored for structs. */ int location; + + /** + * For interface blocks, the interpolation mode (as in + * ir_variable::interpolation). 0 otherwise. + */ + unsigned interpolation:2; + + /** + * For interface blocks, 1 if this variable uses centroid interpolation (as + * in ir_variable::centroid). 0 otherwise. + */ + unsigned centroid:1; + + /** + * For interface blocks, 1 if this variable uses sample interpolation (as + * in ir_variable::sample). 0 otherwise. + */ + unsigned sample:1; + + /** + * For interface blocks, it has a value if this variable uses multiple vertex + * streams (as in ir_variable::stream). -1 otherwise. + */ + int stream; }; static inline unsigned int