summaryrefslogtreecommitdiffstats
path: root/builtins
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2010-05-03 20:05:57 -0700
committerIan Romanick <[email protected]>2010-05-14 16:34:46 -0700
commita4b7b5a654ca810e296bb0cca1b27b8847f5548a (patch)
tree95a2cd0825210f2e928b7c16741ed62d9ae9bc49 /builtins
parentc2de1875234565c53b8f3683b04bc7f901055882 (diff)
Implement "sign" builtin via a new expression operator.
Diffstat (limited to 'builtins')
-rw-r--r--builtins/110/sign34
-rw-r--r--builtins/130/sign34
2 files changed, 68 insertions, 0 deletions
diff --git a/builtins/110/sign b/builtins/110/sign
new file mode 100644
index 00000000000..7d540de405b
--- /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))))
+))
+
diff --git a/builtins/130/sign b/builtins/130/sign
new file mode 100644
index 00000000000..0bdc0e09d25
--- /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))))
+))
+