RavEngine
Loading...
Searching...
No Matches
PxTaskManager.h
1// Redistribution and use in source and binary forms, with or without
2// modification, are permitted provided that the following conditions
3// are met:
4// * Redistributions of source code must retain the above copyright
5// notice, this list of conditions and the following disclaimer.
6// * Redistributions in binary form must reproduce the above copyright
7// notice, this list of conditions and the following disclaimer in the
8// documentation and/or other materials provided with the distribution.
9// * Neither the name of NVIDIA CORPORATION nor the names of its
10// contributors may be used to endorse or promote products derived
11// from this software without specific prior written permission.
12//
13// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
14// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24//
25// Copyright (c) 2008-2022 NVIDIA Corporation. All rights reserved.
26
27#ifndef PX_TASK_MANAGER_H
28#define PX_TASK_MANAGER_H
29
30#include "foundation/PxSimpleTypes.h"
31#include "foundation/PxErrorCallback.h"
32
33#if !PX_DOXYGEN
34namespace physx
35{
36#endif
37
38class PxBaseTask;
39class PxTask;
40class PxLightCpuTask;
41typedef unsigned int PxTaskID;
42
52{
56 enum Enum
57 {
61 TT_CPU PX_DEPRECATED = eCPU,
62 TT_NOT_PRESENT PX_DEPRECATED = eNOT_PRESENT,
63 TT_COMPLETED PX_DEPRECATED = eCOMPLETED
64 };
65};
66
67class PxCpuDispatcher;
68
81{
82public:
83
91 virtual void setCpuDispatcher(PxCpuDispatcher& ref) = 0;
92
100 virtual PxCpuDispatcher* getCpuDispatcher() const = 0;
101
109 virtual void resetDependencies() = 0;
110
118 virtual void startSimulation() = 0;
119
123 virtual void stopSimulation() = 0;
124
130 virtual void taskCompleted(PxTask& task) = 0;
131
138 virtual PxTaskID getNamedTask(const char* name) = 0;
139
148 virtual PxTaskID submitNamedTask(PxTask* task, const char* name, PxTaskType::Enum type = PxTaskType::eCPU) = 0;
149
158 virtual PxTaskID submitUnnamedTask(PxTask& task, PxTaskType::Enum type = PxTaskType::eCPU) = 0;
159
167 virtual PxTask* getTaskFromID(PxTaskID id) = 0;
168
172 virtual void release() = 0;
173
177 static PxTaskManager* createTaskManager(PxErrorCallback& errorCallback, PxCpuDispatcher* = NULL);
178
179protected:
180 virtual ~PxTaskManager() {}
181
184 virtual void finishBefore(PxTask& task, PxTaskID taskID) = 0;
185 virtual void startAfter(PxTask& task, PxTaskID taskID) = 0;
186
187 virtual void addReference(PxTaskID taskID) = 0;
188 virtual void decrReference(PxTaskID taskID) = 0;
189 virtual int32_t getReference(PxTaskID taskID) const = 0;
190
191 virtual void decrReference(PxLightCpuTask&) = 0;
192 virtual void addReference(PxLightCpuTask&) = 0;
193
196 friend class PxBaseTask;
197 friend class PxTask;
198 friend class PxLightCpuTask;
199};
200
201#if !PX_DOXYGEN
202} // namespace physx
203#endif
204
205
206#endif
Base class of all task types.
Definition PxTask.h:45
A CpuDispatcher is responsible for scheduling the execution of tasks passed to it by the SDK.
Definition PxCpuDispatcher.h:50
User defined interface class. Used by the library to emit debug information.
Definition PxErrorCallback.h:51
A PxBaseTask implementation with immediate execution and simple dependencies.
Definition PxTask.h:209
The PxTaskManager interface.
Definition PxTaskManager.h:81
virtual void taskCompleted(PxTask &task)=0
Called by the worker threads to inform the PxTaskManager that a task has completed processing.
virtual PxTaskID submitUnnamedTask(PxTask &task, PxTaskType::Enum type=PxTaskType::eCPU)=0
Submit an unnamed task.
virtual void stopSimulation()=0
Called by the owning scene at the end of a simulation step.
virtual void resetDependencies()=0
Reset any dependencies between Tasks.
virtual PxTaskID submitNamedTask(PxTask *task, const char *name, PxTaskType::Enum type=PxTaskType::eCPU)=0
Submit a task with a unique name.
static PxTaskManager * createTaskManager(PxErrorCallback &errorCallback, PxCpuDispatcher *=NULL)
Construct a new PxTaskManager instance with the given [optional] dispatchers.
Definition TaskManager.cpp:138
virtual void startSimulation()=0
Called by the owning scene to start the task graph.
virtual void release()=0
Release the PxTaskManager object, referenced dispatchers will not be released.
virtual void setCpuDispatcher(PxCpuDispatcher &ref)=0
Set the user-provided dispatcher object for CPU tasks.
virtual PxTaskID getNamedTask(const char *name)=0
Retrieve a task by name.
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.
A PxBaseTask implementation with deferred execution and full dependencies.
Definition PxTask.h:111
#define PX_DEPRECATED
Definition PxPreprocessor.h:418
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
Identifies the type of each heavyweight PxTask object.
Definition PxTaskManager.h:52
Enum
Identifies the type of each heavyweight PxTask object.
Definition PxTaskManager.h:57
@ eNOT_PRESENT
Return code when attempting to find a task that does not exist.
Definition PxTaskManager.h:59
@ eCOMPLETED
PxTask execution has been completed.
Definition PxTaskManager.h:60
@ eCPU
PxTask will be run on the CPU.
Definition PxTaskManager.h:58