Bullet Collision Detection & Physics Library
btGpuDefines.h
Go to the documentation of this file.
1 /*
2 Bullet Continuous Collision Detection and Physics Library, http://bulletphysics.org
3 Copyright (C) 2006, 2009 Sony Computer Entertainment Inc.
4 
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:
10 
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.
14 */
15 
16 
17 
18 // definitions for "GPU on CPU" code
19 
20 
21 #ifndef BT_GPU_DEFINES_H
22 #define BT_GPU_DEFINES_H
23 
24 typedef unsigned int uint;
25 
26 struct int2
27 {
28  int x, y;
29 };
30 
31 struct uint2
32 {
33  unsigned int x, y;
34 };
35 
36 struct int3
37 {
38  int x, y, z;
39 };
40 
41 struct uint3
42 {
43  unsigned int x, y, z;
44 };
45 
46 struct float4
47 {
48  float x, y, z, w;
49 };
50 
51 struct float3
52 {
53  float x, y, z;
54 };
55 
56 
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
68 
69 static inline uint2 bt3dGrid_make_uint2(unsigned int x, unsigned int y)
70 {
71  uint2 t; t.x = x; t.y = y; return t;
72 }
73 #define BT_GPU_make_uint2(x, y) bt3dGrid_make_uint2(x, y)
74 
75 static inline int3 bt3dGrid_make_int3(int x, int y, int z)
76 {
77  int3 t; t.x = x; t.y = y; t.z = z; return t;
78 }
79 #define BT_GPU_make_int3(x, y, z) bt3dGrid_make_int3(x, y, z)
80 
81 static inline float3 bt3dGrid_make_float3(float x, float y, float z)
82 {
83  float3 t; t.x = x; t.y = y; t.z = z; return t;
84 }
85 #define BT_GPU_make_float3(x, y, z) bt3dGrid_make_float3(x, y, z)
86 
88 {
89  float3 t; t.x = f.x; t.y = f.y; t.z = f.z; return t;
90 }
91 #define BT_GPU_make_float34(f) bt3dGrid_make_float34(f)
92 
93 static inline float3 bt3dGrid_make_float31(float f)
94 {
95  float3 t; t.x = t.y = t.z = f; return t;
96 }
97 #define BT_GPU_make_float31(x) bt3dGrid_make_float31(x)
98 
99 static inline float4 bt3dGrid_make_float42(float3 v, float f)
100 {
101  float4 t; t.x = v.x; t.y = v.y; t.z = v.z; t.w = f; return t;
102 }
103 #define BT_GPU_make_float42(a, b) bt3dGrid_make_float42(a, b)
104 
105 static inline float4 bt3dGrid_make_float44(float a, float b, float c, float d)
106 {
107  float4 t; t.x = a; t.y = b; t.z = c; t.w = d; return t;
108 }
109 #define BT_GPU_make_float44(a, b, c, d) bt3dGrid_make_float44(a, b, c, d)
110 
111 inline int3 operator+(int3 a, int3 b)
112 {
113  return bt3dGrid_make_int3(a.x + b.x, a.y + b.y, a.z + b.z);
114 }
115 
116 inline float4 operator+(const float4& a, const float4& b)
117 {
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;
119 }
120 inline float4 operator*(const float4& a, float fact)
121 {
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;
123 }
124 inline float4 operator*(float fact, float4& a)
125 {
126  return (a * fact);
127 }
128 inline float4& operator*=(float4& a, float fact)
129 {
130  a = fact * a;
131  return a;
132 }
133 inline float4& operator+=(float4& a, const float4& b)
134 {
135  a = a + b;
136  return a;
137 }
138 
139 inline float3 operator+(const float3& a, const float3& b)
140 {
141  float3 r; r.x = a.x+b.x; r.y = a.y+b.y; r.z = a.z+b.z; return r;
142 }
143 inline float3 operator-(const float3& a, const float3& b)
144 {
145  float3 r; r.x = a.x-b.x; r.y = a.y-b.y; r.z = a.z-b.z; return r;
146 }
147 static inline float bt3dGrid_dot(float3& a, float3& b)
148 {
149  return a.x*b.x+a.y*b.y+a.z*b.z;
150 }
151 #define BT_GPU_dot(a,b) bt3dGrid_dot(a,b)
152 
153 static inline float bt3dGrid_dot4(float4& a, float4& b)
154 {
155  return a.x*b.x+a.y*b.y+a.z*b.z+a.w*b.w;
156 }
157 #define BT_GPU_dot4(a,b) bt3dGrid_dot4(a,b)
158 
159 static inline float3 bt3dGrid_cross(const float3& a, const float3& b)
160 {
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;
162 }
163 #define BT_GPU_cross(a,b) bt3dGrid_cross(a,b)
164 
165 
166 inline float3 operator*(const float3& a, float fact)
167 {
168  float3 r; r.x = a.x*fact; r.y = a.y*fact; r.z = a.z*fact; return r;
169 }
170 
171 
172 inline float3& operator+=(float3& a, const float3& b)
173 {
174  a = a + b;
175  return a;
176 }
177 inline float3& operator-=(float3& a, const float3& b)
178 {
179  a = a - b;
180  return a;
181 }
182 inline float3& operator*=(float3& a, float fact)
183 {
184  a = a * fact;
185  return a;
186 }
187 inline float3 operator-(const float3& v)
188 {
189  float3 r; r.x = -v.x; r.y = -v.y; r.z = -v.z; return r;
190 }
191 
192 
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)
201 
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;}}}
207 
208 #define BT_GPU_CHECK_ERROR(s)
209 
210 
211 #endif //BT_GPU_DEFINES_H
float4 operator*(const float4 &a, float fact)
Definition: btGpuDefines.h:120
float z
Definition: btGpuDefines.h:53
unsigned int z
Definition: btGpuDefines.h:43
static float3 bt3dGrid_make_float3(float x, float y, float z)
Definition: btGpuDefines.h:81
unsigned int y
Definition: btGpuDefines.h:33
int y
Definition: btGpuDefines.h:28
float w
Definition: btGpuDefines.h:48
static uint2 bt3dGrid_make_uint2(unsigned int x, unsigned int y)
Definition: btGpuDefines.h:69
float x
Definition: btGpuDefines.h:48
static uint2 s_blockIdx
Definition: btGpuDefines.h:202
static float3 bt3dGrid_make_float31(float f)
Definition: btGpuDefines.h:93
float3 & operator-=(float3 &a, const float3 &b)
Definition: btGpuDefines.h:177
static int3 bt3dGrid_make_int3(int x, int y, int z)
Definition: btGpuDefines.h:75
static float3 bt3dGrid_cross(const float3 &a, const float3 &b)
Definition: btGpuDefines.h:159
unsigned int x
Definition: btGpuDefines.h:33
int3 operator+(int3 a, int3 b)
Definition: btGpuDefines.h:111
float4 & operator+=(float4 &a, const float4 &b)
Definition: btGpuDefines.h:133
static float4 bt3dGrid_make_float44(float a, float b, float c, float d)
Definition: btGpuDefines.h:105
static uint2 s_threadIdx
Definition: btGpuDefines.h:202
float y
Definition: btGpuDefines.h:53
float y
Definition: btGpuDefines.h:48
static float4 bt3dGrid_make_float42(float3 v, float f)
Definition: btGpuDefines.h:99
float4 & operator*=(float4 &a, float fact)
Definition: btGpuDefines.h:128
unsigned int y
Definition: btGpuDefines.h:43
static uint2 s_blockDim
Definition: btGpuDefines.h:202
int x
Definition: btGpuDefines.h:28
static float bt3dGrid_dot4(float4 &a, float4 &b)
Definition: btGpuDefines.h:153
float z
Definition: btGpuDefines.h:48
unsigned int uint
Definition: btGpuDefines.h:24
static float bt3dGrid_dot(float3 &a, float3 &b)
Definition: btGpuDefines.h:147
unsigned int x
Definition: btGpuDefines.h:43
int y
Definition: btGpuDefines.h:38
float3 operator-(const float3 &a, const float3 &b)
Definition: btGpuDefines.h:143
int z
Definition: btGpuDefines.h:38
int x
Definition: btGpuDefines.h:38
static float3 bt3dGrid_make_float34(float4 f)
Definition: btGpuDefines.h:87
float x
Definition: btGpuDefines.h:53