| 819 | |
| 820 | |
| 821 | void PhysXSample::onInit() |
| 822 | { |
| 823 | |
| 824 | //Recording memory allocations is necessary if you want to |
| 825 | //use the memory facilities in PVD effectively. Since PVD isn't necessarily connected |
| 826 | //right away, we add a mechanism that records all outstanding memory allocations and |
| 827 | //forwards them to PVD when it does connect. |
| 828 | |
| 829 | //This certainly has a performance and memory profile effect and thus should be used |
| 830 | //only in non-production builds. |
| 831 | bool recordMemoryAllocations = true; |
| 832 | const bool useCustomTrackingAllocator = true; |
| 833 | |
| 834 | PxAllocatorCallback* allocator = &gDefaultAllocatorCallback; |
| 835 | |
| 836 | if(useCustomTrackingAllocator) |
| 837 | allocator = getSampleAllocator(); //optional override that will track memory allocations |
| 838 | |
| 839 | mFoundation = PxCreateFoundation(PX_PHYSICS_VERSION, *allocator, getSampleErrorCallback()); |
| 840 | if(!mFoundation) |
| 841 | fatalError("PxCreateFoundation failed!"); |
| 842 | |
| 843 | #if PX_SUPPORT_GPU_PHYSX |
| 844 | if(mCreateCudaCtxManager) |
| 845 | { |
| 846 | PxCudaContextManagerDesc cudaContextManagerDesc; |
| 847 | |
| 848 | #if defined(RENDERER_ENABLE_CUDA_INTEROP) |
| 849 | if (!mApplication.getCommandLine().hasSwitch("nointerop")) |
| 850 | { |
| 851 | switch(getRenderer()->getDriverType()) |
| 852 | { |
| 853 | case Renderer::DRIVER_DIRECT3D11: |
| 854 | cudaContextManagerDesc.interopMode = PxCudaInteropMode::D3D11_INTEROP; |
| 855 | break; |
| 856 | case Renderer::DRIVER_OPENGL: |
| 857 | cudaContextManagerDesc.interopMode = PxCudaInteropMode::OGL_INTEROP; |
| 858 | break; |
| 859 | } |
| 860 | cudaContextManagerDesc.graphicsDevice = getRenderer()->getDevice(); |
| 861 | } |
| 862 | #endif |
| 863 | mCudaContextManager = PxCreateCudaContextManager(*mFoundation, cudaContextManagerDesc, PxGetProfilerCallback()); |
| 864 | if( mCudaContextManager ) |
| 865 | { |
| 866 | if( !mCudaContextManager->contextIsValid() ) |
| 867 | { |
| 868 | mCudaContextManager->release(); |
| 869 | mCudaContextManager = NULL; |
| 870 | } |
| 871 | } |
| 872 | } |
| 873 | #endif |
| 874 | |
| 875 | createPvdConnection(); |
| 876 | |
| 877 | PxTolerancesScale scale; |
| 878 | customizeTolerances(scale); |
nothing calls this directly
no test coverage detected