On 08/12/2013 01:25 PM, Matt Turner wrote:
---
  src/glsl/ir_builder.cpp | 6 ++++++
  src/glsl/ir_builder.h   | 1 +
  2 files changed, 7 insertions(+)

diff --git a/src/glsl/ir_builder.cpp b/src/glsl/ir_builder.cpp
index 5e1da17..06b6a8c 100644
--- a/src/glsl/ir_builder.cpp
+++ b/src/glsl/ir_builder.cpp
@@ -219,6 +219,12 @@ saturate(operand a)
               new(mem_ctx) ir_constant(0.0f));
  }

+ir_expression *
+abs(operand a)
+{
+   return expr(ir_unop_abs, a);
+}
+
  ir_expression*
  equal(operand a, operand b)
  {

I was concerned that this might conflict with abs(x) from stdlib.h, so I did some experimenting:

Inside a namespace ir_builder { ... } block, it does appear to hide the "real" abs. You have to call it via ::abs(x).

However, in anything that *uses* ir_builder, i.e.

using namespace ir_builder;

... abs(3) ... abs(some_ir_expression)

You can use both functions and they both work fine - it's just an extra overload. This means you can write natural code without worrying about it.

So I'm fine with this patch. Paul and Chad both voiced in person that they approved as well.

For the series:
Reviewed-by: Kenneth Graunke <[email protected]>
_______________________________________________
mesa-dev mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to