PxTaskManager.h
Go to the documentation of this file.
1 //
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions
4 // are met:
5 // * Redistributions of source code must retain the above copyright
6 // notice, this list of conditions and the following disclaimer.
7 // * Redistributions in binary form must reproduce the above copyright
8 // notice, this list of conditions and the following disclaimer in the
9 // documentation and/or other materials provided with the distribution.
10 // * Neither the name of NVIDIA CORPORATION nor the names of its
11 // contributors may be used to endorse or promote products derived
12 // from this software without specific prior written permission.
13 //
14 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
15 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
18 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 //
26 // Copyright (c) 2008-2018 NVIDIA Corporation. All rights reserved.
27 
28 #ifndef PXTASK_PXTASKMANAGER_H
29 #define PXTASK_PXTASKMANAGER_H
30 
31 #include "task/PxTaskDefine.h"
34 
35 namespace physx
36 {
38 
39 class PxBaseTask;
40 class PxTask;
42 typedef unsigned int PxTaskID;
43 
52 struct PxTaskType
53 {
57  enum Enum
58  {
63  };
64 };
65 
66 class PxCpuDispatcher;
67 class PxGpuDispatcher;
68 
82 {
83 public:
84 
92  virtual void setCpuDispatcher(PxCpuDispatcher& ref) = 0;
93 
101  virtual void setGpuDispatcher(PxGpuDispatcher& ref) = 0;
102 
110  virtual PxCpuDispatcher* getCpuDispatcher() const = 0;
111 
119  virtual PxGpuDispatcher* getGpuDispatcher() const = 0;
120 
128  virtual void resetDependencies() = 0;
129 
137  virtual void startSimulation() = 0;
138 
144  virtual void stopSimulation() = 0;
145 
151  virtual void taskCompleted(PxTask& task) = 0;
152 
159  virtual PxTaskID getNamedTask(const char* name) = 0;
160 
169  virtual PxTaskID submitNamedTask(PxTask* task, const char* name, PxTaskType::Enum type = PxTaskType::TT_CPU) = 0;
170 
180 
188  virtual PxTask* getTaskFromID(PxTaskID id) = 0;
189 
193  virtual void release() = 0;
194 
199 
200 protected:
201  virtual ~PxTaskManager() {}
202 
205  virtual void finishBefore(PxTask& task, PxTaskID taskID) = 0;
206  virtual void startAfter(PxTask& task, PxTaskID taskID) = 0;
207 
208  virtual void addReference(PxTaskID taskID) = 0;
209  virtual void decrReference(PxTaskID taskID) = 0;
210  virtual int32_t getReference(PxTaskID taskID) const = 0;
211 
212  virtual void decrReference(PxLightCpuTask&) = 0;
213  virtual void addReference(PxLightCpuTask&) = 0;
214 
217  friend class PxBaseTask;
218  friend class PxTask;
219  friend class PxLightCpuTask;
220  friend class PxGpuWorkerThread;
221 };
222 
224 
225 } // end physx namespace
226 
227 
228 #endif // PXTASK_PXTASKMANAGER_H
Definition: GuContactBuffer.h:37
Base class of all task types.
Definition: PxTask.h:45
PxTask will be run on the GPU.
Definition: PxTaskManager.h:60
User defined interface class. Used by the library to emit debug information.
Definition: PxErrorCallback.h:51
virtual void startSimulation()=0
Called by the owning scene to start the task graph.
virtual void stopSimulation()=0
Called by the owning scene at the end of a simulation step to synchronize the PxGpuDispatcher.
A GpuTask dispatcher.
Definition: PxGpuDispatcher.h:71
unsigned int PxTaskID
Definition: PxTaskManager.h:41
Return code when attempting to find a task that does not exist.
Definition: PxTaskManager.h:61
virtual ~PxTaskManager()
Definition: PxTaskManager.h:201
virtual void resetDependencies()=0
Reset any dependencies between Tasks.
A PxBaseTask implementation with immediate execution and simple dependencies.
Definition: PxTask.h:222
#define PX_POP_PACK
Definition: PxPreprocessor.h:343
virtual void setCpuDispatcher(PxCpuDispatcher &ref)=0
Set the user-provided dispatcher object for CPU tasks.
PxTask will be run on the CPU.
Definition: PxTaskManager.h:59
virtual PxTaskID getNamedTask(const char *name)=0
Retrieve a task by name.
Enum
Identifies the type of each heavyweight PxTask object.
Definition: PxTaskManager.h:57
virtual PxTaskID submitNamedTask(PxTask *task, const char *name, PxTaskType::Enum type=PxTaskType::TT_CPU)=0
Submit a task with a unique name.
Identifies the type of each heavyweight PxTask object.
Definition: PxTaskManager.h:52
The PxTaskManager interface.
Definition: PxTaskManager.h:81
static PxTaskManager * createTaskManager(PxErrorCallback &errorCallback, PxCpuDispatcher *=0, PxGpuDispatcher *=0)
Construct a new PxTaskManager instance with the given [optional] dispatchers.
PxTask execution has been completed.
Definition: PxTaskManager.h:62
friend class PxGpuWorkerThread
Definition: PxTaskManager.h:220
virtual void setGpuDispatcher(PxGpuDispatcher &ref)=0
Set the user-provided dispatcher object for GPU tasks.
virtual void taskCompleted(PxTask &task)=0
Called by the worker threads to inform the PxTaskManager that a task has completed processing...
virtual PxGpuDispatcher * getGpuDispatcher() const =0
Get the user-provided dispatcher object for GPU tasks.
virtual PxTaskID submitUnnamedTask(PxTask &task, PxTaskType::Enum type=PxTaskType::TT_CPU)=0
Submit an unnamed task.
#define PX_PUSH_PACK_DEFAULT
Definition: PxPreprocessor.h:342
A PxBaseTask implementation with deferred execution and full dependencies.
Definition: PxTask.h:111
virtual void release()=0
Release the PxTaskManager object, referenced dispatchers will not be released.
A CpuDispatcher is responsible for scheduling the execution of tasks passed to it by the SDK...
Definition: PxCpuDispatcher.h:49
virtual PxTask * getTaskFromID(PxTaskID id)=0
Retrieve a task given a task ID.
virtual PxCpuDispatcher * getCpuDispatcher() const =0
Get the user-provided dispatcher object for CPU tasks.