RavEngine
Loading...
Searching...
No Matches
PxPhysXGpu.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// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
27// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
28
29#ifndef PX_PHYSX_GPU_H
30#define PX_PHYSX_GPU_H
31
32#include "task/PxTask.h"
33
34#include "foundation/PxPinnedArray.h"
35#include "common/PxPhysXCommonConfig.h"
36#include "PxSceneDesc.h"
37#include "PxBuffer.h"
38#include "cudamanager/PxCudaContextManager.h"
39
40namespace physx
41{
42
43class PxFoundation;
44class PxCudaContextManagerDesc;
45class PxvNphaseImplementationContext;
46class PxsContext;
47class PxsKernelWranglerManager;
48class PxvNphaseImplementationFallback;
49struct PxgDynamicsMemoryConfig;
50class PxsMemoryManager;
51class PxsHeapMemoryAllocatorManager;
52class PxsSimulationController;
53class PxsSimulationControllerCallback;
54class PxDelayLoadHook;
55class PxParticleBuffer;
56class PxParticleAndDiffuseBuffer;
57class PxParticleClothBuffer;
58class PxParticleRigidBuffer;
59
60struct PxvSimStats;
61
62namespace Bp
63{
64 class BroadPhase;
65 class AABBManagerBase;
66 class BoundsArray;
67}
68
69namespace Dy
70{
71 class Context;
72}
73
74namespace IG
75{
76 class IslandSim;
77 class SimpleIslandManager;
78}
79
80namespace Cm
81{
82 class FlushPool;
83}
84
92{
93protected:
94 virtual ~PxPhysXGpu() {}
95 PxPhysXGpu() {}
96public:
97
101 virtual void release() = 0;
102
106 virtual PxBuffer* createBuffer(PxU64 byteSize, PxBufferType::Enum bufferType, PxCudaContextManager* cudaContexManager, PxU64* memStat) = 0;
107 virtual PxBuffer* createBuffer(PxU64 byteSyte, PxBufferType::Enum type, PxCudaContextManager* contextManager, PxU64* memStat, PxsHeapMemoryAllocatorManager* heapMemoryManager, void* stream) = 0;
108
109 virtual PxParticleBuffer* createParticleBuffer(PxU32 maxNumParticles, PxU32 maxVolumes, PxCudaContextManager* cudaContextManager, PxU64* memStat, void (*onParticleBufferRelease)(PxParticleBuffer* buffer)) = 0;
110 virtual PxParticleClothBuffer* createParticleClothBuffer(PxU32 maxNumParticles, PxU32 maxVolumes, PxU32 maxNumCloths, PxU32 maxNumTriangles, PxU32 maxNumSprings, PxCudaContextManager* cudaContextManager, PxU64* memStat, void (*onParticleBufferRelease)(PxParticleBuffer* buffer)) = 0;
111 virtual PxParticleRigidBuffer* createParticleRigidBuffer(PxU32 maxNumParticles, PxU32 maxVolumes, PxU32 maxNumRigids, PxCudaContextManager* cudaContextManager, PxU64* memStat, void (*onParticleBufferRelease)(PxParticleBuffer* buffer)) = 0;
112 virtual PxParticleAndDiffuseBuffer* createParticleAndDiffuseBuffer(PxU32 maxParticles, PxU32 maxVolumes, PxU32 maxDiffuseParticles, PxCudaContextManager* cudaContextManager, PxU64* memStat, void (*onParticleBufferRelease)(PxParticleBuffer* buffer)) = 0;
113
114 virtual void resizeBuffer(PxBuffer* buffer, PxU64 byteSize) = 0;
115
119 virtual void addCopyCommand(PxBuffer& dst, PxBuffer& src, bool flush) = 0;
120 virtual void addCopyCommand(PxBuffer& dst, PxBuffer& src, PxU32 srcOffset, PxU32 dstOffset, PxU32 size, bool flush) = 0;
121
125 virtual PxsMemoryManager* createGpuMemoryManager(PxCudaContextManager* cudaContextManager) = 0;
126
127 virtual PxsHeapMemoryAllocatorManager* createGpuHeapMemoryAllocatorManager(
128 const PxU32 heapCapacity,
129 PxsMemoryManager* memoryManager,
130 const PxU32 gpuComputeVersion) = 0;
131
136 PxCudaContextManager* cudaContextManager,
137 PxErrorCallback& errorCallback,
138 const PxU32 gpuComputeVersion) = 0;
139
144 PxsKernelWranglerManager* gpuKernelWrangler,
145 PxCudaContextManager* cudaContextManager,
146 const PxU32 gpuComputeVersion,
147 const PxgDynamicsMemoryConfig& config,
148 PxsHeapMemoryAllocatorManager* heapMemoryManager, PxU64 contextID) = 0;
149
150
155 PxsKernelWranglerManager* gpuKernelWrangler,
156 PxCudaContextManager* cudaContextManager,
157 const PxU32 gpuComputeVersion,
158 const PxgDynamicsMemoryConfig& config,
159 PxsHeapMemoryAllocatorManager* heapMemoryManager,
160 Bp::BroadPhase& bp,
161 Bp::BoundsArray& boundsArray,
162 PxFloatArrayPinned& contactDistance,
163 PxU32 maxNbAggregates, PxU32 maxNbShapes,
164 PxVirtualAllocator& allocator,
165 PxU64 contextID,
166 PxPairFilteringMode::Enum kineKineFilteringMode,
167 PxPairFilteringMode::Enum staticKineFilteringMode) = 0;
168
173 PxsKernelWranglerManager* gpuKernelWrangler,
174 PxvNphaseImplementationFallback* fallbackForUnsupportedCMs,
175 const PxgDynamicsMemoryConfig& gpuDynamicsConfig, void* contactStreamBase, void* patchStreamBase, void* forceAndIndiceStreamBase,
176 PxBoundsArrayPinned& bounds, IG::IslandSim* islandSim,
177 physx::Dy::Context* dynamicsContext, const PxU32 gpuComputeVersion, PxsHeapMemoryAllocatorManager* heapMemoryManager,
178 bool useGpuBP) = 0;
179
184 PxCudaContextManager* cudaContextManager,
185 Dy::Context* dynamicContext, PxvNphaseImplementationContext* npContext, Bp::BroadPhase* bp,
186 const bool useGpuBroadphase, IG::SimpleIslandManager* simpleIslandSim,
187 PxsSimulationControllerCallback* callback, const PxU32 gpuComputeVersion, PxsHeapMemoryAllocatorManager* heapMemoryManager,
188 const PxU32 maxSoftBodyContacts, const PxU32 maxFemClothContacts, const PxU32 maxParticleContacts, const PxU32 maxHairContacts) = 0;
189
194 PxCudaContextManager* cudaContextManager,
195 const PxgDynamicsMemoryConfig& config, IG::SimpleIslandManager* islandManager, const PxU32 maxNumPartitions, const PxU32 maxNumStaticPartitions,
196 const bool enableStabilization, const bool useEnhancedDeterminism, const PxReal maxBiasCoefficient,
197 const PxU32 gpuComputeVersion, PxvSimStats& simStats, PxsHeapMemoryAllocatorManager* heapMemoryManager,
198 const bool frictionEveryIteration, PxSolverType::Enum solverType, const PxReal lengthScale) = 0;
199
200};
201
202}
203
207PX_C_EXPORT PX_PHYSX_GPU_API physx::PxPhysXGpu* PX_CALL_CONV PxCreatePhysXGpu();
208
212PX_C_EXPORT PX_PHYSX_GPU_API physx::PxCudaContextManager* PX_CALL_CONV PxCreateCudaContextManager(physx::PxFoundation& foundation, const physx::PxCudaContextManagerDesc& desc, physx::PxProfilerCallback* profilerCallback = NULL);
213
217PX_C_EXPORT PX_PHYSX_GPU_API void PX_CALL_CONV PxSetPhysXGpuProfilerCallback(physx::PxProfilerCallback* profilerCallback);
218
222PX_C_EXPORT PX_PHYSX_GPU_API int PX_CALL_CONV PxGetSuggestedCudaDeviceOrdinal(physx::PxErrorCallback& errc);
223
224// Implementation of the corresponding functions from PxGpu.h/cpp in the GPU shared library
225PX_C_EXPORT PX_PHYSX_GPU_API void PX_CALL_CONV PxGpuCudaRegisterFunction(int moduleIndex, const char* functionName);
226PX_C_EXPORT PX_PHYSX_GPU_API void** PX_CALL_CONV PxGpuCudaRegisterFatBinary(void* fatBin);
227#if PX_SUPPORT_GPU_PHYSX
228PX_C_EXPORT PX_PHYSX_GPU_API physx::PxKernelIndex* PX_CALL_CONV PxGpuGetCudaFunctionTable();
229PX_C_EXPORT PX_PHYSX_GPU_API physx::PxU32 PX_CALL_CONV PxGpuGetCudaFunctionTableSize();
230PX_C_EXPORT PX_PHYSX_GPU_API void** PX_CALL_CONV PxGpuGetCudaModuleTable();
231PX_C_EXPORT PX_PHYSX_GPU_API physx::PxU32 PX_CALL_CONV PxGpuGetCudaModuleTableSize();
232#endif
233
234#endif // PX_PHYSX_GPU_H
Definition base.h:1940
A structure responsible for: storing an aabb representation for each active shape in the related scen...
Definition BpAABBManagerBase.h:165
Definition BpAABBManagerBase.h:101
Definition BpBroadPhase.h:99
Definition CmFlushPool.h:49
Definition DyContext.h:76
Definition PxsIslandSim.h:412
Definition PxsSimpleIslandManager.h:87
Buffer for delayed bulk read and write operations supporting host and GPU device memory spaces.
Definition PxBuffer.h:66
User defined interface class. Used by the library to emit debug information.
Definition PxErrorCallback.h:51
Foundation SDK singleton class.
Definition PxFoundation.h:57
A particle buffer used to simulate diffuse particles.
Definition PxParticleBuffer.h:283
The shared base class for all particle buffers, can be instantiated directly to simulate granular and...
Definition PxParticleBuffer.h:81
A particle buffer used to simulate particle cloth.
Definition PxParticleBuffer.h:429
A particle buffer used to simulate rigid bodies using shape matching with particles.
Definition PxParticleBuffer.h:491
Interface to create and run CUDA enabled PhysX features.
Definition PxPhysXGpu.h:92
virtual void addCopyCommand(PxBuffer &dst, PxBuffer &src, bool flush)=0
virtual PxsKernelWranglerManager * createGpuKernelWranglerManager(PxCudaContextManager *cudaContextManager, PxErrorCallback &errorCallback, const PxU32 gpuComputeVersion)=0
virtual void release()=0
Closes this instance of the interface.
virtual PxBuffer * createBuffer(PxU64 byteSize, PxBufferType::Enum bufferType, PxCudaContextManager *cudaContexManager, PxU64 *memStat)=0
virtual Bp::BroadPhase * createGpuBroadPhase(PxsKernelWranglerManager *gpuKernelWrangler, PxCudaContextManager *cudaContextManager, const PxU32 gpuComputeVersion, const PxgDynamicsMemoryConfig &config, PxsHeapMemoryAllocatorManager *heapMemoryManager, PxU64 contextID)=0
virtual Bp::AABBManagerBase * createGpuAABBManager(PxsKernelWranglerManager *gpuKernelWrangler, PxCudaContextManager *cudaContextManager, const PxU32 gpuComputeVersion, const PxgDynamicsMemoryConfig &config, PxsHeapMemoryAllocatorManager *heapMemoryManager, Bp::BroadPhase &bp, Bp::BoundsArray &boundsArray, PxFloatArrayPinned &contactDistance, PxU32 maxNbAggregates, PxU32 maxNbShapes, PxVirtualAllocator &allocator, PxU64 contextID, PxPairFilteringMode::Enum kineKineFilteringMode, PxPairFilteringMode::Enum staticKineFilteringMode)=0
virtual Dy::Context * createGpuDynamicsContext(Cm::FlushPool &taskPool, PxsKernelWranglerManager *gpuKernelWragler, PxCudaContextManager *cudaContextManager, const PxgDynamicsMemoryConfig &config, IG::SimpleIslandManager *islandManager, const PxU32 maxNumPartitions, const PxU32 maxNumStaticPartitions, const bool enableStabilization, const bool useEnhancedDeterminism, const PxReal maxBiasCoefficient, const PxU32 gpuComputeVersion, PxvSimStats &simStats, PxsHeapMemoryAllocatorManager *heapMemoryManager, const bool frictionEveryIteration, PxSolverType::Enum solverType, const PxReal lengthScale)=0
virtual PxvNphaseImplementationContext * createGpuNphaseImplementationContext(PxsContext &context, PxsKernelWranglerManager *gpuKernelWrangler, PxvNphaseImplementationFallback *fallbackForUnsupportedCMs, const PxgDynamicsMemoryConfig &gpuDynamicsConfig, void *contactStreamBase, void *patchStreamBase, void *forceAndIndiceStreamBase, PxBoundsArrayPinned &bounds, IG::IslandSim *islandSim, physx::Dy::Context *dynamicsContext, const PxU32 gpuComputeVersion, PxsHeapMemoryAllocatorManager *heapMemoryManager, bool useGpuBP)=0
virtual PxsSimulationController * createGpuSimulationController(PxsKernelWranglerManager *gpuWranglerManagers, PxCudaContextManager *cudaContextManager, Dy::Context *dynamicContext, PxvNphaseImplementationContext *npContext, Bp::BroadPhase *bp, const bool useGpuBroadphase, IG::SimpleIslandManager *simpleIslandSim, PxsSimulationControllerCallback *callback, const PxU32 gpuComputeVersion, PxsHeapMemoryAllocatorManager *heapMemoryManager, const PxU32 maxSoftBodyContacts, const PxU32 maxFemClothContacts, const PxU32 maxParticleContacts, const PxU32 maxHairContacts)=0
virtual PxsMemoryManager * createGpuMemoryManager(PxCudaContextManager *cudaContextManager)=0
The pure virtual callback interface for general purpose instrumentation and profiling of GameWorks mo...
Definition PxProfiler.h:42
Definition PxAllocator.h:158
Definition PxsContext.h:92
Definition PxsHeapMemoryAllocator.h:83
Definition PxsKernelWrangler.h:41
Definition PxsMemoryManager.h:40
Definition PxsSimulationController.h:114
Definition PxsSimulationController.h:124
Definition PxvNphaseImplementationContext.h:120
Definition PxvNphaseImplementationContext.h:212
#define PX_CALL_CONV
Definition PxPreprocessor.h:299
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
Enum
Definition PxFiltering.h:717
Enum
Definition PxSceneDesc.h:89
Sizes of pre-allocated buffers use for GPU dynamics.
Definition PxSceneDesc.h:377
Definition PxvSimStats.h:52