[Mesa-dev] [PATCH 2/6] glsl: Expand constant_util

Thomas Helland thomashelland90 at gmail.com
Wed Oct 29 18:11:17 PDT 2014


Add functions for is_greater_than_one
and is_less_than_zero

Signed-off-by: Thomas Helland <thomashelland90 at gmail.com>
---
 src/glsl/ir_constant_util.h | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/src/glsl/ir_constant_util.h b/src/glsl/ir_constant_util.h
index b3b9a19..9dae974 100644
--- a/src/glsl/ir_constant_util.h
+++ b/src/glsl/ir_constant_util.h
@@ -86,6 +86,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))
@@ -100,4 +115,20 @@ 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);
+}
+
+
 #endif /* IR_CONSTANT_UTIL_H_ */
-- 
2.0.3



More information about the mesa-dev mailing list