Implement exp2() and log2(), and make ir_unop_exp and ir_unop_log be base e.
authorEric Anholt <eric@anholt.net>
Sat, 27 Mar 2010 20:56:35 +0000 (13:56 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Mon, 29 Mar 2010 19:48:45 +0000 (12:48 -0700)
Making the base e functions IR operations is not a clear win.  i965
doesn't support it, it doesn't look like r600 supports it, but r500
does. It should be easily supportable as a lowering pass, though.

builtin_function.cpp
ir.h
ir_print_visitor.cpp

index 7cd08d772f0a5e24dc60931f5d1cd4b79c548e4c..ef6af2052b919ce52de05a1033f4446adb871833 100644 (file)
@@ -76,6 +76,22 @@ generate_log(exec_list *instructions,
    generate_unop(instructions, declarations, type, ir_unop_log);
 }
 
+static void
+generate_exp2(exec_list *instructions,
+             ir_variable **declarations,
+             const glsl_type *type)
+{
+   generate_unop(instructions, declarations, type, ir_unop_exp2);
+}
+
+static void
+generate_log2(exec_list *instructions,
+             ir_variable **declarations,
+             const glsl_type *type)
+{
+   generate_unop(instructions, declarations, type, ir_unop_log2);
+}
+
 static void
 generate_rsq(exec_list *instructions,
               ir_variable **declarations,
@@ -278,8 +294,8 @@ generate_110_functions(glsl_symbol_table *symtab, exec_list *instructions)
    make_gentype_function(symtab, instructions, "pow", 2, generate_pow);
    make_gentype_function(symtab, instructions, "exp", 1, generate_exp);
    make_gentype_function(symtab, instructions, "log", 1, generate_log);
-   /* FINISHME: exp2() */
-   /* FINISHME: log2() */
+   make_gentype_function(symtab, instructions, "exp2", 1, generate_exp2);
+   make_gentype_function(symtab, instructions, "log2", 1, generate_log2);
    make_gentype_function(symtab, instructions, "sqrt", 1, generate_sqrt);
    make_gentype_function(symtab, instructions, "inversesqrt", 1, generate_rsq);
    make_gentype_function(symtab, instructions, "abs", 1, generate_abs);
diff --git a/ir.h b/ir.h
index 45905289485028ee599287606813cfdcdfdfbed6..600a2cd78de0b1eb76d21b6e688c0f588df9439e 100644 (file)
--- a/ir.h
+++ b/ir.h
@@ -228,6 +228,8 @@ enum ir_expression_operation {
    ir_unop_sqrt,
    ir_unop_exp,
    ir_unop_log,
+   ir_unop_exp2,
+   ir_unop_log2,
    ir_unop_f2i,      /**< Float-to-integer conversion. */
    ir_unop_i2f,      /**< Integer-to-float conversion. */
    ir_unop_u2f,      /**< Unsigned-to-float conversion. */
index 8b2080f7ec520c266fb04ab73afed8c606eb135e..aeff280cdd9e319dc0f40c4ffb3a714123952eff 100644 (file)
@@ -96,6 +96,8 @@ void ir_print_visitor::visit(ir_expression *ir)
       "sqrt",
       "exp",
       "log",
+      "exp2",
+      "log2",
       "f2i",
       "i2f",
       "u2f",