Mochi.PhysX
Mochi.PhysX copied to clipboard
Provide NuGet package for CUDA support
CUDA support in PhysX is closed-source and requires redistributing a pair of additional DLLs. PhysXDevice64.dll
and PhysXGpu_64.dll
For Linux there is just a single libPhysXGpu_64.so
.
These DLLs are fairly huge, even bigger than PhysX its self, so I don't think it makes sense to include them in the Mochi.PhysX.Native
packages since not everyone will want or need them.
For whatever reason, these DLLs are not copied to the install
folder. So we need to dig them out of the bin
directory ourselves.
Additionally, for Windows PhysXGpu_64.dll
is only present in the win.x86_64.vc140.mt
folder. For other versions of MSVC it is copied from there. The PhysXDevice64.dll
is present in all folders, although it's just the same file copied over and over.
It is worth noting that none of these files are the same between build variants. I accidentally loaded the release
GPU DLL with a checked
build and it crashed, so it's important we match variants.
As such I think we should extend MochiPhysX.SelectRuntimeVariant
to call PxSetPhysXGpuLoadHook
as appropriate on the user's behalf. It might also be wise to force it to an invalid value in the event the DLL is missing in order to prevent a crash in the scenario where the developer has a Mochi.PhysX.Native.win-x64-checked
and ``Mochi.PhysX.NativeGpu.win-x64installed but not
Mochi.PhysX.NativeGpu.win-x64.checked. (PhysX gracefully handles the DLL missing, presumably running as if GPU support wasn't enabled. The [structure of
SnippetHelloGRB`](https://github.com/NVIDIAGameWorks/PhysX/blob/c3d5537bdebd6f5cd82fcaf87474b838fe6fd5fa/physx/snippets/snippethellogrb/SnippetHelloGRB.cpp#L111-L118) somewhat implies this is partially the consumer's responsibility, but in practice it doesn't actually seem to work that way.)
Note that while the PhysX user guide doesn't mention PhysXDevice64.dll
, it is mentioned in the Windows platform readme. It is required, and reside alongside PhysXGPU_64.dll
.