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 SPU_RAY_TASK_PROCESS_H |
---|
17 | #define SPU_RAY_TASK_PROCESS_H |
---|
18 | |
---|
19 | #include <assert.h> |
---|
20 | #include <string.h> |
---|
21 | |
---|
22 | #include <LinearMath/btScalar.h> |
---|
23 | #include "BulletCollision/CollisionDispatch/btCollisionObject.h" |
---|
24 | #include <LinearMath/btAlignedAllocator.h> |
---|
25 | |
---|
26 | #include "PlatformDefinitions.h" |
---|
27 | #include "LinearMath/btAlignedObjectArray.h" |
---|
28 | #include "SpuRaycastTask/SpuRaycastTask.h" |
---|
29 | |
---|
30 | #include "btThreadSupportInterface.h" |
---|
31 | |
---|
32 | /// SpuRaycastTaskProcess handles SPU processing of raycast requests |
---|
33 | class SpuRaycastTaskProcess |
---|
34 | { |
---|
35 | unsigned char *m_workUnitTaskBuffers; |
---|
36 | |
---|
37 | // track task buffers that are being used, and total busy tasks |
---|
38 | btAlignedObjectArray<bool> m_taskBusy; |
---|
39 | btAlignedObjectArray<SpuRaycastTaskDesc> m_spuRaycastTaskDesc; |
---|
40 | |
---|
41 | btThreadSupportInterface* m_threadInterface; |
---|
42 | |
---|
43 | int m_maxNumOutstandingTasks; |
---|
44 | |
---|
45 | int m_numBusyTasks; |
---|
46 | |
---|
47 | // the current task and the current entry to insert a new work unit |
---|
48 | int m_currentTask; |
---|
49 | int m_currentWorkUnitInTask; |
---|
50 | int m_numSpuCollisionObjectWrappers; |
---|
51 | void* m_spuCollisionObjectWrappers; |
---|
52 | void issueTask2(); |
---|
53 | //void postProcess(unsigned int taskId, int outputSize); |
---|
54 | |
---|
55 | public: |
---|
56 | SpuRaycastTaskProcess(btThreadSupportInterface* threadInterface, int maxNumOutstandingTasks); |
---|
57 | |
---|
58 | ~SpuRaycastTaskProcess(); |
---|
59 | |
---|
60 | /// call initialize in the beginning of the frame, before addCollisionPairToTask |
---|
61 | void initialize2(void* spuCollisionObjectsWrappers, int numSpuCollisionObjectWrappers); |
---|
62 | |
---|
63 | /// batch up additional work to a current task for SPU processing. When batch is full, it issues the task. |
---|
64 | void addWorkToTask(struct SpuRaycastTaskWorkUnit&); |
---|
65 | |
---|
66 | /// call flush to submit potential outstanding work to SPUs and wait for all involved SPUs to be finished |
---|
67 | void flush2(); |
---|
68 | }; |
---|
69 | |
---|
70 | |
---|
71 | #endif // SPU_COLLISION_TASK_PROCESS_H |
---|
72 | |
---|