Imported Upstream version 2.81
[platform/upstream/libbullet.git] / src / BulletMultiThreaded / SpuGatheringCollisionDispatcher.h
1 /*
2 Bullet Continuous Collision Detection and Physics Library
3 Copyright (c) 2003-2007 Erwin Coumans  http://bulletphysics.com
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 #ifndef BT_SPU_GATHERING_COLLISION__DISPATCHER_H
16 #define BT_SPU_GATHERING_COLLISION__DISPATCHER_H
17
18 #include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h"
19
20
21 ///Tuning value to optimized SPU utilization 
22 ///Too small value means Task overhead is large compared to computation (too fine granularity)
23 ///Too big value might render some SPUs are idle, while a few other SPUs are doing all work.
24 //#define SPU_BATCHSIZE_BROADPHASE_PAIRS 8
25 //#define SPU_BATCHSIZE_BROADPHASE_PAIRS 16
26 //#define SPU_BATCHSIZE_BROADPHASE_PAIRS 64
27 #define SPU_BATCHSIZE_BROADPHASE_PAIRS 128
28 //#define SPU_BATCHSIZE_BROADPHASE_PAIRS 256
29 //#define SPU_BATCHSIZE_BROADPHASE_PAIRS 512
30 //#define SPU_BATCHSIZE_BROADPHASE_PAIRS 1024
31
32
33
34 class SpuCollisionTaskProcess;
35
36 ///SpuGatheringCollisionDispatcher can use SPU to gather and calculate collision detection
37 ///Time of Impact, Closest Points and Penetration Depth.
38 class SpuGatheringCollisionDispatcher : public btCollisionDispatcher
39 {
40         
41         SpuCollisionTaskProcess*        m_spuCollisionTaskProcess;
42         
43 protected:
44
45         class   btThreadSupportInterface*       m_threadInterface;
46
47         unsigned int    m_maxNumOutstandingTasks;
48         
49
50 public:
51
52         //can be used by SPU collision algorithms       
53         SpuCollisionTaskProcess*        getSpuCollisionTaskProcess()
54         {
55                         return m_spuCollisionTaskProcess;
56         }
57         
58         SpuGatheringCollisionDispatcher (class  btThreadSupportInterface*       threadInterface, unsigned int   maxNumOutstandingTasks,btCollisionConfiguration* collisionConfiguration);
59         
60         virtual ~SpuGatheringCollisionDispatcher();
61
62         bool    supportsDispatchPairOnSpu(int proxyType0,int proxyType1);
63
64         virtual void    dispatchAllCollisionPairs(btOverlappingPairCache* pairCache,const btDispatcherInfo& dispatchInfo,btDispatcher* dispatcher) ;
65
66 };
67
68
69
70 #endif //BT_SPU_GATHERING_COLLISION__DISPATCHER_H
71
72