diff options
author | Kenneth Graunke <kenneth@whitecape.org> | 2010-05-03 22:11:17 -0700 |
---|---|---|
committer | Ian Romanick <ian.d.romanick@intel.com> | 2010-05-14 16:34:46 -0700 |
commit | 57e7da173e8d38bf0c95ded535cdf1b12a00a1a2 (patch) | |
tree | dcab2273d6547f95a4df5a623c7af4c196cab09c | |
parent | 6a9b1e1f06c2859f0c20375189c6ff02ed769d1a (diff) |
Implement "sin" and "cos" builtins via new expression operators.
-rw-r--r-- | builtins/110/cos | 21 | ||||
-rw-r--r-- | builtins/110/sin | 21 | ||||
-rw-r--r-- | ir.cpp | 5 | ||||
-rw-r--r-- | ir.h | 8 |
4 files changed, 55 insertions, 0 deletions
diff --git a/builtins/110/cos b/builtins/110/cos new file mode 100644 index 0000000..88f266e --- /dev/null +++ b/builtins/110/cos @@ -0,0 +1,21 @@ +((function cos + (signature float + (parameters + (declare (in) float angle)) + ((return (expression float cos (var_ref angle))))) + + (signature vec2 + (parameters + (declare (in) vec2 angle)) + ((return (expression vec2 cos (var_ref angle))))) + + (signature vec3 + (parameters + (declare (in) vec3 angle)) + ((return (expression vec3 cos (var_ref angle))))) + + (signature vec4 + (parameters + (declare (in) vec4 angle)) + ((return (expression vec4 cos (var_ref angle))))) +)) diff --git a/builtins/110/sin b/builtins/110/sin new file mode 100644 index 0000000..e6009d8 --- /dev/null +++ b/builtins/110/sin @@ -0,0 +1,21 @@ +((function sin + (signature float + (parameters + (declare (in) float angle)) + ((return (expression float sin (var_ref angle))))) + + (signature vec2 + (parameters + (declare (in) vec2 angle)) + ((return (expression vec2 sin (var_ref angle))))) + + (signature vec3 + (parameters + (declare (in) vec3 angle)) + ((return (expression vec3 sin (var_ref angle))))) + + (signature vec4 + (parameters + (declare (in) vec4 angle)) + ((return (expression vec4 sin (var_ref angle))))) +)) @@ -73,6 +73,9 @@ ir_expression::get_num_operands(ir_expression_operation op) 1, /* ir_unop_ceil */ 1, /* ir_unop_floor */ + 1, /* ir_unop_sin */ + 1, /* ir_unop_cos */ + 2, /* ir_binop_add */ 2, /* ir_binop_sub */ 2, /* ir_binop_mul */ @@ -131,6 +134,8 @@ static const char *const operator_strs[] = { "trunc", "ceil", "floor", + "sin", + "cos", "+", "-", "*", @@ -449,6 +449,14 @@ enum ir_expression_operation { ir_unop_floor, /*@}*/ + /** + * \name Trigonometric operations. + */ + /*@{*/ + ir_unop_sin, + ir_unop_cos, + /*@}*/ + ir_binop_add, ir_binop_sub, ir_binop_mul, |