summaryrefslogtreecommitdiff
path: root/builtins/130/sign
diff options
context:
space:
mode:
Diffstat (limited to 'builtins/130/sign')
-rw-r--r--builtins/130/sign34
1 files changed, 34 insertions, 0 deletions
diff --git a/builtins/130/sign b/builtins/130/sign
new file mode 100644
index 0000000000..0bdc0e09d2
--- /dev/null
+++ b/builtins/130/sign
@@ -0,0 +1,34 @@
+((function sign
+ (signature int
+ (parameters
+ (declare (in) int x))
+ ((return (expression int / (var_ref x) (expression int abs (var_ref x))))))
+
+ (signature ivec2
+ (parameters
+ (declare (in) ivec2 x))
+ ((declare () ivec2 t)
+ (assign (constant bool (1)) (swiz x (var_ref t)) (expression int sign (swiz x (var_ref x))))
+ (assign (constant bool (1)) (swiz y (var_ref t)) (expression int sign (swiz y (var_ref x))))
+ (return (var_ref t))))
+
+ (signature ivec3
+ (parameters
+ (declare (in) ivec3 x))
+ ((declare () ivec3 t)
+ (assign (constant bool (1)) (swiz x (var_ref t)) (expression int sign (swiz x (var_ref x))))
+ (assign (constant bool (1)) (swiz y (var_ref t)) (expression int sign (swiz y (var_ref x))))
+ (assign (constant bool (1)) (swiz z (var_ref t)) (expression int sign (swiz z (var_ref x))))
+ (return (var_ref t))))
+
+ (signature ivec4
+ (parameters
+ (declare (in) ivec4 x))
+ ((declare () ivec4 t)
+ (assign (constant bool (1)) (swiz x (var_ref t)) (expression int sign (swiz x (var_ref x))))
+ (assign (constant bool (1)) (swiz y (var_ref t)) (expression int sign (swiz y (var_ref x))))
+ (assign (constant bool (1)) (swiz z (var_ref t)) (expression int sign (swiz z (var_ref x))))
+ (assign (constant bool (1)) (swiz w (var_ref t)) (expression int sign (swiz w (var_ref x))))
+ (return (var_ref t))))
+))
+