From: Eric Anholt Date: Sat, 27 Mar 2010 19:25:20 +0000 (-0700) Subject: Implement additional unary gentype builtins. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2eec73f7354ba4d11907f14381463fc0fa035174;p=mesa.git Implement additional unary gentype builtins. --- diff --git a/builtin_function.cpp b/builtin_function.cpp index fb168acdc3e..fd34fcefb08 100644 --- a/builtin_function.cpp +++ b/builtin_function.cpp @@ -28,20 +28,69 @@ #include "ir.h" static void -generate_exp(exec_list *instructions, - ir_variable **declarations, - const glsl_type *type) +generate_unop(exec_list *instructions, + ir_variable **declarations, + const glsl_type *type, + enum ir_expression_operation op) { ir_dereference *const retval = new ir_dereference(declarations[16]); ir_dereference *const arg = new ir_dereference(declarations[0]); ir_rvalue *result; - result = new ir_expression(ir_unop_exp, type, arg, NULL); + result = new ir_expression(op, type, arg, NULL); ir_instruction *inst = new ir_assignment(retval, result, NULL); instructions->push_tail(inst); } +static void +generate_exp(exec_list *instructions, + ir_variable **declarations, + const glsl_type *type) +{ + generate_unop(instructions, declarations, type, ir_unop_exp); +} + +static void +generate_log(exec_list *instructions, + ir_variable **declarations, + const glsl_type *type) +{ + generate_unop(instructions, declarations, type, ir_unop_log); +} + +static void +generate_rsq(exec_list *instructions, + ir_variable **declarations, + const glsl_type *type) +{ + generate_unop(instructions, declarations, type, ir_unop_rsq); +} + +static void +generate_abs(exec_list *instructions, + ir_variable **declarations, + const glsl_type *type) +{ + generate_unop(instructions, declarations, type, ir_unop_abs); +} + +static void +generate_ceil(exec_list *instructions, + ir_variable **declarations, + const glsl_type *type) +{ + generate_unop(instructions, declarations, type, ir_unop_ceil); +} + +static void +generate_floor(exec_list *instructions, + ir_variable **declarations, + const glsl_type *type) +{ + generate_unop(instructions, declarations, type, ir_unop_floor); +} + void generate_function_instance(ir_function *f, const char *name, @@ -112,15 +161,15 @@ generate_110_functions(glsl_symbol_table *symtab, exec_list *instructions) /* FINISHME: atan(y/x) */ /* FINISHME: pow() */ make_gentype_function(symtab, instructions, "exp", generate_exp); - /* FINISHME: log() */ + make_gentype_function(symtab, instructions, "log", generate_log); /* FINISHME: exp2() */ /* FINISHME: log2() */ /* FINISHME: sqrt() */ - /* FINISHME: inversesqrt() */ - /* FINISHME: abs() */ + make_gentype_function(symtab, instructions, "inversesqrt", generate_rsq); + make_gentype_function(symtab, instructions, "abs", generate_abs); /* FINISHME: sign() */ - /* FINISHME: floor() */ - /* FINISHME: ceil() */ + make_gentype_function(symtab, instructions, "floor", generate_floor); + make_gentype_function(symtab, instructions, "ceil", generate_ceil); /* FINISHME: fract() */ /* FINISHME: mod(x, float y) */ /* FINISHME: mod(x, y) */