From 67e94d4f8c9cb4f64c22cbe91f8dcb7b19ffe577 Mon Sep 17 00:00:00 2001 From: moraaar Date: Mon, 18 Jan 2021 13:06:41 +0000 Subject: [PATCH] - Added support to build both share & static libraries on all platforms (pc, mac, ios, android, linux) + Modified cmake files to be able to choose between static or dynamic libraries + Predefined NvCloth API macros when building staticly so it doesn't include any export/import code. - Fixed linking error on iOS as it didn't include any implementation for Atomics (using unix version as Mac does) - Fixed Windows cmake bug when choosing between /MT and /MD. - Fixed linking error when NEON is enabled caused by compiling SwCollision.cpp, SwSelfCollision.cpp and SwSolverKernel.cpp content twice. - Enabled NEON SIMD instructions on all platforms that supports it: + Modified NEON code to be platform agnostic using macros, not Android only. + Enbled NEON instructions on iOS + Modified Android cmake files to use the right macros depending on ABI being built. - Fixed compilation error when client app uses NvCloth library and the app compiles with Visual Studio 2019. + Microsoft removed from VS2019 16.3 and that header is used by NvCloth library. Fixed nVidia's NvCloth library to use instead from that version. - Fixed unstable cloth simulation on Android (armv8). + Cloth particles during simulation were very unstable on Android (armv8), their location gets out of control really quickly with very unpredictable behaviour. After many attempts to find the source of the problem debugging the library, the solution came by adding the flag "-ffast-math" in the compilation of the library for Android (armv8). --- NvCloth/BuildProjectsIOS.sh | 8 +++++ NvCloth/BuildProjectsOsx.sh | 8 +++++ NvCloth/CmakeGenerateAndroid.bat | 6 ++-- NvCloth/CmakeGenerateProjects.bat | 8 ++++- NvCloth/GenerateProjectsIOS.sh | 2 +- NvCloth/GenerateProjectsLinux.sh | 8 ++--- NvCloth/GenerateProjectsOsx.sh | 2 +- NvCloth/compiler/cmake/android/CMakeLists.txt | 10 ++++-- NvCloth/compiler/cmake/android/NvCloth.cmake | 33 +++++++++++++++---- NvCloth/compiler/cmake/ios/CMakeLists.txt | 2 +- NvCloth/compiler/cmake/ios/NvCloth.cmake | 25 ++++++++++---- NvCloth/compiler/cmake/linux/NvCloth.cmake | 14 ++++---- NvCloth/compiler/cmake/mac/NvCloth.cmake | 18 ++++++---- NvCloth/compiler/cmake/windows/CMakeLists.txt | 2 +- NvCloth/compiler/cmake/windows/NvCloth.cmake | 18 ++++++---- NvCloth/include/NvCloth/ps/PsAllocator.h | 6 +++- NvCloth/scripts/locate_cuda.bat | 2 +- NvCloth/src/SwSolver.cpp | 11 +++++-- NvCloth/src/neon/NeonCollision.cpp | 2 +- NvCloth/src/neon/NeonSelfCollision.cpp | 2 +- NvCloth/src/neon/NeonSolverKernel.cpp | 11 ++++++- PxShared/include/foundation/PxPreprocessor.h | 6 ++-- 22 files changed, 147 insertions(+), 57 deletions(-) diff --git a/NvCloth/BuildProjectsIOS.sh b/NvCloth/BuildProjectsIOS.sh index 5a686c0..882a98c 100644 --- a/NvCloth/BuildProjectsIOS.sh +++ b/NvCloth/BuildProjectsIOS.sh @@ -25,3 +25,11 @@ cd compiler/ios-cmake/ $CMAKE --build . --target ALL_BUILD --clean-first --config debug -- -parallelizeTargets -jobs 5 || exit 1 cd ../../ +cd compiler/ios-cmake/ +$CMAKE --build . --target ALL_BUILD --clean-first --config profile -- -parallelizeTargets -jobs 5 || exit 1 +cd ../../ + +cd compiler/ios-cmake/ +$CMAKE --build . --target ALL_BUILD --clean-first --config checked -- -parallelizeTargets -jobs 5 || exit 1 +cd ../../ + diff --git a/NvCloth/BuildProjectsOsx.sh b/NvCloth/BuildProjectsOsx.sh index e25cffc..93f7c1d 100644 --- a/NvCloth/BuildProjectsOsx.sh +++ b/NvCloth/BuildProjectsOsx.sh @@ -25,3 +25,11 @@ cd compiler/osx64-cmake/ $CMAKE --build . --target ALL_BUILD --clean-first --config debug -- -parallelizeTargets -jobs 5 || exit 1 cd ../../ +cd compiler/osx64-cmake/ +$CMAKE --build . --target ALL_BUILD --clean-first --config profile -- -parallelizeTargets -jobs 5 || exit 1 +cd ../../ + +cd compiler/osx64-cmake/ +$CMAKE --build . --target ALL_BUILD --clean-first --config checked -- -parallelizeTargets -jobs 5 || exit 1 +cd ../../ + diff --git a/NvCloth/CmakeGenerateAndroid.bat b/NvCloth/CmakeGenerateAndroid.bat index fc0a40d..6ffdbc4 100644 --- a/NvCloth/CmakeGenerateAndroid.bat +++ b/NvCloth/CmakeGenerateAndroid.bat @@ -71,15 +71,15 @@ REM https://cmake.org/cmake/help/v3.7/manual/cmake-toolchains.7.html#cross-compi REM https://developer.android.com/ndk/guides/cmake.html REM REM Common cmd line params -set CMAKE_COMMON_PARAMS=-DANDROID_NDK=%NDK% -DANDROID_ABI=%ANDROID_ABI% -DGW_DEPS_ROOT=%GW_DEPS_ROOT% -DPX_OUTPUT_DLL_DIR=%PX_OUTPUT_ROOT%\Bin\%ANDROID_DIR_NAME% -DPX_OUTPUT_LIB_DIR=%PX_OUTPUT_ROOT%\Lib\%ANDROID_DIR_NAME% -DPX_OUTPUT_EXE_DIR=%PX_OUTPUT_ROOT%\Bin\%ANDROID_DIR_NAME% +set CMAKE_COMMON_PARAMS=-DANDROID_NDK=%NDK% -DANDROID_ABI=%ANDROID_ABI% -DGW_DEPS_ROOT=%GW_DEPS_ROOT% -DPX_OUTPUT_DLL_DIR=%PX_OUTPUT_ROOT%\Bin\%ANDROID_DIR_NAME% -DPX_OUTPUT_LIB_DIR=%PX_OUTPUT_ROOT%\Lib\%ANDROID_DIR_NAME% -DPX_OUTPUT_EXE_DIR=%PX_OUTPUT_ROOT%\Bin\%ANDROID_DIR_NAME% -DPX_STATIC_LIBRARIES=1 REM Compiler dependent cmd line params set CMAKE_COMPILER_PARAMS=-G "MinGW Makefiles" -DCMAKE_MAKE_PROGRAM=%NDK_MAKE% -DCMAKE_BUILD_TYPE=%CONFIG_NAME% -DCMAKE_ANDROID_ARCH_ABI=%ANDROID_ABI% REM set CMAKE_COMPILER_PARAMS=-G "Visual Studio 14 2015" -DCMAKE_ANDROID_ARCH=%ANDROID_ABI% REM Toolchain dependent cmd line params -REM set CMAKE_TOOLCHAIN_PARAMS=-DCMAKE_TOOLCHAIN_FILE=C:\Users\lpanov\projects\nvidia\NvCloth\Externals\CMakeModules\Android\android.toolchain.cmake -DANDROID_NATIVE_API_LEVEL=android-%ANDROID_API% -DANDROID_ABI=%ANDROID_ABI% -DANDROID_STL="gnustl_static" -DTARGET_BUILD_PLATFORM=android -set CMAKE_TOOLCHAIN_PARAMS=-DCMAKE_SYSTEM_NAME=Android -DCMAKE_ANDROID_API_MIN=%ANDROID_API% -DCMAKE_ANDROID_API=%ANDROID_API% +set CMAKE_TOOLCHAIN_PARAMS=-DCMAKE_TOOLCHAIN_FILE=%GW_DEPS_ROOT%\NvCloth\Externals\CMakeModules\android\android.toolchain.cmake -DANDROID_NATIVE_API_LEVEL=android-%ANDROID_API% -DANDROID_ABI=%ANDROID_ABI% -DANDROID_STL="gnustl_static" -DTARGET_BUILD_PLATFORM=android +REM set CMAKE_TOOLCHAIN_PARAMS=-DCMAKE_SYSTEM_NAME=Android -DCMAKE_ANDROID_API_MIN=%ANDROID_API% -DCMAKE_ANDROID_API=%ANDROID_API% %CMAKE% ..\cmake\android %CMAKE_COMPILER_PARAMS% %CMAKE_TOOLCHAIN_PARAMS% %CMAKE_COMMON_PARAMS% IF %ERRORLEVEL% NEQ 0 ( diff --git a/NvCloth/CmakeGenerateProjects.bat b/NvCloth/CmakeGenerateProjects.bat index 5896f9a..84bc3c0 100644 --- a/NvCloth/CmakeGenerateProjects.bat +++ b/NvCloth/CmakeGenerateProjects.bat @@ -38,7 +38,7 @@ IF %ERRORLEVEL% NEQ 0 ( set CMAKE=%PM_cmake_PATH%/bin/cmake.exe REM Common for all generators -set CMAKE_COMMON_PARAMS=-DTARGET_BUILD_PLATFORM=windows -DNV_CLOTH_ENABLE_DX11=%USE_DX11% -DNV_CLOTH_ENABLE_CUDA=%USE_CUDA% -DPX_GENERATE_GPU_PROJECTS=1 -DCUDA_TOOLKIT_ROOT_DIR="%CUDA_PATH_%" -DWIN8SDK_PATH="%WIN8SDK_PATH%" -DSTATIC_WINCRT=1 +set CMAKE_COMMON_PARAMS=-DTARGET_BUILD_PLATFORM=windows -DNV_CLOTH_ENABLE_DX11=%USE_DX11% -DNV_CLOTH_ENABLE_CUDA=%USE_CUDA% -DPX_GENERATE_GPU_PROJECTS=1 -DCUDA_TOOLKIT_ROOT_DIR="%CUDA_PATH_%" -DWIN8SDK_PATH="%WIN8SDK_PATH%" -DSTATIC_WINCRT=1 -DPX_STATIC_LIBRARIES=1 REM Generate projects here @@ -73,6 +73,12 @@ pushd compiler\vc14win64-cmake\ %CMAKE% ..\cmake\windows -G "Visual Studio 14 2015" -Ax64 %CMAKE_COMMON_PARAMS% -DPX_OUTPUT_DLL_DIR=%PX_OUTPUT_ROOT%\bin\vc14win64-cmake -DPX_OUTPUT_LIB_DIR=%PX_OUTPUT_ROOT%\lib\vc14win64-cmake -DPX_OUTPUT_EXE_DIR=%PX_OUTPUT_ROOT%\bin\vc14win64-cmake popd +rmdir /s /q compiler\vc141win64-cmake\ +mkdir compiler\vc141win64-cmake\ +pushd compiler\vc141win64-cmake\ +%CMAKE% ..\cmake\windows -G "Visual Studio 15 2017" -Ax64 %CMAKE_COMMON_PARAMS% -DPX_OUTPUT_DLL_DIR=%PX_OUTPUT_ROOT%\bin\vc141win64-cmake -DPX_OUTPUT_LIB_DIR=%PX_OUTPUT_ROOT%\lib\vc141win64-cmake -DPX_OUTPUT_EXE_DIR=%PX_OUTPUT_ROOT%\bin\vc141win64-cmake +popd + goto End diff --git a/NvCloth/GenerateProjectsIOS.sh b/NvCloth/GenerateProjectsIOS.sh index d4acdbe..4937842 100644 --- a/NvCloth/GenerateProjectsIOS.sh +++ b/NvCloth/GenerateProjectsIOS.sh @@ -26,7 +26,7 @@ export USE_CUDA=0 rm -r -f compiler/ios-cmake/ mkdir compiler/ios-cmake/ cd compiler/ios-cmake/ -$CMAKE ../cmake/ios -G Xcode -DCMAKE_TOOLCHAIN_FILE=$GW_DEPS_ROOT/NvCloth/Externals/CMakeModules/ios/ios.toolchain.cmake -DTARGET_BUILD_PLATFORM=ios -DCMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET="8.0" -DNV_CLOTH_ENABLE_CUDA=$USE_CUDA -DUSE_CUDA=$USE_CUDA -DPX_GENERATE_GPU_PROJECTS=0 -DPX_OUTPUT_DLL_DIR=$PX_OUTPUT_ROOT/bin/ios-cmake -DPX_OUTPUT_LIB_DIR=$PX_OUTPUT_ROOT/lib/ios-cmake -DPX_OUTPUT_EXE_DIR=$PX_OUTPUT_ROOT/bin/ios-cmake || exit 1 +$CMAKE ../cmake/ios -G Xcode -DCMAKE_TOOLCHAIN_FILE=$GW_DEPS_ROOT/NvCloth/Externals/CMakeModules/ios/ios.toolchain.cmake -DTARGET_BUILD_PLATFORM=ios -DCMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET="8.0" -DPX_STATIC_LIBRARIES=1 -DNV_CLOTH_ENABLE_CUDA=$USE_CUDA -DUSE_CUDA=$USE_CUDA -DPX_GENERATE_GPU_PROJECTS=0 -DPX_OUTPUT_DLL_DIR=$PX_OUTPUT_ROOT/bin/ios-cmake -DPX_OUTPUT_LIB_DIR=$PX_OUTPUT_ROOT/lib/ios-cmake -DPX_OUTPUT_EXE_DIR=$PX_OUTPUT_ROOT/bin/ios-cmake || exit 1 cd ../../ diff --git a/NvCloth/GenerateProjectsLinux.sh b/NvCloth/GenerateProjectsLinux.sh index 3be88ac..c9a118e 100644 --- a/NvCloth/GenerateProjectsLinux.sh +++ b/NvCloth/GenerateProjectsLinux.sh @@ -43,23 +43,23 @@ export USE_CUDA=0 rm -r -f compiler/linux64-debug-cmake/ mkdir compiler/linux64-debug-cmake/ cd compiler/linux64-debug-cmake/ -$CMAKE ../cmake/linux -G "Unix Makefiles" -DTARGET_BUILD_PLATFORM=linux -DCMAKE_BUILD_TYPE=debug -DNV_CLOTH_ENABLE_CUDA=$USE_CUDA -DPX_GENERATE_GPU_PROJECTS=0 -DPX_OUTPUT_DLL_DIR=$PX_OUTPUT_ROOT/bin/linux64-cmake -DPX_OUTPUT_LIB_DIR=$PX_OUTPUT_ROOT/lib/linux64-cmake -DPX_OUTPUT_EXE_DIR=$PX_OUTPUT_ROOT/bin/linux64-cmake || exit 1 +$CMAKE ../cmake/linux -G "Unix Makefiles" -DTARGET_BUILD_PLATFORM=linux -DCMAKE_BUILD_TYPE=debug -DPX_STATIC_LIBRARIES=1 -DNV_CLOTH_ENABLE_CUDA=$USE_CUDA -DPX_GENERATE_GPU_PROJECTS=0 -DPX_OUTPUT_DLL_DIR=$PX_OUTPUT_ROOT/bin/linux64-cmake -DPX_OUTPUT_LIB_DIR=$PX_OUTPUT_ROOT/lib/linux64-cmake -DPX_OUTPUT_EXE_DIR=$PX_OUTPUT_ROOT/bin/linux64-cmake || exit 1 cd ../../ rm -r -f compiler/linux64-checked-cmake/ mkdir compiler/linux64-checked-cmake/ cd compiler/linux64-checked-cmake/ -$CMAKE ../cmake/linux -G "Unix Makefiles" -DTARGET_BUILD_PLATFORM=linux -DCMAKE_BUILD_TYPE=checked -DNV_CLOTH_ENABLE_CUDA=$USE_CUDA -DPX_GENERATE_GPU_PROJECTS=0 -DPX_OUTPUT_DLL_DIR=$PX_OUTPUT_ROOT/bin/linux64-cmake -DPX_OUTPUT_LIB_DIR=$PX_OUTPUT_ROOT/lib/linux64-cmake -DPX_OUTPUT_EXE_DIR=$PX_OUTPUT_ROOT/bin/linux64-cmake || exit 1 +$CMAKE ../cmake/linux -G "Unix Makefiles" -DTARGET_BUILD_PLATFORM=linux -DCMAKE_BUILD_TYPE=checked -DPX_STATIC_LIBRARIES=1 -DNV_CLOTH_ENABLE_CUDA=$USE_CUDA -DPX_GENERATE_GPU_PROJECTS=0 -DPX_OUTPUT_DLL_DIR=$PX_OUTPUT_ROOT/bin/linux64-cmake -DPX_OUTPUT_LIB_DIR=$PX_OUTPUT_ROOT/lib/linux64-cmake -DPX_OUTPUT_EXE_DIR=$PX_OUTPUT_ROOT/bin/linux64-cmake || exit 1 cd ../../ rm -r -f compiler/linux64-profile-cmake/ mkdir compiler/linux64-profile-cmake/ cd compiler/linux64-profile-cmake/ -$CMAKE ../cmake/linux -G "Unix Makefiles" -DTARGET_BUILD_PLATFORM=linux -DCMAKE_BUILD_TYPE=profile -DNV_CLOTH_ENABLE_CUDA=$USE_CUDA -DPX_GENERATE_GPU_PROJECTS=0 -DPX_OUTPUT_DLL_DIR=$PX_OUTPUT_ROOT/bin/linux64-cmake -DPX_OUTPUT_LIB_DIR=$PX_OUTPUT_ROOT/lib/linux64-cmake -DPX_OUTPUT_EXE_DIR=$PX_OUTPUT_ROOT/bin/linux64-cmake || exit 1 +$CMAKE ../cmake/linux -G "Unix Makefiles" -DTARGET_BUILD_PLATFORM=linux -DCMAKE_BUILD_TYPE=profile -DPX_STATIC_LIBRARIES=1 -DNV_CLOTH_ENABLE_CUDA=$USE_CUDA -DPX_GENERATE_GPU_PROJECTS=0 -DPX_OUTPUT_DLL_DIR=$PX_OUTPUT_ROOT/bin/linux64-cmake -DPX_OUTPUT_LIB_DIR=$PX_OUTPUT_ROOT/lib/linux64-cmake -DPX_OUTPUT_EXE_DIR=$PX_OUTPUT_ROOT/bin/linux64-cmake || exit 1 cd ../../ rm -r -f compiler/linux64-release-cmake/ mkdir compiler/linux64-release-cmake/ cd compiler/linux64-release-cmake/ -$CMAKE ../cmake/linux -G "Unix Makefiles" -DTARGET_BUILD_PLATFORM=linux -DCMAKE_BUILD_TYPE=release -DNV_CLOTH_ENABLE_CUDA=$USE_CUDA -DPX_GENERATE_GPU_PROJECTS=0 -DPX_OUTPUT_DLL_DIR=$PX_OUTPUT_ROOT/bin/linux64-cmake -DPX_OUTPUT_LIB_DIR=$PX_OUTPUT_ROOT/lib/linux64-cmake -DPX_OUTPUT_EXE_DIR=$PX_OUTPUT_ROOT/bin/linux64-cmake || exit 1 +$CMAKE ../cmake/linux -G "Unix Makefiles" -DTARGET_BUILD_PLATFORM=linux -DCMAKE_BUILD_TYPE=release -DPX_STATIC_LIBRARIES=1 -DNV_CLOTH_ENABLE_CUDA=$USE_CUDA -DPX_GENERATE_GPU_PROJECTS=0 -DPX_OUTPUT_DLL_DIR=$PX_OUTPUT_ROOT/bin/linux64-cmake -DPX_OUTPUT_LIB_DIR=$PX_OUTPUT_ROOT/lib/linux64-cmake -DPX_OUTPUT_EXE_DIR=$PX_OUTPUT_ROOT/bin/linux64-cmake || exit 1 cd ../../ diff --git a/NvCloth/GenerateProjectsOsx.sh b/NvCloth/GenerateProjectsOsx.sh index 7dc9b40..ac13310 100644 --- a/NvCloth/GenerateProjectsOsx.sh +++ b/NvCloth/GenerateProjectsOsx.sh @@ -26,6 +26,6 @@ export USE_CUDA=0 rm -r -f compiler/osx64-cmake/ mkdir compiler/osx64-cmake/ cd compiler/osx64-cmake/ -$CMAKE ../cmake/mac -G Xcode -DTARGET_BUILD_PLATFORM=mac -DNV_CLOTH_ENABLE_CUDA=$USE_CUDA -DUSE_CUDA=$USE_CUDA -DPX_GENERATE_GPU_PROJECTS=0 -DPX_OUTPUT_DLL_DIR=$PX_OUTPUT_ROOT/bin/osx64-cmake -DPX_OUTPUT_LIB_DIR=$PX_OUTPUT_ROOT/lib/osx64-cmake -DPX_OUTPUT_EXE_DIR=$PX_OUTPUT_ROOT/bin/osx64-cmake || exit 1 +$CMAKE ../cmake/mac -G Xcode -DTARGET_BUILD_PLATFORM=mac -DPX_STATIC_LIBRARIES=1 -DNV_CLOTH_ENABLE_CUDA=$USE_CUDA -DUSE_CUDA=$USE_CUDA -DPX_GENERATE_GPU_PROJECTS=0 -DPX_OUTPUT_DLL_DIR=$PX_OUTPUT_ROOT/bin/osx64-cmake -DPX_OUTPUT_LIB_DIR=$PX_OUTPUT_ROOT/lib/osx64-cmake -DPX_OUTPUT_EXE_DIR=$PX_OUTPUT_ROOT/bin/osx64-cmake || exit 1 cd ../../ diff --git a/NvCloth/compiler/cmake/android/CMakeLists.txt b/NvCloth/compiler/cmake/android/CMakeLists.txt index 7ef0673..da911d1 100644 --- a/NvCloth/compiler/cmake/android/CMakeLists.txt +++ b/NvCloth/compiler/cmake/android/CMakeLists.txt @@ -16,14 +16,19 @@ ENDIF() if(${ANDROID_ABI} STREQUAL "armeabi-v7a") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-rtti -fno-exceptions -ffunction-sections -fdata-sections -funwind-tables -fomit-frame-pointer -funswitch-loops -finline-limit=300 -fno-strict-aliasing -fstack-protector -Wno-invalid-offsetof ") + SET(NVCLOTH_ANDROID_ABI_DEFS __arm__;PX_SIMD_DISABLED) elseif(${ANDROID_ABI} STREQUAL "armeabi-v7a with NEON") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-rtti -ffast-math -fno-exceptions -ffunction-sections -funwind-tables -fomit-frame-pointer -funswitch-loops -finline-limit=300 -fno-strict-aliasing -fstack-protector -Wno-invalid-offsetof ") + SET(NVCLOTH_ANDROID_ABI_DEFS __arm__;__ARM_NEON__;NV_SIMD_SCALAR=1) elseif(${ANDROID_ABI} STREQUAL "arm64-v8a") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-rtti -fno-exceptions -ffunction-sections -fdata-sections -Wno-invalid-offsetof ") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-rtti -ffast-math -fno-exceptions -ffunction-sections -fdata-sections -Wno-invalid-offsetof ") + SET(NVCLOTH_ANDROID_ABI_DEFS __arm64__;__ARM_NEON__) elseif(${ANDROID_ABI} STREQUAL "x86") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-rtti -fno-exceptions -ffunction-sections -fdata-sections -Wno-invalid-offsetof -fpack-struct=8 -malign-double ") + SET(NVCLOTH_ANDROID_ABI_DEFS __i386__) elseif(${ANDROID_ABI} STREQUAL "x86_64") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-rtti -fno-exceptions -ffunction-sections -fdata-sections -Wno-invalid-offsetof -mstackrealign -msse3 ") + SET(NVCLOTH_ANDROID_ABI_DEFS __x86_64__) endif() SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g") @@ -33,8 +38,7 @@ SET(CMAKE_CXX_FLAGS_RELEASE "-O3") # a version from pxshared #SET(NVCLOTH_ANDROID_COMPILE_DEFS _LIB;__STDC_LIMIT_MACROS;) -# TODO: __ARM_NEON__;__arm64__ only on supporting archs -SET(NVCLOTH_ANDROID_COMPILE_DEFS _LIB;__STDC_LIMIT_MACROS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;PX_NVCLOTH_STATIC_LIB;__ARM_NEON__;__arm64__) +SET(NVCLOTH_ANDROID_COMPILE_DEFS _LIB;__STDC_LIMIT_MACROS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;${NVCLOTH_ANDROID_ABI_DEFS}) SET(NVCLOTH_ANDROID_DEBUG_COMPILE_DEFS _DEBUG;PX_DEBUG=1;PX_CHECKED=1) SET(NVCLOTH_ANDROID_CHECKED_COMPILE_DEFS NDEBUG;PX_CHECKED=1) SET(NVCLOTH_ANDROID_PROFILE_COMPILE_DEFS NDEBUG;PX_PROFILE=1) diff --git a/NvCloth/compiler/cmake/android/NvCloth.cmake b/NvCloth/compiler/cmake/android/NvCloth.cmake index 8463368..13fb92f 100644 --- a/NvCloth/compiler/cmake/android/NvCloth.cmake +++ b/NvCloth/compiler/cmake/android/NvCloth.cmake @@ -6,16 +6,25 @@ SET(GW_DEPS_ROOT $ENV{GW_DEPS_ROOT}) SET(NVCLOTH_SOURCE_DIR ${PROJECT_SOURCE_DIR}/../../../) +if(${ANDROID_ABI} STREQUAL "armeabi-v7a with NEON" OR ${ANDROID_ABI} STREQUAL "arm64-v8a") + SET(NVCLOTH_PLATFORM_NEON_FILES + ${PROJECT_ROOT_DIR}/src/neon/NeonCollision.cpp + ${PROJECT_ROOT_DIR}/src/neon/NeonSelfCollision.cpp + ${PROJECT_ROOT_DIR}/src/neon/NeonSolverKernel.cpp + ${PROJECT_ROOT_DIR}/src/neon/SwCollisionHelpers.h + ) +else() + SET(NVCLOTH_PLATFORM_NEON_FILES + ) +endif() + SET(NVCLOTH_PLATFORM_SOURCE_FILES ${PROJECT_ROOT_DIR}/src/ps/unix/PsUnixAtomic.cpp ${PROJECT_ROOT_DIR}/src/ps/unix/PsUnixFPU.h ${PROJECT_ROOT_DIR}/src/ps/android/cpu-features.c ${PROJECT_ROOT_DIR}/src/ps/android/cpu-features.h - ${PROJECT_ROOT_DIR}/src/neon/NeonCollision.cpp - ${PROJECT_ROOT_DIR}/src/neon/NeonSelfCollision.cpp - ${PROJECT_ROOT_DIR}/src/neon/NeonSolverKernel.cpp - ${PROJECT_ROOT_DIR}/src/neon/SwCollisionHelpers.h + ${NVCLOTH_PLATFORM_NEON_FILES} ) SET(NVCLOTH_PLATFORM_INCLUDES @@ -23,14 +32,18 @@ SET(NVCLOTH_PLATFORM_INCLUDES ${ANDROID_NDK}/sources/android/cpufeatures ) +IF(PX_STATIC_LIBRARIES) + SET(NVCLOTH_API_COMPILE_DEFS NV_CLOTH_IMPORT=;PX_CALL_CONV=;) +ELSE() + SET(NVCLOTH_API_COMPILE_DEFS NV_CLOTH_IMPORT=PX_DLL_EXPORT;) +ENDIF() + # Use generator expressions to set config specific preprocessor definitions SET(NVCLOTH_COMPILE_DEFS ${NVCLOTH_ANDROID_COMPILE_DEFS}; - NvCloth_STATIC_LIB; # TODO: needed? + ${NVCLOTH_API_COMPILE_DEFS} NV_ANDROID - NV_SIMD_SCALAR=1 # always compile scalar paths on android, so we may use them as fallback - NV_CLOTH_IMPORT=PX_DLL_EXPORT NV_CLOTH_ENABLE_DX11=0 NV_CLOTH_ENABLE_CUDA=0 @@ -40,5 +53,11 @@ SET(NVCLOTH_COMPILE_DEFS $<$:${NVCLOTH_ANDROID_RELEASE_COMPILE_DEFS};> ) +IF(PX_STATIC_LIBRARIES) + SET(NVCLOTH_LIBTYPE STATIC) +ELSE() + SET(NVCLOTH_LIBTYPE SHARED) +ENDIF() + # include common low level settings INCLUDE(../common/NvCloth.cmake) diff --git a/NvCloth/compiler/cmake/ios/CMakeLists.txt b/NvCloth/compiler/cmake/ios/CMakeLists.txt index bf36e95..938a5bf 100644 --- a/NvCloth/compiler/cmake/ios/CMakeLists.txt +++ b/NvCloth/compiler/cmake/ios/CMakeLists.txt @@ -28,7 +28,7 @@ SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -g") SET(PHYSX_IOS_ENABLE_NVTX 0) # Disable cuda and dx for all projects on ios -SET(PHYSX_IOS_COMPILE_DEFS DISABLE_COMPUTE_PHYSX) +SET(PHYSX_IOS_COMPILE_DEFS DISABLE_COMPUTE_PHYSX;__ARM_NEON__) SET(PHYSX_IOS_DEBUG_COMPILE_DEFS _DEBUG;PX_DEBUG=1;PX_CHECKED=1;PX_NVTX=${PHYSX_IOS_ENABLE_NVTX};PX_SUPPORT_PVD=0) SET(PHYSX_IOS_CHECKED_COMPILE_DEFS NDEBUG;PX_CHECKED=1;PX_NVTX=${PHYSX_IOS_ENABLE_NVTX};PX_SUPPORT_PVD=0) SET(PHYSX_IOS_PROFILE_COMPILE_DEFS NDEBUG;PX_PROFILE=1;PX_NVTX=${PHYSX_IOS_ENABLE_NVTX};PX_SUPPORT_PVD=0) diff --git a/NvCloth/compiler/cmake/ios/NvCloth.cmake b/NvCloth/compiler/cmake/ios/NvCloth.cmake index 2da5516..c6722e3 100644 --- a/NvCloth/compiler/cmake/ios/NvCloth.cmake +++ b/NvCloth/compiler/cmake/ios/NvCloth.cmake @@ -15,15 +15,24 @@ SET(NVCLOTH_PLATFORM_INCLUDES ) SET(NVCLOTH_PLATFORM_SOURCE_FILES - #${PROJECT_ROOT_DIR}/src/neon/NeonCollision.cpp - #${PROJECT_ROOT_DIR}/src/neon/NeonSelfCollision.cpp - #${PROJECT_ROOT_DIR}/src/neon/NeonSolverKernel.cpp - #${PROJECT_ROOT_DIR}/src/neon/SwCollisionHelpers.h + ${PROJECT_ROOT_DIR}/src/ps/unix/PsUnixAtomic.cpp + ${PROJECT_ROOT_DIR}/src/ps/unix/PsUnixFPU.h + + ${PROJECT_ROOT_DIR}/src/neon/NeonCollision.cpp + ${PROJECT_ROOT_DIR}/src/neon/NeonSelfCollision.cpp + ${PROJECT_ROOT_DIR}/src/neon/NeonSolverKernel.cpp + ${PROJECT_ROOT_DIR}/src/neon/SwCollisionHelpers.h ) +IF(PX_STATIC_LIBRARIES) + SET(NVCLOTH_API_COMPILE_DEFS NV_CLOTH_IMPORT=;PX_CALL_CONV=;) +ELSE() + SET(NVCLOTH_API_COMPILE_DEFS NV_CLOTH_IMPORT=PX_DLL_EXPORT;) +ENDIF() + # Use generator expressions to set config specific preprocessor definitions SET(NVCLOTH_COMPILE_DEFS - NV_CLOTH_IMPORT=PX_DLL_EXPORT + ${NVCLOTH_API_COMPILE_DEFS} NV_CLOTH_ENABLE_DX11=0 NV_CLOTH_ENABLE_CUDA=0 @@ -36,7 +45,11 @@ SET(NVCLOTH_COMPILE_DEFS $<$:${PHYSX_IOS_RELEASE_COMPILE_DEFS};> ) -SET(NVCLOTH_LIBTYPE STATIC) +IF(PX_STATIC_LIBRARIES) + SET(NVCLOTH_LIBTYPE STATIC) +ELSE() + SET(NVCLOTH_LIBTYPE SHARED) +ENDIF() # include common PhysX settings INCLUDE(../common/NvCloth.cmake) diff --git a/NvCloth/compiler/cmake/linux/NvCloth.cmake b/NvCloth/compiler/cmake/linux/NvCloth.cmake index 64188f0..0fb6750 100644 --- a/NvCloth/compiler/cmake/linux/NvCloth.cmake +++ b/NvCloth/compiler/cmake/linux/NvCloth.cmake @@ -32,10 +32,6 @@ SET(NVCLOTH_PLATFORM_INCLUDES SET(NVCLOTH_PLATFORM_SOURCE_FILES ${PROJECT_ROOT_DIR}/src/ps/unix/PsUnixAtomic.cpp ${PROJECT_ROOT_DIR}/src/ps/unix/PsUnixFPU.h - #${PROJECT_ROOT_DIR}/src/neon/NeonCollision.cpp - #${PROJECT_ROOT_DIR}/src/neon/NeonSelfCollision.cpp - #${PROJECT_ROOT_DIR}/src/neon/NeonSolverKernel.cpp - #${PROJECT_ROOT_DIR}/src/neon/SwCollisionHelpers.h ) IF(${NV_CLOTH_ENABLE_CUDA}) LIST(APPEND NVCLOTH_PLATFORM_SOURCE_FILES @@ -96,11 +92,15 @@ DEPENDS ${CUDA_FATBIN} ) ENDIF() - +IF(PX_STATIC_LIBRARIES) + SET(NVCLOTH_API_COMPILE_DEFS NV_CLOTH_IMPORT=;PX_CALL_CONV=;) +ELSE() + SET(NVCLOTH_API_COMPILE_DEFS NV_CLOTH_IMPORT=PX_DLL_EXPORT;) +ENDIF() # Use generator expressions to set config specific preprocessor definitions SET(NVCLOTH_COMPILE_DEFS - NV_CLOTH_IMPORT=PX_DLL_EXPORT + ${NVCLOTH_API_COMPILE_DEFS} NV_CLOTH_ENABLE_DX11=0 # Common to all configurations @@ -121,7 +121,7 @@ LIST(APPEND NVCLOTH_COMPILE_DEFS ) ENDIF() -IF(DEFINED PX_STATIC_LIBRARIES) +IF(PX_STATIC_LIBRARIES) SET(NVCLOTH_LIBTYPE STATIC) ELSE() SET(NVCLOTH_LIBTYPE SHARED) diff --git a/NvCloth/compiler/cmake/mac/NvCloth.cmake b/NvCloth/compiler/cmake/mac/NvCloth.cmake index 086b508..b5310b1 100644 --- a/NvCloth/compiler/cmake/mac/NvCloth.cmake +++ b/NvCloth/compiler/cmake/mac/NvCloth.cmake @@ -17,15 +17,17 @@ SET(NVCLOTH_PLATFORM_INCLUDES SET(NVCLOTH_PLATFORM_SOURCE_FILES ${PROJECT_ROOT_DIR}/src/ps/unix/PsUnixAtomic.cpp ${PROJECT_ROOT_DIR}/src/ps/unix/PsUnixFPU.h - #${PROJECT_ROOT_DIR}/src/neon/NeonCollision.cpp - #${PROJECT_ROOT_DIR}/src/neon/NeonSelfCollision.cpp - #${PROJECT_ROOT_DIR}/src/neon/NeonSolverKernel.cpp - #${PROJECT_ROOT_DIR}/src/neon/SwCollisionHelpers.h ) +IF(PX_STATIC_LIBRARIES) + SET(NVCLOTH_API_COMPILE_DEFS NV_CLOTH_IMPORT=;PX_CALL_CONV=;) +ELSE() + SET(NVCLOTH_API_COMPILE_DEFS NV_CLOTH_IMPORT=PX_DLL_EXPORT;) +ENDIF() + # Use generator expressions to set config specific preprocessor definitions SET(NVCLOTH_COMPILE_DEFS - NV_CLOTH_IMPORT=PX_DLL_EXPORT + ${NVCLOTH_API_COMPILE_DEFS} NV_CLOTH_ENABLE_DX11=0 NV_CLOTH_ENABLE_CUDA=0 @@ -38,7 +40,11 @@ SET(NVCLOTH_COMPILE_DEFS $<$:${PHYSX_MAC_RELEASE_COMPILE_DEFS};> ) -SET(NVCLOTH_LIBTYPE SHARED) +IF(PX_STATIC_LIBRARIES) + SET(NVCLOTH_LIBTYPE STATIC) +ELSE() + SET(NVCLOTH_LIBTYPE SHARED) +ENDIF() # include common PhysX settings INCLUDE(../common/NvCloth.cmake) diff --git a/NvCloth/compiler/cmake/windows/CMakeLists.txt b/NvCloth/compiler/cmake/windows/CMakeLists.txt index 30f2a65..64630bf 100644 --- a/NvCloth/compiler/cmake/windows/CMakeLists.txt +++ b/NvCloth/compiler/cmake/windows/CMakeLists.txt @@ -25,7 +25,7 @@ SET(CMAKE_SHARED_LINKER_FLAGS_RELEASE " /LTCG") SET(CMAKE_SHARED_LINKER_FLAGS_PROFILE " /LTCG") SET(CMAKE_SHARED_LINKER_FLAGS_CHECKED " /LTCG") -IF(DEFINED STATIC_WINCRT) +IF(STATIC_WINCRT) SET(WINCRT_NDEBUG "/MT") SET(WINCRT_DEBUG "/MTd") ELSE() diff --git a/NvCloth/compiler/cmake/windows/NvCloth.cmake b/NvCloth/compiler/cmake/windows/NvCloth.cmake index 065ea18..7641d1a 100644 --- a/NvCloth/compiler/cmake/windows/NvCloth.cmake +++ b/NvCloth/compiler/cmake/windows/NvCloth.cmake @@ -78,10 +78,6 @@ LIST(APPEND NVCLOTH_PLATFORM_SOURCE_FILES ${PROJECT_ROOT_DIR}/src/dx/DxSolverKernelBlob.h ${PROJECT_ROOT_DIR}/src/dx/DxSortKernel.inc - #${PROJECT_ROOT_DIR}/src/neon/NeonCollision.cpp - #${PROJECT_ROOT_DIR}/src/neon/NeonSelfCollision.cpp - #${PROJECT_ROOT_DIR}/src/neon/NeonSolverKernel.cpp - #${PROJECT_ROOT_DIR}/src/neon/SwCollisionHelpers.h ) ENDIF() @@ -134,9 +130,15 @@ DEPENDS ${CUDA_FATBIN} ) ENDIF() +IF(PX_STATIC_LIBRARIES) + SET(NVCLOTH_API_COMPILE_DEFS NV_CLOTH_IMPORT=;PX_CALL_CONV=;) +ELSE() + SET(NVCLOTH_API_COMPILE_DEFS NV_CLOTH_IMPORT=PX_DLL_EXPORT;) +ENDIF() + SET(NVCLOTH_COMPILE_DEFS - NV_CLOTH_IMPORT=PX_DLL_EXPORT + ${NVCLOTH_API_COMPILE_DEFS} $<$:${NVCLOTH_WINDOWS_DEBUG_COMPILE_DEFS};PX_PHYSX_DLL_NAME_POSTFIX=DEBUG;> $<$:${NVCLOTH_WINDOWS_CHECKED_COMPILE_DEFS};PX_PHYSX_DLL_NAME_POSTFIX=CHECKED;> @@ -162,7 +164,11 @@ LIST(APPEND NVCLOTH_COMPILE_DEFS ) ENDIF() -SET(NVCLOTH_LIBTYPE SHARED) +IF(PX_STATIC_LIBRARIES) + SET(NVCLOTH_LIBTYPE STATIC) +ELSE() + SET(NVCLOTH_LIBTYPE SHARED) +ENDIF() # include common NvCloth settings INCLUDE(../common/NvCloth.cmake) diff --git a/NvCloth/include/NvCloth/ps/PsAllocator.h b/NvCloth/include/NvCloth/ps/PsAllocator.h index 7d61bee..81f46fa 100644 --- a/NvCloth/include/NvCloth/ps/PsAllocator.h +++ b/NvCloth/include/NvCloth/ps/PsAllocator.h @@ -37,7 +37,11 @@ #if(PX_WINDOWS_FAMILY || PX_XBOXONE) #include -#include + #if PX_VC >= 16 + #include + #else + #include + #endif #endif #if(PX_APPLE_FAMILY) #include diff --git a/NvCloth/scripts/locate_cuda.bat b/NvCloth/scripts/locate_cuda.bat index 8348aad..2861c9d 100644 --- a/NvCloth/scripts/locate_cuda.bat +++ b/NvCloth/scripts/locate_cuda.bat @@ -2,7 +2,7 @@ setlocal enabledelayedexpansion rem use the following 2 lines to manually point to the google test folder \\sw\%FOLDER_NEEDLE% -set FOLDER=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0 +set FOLDER=%CUDA_PATH% goto :manualfolder set FOLDER_NEEDLE=physx\externals\CUDA\8.0.44 diff --git a/NvCloth/src/SwSolver.cpp b/NvCloth/src/SwSolver.cpp index 356a03e..96dc1e2 100644 --- a/NvCloth/src/SwSolver.cpp +++ b/NvCloth/src/SwSolver.cpp @@ -301,11 +301,16 @@ void cloth::SwSolver::SimulatedCloth::Simulate() SwKernelAllocator allocator(mScratchMemory, uint32_t(mScratchMemorySize)); // construct kernel functor and execute -#if NV_ANDROID +#ifdef __ARM_NEON__ if (!neonSolverKernel(*mCloth, data, allocator, factory)) { - //NV_CLOTH_LOG_WARNING("No NEON CPU support detected. Falling back to scalar types."); - SwSolverKernel(*mCloth, data, allocator, factory)(); + #if NV_SIMD_SCALAR + //NV_CLOTH_LOG_WARNING("No NEON CPU support detected. Falling back to scalar types."); + SwSolverKernel(*mCloth, data, allocator, factory)(); + #else + NV_CLOTH_LOG_ERROR("Error creating NEON solver kernel."); + NV_CLOTH_ASSERT(0); + #endif } #else SwSolverKernel(*mCloth, data, allocator, factory)(); diff --git a/NvCloth/src/neon/NeonCollision.cpp b/NvCloth/src/neon/NeonCollision.cpp index fe45778..16269ac 100644 --- a/NvCloth/src/neon/NeonCollision.cpp +++ b/NvCloth/src/neon/NeonCollision.cpp @@ -31,4 +31,4 @@ #error This file needs to be compiled with NEON support! #endif -#include "SwCollision.cpp" +// SwCollision.cpp is compiled already using Neon implementation when Neon macros are found diff --git a/NvCloth/src/neon/NeonSelfCollision.cpp b/NvCloth/src/neon/NeonSelfCollision.cpp index 8faa407..3e7e96d 100644 --- a/NvCloth/src/neon/NeonSelfCollision.cpp +++ b/NvCloth/src/neon/NeonSelfCollision.cpp @@ -31,4 +31,4 @@ #error This file needs to be compiled with NEON support! #endif -#include "SwSelfCollision.cpp" +// SwSelfCollision.cpp is compiled already using Neon implementation when Neon macros are found diff --git a/NvCloth/src/neon/NeonSolverKernel.cpp b/NvCloth/src/neon/NeonSolverKernel.cpp index 6eb26cf..5e8dbd0 100644 --- a/NvCloth/src/neon/NeonSolverKernel.cpp +++ b/NvCloth/src/neon/NeonSolverKernel.cpp @@ -31,14 +31,23 @@ #error This file needs to be compiled with NEON support! #endif -#include "SwSolverKernel.cpp" +// SwSolverKernel.cpp is compiled already using Neon implementation when Neon macros are found +#include "SwSolverKernel.h" +// On Android armeabi-v7a (32-bits) NEON support is not guaranteed, so there must be an additional runtime check. +#if NV_ANDROID && defined __arm__ #include "../ps/android/cpu-features.h" namespace { const bool sNeonSupport = ANDROID_CPU_ARM_FEATURE_NEON & android_getCpuFeatures(); } +#else +namespace +{ + const bool sNeonSupport = true; +} +#endif namespace nv { diff --git a/PxShared/include/foundation/PxPreprocessor.h b/PxShared/include/foundation/PxPreprocessor.h index 5593a52..bce583d 100644 --- a/PxShared/include/foundation/PxPreprocessor.h +++ b/PxShared/include/foundation/PxPreprocessor.h @@ -53,7 +53,9 @@ All definitions have a value of 1 or 0, use '#if' instead of '#ifdef'. Compiler defines, see http://sourceforge.net/p/predef/wiki/Compilers/ */ #if defined(_MSC_VER) -#if _MSC_VER >= 1910 +#if _MSC_VER >= 1923 +#define PX_VC 16 +#elif _MSC_VER >= 1910 #define PX_VC 15 #elif _MSC_VER >= 1900 #define PX_VC 14 @@ -292,7 +294,7 @@ DLL export macros #define PX_UNIX_EXPORT #endif -#if PX_WINDOWS_FAMILY +#if (PX_WINDOWS_FAMILY || PX_XBOXONE || PX_PS4) #define PX_DLL_EXPORT __declspec(dllexport) #define PX_DLL_IMPORT __declspec(dllimport) #else