[Beignet] [PATCH 2/2] Backend: refine the geometry function
rander
rander.wang at intel.com
Fri Mar 3 08:16:50 UTC 2017
Signed-off-by: rander <rander.wang at intel.com>
---
backend/src/libocl/src/ocl_geometric.cl | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/backend/src/libocl/src/ocl_geometric.cl b/backend/src/libocl/src/ocl_geometric.cl
index af39ed3..346ef9e 100644
--- a/backend/src/libocl/src/ocl_geometric.cl
+++ b/backend/src/libocl/src/ocl_geometric.cl
@@ -100,18 +100,21 @@ OVERLOADABLE float fast_length(float x) { return __gen_ocl_fabs(x); }
OVERLOADABLE float fast_length(float2 x) { return sqrt(dot(x,x)); }
OVERLOADABLE float fast_length(float3 x) { return sqrt(dot(x,x)); }
OVERLOADABLE float fast_length(float4 x) { return sqrt(dot(x,x)); }
-OVERLOADABLE float fast_distance(float x, float y) { return length(x-y); }
-OVERLOADABLE float fast_distance(float2 x, float2 y) { return length(x-y); }
-OVERLOADABLE float fast_distance(float3 x, float3 y) { return length(x-y); }
-OVERLOADABLE float fast_distance(float4 x, float4 y) { return length(x-y); }
+OVERLOADABLE float fast_distance(float x, float y) { return fast_length(x-y); }
+OVERLOADABLE float fast_distance(float2 x, float2 y) { return fast_length(x-y); }
+OVERLOADABLE float fast_distance(float3 x, float3 y) { return fast_length(x-y); }
+OVERLOADABLE float fast_distance(float4 x, float4 y) { return fast_length(x-y); }
OVERLOADABLE float fast_normalize(float x) { return x > 0 ? 1.f : (x < 0 ? -1.f : 0.f); }
OVERLOADABLE float2 fast_normalize(float2 x) { return x * rsqrt(dot(x, x)); }
OVERLOADABLE float3 fast_normalize(float3 x) { return x * rsqrt(dot(x, x)); }
OVERLOADABLE float4 fast_normalize(float4 x) { return x * rsqrt(dot(x, x)); }
-OVERLOADABLE float3 cross(float3 v0, float3 v1) {
- return v0.yzx*v1.zxy-v0.zxy*v1.yzx;
+OVERLOADABLE float3 cross(float3 p0, float3 p1) {
+ return (float3)(p0.y*p1.z - p0.z*p1.y, p0.z*p1.x - p0.x*p1.z,
+ p0.x*p1.y - p0.y*p1.x);
}
-OVERLOADABLE float4 cross(float4 v0, float4 v1) {
- return (float4)(v0.yzx*v1.zxy-v0.zxy*v1.yzx, 0.f);
+OVERLOADABLE float4 cross(float4 p0, float4 p1) {
+ return (float4)(p0.y*p1.z - p0.z*p1.y, p0.z*p1.x - p0.x*p1.z,
+ p0.x*p1.y - p0.y*p1.x, 0.f);
+
}
--
2.7.4
More information about the Beignet
mailing list