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-2021 NVIDIA Corporation. All rights reserved. |
27 | // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. |
28 | // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. |
29 | |
30 | |
31 | #ifndef PX_PHYSX_GPU_H |
32 | #define PX_PHYSX_GPU_H |
33 | |
34 | #include "task/PxTask.h" |
35 | |
36 | #include "Ps.h" |
37 | #include "PsArray.h" |
38 | #include "foundation/PxBounds3.h" |
39 | #include "common/PxPhysXCommonConfig.h" |
40 | #include "CmPhysXCommon.h" |
41 | #include "PxSceneDesc.h" |
42 | |
43 | |
44 | namespace physx |
45 | { |
46 | |
47 | class PxFoundation; |
48 | class PxCudaContextManagerDesc; |
49 | class PxvNphaseImplementationContext; |
50 | class PxsContext; |
51 | class PxsKernelWranglerManager; |
52 | class PxvNphaseImplementationFallback; |
53 | struct PxgDynamicsMemoryConfig; |
54 | class PxsMemoryManager; |
55 | class PxsHeapMemoryAllocatorManager; |
56 | class PxsSimulationController; |
57 | class PxsSimulationControllerCallback; |
58 | class PxDelayLoadHook; |
59 | |
60 | struct PxvSimStats; |
61 | |
62 | namespace Bp |
63 | { |
64 | class BroadPhase; |
65 | } |
66 | |
67 | namespace Dy |
68 | { |
69 | class Context; |
70 | } |
71 | |
72 | namespace IG |
73 | { |
74 | class IslandSim; |
75 | class SimpleIslandManager; |
76 | } |
77 | |
78 | namespace Cm |
79 | { |
80 | class FlushPool; |
81 | } |
82 | |
83 | /** |
84 | \brief Interface to create and run CUDA enabled PhysX features. |
85 | |
86 | The methods of this interface are expected not to be called concurrently. |
87 | Also they are expected to not be called concurrently with any tasks spawned before the end pipeline ... TODO make clear. |
88 | */ |
89 | class PxPhysXGpu |
90 | { |
91 | public: |
92 | /** |
93 | \brief Closes this instance of the interface. |
94 | */ |
95 | virtual void release() = 0; |
96 | |
97 | /** |
98 | Create GPU memory manager. |
99 | */ |
100 | virtual PxsMemoryManager* createGpuMemoryManager(PxCudaContextManager* cudaContextManager, class PxGraphicsContextManager* graphicsContextManager) = 0; |
101 | |
102 | virtual PxsHeapMemoryAllocatorManager* createGpuHeapMemoryAllocatorManager( |
103 | const PxU32 heapCapacity, |
104 | PxsMemoryManager* memoryManager, |
105 | const PxU32 gpuComputeVersion) = 0; |
106 | |
107 | /** |
108 | Create GPU kernel wrangler manager. |
109 | */ |
110 | virtual PxsKernelWranglerManager* createGpuKernelWranglerManager( |
111 | PxCudaContextManager* cudaContextManager, |
112 | PxErrorCallback& errorCallback, |
113 | const PxU32 gpuComputeVersion) = 0; |
114 | |
115 | /** |
116 | Create GPU broadphase. |
117 | */ |
118 | virtual Bp::BroadPhase* createGpuBroadPhase( |
119 | PxsKernelWranglerManager* gpuKernelWrangler, |
120 | PxCudaContextManager* cudaContextManager, |
121 | PxGraphicsContextManager* graphicsContext, |
122 | const PxU32 gpuComputeVersion, |
123 | const PxgDynamicsMemoryConfig& config, |
124 | PxsHeapMemoryAllocatorManager* heapMemoryManager) = 0; |
125 | |
126 | /** |
127 | Create GPU narrow phase context. |
128 | */ |
129 | virtual PxvNphaseImplementationContext* createGpuNphaseImplementationContext(PxsContext& context, |
130 | PxsKernelWranglerManager* gpuKernelWrangler, |
131 | PxvNphaseImplementationFallback* fallbackForUnsupportedCMs, |
132 | const PxgDynamicsMemoryConfig& gpuDynamicsConfig, void* contactStreamBase, void* patchStreamBase, void* forceAndIndiceStreamBase, |
133 | Ps::Array<PxBounds3, Ps::VirtualAllocator>& bounds, IG::IslandSim* islandSim, |
134 | physx::Dy::Context* dynamicsContext, const PxU32 gpuComputeVersion, PxsHeapMemoryAllocatorManager* heapMemoryManager) = 0; |
135 | |
136 | /** |
137 | Create GPU simulation controller. |
138 | */ |
139 | virtual PxsSimulationController* createGpuSimulationController(PxsKernelWranglerManager* gpuWranglerManagers, |
140 | PxCudaContextManager* cudaContextManager, PxGraphicsContextManager* graphicsContextManager, |
141 | Dy::Context* dynamicContext, PxvNphaseImplementationContext* npContext, Bp::BroadPhase* bp, |
142 | const bool useGpuBroadphase, IG::SimpleIslandManager* simpleIslandSim, |
143 | PxsSimulationControllerCallback* callback, const PxU32 gpuComputeVersion, PxsHeapMemoryAllocatorManager* heapMemoryManager) = 0; |
144 | |
145 | /** |
146 | Create GPU dynamics context. |
147 | */ |
148 | virtual Dy::Context* createGpuDynamicsContext(Cm::FlushPool& taskPool, PxsKernelWranglerManager* gpuKernelWragler, |
149 | PxCudaContextManager* cudaContextManager, PxGraphicsContextManager* graphicsContextManager, |
150 | const PxgDynamicsMemoryConfig& config, IG::IslandSim* accurateIslandSim, const PxU32 maxNumPartitions, |
151 | const bool enableStabilization, const bool useEnhancedDeterminism, const bool useAdaptiveForce, const PxReal maxBiasCoefficient, |
152 | const PxU32 gpuComputeVersion, PxvSimStats& simStats, PxsHeapMemoryAllocatorManager* heapMemoryManager, |
153 | const bool frictionEveryIteration, PxSolverType::Enum solverType) = 0; |
154 | |
155 | }; |
156 | |
157 | } |
158 | |
159 | /** |
160 | Create PxPhysXGpu interface class. |
161 | */ |
162 | PX_C_EXPORT PX_PHYSX_GPU_API physx::PxPhysXGpu* PX_CALL_CONV PxCreatePhysXGpu(); |
163 | |
164 | /** |
165 | Create a cuda context manager. |
166 | */ |
167 | PX_C_EXPORT PX_PHYSX_GPU_API physx::PxCudaContextManager* PX_CALL_CONV PxCreateCudaContextManager(physx::PxFoundation& foundation, const physx::PxCudaContextManagerDesc& desc, physx::PxProfilerCallback* profilerCallback = NULL); |
168 | |
169 | /** |
170 | Query the device ordinal - depends on control panel settings. |
171 | */ |
172 | PX_C_EXPORT PX_PHYSX_GPU_API int PX_CALL_CONV PxGetSuggestedCudaDeviceOrdinal(physx::PxErrorCallback& errc); |
173 | |
174 | namespace grid |
175 | { |
176 | class ServerImpl; |
177 | class ClientContextPredictionManager; |
178 | } |
179 | |
180 | PX_C_EXPORT PX_PHYSX_GPU_API grid::ClientContextPredictionManager* PX_CALL_CONV PxCreateCudaClientContextManager(grid::ServerImpl* server, physx::PxU32 maxNbSleepMsg); |
181 | |
182 | #endif // PX_PHYSX_GPU_H |
183 | |