summaryrefslogtreecommitdiff
path: root/builtins/110/sign
diff options
context:
space:
mode:
authorKenneth Graunke <kenneth@whitecape.org>2010-05-03 20:05:57 -0700
committerIan Romanick <ian.d.romanick@intel.com>2010-05-14 16:34:46 -0700
commita4b7b5a654ca810e296bb0cca1b27b8847f5548a (patch)
tree95a2cd0825210f2e928b7c16741ed62d9ae9bc49 /builtins/110/sign
parentc2de1875234565c53b8f3683b04bc7f901055882 (diff)
Implement "sign" builtin via a new expression operator.
Diffstat (limited to 'builtins/110/sign')
-rw-r--r--builtins/110/sign34
1 files changed, 34 insertions, 0 deletions
diff --git a/builtins/110/sign b/builtins/110/sign
new file mode 100644
index 0000000000..7d540de405
--- /dev/null
+++ b/builtins/110/sign
@@ -0,0 +1,34 @@
+((function sign
+ (signature float
+ (parameters
+ (declare (in) float x))
+ ((return (expression float sign (var_ref x)))))
+
+ (signature vec2
+ (parameters
+ (declare (in) vec2 x))
+ ((declare () vec2 t)
+ (assign (constant bool (1)) (swiz x (var_ref t)) (expression float sign (swiz x (var_ref x))))
+ (assign (constant bool (1)) (swiz y (var_ref t)) (expression float sign (swiz y (var_ref x))))
+ (return (var_ref t))))
+
+ (signature vec3
+ (parameters
+ (declare (in) vec3 x))
+ ((declare () vec3 t)
+ (assign (constant bool (1)) (swiz x (var_ref t)) (expression float sign (swiz x (var_ref x))))
+ (assign (constant bool (1)) (swiz y (var_ref t)) (expression float sign (swiz y (var_ref x))))
+ (assign (constant bool (1)) (swiz z (var_ref t)) (expression float sign (swiz z (var_ref x))))
+ (return (var_ref t))))
+
+ (signature vec4
+ (parameters
+ (declare (in) vec4 x))
+ ((declare () vec4 t)
+ (assign (constant bool (1)) (swiz x (var_ref t)) (expression float sign (swiz x (var_ref x))))
+ (assign (constant bool (1)) (swiz y (var_ref t)) (expression float sign (swiz y (var_ref x))))
+ (assign (constant bool (1)) (swiz z (var_ref t)) (expression float sign (swiz z (var_ref x))))
+ (assign (constant bool (1)) (swiz w (var_ref t)) (expression float sign (swiz w (var_ref x))))
+ (return (var_ref t))))
+))
+