2
Bullet Continuous Collision Detection and Physics Library, Copyright (c) 2007 Erwin Coumans
4
This software is provided 'as-is', without any express or implied warranty.
5
In no event will the authors be held liable for any damages arising from the use of this software.
6
Permission is granted to anyone to use this software for any purpose,
7
including commercial applications, and to alter it and redistribute it freely,
8
subject to the following restrictions:
10
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
11
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
12
3. This notice may not be removed or altered from any source distribution.
18
#include "LinearMath/btScalar.h"
20
#include "MiniCL/cl.h"
26
#define get_global_id(a) __guid_arg
27
#define get_local_id(a) ((__guid_arg) % gMiniCLNumOutstandingTasks)
28
#define get_local_size(a) (gMiniCLNumOutstandingTasks)
29
#define get_group_id(a) ((__guid_arg) / gMiniCLNumOutstandingTasks)
31
static unsigned int as_uint(float val) { return *((unsigned int*)&val); }
34
#define CLK_LOCAL_MEM_FENCE 0x01
35
#define CLK_GLOBAL_MEM_FENCE 0x02
37
static void barrier(unsigned int a)
42
//ATTRIBUTE_ALIGNED16(struct) float8
56
s0=s1=s2=s3=s4=s5=s6=s7=scalar;
60
//ATTRIBUTE_ALIGNED16(struct) float4
69
float4 operator*(const float4& other)
79
float4 operator*(const float& other)
91
float4& operator+=(const float4& other)
100
float4& operator-=(const float4& other)
109
float4& operator *=(float scalar)
124
static float4 fabs(const float4& a)
127
tmp.x = a.x < 0.f ? 0.f : a.x;
128
tmp.y = a.y < 0.f ? 0.f : a.y;
129
tmp.z = a.z < 0.f ? 0.f : a.z;
130
tmp.w = a.w < 0.f ? 0.f : a.w;
133
static float4 operator+(const float4& a,const float4& b)
144
static float8 operator+(const float8& a,const float8& b)
147
tmp.s0 = a.s0 + b.s0;
148
tmp.s1 = a.s1 + b.s1;
149
tmp.s2 = a.s2 + b.s2;
150
tmp.s3 = a.s3 + b.s3;
151
tmp.s4 = a.s4 + b.s4;
152
tmp.s5 = a.s5 + b.s5;
153
tmp.s6 = a.s6 + b.s6;
154
tmp.s7 = a.s7 + b.s7;
159
static float4 operator-(const float4& a,const float4& b)
169
static float8 operator-(const float8& a,const float8& b)
172
tmp.s0 = a.s0 - b.s0;
173
tmp.s1 = a.s1 - b.s1;
174
tmp.s2 = a.s2 - b.s2;
175
tmp.s3 = a.s3 - b.s3;
176
tmp.s4 = a.s4 - b.s4;
177
tmp.s5 = a.s5 - b.s5;
178
tmp.s6 = a.s6 - b.s6;
179
tmp.s7 = a.s7 - b.s7;
183
static float4 operator*(float a,const float4& b)
193
static float4 operator/(const float4& b,float a)
206
static float dot(const float4&a ,const float4& b)
213
return tmp.x+tmp.y+tmp.z+tmp.w;
216
static float length(const float4&a)
218
float l = sqrtf(a.x*a.x+a.y*a.y+a.z*a.z);
222
static float4 normalize(const float4&a)
232
static float4 cross(const float4&a ,const float4& b)
235
tmp.x = a.y*b.z - a.z*b.y;
236
tmp.y = -a.x*b.z + a.z*b.x;
237
tmp.z = a.x*b.y - a.y*b.x;
242
static float max(float a, float b)
244
return (a >= b) ? a : b;
248
static float min(float a, float b)
250
return (a <= b) ? a : b;
253
static float fmax(float a, float b)
255
return (a >= b) ? a : b;
258
static float fmin(float a, float b)
260
return (a <= b) ? a : b;
273
//typedef int2 uint2;
275
typedef unsigned int uint;
284
unsigned int x,y,z,w;
286
uint4(uint val) { x = y = z = w = val; }
287
uint4& operator+=(const uint4& other)
296
static uint4 operator+(const uint4& a,const uint4& b)
305
static uint4 operator-(const uint4& a,const uint4& b)
315
#define native_sqrt sqrtf
316
#define native_sin sinf
317
#define native_cos cosf
318
#define native_powr powf
320
#define GUID_ARG ,int __guid_arg
321
#define GUID_ARG_VAL ,__guid_arg
324
#define as_int(a) (*((int*)&(a)))
326
extern "C" int gMiniCLNumOutstandingTasks;
327
// extern "C" void __kernel_func();