[Mesa-dev] [PATCH] glsl/ir_builder: Add a generic constructor for unary expressions.

Kenneth Graunke kenneth at whitecape.org
Sun Jul 8 22:29:05 PDT 2012


I needed to compute logs and square roots in a patch I was working on,
and wanted to use the convenient interface.  We already have a similar
constructor for binops; adding one for unops seems reasonable.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 src/glsl/ir_builder.cpp |    8 ++++++++
 src/glsl/ir_builder.h   |    1 +
 2 files changed, 9 insertions(+)

diff --git a/src/glsl/ir_builder.cpp b/src/glsl/ir_builder.cpp
index 9a16c90..fc6ee96 100644
--- a/src/glsl/ir_builder.cpp
+++ b/src/glsl/ir_builder.cpp
@@ -143,6 +143,14 @@ swizzle_xyzw(operand a)
 }
 
 ir_expression *
+expr(ir_expression_operation op, operand a)
+{
+   void *mem_ctx = ralloc_parent(a.val);
+
+   return new(mem_ctx) ir_expression(op, a.val);
+}
+
+ir_expression *
 expr(ir_expression_operation op, operand a, operand b)
 {
    void *mem_ctx = ralloc_parent(a.val);
diff --git a/src/glsl/ir_builder.h b/src/glsl/ir_builder.h
index 0ebcbab..410b08c 100644
--- a/src/glsl/ir_builder.h
+++ b/src/glsl/ir_builder.h
@@ -83,6 +83,7 @@ public:
 ir_assignment *assign(deref lhs, operand rhs);
 ir_assignment *assign(deref lhs, operand rhs, int writemask);
 
+ir_expression *expr(ir_expression_operation op, operand a);
 ir_expression *expr(ir_expression_operation op, operand a, operand b);
 ir_expression *add(operand a, operand b);
 ir_expression *sub(operand a, operand b);
-- 
1.7.10.4



More information about the mesa-dev mailing list