summaryrefslogtreecommitdiffstats
path: root/src/glsl/builtins/ir/distance.ir
diff options
context:
space:
mode:
Diffstat (limited to 'src/glsl/builtins/ir/distance.ir')
-rw-r--r--src/glsl/builtins/ir/distance.ir31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/glsl/builtins/ir/distance.ir b/src/glsl/builtins/ir/distance.ir
new file mode 100644
index 00000000000..c249f8c9962
--- /dev/null
+++ b/src/glsl/builtins/ir/distance.ir
@@ -0,0 +1,31 @@
+((function distance
+ (signature float
+ (parameters
+ (declare (in) float p0)
+ (declare (in) float p1))
+ ((return (expression float abs (expression float - (var_ref p0) (var_ref p1))))))
+
+ (signature float
+ (parameters
+ (declare (in) vec2 p0)
+ (declare (in) vec2 p1))
+ ((declare () vec2 p)
+ (assign (xy) (var_ref p) (expression vec2 - (var_ref p0) (var_ref p1)))
+ (return (expression float sqrt (expression float dot (var_ref p) (var_ref p))))))
+
+ (signature float
+ (parameters
+ (declare (in) vec3 p0)
+ (declare (in) vec3 p1))
+ ((declare () vec3 p)
+ (assign (xyz) (var_ref p) (expression vec3 - (var_ref p0) (var_ref p1)))
+ (return (expression float sqrt (expression float dot (var_ref p) (var_ref p))))))
+
+ (signature float
+ (parameters
+ (declare (in) vec4 p0)
+ (declare (in) vec4 p1))
+ ((declare () vec4 p)
+ (assign (xyzw) (var_ref p) (expression vec4 - (var_ref p0) (var_ref p1)))
+ (return (expression float sqrt (expression float dot (var_ref p) (var_ref p))))))
+))