summaryrefslogtreecommitdiffstats
path: root/src/glsl/builtins/ir
diff options
context:
space:
mode:
authorPaul Berry <[email protected]>2011-10-06 10:20:10 -0700
committerPaul Berry <[email protected]>2011-10-31 11:24:03 -0700
commitede60bc4670a8d9c14921c77abee1ac57fc0e6bf (patch)
treec545778fe124435a470d0958d60110a52863e242 /src/glsl/builtins/ir
parentb6f32bbe12e1082e78951b6ef073bf244ba0b8b7 (diff)
glsl: Add isinf() and isnan() builtins.
The implementations are as follows: isinf(x) = (abs(x) == +infinity) isnan(x) = (x != x) Note: the latter formula is not necessarily obvious. It works because NaN is the only floating point number that does not equal itself. Fixes piglit tests "isinf-and-isnan fs_basic" and "isinf-and-isnan vs_basic".
Diffstat (limited to 'src/glsl/builtins/ir')
-rw-r--r--src/glsl/builtins/ir/isinf.ir17
-rw-r--r--src/glsl/builtins/ir/isnan.ir17
2 files changed, 34 insertions, 0 deletions
diff --git a/src/glsl/builtins/ir/isinf.ir b/src/glsl/builtins/ir/isinf.ir
new file mode 100644
index 00000000000..92922f6fa36
--- /dev/null
+++ b/src/glsl/builtins/ir/isinf.ir
@@ -0,0 +1,17 @@
+((function isinf
+ (signature bool
+ (parameters
+ (declare (in) float x))
+ ((return (expression bool == (expression float abs (var_ref x)) (constant float (+INF))))))
+ (signature bvec2
+ (parameters
+ (declare (in) vec2 x))
+ ((return (expression bvec2 == (expression vec2 abs (var_ref x)) (constant vec2 (+INF +INF))))))
+ (signature bvec3
+ (parameters
+ (declare (in) vec3 x))
+ ((return (expression bvec3 == (expression vec3 abs (var_ref x)) (constant vec3 (+INF +INF +INF))))))
+ (signature bvec4
+ (parameters
+ (declare (in) vec4 x))
+ ((return (expression bvec4 == (expression vec4 abs (var_ref x)) (constant vec4 (+INF +INF +INF +INF))))))))
diff --git a/src/glsl/builtins/ir/isnan.ir b/src/glsl/builtins/ir/isnan.ir
new file mode 100644
index 00000000000..b67349f2a5c
--- /dev/null
+++ b/src/glsl/builtins/ir/isnan.ir
@@ -0,0 +1,17 @@
+((function isnan
+ (signature bool
+ (parameters
+ (declare (in) float x))
+ ((return (expression bool != (var_ref x) (var_ref x)))))
+ (signature bvec2
+ (parameters
+ (declare (in) vec2 x))
+ ((return (expression bvec2 != (var_ref x) (var_ref x)))))
+ (signature bvec3
+ (parameters
+ (declare (in) vec3 x))
+ ((return (expression bvec3 != (var_ref x) (var_ref x)))))
+ (signature bvec4
+ (parameters
+ (declare (in) vec4 x))
+ ((return (expression bvec4 != (var_ref x) (var_ref x)))))))