ir_to_mesa: add logic_not and f2b to get CorrectParse2.frag working.
authorEric Anholt <eric@anholt.net>
Fri, 7 May 2010 19:12:49 +0000 (12:12 -0700)
committerEric Anholt <eric@anholt.net>
Thu, 24 Jun 2010 22:05:20 +0000 (15:05 -0700)
ir_to_mesa.cpp
ir_to_mesa.h

index 487e24986f96ec76017bc068e82f3fabc5761342..8858d4be68e627e28da95873ad6e755d3c15dcbc 100644 (file)
@@ -195,6 +195,27 @@ ir_to_mesa_visitor::create_tree(int op,
    return tree;
 }
 
+struct mbtree *
+ir_to_mesa_visitor::create_tree_for_float(ir_instruction *ir, float val)
+{
+   struct mbtree *tree = (struct mbtree *)calloc(sizeof(struct mbtree), 1);
+
+   tree = this->create_tree(MB_TERM_reference_vec4, ir, NULL, NULL);
+
+   /* FINISHME: This will end up being _mesa_add_unnamed_constant,
+    * which handles sharing values and sharing channels of vec4
+    * constants for small values.
+    */
+   /* FINISHME: Do something with the constant values for now.
+    */
+   (void)val;
+   ir_to_mesa_set_tree_reg(tree, PROGRAM_CONSTANT, this->next_constant++);
+   tree->src_reg.swizzle = SWIZZLE_NOOP;
+
+   this->result = tree;
+   return tree;
+}
+
 /**
  * In the initial pass of codegen, we assign temporary numbers to
  * intermediate results.  (not SSA -- variable assignments will reuse
@@ -344,6 +365,11 @@ ir_to_mesa_visitor::visit(ir_expression *ir)
    this->result = NULL;
 
    switch (ir->operation) {
+   case ir_unop_logic_not:
+      this->result = this->create_tree_for_float(ir, 0.0);
+      this->result = this->create_tree(MB_TERM_seq_vec4_vec4, ir,
+                                      op[0], this->result);
+      break;
    case ir_unop_exp:
       this->result = this->create_tree(MB_TERM_exp_vec4, ir, op[0], NULL);
       break;
@@ -416,6 +442,11 @@ ir_to_mesa_visitor::visit(ir_expression *ir)
    case ir_unop_f2i:
       this->result = this->create_tree(MB_TERM_trunc_vec4, ir, op[0], NULL);
       break;
+   case ir_unop_f2b:
+      this->result = this->create_tree_for_float(ir, 0.0);
+      this->result = this->create_tree(MB_TERM_sne_vec4_vec4, ir,
+                                      op[0], this->result);
+      break;
    default:
       break;
    }
index 3aa88bcdc40e6388d4bf986be48e87dc3fb6fbf8..43ddd5fe517fe249dd48e283a5cb4d1dbbf2f58a 100644 (file)
@@ -108,6 +108,7 @@ public:
                              ir_instruction *ir,
                              struct mbtree *left,
                              struct mbtree *right);
+   struct mbtree *create_tree_for_float(ir_instruction *ir, float val);
 
    /**
     * \name Visit methods