diff options
author | Eric Anholt <[email protected]> | 2010-04-08 15:41:19 -0700 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2010-04-08 16:08:15 -0700 |
commit | a3fa3fbf7693fc76626e0504cdf315949caa4dfb (patch) | |
tree | 45f0e7e8e849d10aa6f8f1c44cb2e313feaad288 /builtin_function.cpp | |
parent | cc4ef154e6f342266330858563e322dcb640f1f2 (diff) |
Add an implementation of gentype-only clamp().
Diffstat (limited to 'builtin_function.cpp')
-rw-r--r-- | builtin_function.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/builtin_function.cpp b/builtin_function.cpp index c404b3c4e86..bdd745062b7 100644 --- a/builtin_function.cpp +++ b/builtin_function.cpp @@ -188,6 +188,23 @@ generate_max(exec_list *instructions, } static void +generate_clamp(exec_list *instructions, + ir_variable **declarations, + const glsl_type *type) +{ + ir_dereference *const x = new ir_dereference(declarations[0]); + ir_dereference *const minval = new ir_dereference(declarations[1]); + ir_dereference *const maxval = new ir_dereference(declarations[2]); + ir_rvalue *result; + + result = new ir_expression(ir_binop_min, type, x, maxval); + result = new ir_expression(ir_binop_max, type, result, minval); + + ir_instruction *inst = new ir_return(result); + instructions->push_tail(inst); +} + +static void generate_mix_vec(exec_list *instructions, ir_variable **declarations, const glsl_type *type) @@ -750,7 +767,7 @@ generate_110_functions(glsl_symbol_table *symtab, exec_list *instructions) /* FINISHME: min(x, float y) */ make_gentype_function(symtab, instructions, "max", 2, generate_max); /* FINISHME: max(x, float y) */ - /* FINISHME: clamp() */ + make_gentype_function(symtab, instructions, "clamp", 3, generate_clamp); /* FINISHME: clamp() */ make_gentype_function(symtab, instructions, "mix", 3, generate_mix_vec); /* FINISHME: mix() */ |