summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2010-05-19 16:02:00 -0700
committerEric Anholt <[email protected]>2010-06-24 15:05:20 -0700
commitc2014f03e8d6b7e21e2d0c31270ced04e1025653 (patch)
treef13b73799f070dea147fe1398f8e7feae8b3868d
parentc45b615a379e5b9cbcf951f9d738a1be77a5964b (diff)
ir_to_mesa: Add support for trunc/ceil/floor.
-rw-r--r--ir_to_mesa.cpp9
-rw-r--r--mesa_codegen.brg16
2 files changed, 22 insertions, 3 deletions
diff --git a/ir_to_mesa.cpp b/ir_to_mesa.cpp
index 722e93a7977..edc95eb5caa 100644
--- a/ir_to_mesa.cpp
+++ b/ir_to_mesa.cpp
@@ -520,6 +520,15 @@ ir_to_mesa_visitor::visit(ir_expression *ir)
this->result = this->create_tree(MB_TERM_sne_vec4_vec4, ir,
op[0], this->result);
break;
+ case ir_unop_trunc:
+ this->result = this->create_tree(MB_TERM_trunc_vec4, ir, op[0], NULL);
+ break;
+ case ir_unop_ceil:
+ this->result = this->create_tree(MB_TERM_ceil_vec4, ir, op[0], NULL);
+ break;
+ case ir_unop_floor:
+ this->result = this->create_tree(MB_TERM_floor_vec4, ir, op[0], NULL);
+ break;
default:
break;
}
diff --git a/mesa_codegen.brg b/mesa_codegen.brg
index fc59a834f05..25c0c47c02f 100644
--- a/mesa_codegen.brg
+++ b/mesa_codegen.brg
@@ -53,6 +53,9 @@
%term exp2_vec4
%term log_vec4
%term log2_vec4
+%term trunc_vec4
+%term ceil_vec4
+%term floor_vec4
%term sin_vec4
%term cos_vec4
%term add_vec4_vec4
@@ -71,7 +74,6 @@
%term sqrt_vec4
%term rsq_vec4
%term swizzle_vec4
-%term trunc_vec4
# Each tree will produce stmt. Currently, the only production for
# stmt is from an assign rule -- every statement tree from
@@ -159,6 +161,16 @@ vec4: swizzle_vec4(vec4) 1
reg);
}
+vec4: trunc_vec4(vec4) 1 { ir_to_mesa_emit_op1(tree, OPCODE_TRUNC); }
+
+vec4: ceil_vec4(vec4) 1 {
+ tree->left->src_reg.negate = ~tree->left->src_reg.negate;
+ ir_to_mesa_emit_op1(tree, OPCODE_FLR);
+ tree->src_reg.negate = ~tree->left->src_reg.negate;
+}
+
+vec4: floor_vec4(vec4) 1 { ir_to_mesa_emit_op1(tree, OPCODE_FLR); }
+
vec4: sin_vec4(vec4) 1
{
ir_to_mesa_emit_scalar_op1(tree, OPCODE_SIN,
@@ -261,6 +273,4 @@ vec4: log2_vec4(vec4) 1
tree->left->src_reg);
}
-vec4: trunc_vec4(vec4) 1 { ir_to_mesa_emit_op1(tree, OPCODE_TRUNC); }
-
%%