glsl2: Add ir_unop_noise
authorIan Romanick <ian.d.romanick@intel.com>
Thu, 2 Sep 2010 04:12:10 +0000 (21:12 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Thu, 9 Sep 2010 22:39:51 +0000 (15:39 -0700)
src/glsl/ir.cpp
src/glsl/ir.h
src/mesa/program/ir_to_mesa.cpp

index 9ac24858958830ade0683b89da85ca342b197a8c..b0945431ada20f4bb76c8271e3b02b9151abd266 100644 (file)
@@ -196,6 +196,8 @@ ir_expression::get_num_operands(ir_expression_operation op)
       1, /* ir_unop_dFdx */
       1, /* ir_unop_dFdy */
 
+      1, /* ir_unop_noise */
+
       2, /* ir_binop_add */
       2, /* ir_binop_sub */
       2, /* ir_binop_mul */
@@ -261,6 +263,7 @@ static const char *const operator_strs[] = {
    "cos",
    "dFdx",
    "dFdy",
+   "noise",
    "+",
    "-",
    "*",
index 0d933024df08a9ff9abe095000b0051790b75ef0..80a647e0dc2908103b110b8354dfb01654373409 100644 (file)
@@ -650,6 +650,8 @@ enum ir_expression_operation {
    ir_unop_dFdy,
    /*@}*/
 
+   ir_unop_noise,
+
    ir_binop_add,
    ir_binop_sub,
    ir_binop_mul,
index caa906abfadac457c5f52cdf01a46c5c6fba6d67..7307c8506c0e12485666b0e0205cd3eefe4034ad 100644 (file)
@@ -1154,6 +1154,16 @@ ir_to_mesa_visitor::visit(ir_expression *ir)
       ir_to_mesa_emit_op1(ir, OPCODE_DDY, result_dst, op[0]);
       break;
 
+   case ir_unop_noise: {
+      const enum prog_opcode opcode =
+        prog_opcode(OPCODE_NOISE1
+                    + (ir->operands[0]->type->vector_elements) - 1);
+      assert((opcode >= OPCODE_NOISE1) && (opcode <= OPCODE_NOISE4));
+
+      ir_to_mesa_emit_op1(ir, opcode, result_dst, op[0]);
+      break;
+   }
+
    case ir_binop_add:
       ir_to_mesa_emit_op2(ir, OPCODE_ADD, result_dst, op[0], op[1]);
       break;