2
Bullet Continuous Collision Detection and Physics Library, http://bulletphysics.org
3
Copyright (C) 2006, 2009 Sony Computer Entertainment Inc.
5
This software is provided 'as-is', without any express or implied warranty.
6
In no event will the authors be held liable for any damages arising from the use of this software.
7
Permission is granted to anyone to use this software for any purpose,
8
including commercial applications, and to alter it and redistribute it freely,
9
subject to the following restrictions:
11
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.
12
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
13
3. This notice may not be removed or altered from any source distribution.
18
// definitions for "GPU on CPU" code
21
#ifndef BT_GPU_DEFINES_H
22
#define BT_GPU_DEFINES_H
24
typedef unsigned int uint;
57
#define BT_GPU___device__ inline
58
#define BT_GPU___devdata__
59
#define BT_GPU___constant__
60
#define BT_GPU_max(a, b) ((a) > (b) ? (a) : (b))
61
#define BT_GPU_min(a, b) ((a) < (b) ? (a) : (b))
62
#define BT_GPU_params s3DGridBroadphaseParams
63
#define BT_GPU___mul24(a, b) ((a)*(b))
64
#define BT_GPU___global__ inline
65
#define BT_GPU___shared__ static
66
#define BT_GPU___syncthreads()
67
#define CUDART_PI_F SIMD_PI
69
static inline uint2 bt3dGrid_make_uint2(unsigned int x, unsigned int y)
71
uint2 t; t.x = x; t.y = y; return t;
73
#define BT_GPU_make_uint2(x, y) bt3dGrid_make_uint2(x, y)
75
static inline int3 bt3dGrid_make_int3(int x, int y, int z)
77
int3 t; t.x = x; t.y = y; t.z = z; return t;
79
#define BT_GPU_make_int3(x, y, z) bt3dGrid_make_int3(x, y, z)
81
static inline float3 bt3dGrid_make_float3(float x, float y, float z)
83
float3 t; t.x = x; t.y = y; t.z = z; return t;
85
#define BT_GPU_make_float3(x, y, z) bt3dGrid_make_float3(x, y, z)
87
static inline float3 bt3dGrid_make_float34(float4 f)
89
float3 t; t.x = f.x; t.y = f.y; t.z = f.z; return t;
91
#define BT_GPU_make_float34(f) bt3dGrid_make_float34(f)
93
static inline float3 bt3dGrid_make_float31(float f)
95
float3 t; t.x = t.y = t.z = f; return t;
97
#define BT_GPU_make_float31(x) bt3dGrid_make_float31(x)
99
static inline float4 bt3dGrid_make_float42(float3 v, float f)
101
float4 t; t.x = v.x; t.y = v.y; t.z = v.z; t.w = f; return t;
103
#define BT_GPU_make_float42(a, b) bt3dGrid_make_float42(a, b)
105
static inline float4 bt3dGrid_make_float44(float a, float b, float c, float d)
107
float4 t; t.x = a; t.y = b; t.z = c; t.w = d; return t;
109
#define BT_GPU_make_float44(a, b, c, d) bt3dGrid_make_float44(a, b, c, d)
111
inline int3 operator+(int3 a, int3 b)
113
return bt3dGrid_make_int3(a.x + b.x, a.y + b.y, a.z + b.z);
116
inline float4 operator+(const float4& a, const float4& b)
118
float4 r; r.x = a.x+b.x; r.y = a.y+b.y; r.z = a.z+b.z; r.w = a.w+b.w; return r;
120
inline float4 operator*(const float4& a, float fact)
122
float4 r; r.x = a.x*fact; r.y = a.y*fact; r.z = a.z*fact; r.w = a.w*fact; return r;
124
inline float4 operator*(float fact, float4& a)
128
inline float4& operator*=(float4& a, float fact)
133
inline float4& operator+=(float4& a, const float4& b)
139
inline float3 operator+(const float3& a, const float3& b)
141
float3 r; r.x = a.x+b.x; r.y = a.y+b.y; r.z = a.z+b.z; return r;
143
inline float3 operator-(const float3& a, const float3& b)
145
float3 r; r.x = a.x-b.x; r.y = a.y-b.y; r.z = a.z-b.z; return r;
147
static inline float bt3dGrid_dot(float3& a, float3& b)
149
return a.x*b.x+a.y*b.y+a.z*b.z;
151
#define BT_GPU_dot(a,b) bt3dGrid_dot(a,b)
153
static inline float bt3dGrid_dot4(float4& a, float4& b)
155
return a.x*b.x+a.y*b.y+a.z*b.z+a.w*b.w;
157
#define BT_GPU_dot4(a,b) bt3dGrid_dot4(a,b)
159
static inline float3 bt3dGrid_cross(const float3& a, const float3& b)
161
float3 r; r.x = a.y*b.z-a.z*b.y; r.y = -a.x*b.z+a.z*b.x; r.z = a.x*b.y-a.y*b.x; return r;
163
#define BT_GPU_cross(a,b) bt3dGrid_cross(a,b)
166
inline float3 operator*(const float3& a, float fact)
168
float3 r; r.x = a.x*fact; r.y = a.y*fact; r.z = a.z*fact; return r;
172
inline float3& operator+=(float3& a, const float3& b)
177
inline float3& operator-=(float3& a, const float3& b)
182
inline float3& operator*=(float3& a, float fact)
187
inline float3 operator-(const float3& v)
189
float3 r; r.x = -v.x; r.y = -v.y; r.z = -v.z; return r;
193
#define BT_GPU_FETCH(a, b) a[b]
194
#define BT_GPU_FETCH4(a, b) a[b]
195
#define BT_GPU_PREF(func) btGpu_##func
196
#define BT_GPU_SAFE_CALL(func) func
197
#define BT_GPU_Memset memset
198
#define BT_GPU_MemcpyToSymbol(a, b, c) memcpy(&a, b, c)
199
#define BT_GPU_BindTexture(a, b, c, d)
200
#define BT_GPU_UnbindTexture(a)
202
static uint2 s_blockIdx, s_blockDim, s_threadIdx;
203
#define BT_GPU_blockIdx s_blockIdx
204
#define BT_GPU_blockDim s_blockDim
205
#define BT_GPU_threadIdx s_threadIdx
206
#define BT_GPU_EXECKERNEL(numb, numt, kfunc, args) {s_blockDim.x=numt;for(int nb=0;nb<numb;nb++){s_blockIdx.x=nb;for(int nt=0;nt<numt;nt++){s_threadIdx.x=nt;kfunc args;}}}
208
#define BT_GPU_CHECK_ERROR(s)
211
#endif //BT_GPU_DEFINES_H