OSDN Git Service

merge from MikuMikuStudio nativebullet.
[mikumikustudio/libgdx-mikumikustudio.git] / extensions / gdx-bullet / jni / src / bullet / BulletMultiThreaded / btThreadSupportInterface.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
16 #ifndef BT_THREAD_SUPPORT_INTERFACE_H
17 #define BT_THREAD_SUPPORT_INTERFACE_H
18
19
20 #include <LinearMath/btScalar.h> //for ATTRIBUTE_ALIGNED16
21 #include "PlatformDefinitions.h"
22 #include "PpuAddressSpace.h"
23
24 class btBarrier {
25 public:
26         btBarrier() {}
27         virtual ~btBarrier() {}
28
29         virtual void sync() = 0;
30         virtual void setMaxCount(int n) = 0;
31         virtual int  getMaxCount() = 0;
32 };
33
34 class btCriticalSection {
35 public:
36         btCriticalSection() {}
37         virtual ~btCriticalSection() {}
38
39         ATTRIBUTE_ALIGNED16(unsigned int mCommonBuff[32]);
40
41         virtual unsigned int getSharedParam(int i) = 0;
42         virtual void setSharedParam(int i,unsigned int p) = 0;
43
44         virtual void lock() = 0;
45         virtual void unlock() = 0;
46 };
47
48
49 class btThreadSupportInterface
50 {
51 public:
52
53         virtual ~btThreadSupportInterface();
54
55 ///send messages to SPUs
56         virtual void sendRequest(uint32_t uiCommand, ppu_address_t uiArgument0, uint32_t uiArgument1) =0;
57
58 ///check for messages from SPUs
59         virtual void waitForResponse(unsigned int *puiArgument0, unsigned int *puiArgument1) =0;
60
61
62         ///non-blocking test if a task is completed. First implement all versions, and then enable this API
63         ///virtual bool isTaskCompleted(unsigned int *puiArgument0, unsigned int *puiArgument1, int timeOutInMilliseconds)=0;
64
65 ///start the spus (can be called at the beginning of each frame, to make sure that the right SPU program is loaded)
66         virtual void startSPU() =0;
67
68 ///tell the task scheduler we are done with the SPU tasks
69         virtual void stopSPU()=0;
70
71         ///tell the task scheduler to use no more than numTasks tasks
72         virtual void    setNumTasks(int numTasks)=0;
73
74         virtual int             getNumTasks() const = 0;
75
76         virtual btBarrier*      createBarrier() = 0;
77
78         virtual btCriticalSection* createCriticalSection() = 0;
79
80         virtual void deleteBarrier(btBarrier* barrier)=0;
81
82     virtual void deleteCriticalSection(btCriticalSection* criticalSection)=0;
83         
84         virtual void*   getThreadLocalMemory(int taskId) { return 0; }
85
86 };
87
88 #endif //BT_THREAD_SUPPORT_INTERFACE_H
89