Add functions: is_greater_than_one is_less_than_zero Add variations like greater_than_or_equal_zero. --- This is not ideal computation-wise, as we are doing two iterations instead of one. The question is wether or not the extra code is worth the duplicaton. --- src/glsl/ir_constant_util.h | 50 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+)
diff --git a/src/glsl/ir_constant_util.h b/src/glsl/ir_constant_util.h index 4e0fede..dd6452b 100644 --- a/src/glsl/ir_constant_util.h +++ b/src/glsl/ir_constant_util.h @@ -105,6 +105,21 @@ is_less_than_one(ir_constant *ir) } static inline bool +is_greater_than_one(ir_constant *ir) +{ + if (!is_valid_vec_const(ir)) + return false; + + unsigned component = 0; + for (int c = 0; c < ir->type->vector_elements; c++) { + if (ir->get_float_component(c) > 1.0f) + component++; + } + + return (component == ir->type->vector_elements); +} + +static inline bool is_greater_than_zero(ir_constant *ir) { if (!is_valid_vec_const(ir)) @@ -119,4 +134,39 @@ is_greater_than_zero(ir_constant *ir) return (component == ir->type->vector_elements); } +static inline bool +is_less_than_zero(ir_constant *ir) +{ + if (!is_valid_vec_const(ir)) + return false; + + unsigned component = 0; + for (int c = 0; c < ir->type->vector_elements; c++) { + if (ir->get_float_component(c) < 0.0f) + component++; + } + + return (component == ir->type->vector_elements); +} + +static inline bool +is_less_than_or_equal_zero(ir_constant *ir) { + return is_less_than_zero(ir) || is_vec_zero(ir); +} + +static inline bool +is_greater_than_or_equal_zero(ir_constant *ir) { + return is_greater_than_zero(ir) || is_vec_zero(ir); +} + +static inline bool +is_less_than_or_equal_one(ir_constant *ir) { + return is_less_than_one(ir) || is_vec_one(ir); +} + +static inline bool +is_greater_than_or_equal_one(ir_constant *ir) { + return is_greater_than_one(ir) || is_vec_one(ir); +} + #endif /* IR_CONSTANT_UTIL_H_ */ -- 2.0.3 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev