summaryrefslogtreecommitdiffstats
path: root/src/glsl/glsl_types.h
diff options
context:
space:
mode:
authorFrancisco Jerez <currojerez@riseup.net>2013-11-25 14:03:06 -0800
committerFrancisco Jerez <currojerez@riseup.net>2014-02-12 18:43:37 +0100
commit107d03a6d5b63687361b2b4d2876ef52b082cbb5 (patch)
treed324b5e64917a4deb3f282a5112e2205454210fd /src/glsl/glsl_types.h
parent8a2508ee0726b349318c1e05122edbe5a545480a (diff)
downloadexternal_mesa3d-107d03a6d5b63687361b2b4d2876ef52b082cbb5.zip
external_mesa3d-107d03a6d5b63687361b2b4d2876ef52b082cbb5.tar.gz
external_mesa3d-107d03a6d5b63687361b2b4d2876ef52b082cbb5.tar.bz2
glsl: Add helper methods to glsl_type for dealing with images.
Add predicates to query if a GLSL type is or contains an image. Rename sampler_coordinate_components() to coordinate_components(). v2: Use assert instead of unreachable. v3: No need to use a separate code-path for images in coordinate_components() after merging image and sampler fields in the glsl_type structure. Reviewed-by: Paul Berry <stereotype441@gmail.com>
Diffstat (limited to 'src/glsl/glsl_types.h')
-rw-r--r--src/glsl/glsl_types.h19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h
index 6b38e09..ae3829f 100644
--- a/src/glsl/glsl_types.h
+++ b/src/glsl/glsl_types.h
@@ -404,6 +404,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
*/
bool is_array() const
@@ -533,7 +547,8 @@ struct glsl_type {
}
/**
- * Return the number of coordinate components needed for this sampler type.
+ * 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.
@@ -542,7 +557,7 @@ 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.