diff options
author | Kenneth Graunke <kenneth@whitecape.org> | 2014-01-05 22:42:31 -0800 |
---|---|---|
committer | Kenneth Graunke <kenneth@whitecape.org> | 2014-01-07 12:54:57 -0800 |
commit | 5e3fd6a9dbd62ca5cd9965282fac01a34d23733e (patch) | |
tree | 6606b35cd8c5b1f3f4bd585b9b87db4323aa0c07 /src/glsl/ir.h | |
parent | d6c1d66d3a74e25435b5ebcde208e8049b669120 (diff) | |
download | external_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.h | 6 |
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; |