Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/physics/src/bullet/BulletMultiThreaded/SpuRaycastTaskProcess.h @ 1967

Last change on this file since 1967 was 1966, checked in by rgrieder, 16 years ago

Let's go for multithreaded physics!

  • Property svn:eol-style set to native
File size: 2.6 KB
Line 
1/*
2Bullet Continuous Collision Detection and Physics Library
3Copyright (c) 2003-2007 Erwin Coumans  http://bulletphysics.com
4
5This software is provided 'as-is', without any express or implied warranty.
6In no event will the authors be held liable for any damages arising from the use of this software.
7Permission is granted to anyone to use this software for any purpose,
8including commercial applications, and to alter it and redistribute it freely,
9subject to the following restrictions:
10
111. 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.
122. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
133. 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
33class 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
55public:
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
Note: See TracBrowser for help on using the repository browser.