summaryrefslogtreecommitdiffstats
path: root/src/glsl/ir.h
diff options
context:
space:
mode:
authorKenneth Graunke <kenneth@whitecape.org>2014-01-05 22:42:31 -0800
committerKenneth Graunke <kenneth@whitecape.org>2014-01-07 12:54:57 -0800
commit5e3fd6a9dbd62ca5cd9965282fac01a34d23733e (patch)
tree6606b35cd8c5b1f3f4bd585b9b87db4323aa0c07 /src/glsl/ir.h
parentd6c1d66d3a74e25435b5ebcde208e8049b669120 (diff)
downloadexternal_mesa3d-5e3fd6a9dbd62ca5cd9965282fac01a34d23733e.zip
external_mesa3d-5e3fd6a9dbd62ca5cd9965282fac01a34d23733e.tar.gz
external_mesa3d-5e3fd6a9dbd62ca5cd9965282fac01a34d23733e.tar.bz2
glsl: Refactor is_zero/one/negative_one into an is_value() method.
This patch creates a new generic is_value() method, which checks if an ir_constant has a particular value. (For vectors, it must have the single value repeated across all components.) It then rewrites the is_zero/is_one/is_negative_one methods to use this generic helper. All three were basically identical except for the value they checked for. The other difference is that is_negative_one rejects boolean types. The new is_value function maintains this behavior, only allowing boolean types when checking for 0 or 1. Signed-off-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Matt Turner <mattst88@gmail.com>
Diffstat (limited to 'src/glsl/ir.h')
-rw-r--r--src/glsl/ir.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/glsl/ir.h b/src/glsl/ir.h
index 780959b..4d86385 100644
--- a/src/glsl/ir.h
+++ b/src/glsl/ir.h
@@ -2186,6 +2186,12 @@ public:
*/
bool has_value(const ir_constant *) const;
+ /**
+ * Return true if this ir_constant represents the given value.
+ *
+ * For vectors, this checks that each component is the given value.
+ */
+ virtual bool is_value(float f, int i) const;
virtual bool is_zero() const;
virtual bool is_one() const;
virtual bool is_negative_one() const;