diff options
| author | Marijn Tamis <[email protected]> | 2019-04-01 14:21:09 +0200 |
|---|---|---|
| committer | Marijn Tamis <[email protected]> | 2019-04-01 14:21:09 +0200 |
| commit | d243404d4ba88bcf53f7310cc8980b4efe38c19f (patch) | |
| tree | dcc8ce2904e9f813e03f71f825c4d3c9ec565d91 /NvCloth | |
| parent | Add new SetSpheres and SetPlanes api's to bring them in line with setTriangles. (diff) | |
| download | nvcloth-1.1.6.tar.xz nvcloth-1.1.6.zip | |
1.1.6 Release.1.1.6
Diffstat (limited to 'NvCloth')
142 files changed, 9964 insertions, 445 deletions
diff --git a/NvCloth/BuildProjectsIOS.sh b/NvCloth/BuildProjectsIOS.sh index aa6bca2..5a686c0 100644 --- a/NvCloth/BuildProjectsIOS.sh +++ b/NvCloth/BuildProjectsIOS.sh @@ -2,11 +2,7 @@ # Make sure the various variables that we need are set -export GW_DEPS_ROOT="$PWD""/../../../../../" - -if [ -e $PWD"/../../Externals/CMakeModules" ]; then - export GW_DEPS_ROOT="$PWD""/../../" -fi +export GW_DEPS_ROOT="$PWD""/../" [ -z "$GW_DEPS_ROOT" ] && echo "GW_DEPS_ROOT not defined." && exit 1; diff --git a/NvCloth/BuildProjectsOsx.sh b/NvCloth/BuildProjectsOsx.sh index d0c6223..e25cffc 100644 --- a/NvCloth/BuildProjectsOsx.sh +++ b/NvCloth/BuildProjectsOsx.sh @@ -2,11 +2,7 @@ # Make sure the various variables that we need are set -export GW_DEPS_ROOT="$PWD""/../../../../../../" - -if [ -e $PWD"/../../Externals/CMakeModules" ]; then - export GW_DEPS_ROOT="$PWD""/../../" -fi +export GW_DEPS_ROOT="$PWD""/../" [ -z "$GW_DEPS_ROOT" ] && echo "GW_DEPS_ROOT not defined." && exit 1; @@ -21,10 +17,6 @@ export CMAKE="$PM_cmake_PATH/bin/cmake" # Build projects here -cd compiler/osx32-cmake/ -$CMAKE --build . --target ALL_BUILD --clean-first --config release -- -parallelizeTargets -jobs 5 || exit 1 -cd ../../ - cd compiler/osx64-cmake/ $CMAKE --build . --target ALL_BUILD --clean-first --config release -- -parallelizeTargets -jobs 5 || exit 1 cd ../../ diff --git a/NvCloth/CmakeGenerateAndroid.bat b/NvCloth/CmakeGenerateAndroid.bat index 38d255e..fc0a40d 100644 --- a/NvCloth/CmakeGenerateAndroid.bat +++ b/NvCloth/CmakeGenerateAndroid.bat @@ -2,18 +2,13 @@ set EXIT_CODE=0 REM Make sure the various variables that we need are set -CD /D %~dp0 -REM echo "Note: You need to run this with admin rights for the first time to set GW_DEPS_ROOT globally." -call "./scripts/locate_gw_root.bat" GW_DEPS_ROOT_F -@echo on -set GW_DEPS_ROOT=%GW_DEPS_ROOT_F% +echo "Note: You need to run this with admin rights for the first time to set GW_DEPS_ROOT globally." +REM single " is not a mistake +setx GW_DEPS_ROOT "%GW_DEPS_ROOT% +REM this one is for local use +set GW_DEPS_ROOT=%GW_DEPS_ROOT% echo GW_DEPS_ROOT = %GW_DEPS_ROOT% -@echo off -IF EXIST %~dp0..\Externals\CMakeModules ( - set GW_DEPS_ROOT=%~dp0..\ -) - IF NOT DEFINED GW_DEPS_ROOT GOTO GW_DEPS_ROOT_UNDEFINED set PX_OUTPUT_ROOT=%~dp0 @@ -86,7 +81,7 @@ 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% -cmake ..\cmake\android %CMAKE_COMPILER_PARAMS% %CMAKE_TOOLCHAIN_PARAMS% %CMAKE_COMMON_PARAMS% +%CMAKE% ..\cmake\android %CMAKE_COMPILER_PARAMS% %CMAKE_TOOLCHAIN_PARAMS% %CMAKE_COMMON_PARAMS% IF %ERRORLEVEL% NEQ 0 ( set EXIT_CODE=%ERRORLEVEL% GOTO :End diff --git a/NvCloth/CmakeGenerateProjects.bat b/NvCloth/CmakeGenerateProjects.bat index 6e0f7dc..5896f9a 100644 --- a/NvCloth/CmakeGenerateProjects.bat +++ b/NvCloth/CmakeGenerateProjects.bat @@ -4,22 +4,19 @@ set EXIT_CODE=0 REM Make sure the various variables that we need are set CD /D %~dp0 -echo "Note: You need to run this with admin rights for the first time to set GW_DEPS_ROOT globally." -call "./scripts/locate_gw_root.bat" GW_DEPS_ROOT_F -REM single " is not a mistake -setx GW_DEPS_ROOT "%GW_DEPS_ROOT_F% -REM this one is for local use -set GW_DEPS_ROOT=%GW_DEPS_ROOT_F% -echo GW_DEPS_ROOT = %GW_DEPS_ROOT% REM Make sure the various variables that we need are set call "./scripts/locate_cuda.bat" CUDA_PATH_ echo CUDA_PATH_ = %CUDA_PATH_% -IF EXIST %~dp0..\Externals\CMakeModules ( - set GW_DEPS_ROOT=%~dp0..\ -) +set GW_DEPS_ROOT=%~dp0..\ +echo "Note: You need to run this with admin rights for the first time to set GW_DEPS_ROOT globally." +REM single " is not a mistake +setx GW_DEPS_ROOT "%GW_DEPS_ROOT% +REM this one is for local use +set GW_DEPS_ROOT=%GW_DEPS_ROOT% +echo GW_DEPS_ROOT = %GW_DEPS_ROOT% IF NOT DEFINED GW_DEPS_ROOT goto GW_DEPS_ROOT_UNDEFINED @@ -70,12 +67,6 @@ pushd compiler\vc12win64-cmake\ %CMAKE% ..\cmake\windows -G "Visual Studio 12 2013" -Ax64 %CMAKE_COMMON_PARAMS% -DPX_OUTPUT_DLL_DIR=%PX_OUTPUT_ROOT%\bin\vc12win64-cmake -DPX_OUTPUT_LIB_DIR=%PX_OUTPUT_ROOT%\lib\vc12win64-cmake -DPX_OUTPUT_EXE_DIR=%PX_OUTPUT_ROOT%\bin\vc12win64-cmake popd -rmdir /s /q compiler\vc14win32-cmake\ -mkdir compiler\vc14win32-cmake\ -pushd compiler\vc14win32-cmake\ -%CMAKE% ..\cmake\windows -G "Visual Studio 14 2015" -AWin32 %CMAKE_COMMON_PARAMS% -DPX_OUTPUT_DLL_DIR=%PX_OUTPUT_ROOT%\bin\vc14win32-cmake -DPX_OUTPUT_LIB_DIR=%PX_OUTPUT_ROOT%\lib\vc14win32-cmake -DPX_OUTPUT_EXE_DIR=%PX_OUTPUT_ROOT%\bin\vc14win32-cmake -popd - rmdir /s /q compiler\vc14win64-cmake\ mkdir compiler\vc14win64-cmake\ pushd compiler\vc14win64-cmake\ diff --git a/NvCloth/Externals/CMakeModules/FindGoogleTest.cmake b/NvCloth/Externals/CMakeModules/FindGoogleTest.cmake new file mode 100644 index 0000000..df03868 --- /dev/null +++ b/NvCloth/Externals/CMakeModules/FindGoogleTest.cmake @@ -0,0 +1,28 @@ +# - Try to find GoogleTest +# Once done this will define +# GOOGLETEST_FOUND - System has GoogleTest +# GOOGLETEST_INCLUDE_DIR - The GoogleTest include directory +# GOOGLETEST_SRC_DIR - The GoogleTest src directory + +FIND_PATH( GOOGLETEST_INCLUDE_DIR gtest/gtest.h + HINTS + ${GW_DEPS_ROOT}/GoogleTest + ${GW_DEPS_ROOT}/NvCloth/test/external/gtest-1.4.0 + ${GW_DEPS_ROOT}/sw/physx/externals/GoogleTest/gtest-1.4.0 + PATH_SUFFIXES include + NO_DEFAULT_PATH + NO_CMAKE_FIND_ROOT_PATH) + +FIND_PATH( GOOGLETEST_SRC_DIR gtest.cpp + HINTS + ${GW_DEPS_ROOT}/GoogleTest + ${GW_DEPS_ROOT}/NvCloth/test/external/gtest-1.4.0 + ${GW_DEPS_ROOT}/sw/physx/externals/GoogleTest/gtest-1.4.0 + PATH_SUFFIXES src + NO_DEFAULT_PATH + NO_CMAKE_FIND_ROOT_PATH) + +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(GoogleTest DEFAULT_MSG GOOGLETEST_INCLUDE_DIR GOOGLETEST_SRC_DIR) + +mark_as_advanced(GOOGLETEST_INCLUDE_DIR GOOGLETEST_SRC_DIR) diff --git a/NvCloth/Externals/CMakeModules/FindNvSimd.cmake b/NvCloth/Externals/CMakeModules/FindNvSimd.cmake new file mode 100644 index 0000000..02d152c --- /dev/null +++ b/NvCloth/Externals/CMakeModules/FindNvSimd.cmake @@ -0,0 +1,21 @@ +# - Try to find NvSimd +# Once done this will define +# NVSIMD_FOUND - System has NvSimd +# NVSIMD_INCLUDE_DIR - The NvSimd include directories + +# TODO: Support version +FIND_PATH( NVSIMD_INCLUDE_DIR include/NvSimd4f.h + HINTS + ${GW_DEPS_ROOT}/NvSimd + ${GW_DEPS_ROOT}/PxShared/NvSimd + ${GW_DEPS_ROOT}/PxShared/src/NvSimd + ${GW_DEPS_ROOT}/sw/devrel/GameWorks/Shared/NvSimd/${PACKAGE_FIND_VERSION}/trunk + ${GW_DEPS_ROOT}/sw/devrel/GameWorks/Shared/NvSimd/1.1/trunk + ) + +MESSAGE(${NVSIMD_INCLUDE_DIR}) + +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(NvSimd DEFAULT_MSG NVSIMD_INCLUDE_DIR) + +mark_as_advanced(NVSIMD_INCLUDE_DIR) diff --git a/NvCloth/Externals/CMakeModules/FindPhysX.cmake b/NvCloth/Externals/CMakeModules/FindPhysX.cmake new file mode 100644 index 0000000..5b07c14 --- /dev/null +++ b/NvCloth/Externals/CMakeModules/FindPhysX.cmake @@ -0,0 +1,21 @@ +# +# Find PhysX +# +# This is a really dumb finder - it finds the PhysX install we're going to use add_subdirectory on. +# PHYSX_FOUND - System has PhysX +# PHYSX_ROOT_DIR - The PhysX root directory + +# First look for the feature branch, then for the trunk +FIND_PATH( PHYSX_ROOT_DIR Include/PxActor.h + HINTS + ${GW_DEPS_ROOT}/PhysXSDK + ${GW_DEPS_ROOT}/PhysX_3.4 + ${GW_DEPS_ROOT}/sw/physx/PhysXSDK/3.4/trunk + ) + +MESSAGE(${PHYSX_ROOT_DIR}) + +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(PhysX DEFAULT_MSG PHYSX_ROOT_DIR) + +mark_as_advanced(PHYSX_ROOT_DIR) diff --git a/NvCloth/Tools/AuthoringLibrary/external/CMakeModules/FindPxShared.cmake b/NvCloth/Externals/CMakeModules/FindPxShared.cmake index c094676..3297996 100644 --- a/NvCloth/Tools/AuthoringLibrary/external/CMakeModules/FindPxShared.cmake +++ b/NvCloth/Externals/CMakeModules/FindPxShared.cmake @@ -4,16 +4,13 @@ # PXSHARED_ROOT_DIR - The root of PxShared # NOTE: We're including a version in this, but the first hint is without one - we should use that! -FIND_PATH( PXSHARED_ROOT_DIR include/cudamanager/PxGpuCopyDesc.h +FIND_PATH( PXSHARED_ROOT_DIR include/foundation/Px.h HINTS - ${GW_DEPS_ROOT}/PxShared/${PxShared_FIND_VERSION} + ${GW_DEPS_ROOT}/PxShared ${GW_DEPS_ROOT}/sw/physx/PxShared/1.0/trunk - - ) - - - - + NO_DEFAULT_PATH + NO_CMAKE_FIND_ROOT_PATH) + INCLUDE(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(PxShared DEFAULT_MSG PXSHARED_ROOT_DIR) diff --git a/NvCloth/Externals/CMakeModules/FindPxToolkit.cmake b/NvCloth/Externals/CMakeModules/FindPxToolkit.cmake new file mode 100644 index 0000000..583899b --- /dev/null +++ b/NvCloth/Externals/CMakeModules/FindPxToolkit.cmake @@ -0,0 +1,26 @@ +# - Try to find PXTOOLKIT +# Once done this will define +# PXTOOLKIT_FOUND - System has PXTOOLKIT +# PXTOOLKIT_ROOT - The PXTOOLKIT root directory +# PXTOOLKIT_INCLUDE_DIR - The PXTOOLKIT include directory +# PXTOOLKIT_SRC_DIR - The PXTOOLKIT src directory + +FIND_PATH( PXTOOLKIT_INCLUDE_DIR PxTkBmpLoader.h + HINTS + ${GW_DEPS_ROOT}/PxToolKit + ${GW_DEPS_ROOT}/PhysX_3.4/Samples/PxToolkit + ${GW_DEPS_ROOT}/sw/physx/PhysXSDK/3.4/trunk/Samples/PxToolkit + PATH_SUFFIXES include) + +FIND_PATH( PXTOOLKIT_SRC_DIR PxTkBmpLoader.cpp + HINTS + ${GW_DEPS_ROOT}/PxToolKit + ${GW_DEPS_ROOT}/PhysX_3.4/Samples/PxToolkit + ${GW_DEPS_ROOT}/sw/physx/PhysXSDK/3.4/trunk/Samples/PxToolkit + PATH_SUFFIXES src) + +INCLUDE(FindPackageHandleStandardArgs) + +FIND_PACKAGE_HANDLE_STANDARD_ARGS(PxToolKit DEFAULT_MSG PXTOOLKIT_INCLUDE_DIR PXTOOLKIT_SRC_DIR) + +mark_as_advanced(PXTOOLKIT_INCLUDE_DIR PXTOOLKIT_SRC_DIR) diff --git a/NvCloth/Externals/CMakeModules/FindTarga.cmake b/NvCloth/Externals/CMakeModules/FindTarga.cmake new file mode 100644 index 0000000..b042c96 --- /dev/null +++ b/NvCloth/Externals/CMakeModules/FindTarga.cmake @@ -0,0 +1,23 @@ +# - Try to find Targa +# Once done this will define +# TARGA_FOUND - System has targa +# TARGA_INCLUDE_DIR - The targa include directory +# TARGA_SRC_DIR - The targa src directory + +FIND_PATH( TARGA_INCLUDE_DIR targa.h + HINTS + ${GW_DEPS_ROOT}/externals/targa/1 + ${GW_DEPS_ROOT}/sw/physx/externals/targa/1 + PATH_SUFFIXES include) + +FIND_PATH( TARGA_SRC_DIR targa.cpp + HINTS + ${GW_DEPS_ROOT}/externals/targa/1 + ${GW_DEPS_ROOT}/sw/physx/externals/targa/1 + PATH_SUFFIXES src) + +INCLUDE(FindPackageHandleStandardArgs) + +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Targa DEFAULT_MSG TARGA_INCLUDE_DIR TARGA_SRC_DIR) + +mark_as_advanced(TARGA_INCLUDE_DIR TARGA_SRC_DIR)
\ No newline at end of file diff --git a/NvCloth/Externals/CMakeModules/FindnvToolsExt.cmake b/NvCloth/Externals/CMakeModules/FindnvToolsExt.cmake new file mode 100644 index 0000000..26c00dc --- /dev/null +++ b/NvCloth/Externals/CMakeModules/FindnvToolsExt.cmake @@ -0,0 +1,40 @@ +# - Try to find nvToolsExt +# Once done this will define +# NVTOOLSEXT_FOUND - System has nvToolsExt +# NVTOOLSEXT_INCLUDE_DIRS - The nvToolsExt include directories +# NVTOOLSEXT_LIBRARIES - The libraries needed to use nvToolsExt +# NVTOOLSEXT_DEFINITIONS - Compiler switches required for using nvToolsExt + +FIND_PATH( NVTOOLSEXT_INCLUDE_DIRS nvToolsExt.h + HINTS + ${GW_DEPS_ROOT}/nvToolsExt + ${GW_DEPS_ROOT}/Externals/nvToolsExt/1 + ${GW_DEPS_ROOT}/sw/physx/externals/nvToolsExt/1 + PATH_SUFFIXES include) + +INCLUDE(FindPackageHandleStandardArgs) + +IF(TARGET_BUILD_PLATFORM STREQUAL "Windows") + # NOTE: Doesn't make sense for all platforms - ARM + IF(CMAKE_CL_64) + SET(NVTOOLSEXT_LIBNAME "nvToolsExt64_1") + SET(NVTOOLSEXT_LIBPATH_SUFFIX "x64") + ELSE(CMAKE_CL_64) + SET(NVTOOLSEXT_LIBNAME nvToolsExt32_1) + SET(NVTOOLSEXT_LIBPATH_SUFFIX "Win32") + ENDIF(CMAKE_CL_64) + + + FIND_LIBRARY( NVTOOLSEXT_LIBRARIES ${NVTOOLSEXT_LIBNAME} + ${GW_DEPS_ROOT}/nvToolsExt + ${GW_DEPS_ROOT}/Externals/nvToolsExt/1/lib/${NVTOOLSEXT_LIBPATH_SUFFIX} + ${GW_DEPS_ROOT}/sw/physx/externals/nvToolsExt/1/lib/${NVTOOLSEXT_LIBPATH_SUFFIX} + ) + + FIND_PACKAGE_HANDLE_STANDARD_ARGS(nvToolsExt DEFAULT_MSG NVTOOLSEXT_LIBRARIES NVTOOLSEXT_INCLUDE_DIRS) +ELSE() + # Exclude the libraries for non-windows platforms + FIND_PACKAGE_HANDLE_STANDARD_ARGS(nvToolsExt DEFAULT_MSG NVTOOLSEXT_INCLUDE_DIRS) +ENDIF() + +mark_as_advanced(NVTOOLSEXT_INCLUDE_DIRS NVTOOLSEXT_LIBRARIES)
\ No newline at end of file diff --git a/NvCloth/Externals/CMakeModules/NvidiaBuildOptions.cmake b/NvCloth/Externals/CMakeModules/NvidiaBuildOptions.cmake new file mode 100644 index 0000000..e5d89af --- /dev/null +++ b/NvCloth/Externals/CMakeModules/NvidiaBuildOptions.cmake @@ -0,0 +1,180 @@ +# Define the options up front + +OPTION(APPEND_CONFIG_NAME "Append config (DEBUG, CHECKED, PROFILE or '' for release) to outputted binaries." OFF) +OPTION(USE_GAMEWORKS_OUTPUT_DIRS "Use new GameWorks folder structure for binary output." ON) +OPTION(USE_STATIC_WINCRT "Use the statically linked windows CRT" OFF) +OPTION(USE_DEBUG_WINCRT "Use the debug version of the CRT" OFF) +OPTION(GENERATE_STATIC_LIBRARIES "Generate static libraries" OFF) + +INCLUDE(SetOutputPaths) + + # Set the WINCRT_DEBUG and WINCRT_NDEBUG variables for use in project compile settings + # Really only relevant to windows + + SET(DISABLE_ITERATOR_DEBUGGING "/D \"_HAS_ITERATOR_DEBUGGING=0\" /D \"_ITERATOR_DEBUG_LEVEL=0\"") + SET(DISABLE_ITERATOR_DEBUGGING_CUDA "-D_HAS_ITERATOR_DEBUGGING=0 -D_ITERATOR_DEBUG_LEVEL=0") + SET(CRT_DEBUG_FLAG "/D \"_DEBUG\"") + SET(CRT_NDEBUG_FLAG "/D \"NDEBUG\"") + + # Need a different format for CUDA + SET(CUDA_DEBUG_FLAG "-DNDEBUG ${DISABLE_ITERATOR_DEBUGGING_CUDA}") + SET(CUDA_NDEBUG_FLAG "-DNDEBUG") + + SET(CUDA_CRT_COMPILE_OPTIONS_NDEBUG "") + SET(CUDA_CRT_COMPILE_OPTIONS_DEBUG "") + + + IF(USE_STATIC_WINCRT) + SET(WINCRT_NDEBUG "/MT ${DISABLE_ITERATOR_DEBUGGING} ${CRT_NDEBUG_FLAG}" CACHE INTERNAL "Windows CRT build setting") + SET(CUDA_CRT_COMPILE_OPTIONS_NDEBUG "/MT") + + IF (USE_DEBUG_WINCRT) + SET(CUDA_DEBUG_FLAG "-D_DEBUG") + SET(WINCRT_DEBUG "/MTd ${CRT_DEBUG_FLAG}" CACHE INTERNAL "Windows CRT build setting") + SET(CUDA_CRT_COMPILE_OPTIONS_DEBUG "/MTd") + ELSE() + SET(WINCRT_DEBUG "/MT ${DISABLE_ITERATOR_DEBUGGING} ${CRT_NDEBUG_FLAG}" CACHE INTERNAL "Windows CRT build setting") + SET(CUDA_CRT_COMPILE_OPTIONS_DEBUG "/MT") + ENDIF() + ELSE() + SET(WINCRT_NDEBUG "/MD ${DISABLE_ITERATOR_DEBUGGING} ${CRT_NDEBUG_FLAG}") + SET(CUDA_CRT_COMPILE_OPTIONS_NDEBUG "/MD") + + IF(USE_DEBUG_WINCRT) + SET(CUDA_DEBUG_FLAG "-D_DEBUG") + SET(WINCRT_DEBUG "/MDd ${CRT_DEBUG_FLAG}" CACHE INTERNAL "Windows CRT build setting") + SET(CUDA_CRT_COMPILE_OPTIONS_DEBUG "/MDd") + ELSE() + SET(WINCRT_DEBUG "/MD ${DISABLE_ITERATOR_DEBUGGING} ${CRT_NDEBUG_FLAG}" CACHE INTERNAL "Windows CRT build setting") + SET(CUDA_CRT_COMPILE_OPTIONS_DEBUG "/MD") + ENDIF() + ENDIF() + + +IF(USE_GAMEWORKS_OUTPUT_DIRS) + + # New bitness suffix + IF(CMAKE_SIZEOF_VOID_P EQUAL 8) + SET(LIBPATH_SUFFIX "64") + # Set default exe suffix. Unset on platforms that don't need it. Include underscore since it's optional + SET(EXE_SUFFIX "_64") + ELSE() + SET(LIBPATH_SUFFIX "32") + # Set default exe suffix. Unset on platforms that don't need it. Include underscore since it's optional + SET(EXE_SUFFIX "_32") + ENDIF() + + IF (NOT DEFINED PX_OUTPUT_LIB_DIR) + MESSAGE(FATAL_ERROR "When using the GameWorks output structure you must specify PX_OUTPUT_LIB_DIR as the base") + ENDIF() + + IF (NOT DEFINED PX_OUTPUT_BIN_DIR) + MESSAGE(FATAL_ERROR "When using the GameWorks output structure you must specify PX_OUTPUT_BIN_DIR as the base") + ENDIF() + + + INCLUDE(GetCompilerAndPlatform) + # Get the compiler and platform string into COMPILER_AND_PLATFORM + GetCompilerAndPlatform(COMPILER_AND_PLATFORM) + + GetStaticCRTString(CRT_STRING) + + IF(NOT CRT_STRING) # Non windows returns empty string + IF (NOT DEFINED PX_OUTPUT_ARCH) # platforms with fixed arch like ps4 dont need to have arch defined + # Set the path the DLLs and static libs go to + SET(PX_ROOT_LIB_DIR "bin/${COMPILER_AND_PLATFORM}" CACHE INTERNAL "Relative root of the lib output directory") + SET(PX_ROOT_EXE_DIR "bin/${COMPILER_AND_PLATFORM}" CACHE INTERNAL "Relative root dir of the exe output directory") + + # If there's no arch, then no bitness either. + + SET(EXE_SUFFIX "") + ELSE() + # Set the path the DLLs and static libs go to + SET(PX_ROOT_LIB_DIR "bin/${COMPILER_AND_PLATFORM}/${PX_OUTPUT_ARCH}" CACHE INTERNAL "Relative root of the lib output directory") + SET(PX_ROOT_EXE_DIR "bin/${COMPILER_AND_PLATFORM}/${PX_OUTPUT_ARCH}" CACHE INTERNAL "Relative root dir of the exe output directory") + ENDIF() + ELSE() + # Set the path the DLLs and static libs go to + SET(PX_ROOT_LIB_DIR "bin/${COMPILER_AND_PLATFORM}/${PX_OUTPUT_ARCH}/${CRT_STRING}" CACHE INTERNAL "Relative root of the lib output directory") + SET(PX_ROOT_EXE_DIR "bin/${COMPILER_AND_PLATFORM}/${PX_OUTPUT_ARCH}/${CRT_STRING}" CACHE INTERNAL "Relative root dir of the exe output directory") + ENDIF() + + # Override our normal PX_ROOT_LIB_DIR for Android + IF(TARGET_BUILD_PLATFORM STREQUAL "Android") + SET(PX_ROOT_LIB_DIR "bin/${COMPILER_AND_PLATFORM}/${ANDROID_ABI}/${CM_ANDROID_FP}" CACHE INTERNAL "Relative root of the lib output directory") + ENDIF() + + SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${PX_OUTPUT_LIB_DIR}/${PX_ROOT_LIB_DIR}/debug" ) + SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_PROFILE "${PX_OUTPUT_LIB_DIR}/${PX_ROOT_LIB_DIR}/profile" ) + SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_CHECKED "${PX_OUTPUT_LIB_DIR}/${PX_ROOT_LIB_DIR}/checked" ) + SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${PX_OUTPUT_LIB_DIR}/${PX_ROOT_LIB_DIR}/release" ) + + SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG "${PX_OUTPUT_LIB_DIR}/${PX_ROOT_LIB_DIR}/debug" ) + SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY_PROFILE "${PX_OUTPUT_LIB_DIR}/${PX_ROOT_LIB_DIR}/profile" ) + SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY_CHECKED "${PX_OUTPUT_LIB_DIR}/${PX_ROOT_LIB_DIR}/checked" ) + SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE "${PX_OUTPUT_LIB_DIR}/${PX_ROOT_LIB_DIR}/release" ) + + # Set the RUNTIME output directories - this is executables, etc. + # Override our normal PX_ROOT_EXE_DIR for Android + IF(TARGET_BUILD_PLATFORM STREQUAL "Android") + SET(PX_ROOT_EXE_DIR "bin/${COMPILER_AND_PLATFORM}/${ANDROID_ABI}/${CM_ANDROID_FP}" CACHE INTERNAL "Relative root dir of the exe output directory") + ENDIF() + + # RFC 108, we're doing EXEs as the special case since there will be presumable be less of those. + SET(PX_EXE_OUTPUT_DIRECTORY_DEBUG "${PX_OUTPUT_BIN_DIR}/${PX_ROOT_EXE_DIR}/debug" CACHE INTERNAL "Directory to put debug exes in") + SET(PX_EXE_OUTPUT_DIRECTORY_PROFILE "${PX_OUTPUT_BIN_DIR}/${PX_ROOT_EXE_DIR}/profile" CACHE INTERNAL "Directory to put profile exes in") + SET(PX_EXE_OUTPUT_DIRECTORY_CHECKED "${PX_OUTPUT_BIN_DIR}/${PX_ROOT_EXE_DIR}/checked" CACHE INTERNAL "Directory to put checked exes in") + SET(PX_EXE_OUTPUT_DIRECTORY_RELEASE "${PX_OUTPUT_BIN_DIR}/${PX_ROOT_EXE_DIR}/release" CACHE INTERNAL "Directory to put release exes in") + + SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG} ) + SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_PROFILE ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY_PROFILE} ) + SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_CHECKED ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY_CHECKED} ) + SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE} ) + + +ELSE() + # old bitness suffix + IF(CMAKE_SIZEOF_VOID_P EQUAL 8) + SET(LIBPATH_SUFFIX "x64") + ELSE() + SET(LIBPATH_SUFFIX "x86") + ENDIF() + + + IF(DEFINED PX_OUTPUT_EXE_DIR) + SetExeOutputPath(${PX_OUTPUT_EXE_DIR}) + ENDIF() + IF(DEFINED PX_OUTPUT_DLL_DIR) + SetDllOutputPath(${PX_OUTPUT_DLL_DIR}) + ENDIF() + IF(DEFINED PX_OUTPUT_LIB_DIR) + SetLibOutputPath(${PX_OUTPUT_LIB_DIR}) + ENDIF() + # All EXE/DLL/LIB output will be overwritten if PX_OUTPUT_ALL_DIR is defined + IF(DEFINED PX_OUTPUT_ALL_DIR) + SetSingleOutputPath(${PX_OUTPUT_ALL_DIR}) + ENDIF() +ENDIF() + +IF(APPEND_CONFIG_NAME) + SET(CMAKE_DEBUG_POSTFIX "DEBUG_${LIBPATH_SUFFIX}") + SET(CMAKE_PROFILE_POSTFIX "PROFILE_${LIBPATH_SUFFIX}") + SET(CMAKE_CHECKED_POSTFIX "CHECKED_${LIBPATH_SUFFIX}") + SET(CMAKE_RELEASE_POSTFIX "_${LIBPATH_SUFFIX}") +ELSE() + IF (DEFINED PX_OUTPUT_ARCH) # platforms with fixed arch like ps4 dont need to have arch defined, then dont add bitness + SET(CMAKE_DEBUG_POSTFIX "_${LIBPATH_SUFFIX}") + SET(CMAKE_PROFILE_POSTFIX "_${LIBPATH_SUFFIX}") + SET(CMAKE_CHECKED_POSTFIX "_${LIBPATH_SUFFIX}") + SET(CMAKE_RELEASE_POSTFIX "_${LIBPATH_SUFFIX}") + ENDIF() +ENDIF() + +# Can no longer just use LIBPATH_SUFFIX since it depends on build type +IF(CMAKE_CL_64) + SET(RESOURCE_LIBPATH_SUFFIX "x64") +ELSE(CMAKE_CL_64) + SET(RESOURCE_LIBPATH_SUFFIX "x86") +ENDIF(CMAKE_CL_64) + + diff --git a/NvCloth/Externals/CMakeModules/SetOutputPaths.cmake b/NvCloth/Externals/CMakeModules/SetOutputPaths.cmake new file mode 100644 index 0000000..db0be34 --- /dev/null +++ b/NvCloth/Externals/CMakeModules/SetOutputPaths.cmake @@ -0,0 +1,94 @@ +FUNCTION(SetOutputPaths + OUTPUT_EXE_DIR + OUTPUT_DLL_DIR + OUTPUT_LIB_DIR) + + SET(EXE_DIR ${OUTPUT_EXE_DIR}) + SET(DLL_DIR ${OUTPUT_DLL_DIR}) + SET(LIB_DIR ${OUTPUT_LIB_DIR}) + + # Override the default output directories for all configurations. + SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${EXE_DIR} PARENT_SCOPE) + SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${DLL_DIR} PARENT_SCOPE) + SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${LIB_DIR} PARENT_SCOPE) + + SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_CHECKED ${EXE_DIR} PARENT_SCOPE) + SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY_CHECKED ${DLL_DIR} PARENT_SCOPE) + SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_CHECKED ${LIB_DIR} PARENT_SCOPE) + + SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_PROFILE ${EXE_DIR} PARENT_SCOPE) + SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY_PROFILE ${DLL_DIR} PARENT_SCOPE) + SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_PROFILE ${LIB_DIR} PARENT_SCOPE) + + SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${EXE_DIR} PARENT_SCOPE) + SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${DLL_DIR} PARENT_SCOPE) + SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${LIB_DIR} PARENT_SCOPE) + + SET(CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY ${LIB_DIR}) + +ENDFUNCTION(SetOutputPaths) + +FUNCTION(SetExeOutputPath OUTPUT_EXE_DIR) + + SET(EXE_DIR ${OUTPUT_EXE_DIR}) + + # Override the default output directories for all configurations. + SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${EXE_DIR} PARENT_SCOPE) + SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_CHECKED ${EXE_DIR} PARENT_SCOPE) + SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_PROFILE ${EXE_DIR} PARENT_SCOPE) + SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${EXE_DIR} PARENT_SCOPE) + +ENDFUNCTION(SetExeOutputPath) + +FUNCTION(SetDllOutputPath OUTPUT_DLL_DIR) + + SET(DLL_DIR ${OUTPUT_DLL_DIR}) + + # Override the default output directories for all configurations. + SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${DLL_DIR} PARENT_SCOPE) + SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY_CHECKED ${DLL_DIR} PARENT_SCOPE) + SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY_PROFILE ${DLL_DIR} PARENT_SCOPE) + SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${DLL_DIR} PARENT_SCOPE) + +ENDFUNCTION(SetDllOutputPath) + +FUNCTION(SetLibOutputPath OUTPUT_LIB_DIR) + + SET(LIB_DIR ${OUTPUT_LIB_DIR}) + + # Override the default output directories for all configurations. + SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${LIB_DIR} PARENT_SCOPE) + SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_CHECKED ${LIB_DIR} PARENT_SCOPE) + SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_PROFILE ${LIB_DIR} PARENT_SCOPE) + SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${LIB_DIR} PARENT_SCOPE) + + SET(CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY ${LIB_DIR}) + +ENDFUNCTION(SetLibOutputPath) + +FUNCTION(SetSingleOutputPath OUTPUT_ALL_DIR) + + SET(EXE_DIR ${OUTPUT_ALL_DIR}) + SET(DLL_DIR ${OUTPUT_ALL_DIR}) + SET(LIB_DIR ${OUTPUT_ALL_DIR}) + + # Override the default output directories for all configurations. + SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${EXE_DIR} PARENT_SCOPE) + SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${DLL_DIR} PARENT_SCOPE) + SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${LIB_DIR} PARENT_SCOPE) + + SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_CHECKED ${EXE_DIR} PARENT_SCOPE) + SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY_CHECKED ${DLL_DIR} PARENT_SCOPE) + SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_CHECKED ${LIB_DIR} PARENT_SCOPE) + + SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_PROFILE ${EXE_DIR} PARENT_SCOPE) + SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY_PROFILE ${DLL_DIR} PARENT_SCOPE) + SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_PROFILE ${LIB_DIR} PARENT_SCOPE) + + SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${EXE_DIR} PARENT_SCOPE) + SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${DLL_DIR} PARENT_SCOPE) + SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${LIB_DIR} PARENT_SCOPE) + + SET(CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY ${LIB_DIR}) + +ENDFUNCTION(SetSingleOutputPath)
\ No newline at end of file diff --git a/NvCloth/Externals/CMakeModules/android/AndroidCMake.tps b/NvCloth/Externals/CMakeModules/android/AndroidCMake.tps new file mode 100644 index 0000000..6ca944a --- /dev/null +++ b/NvCloth/Externals/CMakeModules/android/AndroidCMake.tps @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="utf-8"?> +<TpsData xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <Name /> + <Location>/Engine/Source/Runtime/Navmesh/RecastDemo/Bin/DroidSans.ttf</Location> + <Function /> + <Justification /> + <Platforms /> + <Products /> + <Eula /> + <RedistributeTo /> + <Redistribute>false</Redistribute> + <IsSourceAvailable>false</IsSourceAvailable> + <Notification> +Redirect: ../../../../HarfBuzz/harfbuzz-1.2.4/BuildForUE/Android/AndroidCMake.tps +</Notification> + <LicenseFolder /> +</TpsData>
\ No newline at end of file diff --git a/NvCloth/Externals/CMakeModules/android/AndroidNdkGdb.cmake b/NvCloth/Externals/CMakeModules/android/AndroidNdkGdb.cmake new file mode 100644 index 0000000..0677dcd --- /dev/null +++ b/NvCloth/Externals/CMakeModules/android/AndroidNdkGdb.cmake @@ -0,0 +1,96 @@ +# Copyright (c) 2014, Pavel Rojtberg +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived from this +# software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + +# ------------------------------------------------------------------------------ +# Usage: +# 1. place AndroidNdkGdb.cmake somewhere inside ${CMAKE_MODULE_PATH} +# 2. inside your project add +# +# include(AndroidNdkGdb) +# android_ndk_gdb_enable() +# # for each target +# add_library(MyLibrary ...) +# android_ndk_gdb_debuggable(MyLibrary) + + +# add gdbserver and general gdb configuration to project +# also create a mininal NDK skeleton so ndk-gdb finds the paths +# +# the optional parameter defines the path to the android project. +# uses PROJECT_SOURCE_DIR by default. +macro(android_ndk_gdb_enable) + if(ANDROID) + # create custom target that depends on the real target so it gets executed afterwards + add_custom_target(NDK_GDB ALL) + + if(${ARGC}) + set(ANDROID_PROJECT_DIR ${ARGV0}) + else() + set(ANDROID_PROJECT_DIR ${PROJECT_SOURCE_DIR}) + endif() + + set(NDK_GDB_SOLIB_PATH ${ANDROID_PROJECT_DIR}/obj/local/${ANDROID_NDK_ABI_NAME}/) + file(MAKE_DIRECTORY ${NDK_GDB_SOLIB_PATH}) + + # 1. generate essential Android Makefiles + file(MAKE_DIRECTORY ${ANDROID_PROJECT_DIR}/jni) + if(NOT EXISTS ${ANDROID_PROJECT_DIR}/jni/Android.mk) + file(WRITE ${ANDROID_PROJECT_DIR}/jni/Android.mk "APP_ABI := ${ANDROID_NDK_ABI_NAME}\n") + endif() + if(NOT EXISTS ${ANDROID_PROJECT_DIR}/jni/Application.mk) + file(WRITE ${ANDROID_PROJECT_DIR}/jni/Application.mk "APP_ABI := ${ANDROID_NDK_ABI_NAME}\n") + endif() + + # 2. generate gdb.setup + get_directory_property(PROJECT_INCLUDES DIRECTORY ${PROJECT_SOURCE_DIR} INCLUDE_DIRECTORIES) + string(REGEX REPLACE ";" " " PROJECT_INCLUDES "${PROJECT_INCLUDES}") + file(WRITE ${LIBRARY_OUTPUT_PATH}/gdb.setup "set solib-search-path ${NDK_GDB_SOLIB_PATH}\n") + file(APPEND ${LIBRARY_OUTPUT_PATH}/gdb.setup "directory ${PROJECT_INCLUDES}\n") + + # 3. copy gdbserver executable + file(COPY ${ANDROID_NDK}/prebuilt/android-${ANDROID_ARCH_NAME}/gdbserver/gdbserver DESTINATION ${LIBRARY_OUTPUT_PATH}) + endif() +endmacro() + +# register a target for remote debugging +# copies the debug version to NDK_GDB_SOLIB_PATH then strips symbols of original +macro(android_ndk_gdb_debuggable TARGET_NAME) + if(ANDROID) + get_property(TARGET_LOCATION TARGET ${TARGET_NAME} PROPERTY LOCATION) + + # create custom target that depends on the real target so it gets executed afterwards + add_dependencies(NDK_GDB ${TARGET_NAME}) + + # 4. copy lib to obj + add_custom_command(TARGET NDK_GDB POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different ${TARGET_LOCATION} ${NDK_GDB_SOLIB_PATH}) + + # 5. strip symbols + add_custom_command(TARGET NDK_GDB POST_BUILD COMMAND ${CMAKE_STRIP} ${TARGET_LOCATION}) + endif() +endmacro() diff --git a/NvCloth/Externals/CMakeModules/android/AndroidNdkModules.cmake b/NvCloth/Externals/CMakeModules/android/AndroidNdkModules.cmake new file mode 100644 index 0000000..64f37fd --- /dev/null +++ b/NvCloth/Externals/CMakeModules/android/AndroidNdkModules.cmake @@ -0,0 +1,58 @@ +# Copyright (c) 2014, Pavel Rojtberg +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived from this +# software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + +macro(android_ndk_import_module_cpufeatures) + if(ANDROID) + include_directories(${ANDROID_NDK}/sources/android/cpufeatures) + add_library(cpufeatures ${ANDROID_NDK}/sources/android/cpufeatures/cpu-features.c) + target_link_libraries(cpufeatures dl) + endif() +endmacro() + +macro(android_ndk_import_module_native_app_glue) + if(ANDROID) + include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + add_library(native_app_glue ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + target_link_libraries(native_app_glue log) + endif() +endmacro() + +macro(android_ndk_import_module_ndk_helper) + if(ANDROID) + android_ndk_import_module_cpufeatures() + android_ndk_import_module_native_app_glue() + + include_directories(${ANDROID_NDK}/sources/android/ndk_helper) + file(GLOB _NDK_HELPER_SRCS ${ANDROID_NDK}/sources/android/ndk_helper/*.cpp ${ANDROID_NDK}/sources/android/ndk_helper/gl3stub.c) + add_library(ndk_helper ${_NDK_HELPER_SRCS}) + target_link_libraries(ndk_helper log android EGL GLESv2 cpufeatures native_app_glue) + + unset(_NDK_HELPER_SRCS) + endif() +endmacro()
\ No newline at end of file diff --git a/NvCloth/Externals/CMakeModules/android/README.md b/NvCloth/Externals/CMakeModules/android/README.md new file mode 100644 index 0000000..ee63021 --- /dev/null +++ b/NvCloth/Externals/CMakeModules/android/README.md @@ -0,0 +1,240 @@ +# android-cmake + +CMake is great, and so is Android. This is a collection of CMake scripts that may be useful to the Android NDK community. It is based on experience from porting OpenCV library to Android: http://opencv.org/platforms/android.html + +Main goal is to share these scripts so that devs that use CMake as their build system may easily compile native code for Android. + +## TL;DR + + cmake -DCMAKE_TOOLCHAIN_FILE=android.toolchain.cmake \ + -DANDROID_NDK=<ndk_path> \ + -DCMAKE_BUILD_TYPE=Release \ + -DANDROID_ABI="armeabi-v7a with NEON" \ + <source_path> + cmake --build . + +One-liner: + + cmake -DCMAKE_TOOLCHAIN_FILE=android.toolchain.cmake -DANDROID_NDK=<ndk_path> -DCMAKE_BUILD_TYPE=Release -DANDROID_ABI="armeabi-v7a with NEON" <source_path> && cmake --build . + +_android-cmake_ will search for your NDK install in the following order: + +1. Value of `ANDROID_NDK` CMake variable; +1. Value of `ANDROID_NDK` environment variable; +1. Search under paths from `ANDROID_NDK_SEARCH_PATHS` CMake variable; +1. Search platform specific locations (home folder, Windows "Program Files", etc). + +So if you have installed the NDK as `~/android-ndk-r10d` then _android-cmake_ will locate it automatically. + +## Getting started + +To build a cmake-based C/C++ project for Android you need: + +* Android NDK (>= r5) http://developer.android.com/tools/sdk/ndk/index.html +* CMake (>= v2.6.3, >= v2.8.9 recommended) http://www.cmake.org/download + +The _android-cmake_ is also capable to build with NDK from AOSP or Linaro Android source tree, but you may be required to manually specify path to `libm` binary to link with. + +## Difference from traditional CMake + +Folowing the _ndk-build_ the _android-cmake_ supports **only two build targets**: + +* `-DCMAKE_BUILD_TYPE=Release` +* `-DCMAKE_BUILD_TYPE=Debug` + +So don't even try other targets that can be found in CMake documentation and don't forget to explicitly specify `Release` or `Debug` because CMake builds without a build configuration by default. + +## Difference from _ndk-build_ + +* Latest GCC available in NDK is used as the default compiler; +* `Release` builds with `-O3` instead of `-Os`; +* `Release` builds without debug info (without `-g`) (because _ndk-build_ always creates a stripped version but cmake delays this for `install/strip` target); +* `-fsigned-char` is added to compiler flags to make `char` signed by default as it is on x86/x86_64; +* GCC's stack protector is not used neither in `Debug` nor `Release` configurations; +* No builds for multiple platforms (e.g. building for both arm and x86 require to run cmake twice with different parameters); +* No file level Neon via `.neon` suffix; + +The following features of _ndk-build_ are not supported by the _android-cmake_ yet: + +* `armeabi-v7a-hard` ABI +* `libc++_static`/`libc++_shared` STL runtime + +## Basic options + +Similarly to the NDK build system _android-cmake_ allows to select between several compiler toolchains and target platforms. Most of the options can be set either as cmake arguments: `-D<NAME>=<VALUE>` or as environment variables: + +* **ANDROID_NDK** - path to the Android NDK. If not set then _android-cmake_ will search for the most recent version of supported NDK in commonly used locations; +* **ANDROID_ABI** - specifies the target Application Binary Interface (ABI). This option nearly matches to the APP_ABI variable used by ndk-build tool from Android NDK. If not specified then set to `armeabi-v7a`. Possible target names are: + * `armeabi` - ARMv5TE based CPU with software floating point operations; + * **`armeabi-v7a`** - ARMv7 based devices with hardware FPU instructions (VFPv3_D16); + * `armeabi-v7a with NEON` - same as armeabi-v7a, but sets NEON as floating-point unit; + * `armeabi-v7a with VFPV3` - same as armeabi-v7a, but sets VFPv3_D32 as floating-point unit; + * `armeabi-v6 with VFP` - tuned for ARMv6 processors having VFP; + * `x86` - IA-32 instruction set + * `mips` - MIPS32 instruction set + * `arm64-v8a` - ARMv8 AArch64 instruction set - only for NDK r10 and newer + * `x86_64` - Intel64 instruction set (r1) - only for NDK r10 and newer + * `mips64` - MIPS64 instruction set (r6) - only for NDK r10 and newer +* **ANDROID_NATIVE_API_LEVEL** - level of android API to build for. Can be set either to full name (example: `android-8`) or a numeric value (example: `17`). The default API level depends on the target ABI: + * `android-8` for ARM; + * `android-9` for x86 and MIPS; + * `android-21` for 64-bit ABIs. + + Building for `android-L` is possible only when it is explicitly selected. +* **ANDROID_TOOLCHAIN_NAME** - the name of compiler toolchain to be used. This option allows to select between different GCC and Clang versions. The list of possible values depends on the NDK version and will be printed by toolchain file if an invalid value is set. By default _android-cmake_ selects the most recent version of GCC which can build for specified `ANDROID_ABI`. + + Example values are: + * `aarch64-linux-android-4.9` + * `aarch64-linux-android-clang3.5` + * `arm-linux-androideabi-4.8` + * `arm-linux-androideabi-4.9` + * `arm-linux-androideabi-clang3.5` + * `mips64el-linux-android-4.9` + * `mipsel-linux-android-4.8` + * `x86-4.9` + * `x86_64-4.9` + * etc. +* **ANDROID_STL** - the name of C++ runtime to use. The default is `gnustl_static`. + * `none` - do not configure the runtime. + * `system` - use the default minimal system C++ runtime library. + * Implies `-fno-rtti -fno-exceptions`. + * `system_re` - use the default minimal system C++ runtime library. + * Implies `-frtti -fexceptions`. + * `gabi++_static` - use the GAbi++ runtime as a static library. + * Implies `-frtti -fno-exceptions`. + * Available for NDK r7 and newer. + * `gabi++_shared` - use the GAbi++ runtime as a shared library. + * Implies `-frtti -fno-exceptions`. + * Available for NDK r7 and newer. + * `stlport_static` - use the STLport runtime as a static library. + * Implies `-fno-rtti -fno-exceptions` for NDK before r7. + * Implies `-frtti -fno-exceptions` for NDK r7 and newer. + * `stlport_shared` - use the STLport runtime as a shared library. + * Implies `-fno-rtti -fno-exceptions` for NDK before r7. + * Implies `-frtti -fno-exceptions` for NDK r7 and newer. + * **`gnustl_static`** - use the GNU STL as a static library. + * Implies `-frtti -fexceptions`. + * `gnustl_shared` - use the GNU STL as a shared library. + * Implies `-frtti -fno-exceptions`. + * Available for NDK r7b and newer. + * Silently degrades to `gnustl_static` if not available. +* **NDK_CCACHE** - path to `ccache` executable. If not set then initialized from `NDK_CCACHE` environment variable. + +## Advanced _android-cmake_ options + +Normally _android-cmake_ users are not supposed to touch these variables but they might be useful to workaround some build issues: + +* **ANDROID_FORCE_ARM_BUILD** = `OFF` - generate 32-bit ARM instructions instead of Thumb. Applicable only for arm ABIs and is forced to be `ON` for `armeabi-v6 with VFP`; +* **ANDROID_NO_UNDEFINED** = `ON` - show all undefined symbols as linker errors; +* **ANDROID_SO_UNDEFINED** = `OFF` - allow undefined symbols in shared libraries; + * actually it is turned `ON` by default for NDK older than `r7` +* **ANDROID_STL_FORCE_FEATURES** = `ON` - automatically configure rtti and exceptions support based on C++ runtime; +* **ANDROID_NDK_LAYOUT** = `RELEASE` - inner layout of Android NDK, should be detected automatically. Possible values are: + * `RELEASE` - public releases from Google; + * `LINARO` - NDK from Linaro project; + * `ANDROID` - NDK from AOSP. +* **ANDROID_FUNCTION_LEVEL_LINKING** = `ON` - enables saparate putting each function and data items into separate sections and enable garbage collection of unused input sections at link time (`-fdata-sections -ffunction-sections -Wl,--gc-sections`); +* **ANDROID_GOLD_LINKER** = `ON` - use gold linker with GCC 4.6 for NDK r8b and newer (only for ARM and x86); +* **ANDROID_NOEXECSTACK** = `ON` - enables or disables stack execution protection code (`-Wl,-z,noexecstack`); +* **ANDROID_RELRO** = `ON` - Enables RELRO - a memory corruption mitigation technique (`-Wl,-z,relro -Wl,-z,now`); +* **ANDROID_LIBM_PATH** - path to `libm.so` (set to something like `$(TOP)/out/target/product/<product_name>/obj/lib/libm.so`) to workaround unresolved `sincos`. + +## Fine-tuning `CMakeLists.txt` for _android-cmake_ + +### Recognizing Android build + +_android-cmake_ defines `ANDROID` CMake variable which can be used to add Android-specific stuff: + + if (ANDROID) + message(STATUS "Hello from Android build!") + endif() + +The recommended way to identify ARM/MIPS/x86 architecture is examining `CMAKE_SYSTEM_PROCESSOR` which is set to the appropriate value: + +* `armv5te` - for `armeabi` ABI +* `armv6` - for `armeabi-v6 with VFP` ABI +* `armv7-a` - for `armeabi-v7a`, `armeabi-v7a with VFPV3` and `armeabi-v7a with NEON` ABIs +* `aarch64` - for `arm64-v8a` ABI +* `i686` - for `x86` ABI +* `x86_64` - for `x86_64` ABI +* `mips` - for `mips` ABI +* `mips64` - for `mips64` ABI + +Other variables that are set by _android-cmake_ and can be used for the fine-grained build configuration are: + +* `NEON` - set if target ABI supports Neon; +* `ANDROID_NATIVE_API_LEVEL` - native Android API level we are building for (note: Java part of Andoid application can be built for another API level) +* `ANDROID_NDK_RELEASE` - version of the Android NDK +* `ANDROID_NDK_HOST_SYSTEM_NAME` - "windows", "linux-x86" or "darwin-x86" depending on the host platform +* `ANDROID_RTTI` - set if rtti is enabled by the runtime +* `ANDROID_EXCEPTIONS` - set if exceptions are enabled by the runtime + +### Finding packages + +When crosscompiling CMake `find_*` commands are normally expected to find libraries and packages belonging to the same build target. So _android-cmake_ configures CMake to search in Android-specific paths only and ignore your host system locations. So + + find_package(ZLIB) + +will surely find libz.so within the Android NDK. + +However sometimes you need to locate a host package even when cross-compiling. For example you can be searching for your documentation generator. The _android-cmake_ recommends you to use `find_host_package` and `find_host_program` macro defined in the `android.toolchain.cmake`: + + find_host_package(Doxygen) + find_host_program(PDFLATEX pdflatex) + +However this will break regular builds so instead of wrapping package search into platform-specific logic you can copy the following snippet into your project (put it after your top-level `project()` command): + + # Search packages for host system instead of packages for target system + # in case of cross compilation these macro should be defined by toolchain file + if(NOT COMMAND find_host_package) + macro(find_host_package) + find_package(${ARGN}) + endmacro() + endif() + if(NOT COMMAND find_host_program) + macro(find_host_program) + find_program(${ARGN}) + endmacro() + endif() + +### Compiler flags recycling + +Make sure to do the following in your scripts: + + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${my_cxx_flags}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${my_cxx_flags}") + +The flags will be prepopulated with critical flags, so don't loose them. Also be aware that _android-cmake_ also sets configuration-specific compiler and linker flags. + +## Troubleshooting + +### Building on Windows + +First of all `cygwin` builds are **NOT supported** and will not be supported by _android-cmake_. To build natively on Windows you need a port of make but I recommend http://martine.github.io/ninja/ instead. + +To build with Ninja you need: + +* Ensure you are using CMake newer than 2.8.9; +* Download the latest Ninja from https://github.com/martine/ninja/releases; +* Put the `ninja.exe` into your PATH (or add path to `ninja.exe` to your PATH environment variable); +* Pass `-GNinja` to `cmake` alongside with other arguments (or choose Ninja generator in `cmake-gui`). +* Enjoy the fast native multithreaded build :) + +But if you still want to stick to old make then: + +* Get a Windows port of GNU Make: + * Android NDK r7 (and newer) already has `make.exe` on board; + * `mingw-make` should work as fine; + * Download some other port. For example, this one: http://gnuwin32.sourceforge.net/packages/make.htm. +* Add path to your `make.exe` to system PATH or always use full path; +* Pass `-G"MinGW Makefiles"` and `-DCMAKE_MAKE_PROGRAM="<full/path/to/>make.exe"` + * It must be `MinGW Makefiles` and not `Unix Makefiles` even if your `make.exe` is not a MinGW's make. +* Run `make.exe` or `cmake --build .` for single-threaded build. + +### Projects with assembler files + +The _android-cmake_ should correctly handle projects with assembler sources (`*.s` or `*.S`). But if you still facing problems with assembler then try to upgrade your CMake to version newer than 2.8.5 + +## Copying + +_android-cmake_ is distributed under the terms of [BSD 3-Clause License](http://opensource.org/licenses/BSD-3-Clause)
\ No newline at end of file diff --git a/NvCloth/Externals/CMakeModules/android/android.toolchain.cmake b/NvCloth/Externals/CMakeModules/android/android.toolchain.cmake new file mode 100644 index 0000000..7fc54f2 --- /dev/null +++ b/NvCloth/Externals/CMakeModules/android/android.toolchain.cmake @@ -0,0 +1,1693 @@ +# Copyright (c) 2010-2011, Ethan Rublee +# Copyright (c) 2011-2014, Andrey Kamaev +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived from this +# software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + +# ------------------------------------------------------------------------------ +# Android CMake toolchain file, for use with the Android NDK r5-r10d +# Requires cmake 2.6.3 or newer (2.8.9 or newer is recommended). +# See home page: https://github.com/taka-no-me/android-cmake +# +# Usage Linux: +# $ export ANDROID_NDK=/absolute/path/to/the/android-ndk +# $ mkdir build && cd build +# $ cmake -DCMAKE_TOOLCHAIN_FILE=path/to/the/android.toolchain.cmake .. +# $ make -j8 +# +# Usage Windows: +# You need native port of make to build your project. +# Android NDK r7 (and newer) already has make.exe on board. +# For older NDK you have to install it separately. +# For example, this one: http://gnuwin32.sourceforge.net/packages/make.htm +# +# $ SET ANDROID_NDK=C:\absolute\path\to\the\android-ndk +# $ mkdir build && cd build +# $ cmake.exe -G"MinGW Makefiles" +# -DCMAKE_TOOLCHAIN_FILE=path\to\the\android.toolchain.cmake +# -DCMAKE_MAKE_PROGRAM="%ANDROID_NDK%\prebuilt\windows\bin\make.exe" .. +# $ cmake.exe --build . +# +# +# Options (can be set as cmake parameters: -D<option_name>=<value>): +# ANDROID_NDK=/opt/android-ndk - path to the NDK root. +# Can be set as environment variable. Can be set only at first cmake run. +# +# ANDROID_ABI=armeabi-v7a - specifies the target Application Binary +# Interface (ABI). This option nearly matches to the APP_ABI variable +# used by ndk-build tool from Android NDK. +# +# Possible targets are: +# "armeabi" - ARMv5TE based CPU with software floating point operations +# "armeabi-v7a" - ARMv7 based devices with hardware FPU instructions +# this ABI target is used by default +# "armeabi-v7a with NEON" - same as armeabi-v7a, but +# sets NEON as floating-point unit +# "armeabi-v7a with VFPV3" - same as armeabi-v7a, but +# sets VFPV3 as floating-point unit (has 32 registers instead of 16) +# "armeabi-v6 with VFP" - tuned for ARMv6 processors having VFP +# "x86" - IA-32 instruction set +# "mips" - MIPS32 instruction set +# +# 64-bit ABIs for NDK r10 and newer: +# "arm64-v8a" - ARMv8 AArch64 instruction set +# "x86_64" - Intel64 instruction set (r1) +# "mips64" - MIPS64 instruction set (r6) +# +# ANDROID_NATIVE_API_LEVEL=android-8 - level of Android API compile for. +# Option is read-only when standalone toolchain is used. +# Note: building for "android-L" requires explicit configuration. +# +# ANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-4.9 - the name of compiler +# toolchain to be used. The list of possible values depends on the NDK +# version. For NDK r10c the possible values are: +# +# * aarch64-linux-android-4.9 +# * aarch64-linux-android-clang3.4 +# * aarch64-linux-android-clang3.5 +# * arm-linux-androideabi-4.6 +# * arm-linux-androideabi-4.8 +# * arm-linux-androideabi-4.9 (default) +# * arm-linux-androideabi-clang3.4 +# * arm-linux-androideabi-clang3.5 +# * mips64el-linux-android-4.9 +# * mips64el-linux-android-clang3.4 +# * mips64el-linux-android-clang3.5 +# * mipsel-linux-android-4.6 +# * mipsel-linux-android-4.8 +# * mipsel-linux-android-4.9 +# * mipsel-linux-android-clang3.4 +# * mipsel-linux-android-clang3.5 +# * x86-4.6 +# * x86-4.8 +# * x86-4.9 +# * x86-clang3.4 +# * x86-clang3.5 +# * x86_64-4.9 +# * x86_64-clang3.4 +# * x86_64-clang3.5 +# +# ANDROID_FORCE_ARM_BUILD=OFF - set ON to generate 32-bit ARM instructions +# instead of Thumb. Is not available for "armeabi-v6 with VFP" +# (is forced to be ON) ABI. +# +# ANDROID_NO_UNDEFINED=ON - set ON to show all undefined symbols as linker +# errors even if they are not used. +# +# ANDROID_SO_UNDEFINED=OFF - set ON to allow undefined symbols in shared +# libraries. Automatically turned for NDK r5x and r6x due to GLESv2 +# problems. +# +# ANDROID_STL=gnustl_static - specify the runtime to use. +# +# Possible values are: +# none -> Do not configure the runtime. +# system -> Use the default minimal system C++ runtime library. +# Implies -fno-rtti -fno-exceptions. +# Is not available for standalone toolchain. +# system_re -> Use the default minimal system C++ runtime library. +# Implies -frtti -fexceptions. +# Is not available for standalone toolchain. +# gabi++_static -> Use the GAbi++ runtime as a static library. +# Implies -frtti -fno-exceptions. +# Available for NDK r7 and newer. +# Is not available for standalone toolchain. +# gabi++_shared -> Use the GAbi++ runtime as a shared library. +# Implies -frtti -fno-exceptions. +# Available for NDK r7 and newer. +# Is not available for standalone toolchain. +# stlport_static -> Use the STLport runtime as a static library. +# Implies -fno-rtti -fno-exceptions for NDK before r7. +# Implies -frtti -fno-exceptions for NDK r7 and newer. +# Is not available for standalone toolchain. +# stlport_shared -> Use the STLport runtime as a shared library. +# Implies -fno-rtti -fno-exceptions for NDK before r7. +# Implies -frtti -fno-exceptions for NDK r7 and newer. +# Is not available for standalone toolchain. +# gnustl_static -> Use the GNU STL as a static library. +# Implies -frtti -fexceptions. +# gnustl_shared -> Use the GNU STL as a shared library. +# Implies -frtti -fno-exceptions. +# Available for NDK r7b and newer. +# Silently degrades to gnustl_static if not available. +# +# ANDROID_STL_FORCE_FEATURES=ON - turn rtti and exceptions support based on +# chosen runtime. If disabled, then the user is responsible for settings +# these options. +# +# What?: +# android-cmake toolchain searches for NDK/toolchain in the following order: +# ANDROID_NDK - cmake parameter +# ANDROID_NDK - environment variable +# ANDROID_STANDALONE_TOOLCHAIN - cmake parameter +# ANDROID_STANDALONE_TOOLCHAIN - environment variable +# ANDROID_NDK - default locations +# ANDROID_STANDALONE_TOOLCHAIN - default locations +# +# Make sure to do the following in your scripts: +# SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${my_cxx_flags}" ) +# SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${my_cxx_flags}" ) +# The flags will be prepopulated with critical flags, so don't loose them. +# Also be aware that toolchain also sets configuration-specific compiler +# flags and linker flags. +# +# ANDROID and BUILD_ANDROID will be set to true, you may test any of these +# variables to make necessary Android-specific configuration changes. +# +# Also ARMEABI or ARMEABI_V7A or X86 or MIPS or ARM64_V8A or X86_64 or MIPS64 +# will be set true, mutually exclusive. NEON option will be set true +# if VFP is set to NEON. +# +# ------------------------------------------------------------------------------ + +cmake_minimum_required( VERSION 2.6.3 ) + +if( DEFINED CMAKE_CROSSCOMPILING ) + # subsequent toolchain loading is not really needed + return() +endif() + +if( CMAKE_TOOLCHAIN_FILE ) + # touch toolchain variable to suppress "unused variable" warning +endif() + +# inherit settings in recursive loads +get_property( _CMAKE_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE ) +if( _CMAKE_IN_TRY_COMPILE ) + include( "${CMAKE_CURRENT_SOURCE_DIR}/../android.toolchain.config.cmake" OPTIONAL ) +endif() + +# this one is important +if( CMAKE_VERSION VERSION_GREATER "3.0.99" ) + set( CMAKE_SYSTEM_NAME Android ) +else() + set( CMAKE_SYSTEM_NAME Linux ) +endif() + +# this one not so much +set( CMAKE_SYSTEM_VERSION 1 ) + +# rpath makes low sense for Android +set( CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "" ) +set( CMAKE_SKIP_RPATH TRUE CACHE BOOL "If set, runtime paths are not added when using shared libraries." ) + +# NDK search paths +set( ANDROID_SUPPORTED_NDK_VERSIONS ${ANDROID_EXTRA_NDK_VERSIONS} -r11c -r11b -r11a -r10e -r10d -r10c -r10b -r10 -r9d -r9c -r9b -r9 -r8e -r8d -r8c -r8b -r8 -r7c -r7b -r7 -r6b -r6 -r5c -r5b -r5 "" ) +if( NOT DEFINED ANDROID_NDK_SEARCH_PATHS ) + if( CMAKE_HOST_WIN32 ) + file( TO_CMAKE_PATH "$ENV{PROGRAMFILES}" ANDROID_NDK_SEARCH_PATHS ) + set( ANDROID_NDK_SEARCH_PATHS "${ANDROID_NDK_SEARCH_PATHS}" "$ENV{SystemDrive}/NVPACK" ) + else() + file( TO_CMAKE_PATH "$ENV{HOME}" ANDROID_NDK_SEARCH_PATHS ) + set( ANDROID_NDK_SEARCH_PATHS /opt "${ANDROID_NDK_SEARCH_PATHS}/NVPACK" ) + endif() +endif() +if( NOT DEFINED ANDROID_STANDALONE_TOOLCHAIN_SEARCH_PATH ) + set( ANDROID_STANDALONE_TOOLCHAIN_SEARCH_PATH /opt/android-toolchain ) +endif() + +# known ABIs +set( ANDROID_SUPPORTED_ABIS_arm "armeabi-v7a;armeabi;armeabi-v7a with NEON;armeabi-v7a with VFPV3;armeabi-v6 with VFP" ) +set( ANDROID_SUPPORTED_ABIS_arm64 "arm64-v8a" ) +set( ANDROID_SUPPORTED_ABIS_x86 "x86" ) +set( ANDROID_SUPPORTED_ABIS_x86_64 "x86_64" ) +set( ANDROID_SUPPORTED_ABIS_mips "mips" ) +set( ANDROID_SUPPORTED_ABIS_mips64 "mips64" ) + +# API level defaults +set( ANDROID_DEFAULT_NDK_API_LEVEL 8 ) +set( ANDROID_DEFAULT_NDK_API_LEVEL_arm64 21 ) +set( ANDROID_DEFAULT_NDK_API_LEVEL_x86 9 ) +set( ANDROID_DEFAULT_NDK_API_LEVEL_x86_64 21 ) +set( ANDROID_DEFAULT_NDK_API_LEVEL_mips 9 ) +set( ANDROID_DEFAULT_NDK_API_LEVEL_mips64 21 ) + + +macro( __LIST_FILTER listvar regex ) + if( ${listvar} ) + foreach( __val ${${listvar}} ) + if( __val MATCHES "${regex}" ) + list( REMOVE_ITEM ${listvar} "${__val}" ) + endif() + endforeach() + endif() +endmacro() + +macro( __INIT_VARIABLE var_name ) + set( __test_path 0 ) + foreach( __var ${ARGN} ) + if( __var STREQUAL "PATH" ) + set( __test_path 1 ) + break() + endif() + endforeach() + + if( __test_path AND NOT EXISTS "${${var_name}}" ) + unset( ${var_name} CACHE ) + endif() + + if( " ${${var_name}}" STREQUAL " " ) + set( __values 0 ) + foreach( __var ${ARGN} ) + if( __var STREQUAL "VALUES" ) + set( __values 1 ) + elseif( NOT __var STREQUAL "PATH" ) + if( __var MATCHES "^ENV_.*$" ) + string( REPLACE "ENV_" "" __var "${__var}" ) + set( __value "$ENV{${__var}}" ) + elseif( DEFINED ${__var} ) + set( __value "${${__var}}" ) + elseif( __values ) + set( __value "${__var}" ) + else() + set( __value "" ) + endif() + + if( NOT " ${__value}" STREQUAL " " AND (NOT __test_path OR EXISTS "${__value}") ) + set( ${var_name} "${__value}" ) + break() + endif() + endif() + endforeach() + unset( __value ) + unset( __values ) + endif() + + if( __test_path ) + file( TO_CMAKE_PATH "${${var_name}}" ${var_name} ) + endif() + unset( __test_path ) +endmacro() + +macro( __DETECT_NATIVE_API_LEVEL _var _path ) + set( __ndkApiLevelRegex "^[\t ]*#define[\t ]+__ANDROID_API__[\t ]+([0-9]+)[\t ]*.*$" ) + file( STRINGS ${_path} __apiFileContent REGEX "${__ndkApiLevelRegex}" ) + if( NOT __apiFileContent ) + message( SEND_ERROR "Could not get Android native API level. Probably you have specified invalid level value, or your copy of NDK/toolchain is broken." ) + endif() + string( REGEX REPLACE "${__ndkApiLevelRegex}" "\\1" ${_var} "${__apiFileContent}" ) + unset( __apiFileContent ) + unset( __ndkApiLevelRegex ) +endmacro() + +macro( __DETECT_TOOLCHAIN_MACHINE_NAME _var _root ) + if( EXISTS "${_root}" ) + file( GLOB __gccExePath RELATIVE "${_root}/bin/" "${_root}/bin/*-gcc${TOOL_OS_SUFFIX}" ) + __LIST_FILTER( __gccExePath "^[.].*" ) + list( LENGTH __gccExePath __gccExePathsCount ) + if( NOT __gccExePathsCount EQUAL 1 AND NOT _CMAKE_IN_TRY_COMPILE ) + message( WARNING "Could not determine machine name for compiler from ${_root}" ) + set( ${_var} "" ) + else() + get_filename_component( __gccExeName "${__gccExePath}" NAME_WE ) + string( REPLACE "-gcc" "" ${_var} "${__gccExeName}" ) + endif() + unset( __gccExePath ) + unset( __gccExePathsCount ) + unset( __gccExeName ) + else() + set( ${_var} "" ) + endif() +endmacro() + + +# fight against cygwin +set( ANDROID_FORBID_SYGWIN TRUE CACHE BOOL "Prevent cmake from working under cygwin and using cygwin tools") +mark_as_advanced( ANDROID_FORBID_SYGWIN ) +if( ANDROID_FORBID_SYGWIN ) + if( CYGWIN ) + message( FATAL_ERROR "Android NDK and android-cmake toolchain are not welcome Cygwin. It is unlikely that this cmake toolchain will work under cygwin. But if you want to try then you can set cmake variable ANDROID_FORBID_SYGWIN to FALSE and rerun cmake." ) + endif() + + if( CMAKE_HOST_WIN32 ) + # remove cygwin from PATH + set( __new_path "$ENV{PATH}") + __LIST_FILTER( __new_path "cygwin" ) + set(ENV{PATH} "${__new_path}") + unset(__new_path) + endif() +endif() + + +# detect current host platform +if( NOT DEFINED ANDROID_NDK_HOST_X64 AND (CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "amd64|x86_64|AMD64" OR CMAKE_HOST_APPLE) ) + set( ANDROID_NDK_HOST_X64 1 CACHE BOOL "Try to use 64-bit compiler toolchain" ) + mark_as_advanced( ANDROID_NDK_HOST_X64 ) +endif() + +set( TOOL_OS_SUFFIX "" ) +if( CMAKE_HOST_APPLE ) + set( ANDROID_NDK_HOST_SYSTEM_NAME "darwin-x86_64" ) + set( ANDROID_NDK_HOST_SYSTEM_NAME2 "darwin-x86" ) +elseif( CMAKE_HOST_WIN32 ) + set( ANDROID_NDK_HOST_SYSTEM_NAME "windows-x86_64" ) + set( ANDROID_NDK_HOST_SYSTEM_NAME2 "windows" ) + set( TOOL_OS_SUFFIX ".exe" ) +elseif( CMAKE_HOST_UNIX ) + set( ANDROID_NDK_HOST_SYSTEM_NAME "linux-x86_64" ) + set( ANDROID_NDK_HOST_SYSTEM_NAME2 "linux-x86" ) +else() + message( FATAL_ERROR "Cross-compilation on your platform is not supported by this cmake toolchain" ) +endif() + +if( NOT ANDROID_NDK_HOST_X64 ) + set( ANDROID_NDK_HOST_SYSTEM_NAME ${ANDROID_NDK_HOST_SYSTEM_NAME2} ) +endif() + +# see if we have path to Android NDK +if( NOT ANDROID_NDK AND NOT ANDROID_STANDALONE_TOOLCHAIN ) + __INIT_VARIABLE( ANDROID_NDK PATH ENV_ANDROID_NDK ) +endif() +if( NOT ANDROID_NDK ) + # see if we have path to Android standalone toolchain + __INIT_VARIABLE( ANDROID_STANDALONE_TOOLCHAIN PATH ENV_ANDROID_STANDALONE_TOOLCHAIN ) + + if( NOT ANDROID_STANDALONE_TOOLCHAIN ) + #try to find Android NDK in one of the the default locations + set( __ndkSearchPaths ) + foreach( __ndkSearchPath ${ANDROID_NDK_SEARCH_PATHS} ) + foreach( suffix ${ANDROID_SUPPORTED_NDK_VERSIONS} ) + list( APPEND __ndkSearchPaths "${__ndkSearchPath}/android-ndk${suffix}" ) + endforeach() + endforeach() + __INIT_VARIABLE( ANDROID_NDK PATH VALUES ${__ndkSearchPaths} ) + unset( __ndkSearchPaths ) + + if( ANDROID_NDK ) + message( STATUS "Using default path for Android NDK: ${ANDROID_NDK}" ) + message( STATUS " If you prefer to use a different location, please define a cmake or environment variable: ANDROID_NDK" ) + else() + #try to find Android standalone toolchain in one of the the default locations + __INIT_VARIABLE( ANDROID_STANDALONE_TOOLCHAIN PATH ANDROID_STANDALONE_TOOLCHAIN_SEARCH_PATH ) + + if( ANDROID_STANDALONE_TOOLCHAIN ) + message( STATUS "Using default path for standalone toolchain ${ANDROID_STANDALONE_TOOLCHAIN}" ) + message( STATUS " If you prefer to use a different location, please define the variable: ANDROID_STANDALONE_TOOLCHAIN" ) + endif( ANDROID_STANDALONE_TOOLCHAIN ) + endif( ANDROID_NDK ) + endif( NOT ANDROID_STANDALONE_TOOLCHAIN ) +endif( NOT ANDROID_NDK ) + +# remember found paths +if( ANDROID_NDK ) + get_filename_component( ANDROID_NDK "${ANDROID_NDK}" ABSOLUTE ) + set( ANDROID_NDK "${ANDROID_NDK}" CACHE INTERNAL "Path of the Android NDK" FORCE ) + set( BUILD_WITH_ANDROID_NDK True ) + if( EXISTS "${ANDROID_NDK}/RELEASE.TXT" ) + file( STRINGS "${ANDROID_NDK}/RELEASE.TXT" ANDROID_NDK_RELEASE_FULL LIMIT_COUNT 1 REGEX "r[0-9]+[a-z]?" ) + string( REGEX MATCH "r([0-9]+)([a-z]?)" ANDROID_NDK_RELEASE "${ANDROID_NDK_RELEASE_FULL}" ) + else() + set( ANDROID_NDK_RELEASE "r1x" ) + set( ANDROID_NDK_RELEASE_FULL "unreleased" ) + endif() + string( REGEX REPLACE "r([0-9]+)([a-z]?)" "\\1*1000" ANDROID_NDK_RELEASE_NUM "${ANDROID_NDK_RELEASE}" ) + string( FIND " abcdefghijklmnopqastuvwxyz" "${CMAKE_MATCH_2}" __ndkReleaseLetterNum ) + math( EXPR ANDROID_NDK_RELEASE_NUM "${ANDROID_NDK_RELEASE_NUM}+${__ndkReleaseLetterNum}" ) +elseif( ANDROID_STANDALONE_TOOLCHAIN ) + get_filename_component( ANDROID_STANDALONE_TOOLCHAIN "${ANDROID_STANDALONE_TOOLCHAIN}" ABSOLUTE ) + # try to detect change + if( CMAKE_AR ) + string( LENGTH "${ANDROID_STANDALONE_TOOLCHAIN}" __length ) + string( SUBSTRING "${CMAKE_AR}" 0 ${__length} __androidStandaloneToolchainPreviousPath ) + if( NOT __androidStandaloneToolchainPreviousPath STREQUAL ANDROID_STANDALONE_TOOLCHAIN ) + message( FATAL_ERROR "It is not possible to change path to the Android standalone toolchain on subsequent run." ) + endif() + unset( __androidStandaloneToolchainPreviousPath ) + unset( __length ) + endif() + set( ANDROID_STANDALONE_TOOLCHAIN "${ANDROID_STANDALONE_TOOLCHAIN}" CACHE INTERNAL "Path of the Android standalone toolchain" FORCE ) + set( BUILD_WITH_STANDALONE_TOOLCHAIN True ) +else() + list(GET ANDROID_NDK_SEARCH_PATHS 0 ANDROID_NDK_SEARCH_PATH) + message( FATAL_ERROR "Could not find neither Android NDK nor Android standalone toolchain. + You should either set an environment variable: + export ANDROID_NDK=~/my-android-ndk + or + export ANDROID_STANDALONE_TOOLCHAIN=~/my-android-toolchain + or put the toolchain or NDK in the default path: + sudo ln -s ~/my-android-ndk ${ANDROID_NDK_SEARCH_PATH}/android-ndk + sudo ln -s ~/my-android-toolchain ${ANDROID_STANDALONE_TOOLCHAIN_SEARCH_PATH}" ) +endif() + +# android NDK layout +if( BUILD_WITH_ANDROID_NDK ) + if( NOT DEFINED ANDROID_NDK_LAYOUT ) + # try to automatically detect the layout + if( EXISTS "${ANDROID_NDK}/RELEASE.TXT") + set( ANDROID_NDK_LAYOUT "RELEASE" ) + elseif( EXISTS "${ANDROID_NDK}/../../linux-x86/toolchain/" ) + set( ANDROID_NDK_LAYOUT "LINARO" ) + elseif( EXISTS "${ANDROID_NDK}/../../gcc/" ) + set( ANDROID_NDK_LAYOUT "ANDROID" ) + endif() + endif() + set( ANDROID_NDK_LAYOUT "${ANDROID_NDK_LAYOUT}" CACHE STRING "The inner layout of NDK" ) + mark_as_advanced( ANDROID_NDK_LAYOUT ) + if( ANDROID_NDK_LAYOUT STREQUAL "LINARO" ) + set( ANDROID_NDK_HOST_SYSTEM_NAME ${ANDROID_NDK_HOST_SYSTEM_NAME2} ) # only 32-bit at the moment + set( ANDROID_NDK_TOOLCHAINS_PATH "${ANDROID_NDK}/../../${ANDROID_NDK_HOST_SYSTEM_NAME}/toolchain" ) + set( ANDROID_NDK_TOOLCHAINS_SUBPATH "" ) + set( ANDROID_NDK_TOOLCHAINS_SUBPATH2 "" ) + elseif( ANDROID_NDK_LAYOUT STREQUAL "ANDROID" ) + set( ANDROID_NDK_HOST_SYSTEM_NAME ${ANDROID_NDK_HOST_SYSTEM_NAME2} ) # only 32-bit at the moment + set( ANDROID_NDK_TOOLCHAINS_PATH "${ANDROID_NDK}/../../gcc/${ANDROID_NDK_HOST_SYSTEM_NAME}/arm" ) + set( ANDROID_NDK_TOOLCHAINS_SUBPATH "" ) + set( ANDROID_NDK_TOOLCHAINS_SUBPATH2 "" ) + else() # ANDROID_NDK_LAYOUT STREQUAL "RELEASE" + set( ANDROID_NDK_TOOLCHAINS_PATH "${ANDROID_NDK}/toolchains" ) + set( ANDROID_NDK_TOOLCHAINS_SUBPATH "/prebuilt/${ANDROID_NDK_HOST_SYSTEM_NAME}" ) + set( ANDROID_NDK_TOOLCHAINS_SUBPATH2 "/prebuilt/${ANDROID_NDK_HOST_SYSTEM_NAME2}" ) + endif() + get_filename_component( ANDROID_NDK_TOOLCHAINS_PATH "${ANDROID_NDK_TOOLCHAINS_PATH}" ABSOLUTE ) + + # try to detect change of NDK + if( CMAKE_AR ) + string( LENGTH "${ANDROID_NDK_TOOLCHAINS_PATH}" __length ) + string( SUBSTRING "${CMAKE_AR}" 0 ${__length} __androidNdkPreviousPath ) + if( NOT __androidNdkPreviousPath STREQUAL ANDROID_NDK_TOOLCHAINS_PATH ) + message( FATAL_ERROR "It is not possible to change the path to the NDK on subsequent CMake run. You must remove all generated files from your build folder first. + " ) + endif() + unset( __androidNdkPreviousPath ) + unset( __length ) + endif() +endif() + + +# get all the details about standalone toolchain +if( BUILD_WITH_STANDALONE_TOOLCHAIN ) + __DETECT_NATIVE_API_LEVEL( ANDROID_SUPPORTED_NATIVE_API_LEVELS "${ANDROID_STANDALONE_TOOLCHAIN}/sysroot/usr/include/android/api-level.h" ) + set( ANDROID_STANDALONE_TOOLCHAIN_API_LEVEL ${ANDROID_SUPPORTED_NATIVE_API_LEVELS} ) + set( __availableToolchains "standalone" ) + __DETECT_TOOLCHAIN_MACHINE_NAME( __availableToolchainMachines "${ANDROID_STANDALONE_TOOLCHAIN}" ) + if( NOT __availableToolchainMachines ) + message( FATAL_ERROR "Could not determine machine name of your toolchain. Probably your Android standalone toolchain is broken." ) + endif() + if( __availableToolchainMachines MATCHES x86_64 ) + set( __availableToolchainArchs "x86_64" ) + elseif( __availableToolchainMachines MATCHES i686 ) + set( __availableToolchainArchs "x86" ) + elseif( __availableToolchainMachines MATCHES aarch64 ) + set( __availableToolchainArchs "arm64" ) + elseif( __availableToolchainMachines MATCHES arm ) + set( __availableToolchainArchs "arm" ) + elseif( __availableToolchainMachines MATCHES mips64el ) + set( __availableToolchainArchs "mips64" ) + elseif( __availableToolchainMachines MATCHES mipsel ) + set( __availableToolchainArchs "mips" ) + endif() + execute_process( COMMAND "${ANDROID_STANDALONE_TOOLCHAIN}/bin/${__availableToolchainMachines}-gcc${TOOL_OS_SUFFIX}" -dumpversion + OUTPUT_VARIABLE __availableToolchainCompilerVersions OUTPUT_STRIP_TRAILING_WHITESPACE ) + string( REGEX MATCH "[0-9]+[.][0-9]+([.][0-9]+)?" __availableToolchainCompilerVersions "${__availableToolchainCompilerVersions}" ) + if( EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/bin/clang${TOOL_OS_SUFFIX}" ) + list( APPEND __availableToolchains "standalone-clang" ) + list( APPEND __availableToolchainMachines ${__availableToolchainMachines} ) + list( APPEND __availableToolchainArchs ${__availableToolchainArchs} ) + list( APPEND __availableToolchainCompilerVersions ${__availableToolchainCompilerVersions} ) + endif() +endif() + +macro( __GLOB_NDK_TOOLCHAINS __availableToolchainsVar __availableToolchainsLst __toolchain_subpath ) + foreach( __toolchain ${${__availableToolchainsLst}} ) + if( "${__toolchain}" MATCHES "-clang3[.][0-9]$" AND NOT EXISTS "${ANDROID_NDK_TOOLCHAINS_PATH}/${__toolchain}${__toolchain_subpath}" ) + SET( __toolchainVersionRegex "^TOOLCHAIN_VERSION[\t ]+:=[\t ]+(.*)$" ) + FILE( STRINGS "${ANDROID_NDK_TOOLCHAINS_PATH}/${__toolchain}/setup.mk" __toolchainVersionStr REGEX "${__toolchainVersionRegex}" ) + if( __toolchainVersionStr ) + string( REGEX REPLACE "${__toolchainVersionRegex}" "\\1" __toolchainVersionStr "${__toolchainVersionStr}" ) + string( REGEX REPLACE "-clang3[.][0-9]$" "-${__toolchainVersionStr}" __gcc_toolchain "${__toolchain}" ) + else() + string( REGEX REPLACE "-clang3[.][0-9]$" "-4.6" __gcc_toolchain "${__toolchain}" ) + endif() + unset( __toolchainVersionStr ) + unset( __toolchainVersionRegex ) + else() + set( __gcc_toolchain "${__toolchain}" ) + endif() + __DETECT_TOOLCHAIN_MACHINE_NAME( __machine "${ANDROID_NDK_TOOLCHAINS_PATH}/${__gcc_toolchain}${__toolchain_subpath}" ) + if( __machine ) + string( REGEX MATCH "[0-9]+[.][0-9]+([.][0-9x]+)?$" __version "${__gcc_toolchain}" ) + if( __machine MATCHES x86_64 ) + set( __arch "x86_64" ) + elseif( __machine MATCHES i686 ) + set( __arch "x86" ) + elseif( __machine MATCHES aarch64 ) + set( __arch "arm64" ) + elseif( __machine MATCHES arm ) + set( __arch "arm" ) + elseif( __machine MATCHES mips64el ) + set( __arch "mips64" ) + elseif( __machine MATCHES mipsel ) + set( __arch "mips" ) + else() + set( __arch "" ) + endif() + #message("machine: !${__machine}!\narch: !${__arch}!\nversion: !${__version}!\ntoolchain: !${__toolchain}!\n") + if (__arch) + list( APPEND __availableToolchainMachines "${__machine}" ) + list( APPEND __availableToolchainArchs "${__arch}" ) + list( APPEND __availableToolchainCompilerVersions "${__version}" ) + list( APPEND ${__availableToolchainsVar} "${__toolchain}" ) + endif() + endif() + unset( __gcc_toolchain ) + endforeach() +endmacro() + +# get all the details about NDK +if( BUILD_WITH_ANDROID_NDK ) + file( GLOB ANDROID_SUPPORTED_NATIVE_API_LEVELS RELATIVE "${ANDROID_NDK}/platforms" "${ANDROID_NDK}/platforms/android-*" ) + string( REPLACE "android-" "" ANDROID_SUPPORTED_NATIVE_API_LEVELS "${ANDROID_SUPPORTED_NATIVE_API_LEVELS}" ) + set( __availableToolchains "" ) + set( __availableToolchainMachines "" ) + set( __availableToolchainArchs "" ) + set( __availableToolchainCompilerVersions "" ) + if( ANDROID_TOOLCHAIN_NAME AND EXISTS "${ANDROID_NDK_TOOLCHAINS_PATH}/${ANDROID_TOOLCHAIN_NAME}/" ) + # do not go through all toolchains if we know the name + set( __availableToolchainsLst "${ANDROID_TOOLCHAIN_NAME}" ) + __GLOB_NDK_TOOLCHAINS( __availableToolchains __availableToolchainsLst "${ANDROID_NDK_TOOLCHAINS_SUBPATH}" ) + if( NOT __availableToolchains AND NOT ANDROID_NDK_TOOLCHAINS_SUBPATH STREQUAL ANDROID_NDK_TOOLCHAINS_SUBPATH2 ) + __GLOB_NDK_TOOLCHAINS( __availableToolchains __availableToolchainsLst "${ANDROID_NDK_TOOLCHAINS_SUBPATH2}" ) + if( __availableToolchains ) + set( ANDROID_NDK_TOOLCHAINS_SUBPATH ${ANDROID_NDK_TOOLCHAINS_SUBPATH2} ) + endif() + endif() + endif() + if( NOT __availableToolchains ) + file( GLOB __availableToolchainsLst RELATIVE "${ANDROID_NDK_TOOLCHAINS_PATH}" "${ANDROID_NDK_TOOLCHAINS_PATH}/*" ) + if( __availableToolchainsLst ) + list(SORT __availableToolchainsLst) # we need clang to go after gcc + endif() + __LIST_FILTER( __availableToolchainsLst "^[.]" ) + __LIST_FILTER( __availableToolchainsLst "llvm" ) + __LIST_FILTER( __availableToolchainsLst "renderscript" ) + __GLOB_NDK_TOOLCHAINS( __availableToolchains __availableToolchainsLst "${ANDROID_NDK_TOOLCHAINS_SUBPATH}" ) + if( NOT __availableToolchains AND NOT ANDROID_NDK_TOOLCHAINS_SUBPATH STREQUAL ANDROID_NDK_TOOLCHAINS_SUBPATH2 ) + __GLOB_NDK_TOOLCHAINS( __availableToolchains __availableToolchainsLst "${ANDROID_NDK_TOOLCHAINS_SUBPATH2}" ) + if( __availableToolchains ) + set( ANDROID_NDK_TOOLCHAINS_SUBPATH ${ANDROID_NDK_TOOLCHAINS_SUBPATH2} ) + endif() + endif() + endif() + if( NOT __availableToolchains ) + message( FATAL_ERROR "Could not find any working toolchain in the NDK. Probably your Android NDK is broken." ) + endif() +endif() + +# build list of available ABIs +set( ANDROID_SUPPORTED_ABIS "" ) +set( __uniqToolchainArchNames ${__availableToolchainArchs} ) +list( REMOVE_DUPLICATES __uniqToolchainArchNames ) +list( SORT __uniqToolchainArchNames ) +foreach( __arch ${__uniqToolchainArchNames} ) + list( APPEND ANDROID_SUPPORTED_ABIS ${ANDROID_SUPPORTED_ABIS_${__arch}} ) +endforeach() +unset( __uniqToolchainArchNames ) +if( NOT ANDROID_SUPPORTED_ABIS ) + message( FATAL_ERROR "No one of known Android ABIs is supported by this cmake toolchain." ) +endif() + +# choose target ABI +__INIT_VARIABLE( ANDROID_ABI VALUES ${ANDROID_SUPPORTED_ABIS} ) +# verify that target ABI is supported +list( FIND ANDROID_SUPPORTED_ABIS "${ANDROID_ABI}" __androidAbiIdx ) +if( __androidAbiIdx EQUAL -1 ) + string( REPLACE ";" "\", \"" PRINTABLE_ANDROID_SUPPORTED_ABIS "${ANDROID_SUPPORTED_ABIS}" ) + message( FATAL_ERROR "Specified ANDROID_ABI = \"${ANDROID_ABI}\" is not supported by this cmake toolchain or your NDK/toolchain. + Supported values are: \"${PRINTABLE_ANDROID_SUPPORTED_ABIS}\" + " ) +endif() +unset( __androidAbiIdx ) + +# set target ABI options +if( ANDROID_ABI STREQUAL "x86" ) + set( X86 true ) + set( ANDROID_NDK_ABI_NAME "x86" ) + set( ANDROID_ARCH_NAME "x86" ) + set( ANDROID_LLVM_TRIPLE "i686-none-linux-android" ) + set( CMAKE_SYSTEM_PROCESSOR "i686" ) +elseif( ANDROID_ABI STREQUAL "x86_64" ) + set( X86 true ) + set( X86_64 true ) + set( ANDROID_NDK_ABI_NAME "x86_64" ) + set( ANDROID_ARCH_NAME "x86_64" ) + set( CMAKE_SYSTEM_PROCESSOR "x86_64" ) + set( ANDROID_LLVM_TRIPLE "x86_64-none-linux-android" ) +elseif( ANDROID_ABI STREQUAL "mips64" ) + set( MIPS64 true ) + set( ANDROID_NDK_ABI_NAME "mips64" ) + set( ANDROID_ARCH_NAME "mips64" ) + set( ANDROID_LLVM_TRIPLE "mips64el-none-linux-android" ) + set( CMAKE_SYSTEM_PROCESSOR "mips64" ) +elseif( ANDROID_ABI STREQUAL "mips" ) + set( MIPS true ) + set( ANDROID_NDK_ABI_NAME "mips" ) + set( ANDROID_ARCH_NAME "mips" ) + set( ANDROID_LLVM_TRIPLE "mipsel-none-linux-android" ) + set( CMAKE_SYSTEM_PROCESSOR "mips" ) +elseif( ANDROID_ABI STREQUAL "arm64-v8a" ) + set( ARM64_V8A true ) + set( ANDROID_NDK_ABI_NAME "arm64-v8a" ) + set( ANDROID_ARCH_NAME "arm64" ) + set( ANDROID_LLVM_TRIPLE "aarch64-none-linux-android" ) + set( CMAKE_SYSTEM_PROCESSOR "aarch64" ) + set( VFPV3 true ) + set( NEON true ) +elseif( ANDROID_ABI STREQUAL "armeabi" ) + set( ARMEABI true ) + set( ANDROID_NDK_ABI_NAME "armeabi" ) + set( ANDROID_ARCH_NAME "arm" ) + set( ANDROID_LLVM_TRIPLE "armv5te-none-linux-androideabi" ) + set( CMAKE_SYSTEM_PROCESSOR "armv5te" ) +elseif( ANDROID_ABI STREQUAL "armeabi-v6 with VFP" ) + set( ARMEABI_V6 true ) + set( ANDROID_NDK_ABI_NAME "armeabi" ) + set( ANDROID_ARCH_NAME "arm" ) + set( ANDROID_LLVM_TRIPLE "armv5te-none-linux-androideabi" ) + set( CMAKE_SYSTEM_PROCESSOR "armv6" ) + # need always fallback to older platform + set( ARMEABI true ) +elseif( ANDROID_ABI STREQUAL "armeabi-v7a") + set( ARMEABI_V7A true ) + set( ANDROID_NDK_ABI_NAME "armeabi-v7a" ) + set( ANDROID_ARCH_NAME "arm" ) + set( ANDROID_LLVM_TRIPLE "armv7-none-linux-androideabi" ) + set( CMAKE_SYSTEM_PROCESSOR "armv7-a" ) +elseif( ANDROID_ABI STREQUAL "armeabi-v7a with VFPV3" ) + set( ARMEABI_V7A true ) + set( ANDROID_NDK_ABI_NAME "armeabi-v7a" ) + set( ANDROID_ARCH_NAME "arm" ) + set( ANDROID_LLVM_TRIPLE "armv7-none-linux-androideabi" ) + set( CMAKE_SYSTEM_PROCESSOR "armv7-a" ) + set( VFPV3 true ) +elseif( ANDROID_ABI STREQUAL "armeabi-v7a with NEON" ) + set( ARMEABI_V7A true ) + set( ANDROID_NDK_ABI_NAME "armeabi-v7a" ) + set( ANDROID_ARCH_NAME "arm" ) + set( ANDROID_LLVM_TRIPLE "armv7-none-linux-androideabi" ) + set( CMAKE_SYSTEM_PROCESSOR "armv7-a" ) + set( VFPV3 true ) + set( NEON true ) +else() + message( SEND_ERROR "Unknown ANDROID_ABI=\"${ANDROID_ABI}\" is specified." ) +endif() + +if( CMAKE_BINARY_DIR AND EXISTS "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeSystem.cmake" ) + # really dirty hack + # it is not possible to change CMAKE_SYSTEM_PROCESSOR after the first run... + file( APPEND "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeSystem.cmake" "SET(CMAKE_SYSTEM_PROCESSOR \"${CMAKE_SYSTEM_PROCESSOR}\")\n" ) +endif() + +if( ANDROID_ARCH_NAME STREQUAL "arm" AND NOT ARMEABI_V6 ) + __INIT_VARIABLE( ANDROID_FORCE_ARM_BUILD VALUES OFF ) + set( ANDROID_FORCE_ARM_BUILD ${ANDROID_FORCE_ARM_BUILD} CACHE BOOL "Use 32-bit ARM instructions instead of Thumb-1" FORCE ) + mark_as_advanced( ANDROID_FORCE_ARM_BUILD ) +else() + unset( ANDROID_FORCE_ARM_BUILD CACHE ) +endif() + +# choose toolchain +if( ANDROID_TOOLCHAIN_NAME ) + list( FIND __availableToolchains "${ANDROID_TOOLCHAIN_NAME}" __toolchainIdx ) + if( __toolchainIdx EQUAL -1 ) + list( SORT __availableToolchains ) + string( REPLACE ";" "\n * " toolchains_list "${__availableToolchains}" ) + set( toolchains_list " * ${toolchains_list}") + message( FATAL_ERROR "Specified toolchain \"${ANDROID_TOOLCHAIN_NAME}\" is missing in your NDK or broken. Please verify that your NDK is working or select another compiler toolchain. +To configure the toolchain set CMake variable ANDROID_TOOLCHAIN_NAME to one of the following values:\n${toolchains_list}\n" ) + endif() + list( GET __availableToolchainArchs ${__toolchainIdx} __toolchainArch ) + if( NOT __toolchainArch STREQUAL ANDROID_ARCH_NAME ) + message( SEND_ERROR "Selected toolchain \"${ANDROID_TOOLCHAIN_NAME}\" is not able to compile binaries for the \"${ANDROID_ARCH_NAME}\" platform." ) + endif() +else() + set( __toolchainIdx -1 ) + set( __applicableToolchains "" ) + set( __toolchainMaxVersion "0.0.0" ) + list( LENGTH __availableToolchains __availableToolchainsCount ) + math( EXPR __availableToolchainsCount "${__availableToolchainsCount}-1" ) + foreach( __idx RANGE ${__availableToolchainsCount} ) + list( GET __availableToolchainArchs ${__idx} __toolchainArch ) + if( __toolchainArch STREQUAL ANDROID_ARCH_NAME ) + list( GET __availableToolchainCompilerVersions ${__idx} __toolchainVersion ) + string( REPLACE "x" "99" __toolchainVersion "${__toolchainVersion}") + if( __toolchainVersion VERSION_GREATER __toolchainMaxVersion ) + set( __toolchainMaxVersion "${__toolchainVersion}" ) + set( __toolchainIdx ${__idx} ) + endif() + endif() + endforeach() + unset( __availableToolchainsCount ) + unset( __toolchainMaxVersion ) + unset( __toolchainVersion ) +endif() +unset( __toolchainArch ) +if( __toolchainIdx EQUAL -1 ) + message( FATAL_ERROR "No one of available compiler toolchains is able to compile for ${ANDROID_ARCH_NAME} platform." ) +endif() +list( GET __availableToolchains ${__toolchainIdx} ANDROID_TOOLCHAIN_NAME ) +list( GET __availableToolchainMachines ${__toolchainIdx} ANDROID_TOOLCHAIN_MACHINE_NAME ) +list( GET __availableToolchainCompilerVersions ${__toolchainIdx} ANDROID_COMPILER_VERSION ) + +unset( __toolchainIdx ) +unset( __availableToolchains ) +unset( __availableToolchainMachines ) +unset( __availableToolchainArchs ) +unset( __availableToolchainCompilerVersions ) + +# choose native API level +__INIT_VARIABLE( ANDROID_NATIVE_API_LEVEL ENV_ANDROID_NATIVE_API_LEVEL ANDROID_API_LEVEL ENV_ANDROID_API_LEVEL ANDROID_STANDALONE_TOOLCHAIN_API_LEVEL ANDROID_DEFAULT_NDK_API_LEVEL_${ANDROID_ARCH_NAME} ANDROID_DEFAULT_NDK_API_LEVEL ) +string( REPLACE "android-" "" ANDROID_NATIVE_API_LEVEL "${ANDROID_NATIVE_API_LEVEL}" ) +string( STRIP "${ANDROID_NATIVE_API_LEVEL}" ANDROID_NATIVE_API_LEVEL ) +# adjust API level +set( __real_api_level ${ANDROID_DEFAULT_NDK_API_LEVEL_${ANDROID_ARCH_NAME}} ) +foreach( __level ${ANDROID_SUPPORTED_NATIVE_API_LEVELS} ) + if( (__level LESS ANDROID_NATIVE_API_LEVEL OR __level STREQUAL ANDROID_NATIVE_API_LEVEL) AND NOT __level LESS __real_api_level ) + set( __real_api_level ${__level} ) + endif() +endforeach() +if( __real_api_level AND NOT ANDROID_NATIVE_API_LEVEL STREQUAL __real_api_level ) + message( STATUS "Adjusting Android API level 'android-${ANDROID_NATIVE_API_LEVEL}' to 'android-${__real_api_level}'") + set( ANDROID_NATIVE_API_LEVEL ${__real_api_level} ) +endif() +unset(__real_api_level) +# validate +list( FIND ANDROID_SUPPORTED_NATIVE_API_LEVELS "${ANDROID_NATIVE_API_LEVEL}" __levelIdx ) +if( __levelIdx EQUAL -1 ) + message( SEND_ERROR "Specified Android native API level 'android-${ANDROID_NATIVE_API_LEVEL}' is not supported by your NDK/toolchain." ) +else() + if( BUILD_WITH_ANDROID_NDK ) + __DETECT_NATIVE_API_LEVEL( __realApiLevel "${ANDROID_NDK}/platforms/android-${ANDROID_NATIVE_API_LEVEL}/arch-${ANDROID_ARCH_NAME}/usr/include/android/api-level.h" ) + if( NOT __realApiLevel EQUAL ANDROID_NATIVE_API_LEVEL AND NOT __realApiLevel GREATER 9000 ) + message( SEND_ERROR "Specified Android API level (${ANDROID_NATIVE_API_LEVEL}) does not match to the level found (${__realApiLevel}). Probably your copy of NDK is broken." ) + endif() + unset( __realApiLevel ) + endif() + set( ANDROID_NATIVE_API_LEVEL "${ANDROID_NATIVE_API_LEVEL}" CACHE STRING "Android API level for native code" FORCE ) + set( CMAKE_ANDROID_API ${ANDROID_NATIVE_API_LEVEL} ) + if( CMAKE_VERSION VERSION_GREATER "2.8" ) + list( SORT ANDROID_SUPPORTED_NATIVE_API_LEVELS ) + set_property( CACHE ANDROID_NATIVE_API_LEVEL PROPERTY STRINGS ${ANDROID_SUPPORTED_NATIVE_API_LEVELS} ) + endif() +endif() +unset( __levelIdx ) + + +# remember target ABI +set( ANDROID_ABI "${ANDROID_ABI}" CACHE STRING "The target ABI for Android. If arm, then armeabi-v7a is recommended for hardware floating point." FORCE ) +if( CMAKE_VERSION VERSION_GREATER "2.8" ) + list( SORT ANDROID_SUPPORTED_ABIS_${ANDROID_ARCH_NAME} ) + set_property( CACHE ANDROID_ABI PROPERTY STRINGS ${ANDROID_SUPPORTED_ABIS_${ANDROID_ARCH_NAME}} ) +endif() + + +# runtime choice (STL, rtti, exceptions) +if( NOT ANDROID_STL ) + set( ANDROID_STL gnustl_static ) +endif() +set( ANDROID_STL "${ANDROID_STL}" CACHE STRING "C++ runtime" ) +set( ANDROID_STL_FORCE_FEATURES ON CACHE BOOL "automatically configure rtti and exceptions support based on C++ runtime" ) +mark_as_advanced( ANDROID_STL ANDROID_STL_FORCE_FEATURES ) + +if( BUILD_WITH_ANDROID_NDK ) + if( NOT "${ANDROID_STL}" MATCHES "^(none|system|system_re|gabi\\+\\+_static|gabi\\+\\+_shared|stlport_static|stlport_shared|gnustl_static|gnustl_shared)$") + message( FATAL_ERROR "ANDROID_STL is set to invalid value \"${ANDROID_STL}\". +The possible values are: + none -> Do not configure the runtime. + system -> Use the default minimal system C++ runtime library. + system_re -> Same as system but with rtti and exceptions. + gabi++_static -> Use the GAbi++ runtime as a static library. + gabi++_shared -> Use the GAbi++ runtime as a shared library. + stlport_static -> Use the STLport runtime as a static library. + stlport_shared -> Use the STLport runtime as a shared library. + gnustl_static -> (default) Use the GNU STL as a static library. + gnustl_shared -> Use the GNU STL as a shared library. +" ) + endif() +elseif( BUILD_WITH_STANDALONE_TOOLCHAIN ) + if( NOT "${ANDROID_STL}" MATCHES "^(none|gnustl_static|gnustl_shared)$") + message( FATAL_ERROR "ANDROID_STL is set to invalid value \"${ANDROID_STL}\". +The possible values are: + none -> Do not configure the runtime. + gnustl_static -> (default) Use the GNU STL as a static library. + gnustl_shared -> Use the GNU STL as a shared library. +" ) + endif() +endif() + +unset( ANDROID_RTTI ) +unset( ANDROID_EXCEPTIONS ) +unset( ANDROID_STL_INCLUDE_DIRS ) +unset( __libstl ) +unset( __libsupcxx ) + +if( NOT _CMAKE_IN_TRY_COMPILE AND ANDROID_NDK_RELEASE STREQUAL "r7b" AND ARMEABI_V7A AND NOT VFPV3 AND ANDROID_STL MATCHES "gnustl" ) + message( WARNING "The GNU STL armeabi-v7a binaries from NDK r7b can crash non-NEON devices. The files provided with NDK r7b were not configured properly, resulting in crashes on Tegra2-based devices and others when trying to use certain floating-point functions (e.g., cosf, sinf, expf). +You are strongly recommended to switch to another NDK release. +" ) +endif() + +if( NOT _CMAKE_IN_TRY_COMPILE AND X86 AND ANDROID_STL MATCHES "gnustl" AND ANDROID_NDK_RELEASE STREQUAL "r6" ) + message( WARNING "The x86 system header file from NDK r6 has incorrect definition for ptrdiff_t. You are recommended to upgrade to a newer NDK release or manually patch the header: +See https://android.googlesource.com/platform/development.git f907f4f9d4e56ccc8093df6fee54454b8bcab6c2 + diff --git a/ndk/platforms/android-9/arch-x86/include/machine/_types.h b/ndk/platforms/android-9/arch-x86/include/machine/_types.h + index 5e28c64..65892a1 100644 + --- a/ndk/platforms/android-9/arch-x86/include/machine/_types.h + +++ b/ndk/platforms/android-9/arch-x86/include/machine/_types.h + @@ -51,7 +51,11 @@ typedef long int ssize_t; + #endif + #ifndef _PTRDIFF_T + #define _PTRDIFF_T + -typedef long ptrdiff_t; + +# ifdef __ANDROID__ + + typedef int ptrdiff_t; + +# else + + typedef long ptrdiff_t; + +# endif + #endif +" ) +endif() + + +# setup paths and STL for standalone toolchain +if( BUILD_WITH_STANDALONE_TOOLCHAIN ) + set( ANDROID_TOOLCHAIN_ROOT "${ANDROID_STANDALONE_TOOLCHAIN}" ) + set( ANDROID_CLANG_TOOLCHAIN_ROOT "${ANDROID_STANDALONE_TOOLCHAIN}" ) + set( ANDROID_SYSROOT "${ANDROID_STANDALONE_TOOLCHAIN}/sysroot" ) + + if( NOT ANDROID_STL STREQUAL "none" ) + set( ANDROID_STL_INCLUDE_DIRS "${ANDROID_STANDALONE_TOOLCHAIN}/include/c++/${ANDROID_COMPILER_VERSION}" ) + if( NOT EXISTS "${ANDROID_STL_INCLUDE_DIRS}" ) + # old location ( pre r8c ) + set( ANDROID_STL_INCLUDE_DIRS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/include/c++/${ANDROID_COMPILER_VERSION}" ) + endif() + if( ARMEABI_V7A AND EXISTS "${ANDROID_STL_INCLUDE_DIRS}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/${CMAKE_SYSTEM_PROCESSOR}/bits" ) + list( APPEND ANDROID_STL_INCLUDE_DIRS "${ANDROID_STL_INCLUDE_DIRS}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/${CMAKE_SYSTEM_PROCESSOR}" ) + elseif( ARMEABI AND NOT ANDROID_FORCE_ARM_BUILD AND EXISTS "${ANDROID_STL_INCLUDE_DIRS}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/thumb/bits" ) + list( APPEND ANDROID_STL_INCLUDE_DIRS "${ANDROID_STL_INCLUDE_DIRS}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/thumb" ) + else() + list( APPEND ANDROID_STL_INCLUDE_DIRS "${ANDROID_STL_INCLUDE_DIRS}/${ANDROID_TOOLCHAIN_MACHINE_NAME}" ) + endif() + # always search static GNU STL to get the location of libsupc++.a + if( ARMEABI_V7A AND NOT ANDROID_FORCE_ARM_BUILD AND EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/thumb/libstdc++.a" ) + set( __libstl "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/thumb" ) + elseif( ARMEABI_V7A AND EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/libstdc++.a" ) + set( __libstl "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}" ) + elseif( ARMEABI AND NOT ANDROID_FORCE_ARM_BUILD AND EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/thumb/libstdc++.a" ) + set( __libstl "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/thumb" ) + elseif( EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/libstdc++.a" ) + set( __libstl "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib" ) + endif() + if( __libstl ) + set( __libsupcxx "${__libstl}/libsupc++.a" ) + set( __libstl "${__libstl}/libstdc++.a" ) + endif() + if( NOT EXISTS "${__libsupcxx}" ) + message( FATAL_ERROR "The required libstdsupc++.a is missing in your standalone toolchain. + Usually it happens because of bug in make-standalone-toolchain.sh script from NDK r7, r7b and r7c. + You need to either upgrade to newer NDK or manually copy + $ANDROID_NDK/sources/cxx-stl/gnu-libstdc++/libs/${ANDROID_NDK_ABI_NAME}/libsupc++.a + to + ${__libsupcxx} + " ) + endif() + if( ANDROID_STL STREQUAL "gnustl_shared" ) + if( ARMEABI_V7A AND EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/libgnustl_shared.so" ) + set( __libstl "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/libgnustl_shared.so" ) + elseif( ARMEABI AND NOT ANDROID_FORCE_ARM_BUILD AND EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/thumb/libgnustl_shared.so" ) + set( __libstl "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/thumb/libgnustl_shared.so" ) + elseif( EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/libgnustl_shared.so" ) + set( __libstl "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/libgnustl_shared.so" ) + endif() + endif() + endif() +endif() + +# clang +if( "${ANDROID_TOOLCHAIN_NAME}" STREQUAL "standalone-clang" ) + set( ANDROID_COMPILER_IS_CLANG 1 ) + execute_process( COMMAND "${ANDROID_CLANG_TOOLCHAIN_ROOT}/bin/clang${TOOL_OS_SUFFIX}" --version OUTPUT_VARIABLE ANDROID_CLANG_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE ) + string( REGEX MATCH "[0-9]+[.][0-9]+" ANDROID_CLANG_VERSION "${ANDROID_CLANG_VERSION}") +elseif( "${ANDROID_TOOLCHAIN_NAME}" MATCHES "-clang3[.][0-9]?$" ) + string( REGEX MATCH "3[.][0-9]$" ANDROID_CLANG_VERSION "${ANDROID_TOOLCHAIN_NAME}") + string( REGEX REPLACE "-clang${ANDROID_CLANG_VERSION}$" "-${ANDROID_COMPILER_VERSION}" ANDROID_GCC_TOOLCHAIN_NAME "${ANDROID_TOOLCHAIN_NAME}" ) + if( NOT EXISTS "${ANDROID_NDK_TOOLCHAINS_PATH}/llvm-${ANDROID_CLANG_VERSION}${ANDROID_NDK_TOOLCHAINS_SUBPATH}/bin/clang${TOOL_OS_SUFFIX}" ) + message( FATAL_ERROR "Could not find the Clang compiler driver" ) + endif() + set( ANDROID_COMPILER_IS_CLANG 1 ) + set( ANDROID_CLANG_TOOLCHAIN_ROOT "${ANDROID_NDK_TOOLCHAINS_PATH}/llvm-${ANDROID_CLANG_VERSION}${ANDROID_NDK_TOOLCHAINS_SUBPATH}" ) +else() + set( ANDROID_GCC_TOOLCHAIN_NAME "${ANDROID_TOOLCHAIN_NAME}" ) + unset( ANDROID_COMPILER_IS_CLANG CACHE ) +endif() + +string( REPLACE "." "" _clang_name "clang${ANDROID_CLANG_VERSION}" ) +if( NOT EXISTS "${ANDROID_CLANG_TOOLCHAIN_ROOT}/bin/${_clang_name}${TOOL_OS_SUFFIX}" ) + set( _clang_name "clang" ) +endif() + + +# setup paths and STL for NDK +if( BUILD_WITH_ANDROID_NDK ) + set( ANDROID_TOOLCHAIN_ROOT "${ANDROID_NDK_TOOLCHAINS_PATH}/${ANDROID_GCC_TOOLCHAIN_NAME}${ANDROID_NDK_TOOLCHAINS_SUBPATH}" ) + set( ANDROID_SYSROOT "${ANDROID_NDK}/platforms/android-${ANDROID_NATIVE_API_LEVEL}/arch-${ANDROID_ARCH_NAME}" ) + + if( ANDROID_STL STREQUAL "none" ) + # do nothing + elseif( ANDROID_STL STREQUAL "system" ) + set( ANDROID_RTTI OFF ) + set( ANDROID_EXCEPTIONS OFF ) + set( ANDROID_STL_INCLUDE_DIRS "${ANDROID_NDK}/sources/cxx-stl/system/include" ) + elseif( ANDROID_STL STREQUAL "system_re" ) + set( ANDROID_RTTI ON ) + set( ANDROID_EXCEPTIONS ON ) + set( ANDROID_STL_INCLUDE_DIRS "${ANDROID_NDK}/sources/cxx-stl/system/include" ) + elseif( ANDROID_STL MATCHES "gabi" ) + if( ANDROID_NDK_RELEASE_NUM LESS 7000 ) # before r7 + message( FATAL_ERROR "gabi++ is not available in your NDK. You have to upgrade to NDK r7 or newer to use gabi++.") + endif() + set( ANDROID_RTTI ON ) + set( ANDROID_EXCEPTIONS OFF ) + set( ANDROID_STL_INCLUDE_DIRS "${ANDROID_NDK}/sources/cxx-stl/gabi++/include" ) + set( __libstl "${ANDROID_NDK}/sources/cxx-stl/gabi++/libs/${ANDROID_NDK_ABI_NAME}/libgabi++_static.a" ) + elseif( ANDROID_STL MATCHES "stlport" ) + if( NOT ANDROID_NDK_RELEASE_NUM LESS 8004 ) # before r8d + set( ANDROID_EXCEPTIONS ON ) + else() + set( ANDROID_EXCEPTIONS OFF ) + endif() + if( ANDROID_NDK_RELEASE_NUM LESS 7000 ) # before r7 + set( ANDROID_RTTI OFF ) + else() + set( ANDROID_RTTI ON ) + endif() + set( ANDROID_STL_INCLUDE_DIRS "${ANDROID_NDK}/sources/cxx-stl/stlport/stlport" ) + set( __libstl "${ANDROID_NDK}/sources/cxx-stl/stlport/libs/${ANDROID_NDK_ABI_NAME}/libstlport_static.a" ) + elseif( ANDROID_STL MATCHES "gnustl" ) + set( ANDROID_EXCEPTIONS ON ) + set( ANDROID_RTTI ON ) + if( EXISTS "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${ANDROID_COMPILER_VERSION}" ) + if( ARMEABI_V7A AND ANDROID_COMPILER_VERSION VERSION_EQUAL "4.7" AND ANDROID_NDK_RELEASE STREQUAL "r8d" ) + # gnustl binary for 4.7 compiler is buggy :( + # TODO: look for right fix + set( __libstl "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/4.6" ) + else() + set( __libstl "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${ANDROID_COMPILER_VERSION}" ) + endif() + else() + set( __libstl "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++" ) + endif() + set( ANDROID_STL_INCLUDE_DIRS "${__libstl}/include" "${__libstl}/libs/${ANDROID_NDK_ABI_NAME}/include" "${__libstl}/include/backward" ) + if( EXISTS "${__libstl}/libs/${ANDROID_NDK_ABI_NAME}/libgnustl_static.a" ) + set( __libstl "${__libstl}/libs/${ANDROID_NDK_ABI_NAME}/libgnustl_static.a" ) + else() + set( __libstl "${__libstl}/libs/${ANDROID_NDK_ABI_NAME}/libstdc++.a" ) + endif() + else() + message( FATAL_ERROR "Unknown runtime: ${ANDROID_STL}" ) + endif() + # find libsupc++.a - rtti & exceptions + if( ANDROID_STL STREQUAL "system_re" OR ANDROID_STL MATCHES "gnustl" ) + set( __libsupcxx "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${ANDROID_COMPILER_VERSION}/libs/${ANDROID_NDK_ABI_NAME}/libsupc++.a" ) # r8b or newer + if( NOT EXISTS "${__libsupcxx}" ) + set( __libsupcxx "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/libs/${ANDROID_NDK_ABI_NAME}/libsupc++.a" ) # r7-r8 + endif() + if( NOT EXISTS "${__libsupcxx}" ) # before r7 + if( ARMEABI_V7A ) + if( ANDROID_FORCE_ARM_BUILD ) + set( __libsupcxx "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/libsupc++.a" ) + else() + set( __libsupcxx "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/thumb/libsupc++.a" ) + endif() + elseif( ARMEABI AND NOT ANDROID_FORCE_ARM_BUILD ) + set( __libsupcxx "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/thumb/libsupc++.a" ) + else() + set( __libsupcxx "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/libsupc++.a" ) + endif() + endif() + if( NOT EXISTS "${__libsupcxx}") + message( ERROR "Could not find libsupc++.a for a chosen platform. Either your NDK is not supported or is broken.") + endif() + endif() +endif() + + +# case of shared STL linkage +if( ANDROID_STL MATCHES "shared" AND DEFINED __libstl ) + string( REPLACE "_static.a" "_shared.so" __libstl "${__libstl}" ) + # TODO: check if .so file exists before the renaming +endif() + + +# ccache support +__INIT_VARIABLE( _ndk_ccache NDK_CCACHE ENV_NDK_CCACHE ) +if( _ndk_ccache ) + if( DEFINED NDK_CCACHE AND NOT EXISTS NDK_CCACHE ) + unset( NDK_CCACHE CACHE ) + endif() + find_program( NDK_CCACHE "${_ndk_ccache}" DOC "The path to ccache binary") +else() + unset( NDK_CCACHE CACHE ) +endif() +unset( _ndk_ccache ) + + +# setup the cross-compiler +if( NOT CMAKE_C_COMPILER ) + if( NDK_CCACHE AND NOT ANDROID_SYSROOT MATCHES "[ ;\"]" ) + set( CMAKE_C_COMPILER "${NDK_CCACHE}" CACHE PATH "ccache as C compiler" ) + set( CMAKE_CXX_COMPILER "${NDK_CCACHE}" CACHE PATH "ccache as C++ compiler" ) + if( ANDROID_COMPILER_IS_CLANG ) + set( CMAKE_C_COMPILER_ARG1 "${ANDROID_CLANG_TOOLCHAIN_ROOT}/bin/${_clang_name}${TOOL_OS_SUFFIX}" CACHE PATH "C compiler") + set( CMAKE_CXX_COMPILER_ARG1 "${ANDROID_CLANG_TOOLCHAIN_ROOT}/bin/${_clang_name}++${TOOL_OS_SUFFIX}" CACHE PATH "C++ compiler") + else() + set( CMAKE_C_COMPILER_ARG1 "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-gcc${TOOL_OS_SUFFIX}" CACHE PATH "C compiler") + set( CMAKE_CXX_COMPILER_ARG1 "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-g++${TOOL_OS_SUFFIX}" CACHE PATH "C++ compiler") + endif() + else() + if( ANDROID_COMPILER_IS_CLANG ) + set( CMAKE_C_COMPILER "${ANDROID_CLANG_TOOLCHAIN_ROOT}/bin/${_clang_name}${TOOL_OS_SUFFIX}" CACHE PATH "C compiler") + set( CMAKE_CXX_COMPILER "${ANDROID_CLANG_TOOLCHAIN_ROOT}/bin/${_clang_name}++${TOOL_OS_SUFFIX}" CACHE PATH "C++ compiler") + else() + set( CMAKE_C_COMPILER "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-gcc${TOOL_OS_SUFFIX}" CACHE PATH "C compiler" ) + set( CMAKE_CXX_COMPILER "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-g++${TOOL_OS_SUFFIX}" CACHE PATH "C++ compiler" ) + endif() + endif() + set( CMAKE_ASM_COMPILER "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-gcc${TOOL_OS_SUFFIX}" CACHE PATH "assembler" ) + set( CMAKE_STRIP "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-strip${TOOL_OS_SUFFIX}" CACHE PATH "strip" ) + if( EXISTS "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-gcc-ar${TOOL_OS_SUFFIX}" ) + # Use gcc-ar if we have it for better LTO support. + set( CMAKE_AR "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-gcc-ar${TOOL_OS_SUFFIX}" CACHE PATH "archive" ) + else() + set( CMAKE_AR "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-ar${TOOL_OS_SUFFIX}" CACHE PATH "archive" ) + endif() + set( CMAKE_LINKER "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-ld${TOOL_OS_SUFFIX}" CACHE PATH "linker" ) + set( CMAKE_NM "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-nm${TOOL_OS_SUFFIX}" CACHE PATH "nm" ) + set( CMAKE_OBJCOPY "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-objcopy${TOOL_OS_SUFFIX}" CACHE PATH "objcopy" ) + set( CMAKE_OBJDUMP "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-objdump${TOOL_OS_SUFFIX}" CACHE PATH "objdump" ) + set( CMAKE_RANLIB "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-ranlib${TOOL_OS_SUFFIX}" CACHE PATH "ranlib" ) +endif() + +set( _CMAKE_TOOLCHAIN_PREFIX "${ANDROID_TOOLCHAIN_MACHINE_NAME}-" ) +if( CMAKE_VERSION VERSION_LESS 2.8.5 ) + set( CMAKE_ASM_COMPILER_ARG1 "-c" ) +endif() +if( APPLE ) + find_program( CMAKE_INSTALL_NAME_TOOL NAMES install_name_tool ) + if( NOT CMAKE_INSTALL_NAME_TOOL ) + message( FATAL_ERROR "Could not find install_name_tool, please check your installation." ) + endif() + mark_as_advanced( CMAKE_INSTALL_NAME_TOOL ) +endif() + +# Force set compilers because standard identification works badly for us +include( CMakeForceCompiler ) +CMAKE_FORCE_C_COMPILER( "${CMAKE_C_COMPILER}" GNU ) +if( ANDROID_COMPILER_IS_CLANG ) + set( CMAKE_C_COMPILER_ID Clang ) +endif() +set( CMAKE_C_PLATFORM_ID Linux ) +if( X86_64 OR MIPS64 OR ARM64_V8A ) + set( CMAKE_C_SIZEOF_DATA_PTR 8 ) +else() + set( CMAKE_C_SIZEOF_DATA_PTR 4 ) +endif() +set( CMAKE_C_HAS_ISYSROOT 1 ) +set( CMAKE_C_COMPILER_ABI ELF ) +CMAKE_FORCE_CXX_COMPILER( "${CMAKE_CXX_COMPILER}" GNU ) +if( ANDROID_COMPILER_IS_CLANG ) + set( CMAKE_CXX_COMPILER_ID Clang) +endif() +set( CMAKE_CXX_PLATFORM_ID Linux ) +set( CMAKE_CXX_SIZEOF_DATA_PTR ${CMAKE_C_SIZEOF_DATA_PTR} ) +set( CMAKE_CXX_HAS_ISYSROOT 1 ) +set( CMAKE_CXX_COMPILER_ABI ELF ) +set( CMAKE_CXX_SOURCE_FILE_EXTENSIONS cc cp cxx cpp CPP c++ C ) +# force ASM compiler (required for CMake < 2.8.5) +set( CMAKE_ASM_COMPILER_ID_RUN TRUE ) +set( CMAKE_ASM_COMPILER_ID GNU ) +set( CMAKE_ASM_COMPILER_WORKS TRUE ) +set( CMAKE_ASM_COMPILER_FORCED TRUE ) +set( CMAKE_COMPILER_IS_GNUASM 1) +set( CMAKE_ASM_SOURCE_FILE_EXTENSIONS s S asm ) + +foreach( lang C CXX ASM ) + if( ANDROID_COMPILER_IS_CLANG ) + set( CMAKE_${lang}_COMPILER_VERSION ${ANDROID_CLANG_VERSION} ) + else() + set( CMAKE_${lang}_COMPILER_VERSION ${ANDROID_COMPILER_VERSION} ) + endif() +endforeach() + +# flags and definitions +remove_definitions( -DANDROID ) +add_definitions( -DANDROID ) + +if( ANDROID_SYSROOT MATCHES "[ ;\"]" ) + if( CMAKE_HOST_WIN32 ) + # try to convert path to 8.3 form + file( WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/cvt83.cmd" "@echo %~s1" ) + execute_process( COMMAND "$ENV{ComSpec}" /c "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/cvt83.cmd" "${ANDROID_SYSROOT}" + OUTPUT_VARIABLE __path OUTPUT_STRIP_TRAILING_WHITESPACE + RESULT_VARIABLE __result ERROR_QUIET ) + if( __result EQUAL 0 ) + file( TO_CMAKE_PATH "${__path}" ANDROID_SYSROOT ) + set( ANDROID_CXX_FLAGS "--sysroot=${ANDROID_SYSROOT}" ) + else() + set( ANDROID_CXX_FLAGS "--sysroot=\"${ANDROID_SYSROOT}\"" ) + endif() + else() + set( ANDROID_CXX_FLAGS "'--sysroot=${ANDROID_SYSROOT}'" ) + endif() + if( NOT _CMAKE_IN_TRY_COMPILE ) + # quotes can break try_compile and compiler identification + message(WARNING "Path to your Android NDK (or toolchain) has non-alphanumeric symbols.\nThe build might be broken.\n") + endif() +else() + set( ANDROID_CXX_FLAGS "--sysroot=${ANDROID_SYSROOT}" ) +endif() + +# NDK flags +if (ARM64_V8A ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -funwind-tables" ) + set( ANDROID_CXX_FLAGS_RELEASE "-fomit-frame-pointer -fstrict-aliasing" ) + set( ANDROID_CXX_FLAGS_DEBUG "-fno-omit-frame-pointer -fno-strict-aliasing" ) + if( NOT ANDROID_COMPILER_IS_CLANG ) + set( ANDROID_CXX_FLAGS_RELEASE "${ANDROID_CXX_FLAGS_RELEASE} -funswitch-loops -finline-limit=300" ) + endif() +elseif( ARMEABI OR ARMEABI_V7A) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -funwind-tables" ) + if( NOT ANDROID_FORCE_ARM_BUILD AND NOT ARMEABI_V6 ) + set( ANDROID_CXX_FLAGS_RELEASE "-mthumb -fomit-frame-pointer -fno-strict-aliasing" ) + set( ANDROID_CXX_FLAGS_DEBUG "-marm -fno-omit-frame-pointer -fno-strict-aliasing" ) + if( NOT ANDROID_COMPILER_IS_CLANG ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -finline-limit=64" ) + endif() + else() + # always compile ARMEABI_V6 in arm mode; otherwise there is no difference from ARMEABI + set( ANDROID_CXX_FLAGS_RELEASE "-marm -fomit-frame-pointer -fstrict-aliasing" ) + set( ANDROID_CXX_FLAGS_DEBUG "-marm -fno-omit-frame-pointer -fno-strict-aliasing" ) + if( NOT ANDROID_COMPILER_IS_CLANG ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -funswitch-loops -finline-limit=300" ) + endif() + endif() +elseif( X86 OR X86_64 ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -funwind-tables" ) + if( NOT ANDROID_COMPILER_IS_CLANG ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -funswitch-loops -finline-limit=300" ) + endif() + set( ANDROID_CXX_FLAGS_RELEASE "-fomit-frame-pointer -fstrict-aliasing" ) + set( ANDROID_CXX_FLAGS_DEBUG "-fno-omit-frame-pointer -fno-strict-aliasing" ) +elseif( MIPS OR MIPS64 ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fno-strict-aliasing -finline-functions -funwind-tables -fmessage-length=0" ) + set( ANDROID_CXX_FLAGS_RELEASE "-fomit-frame-pointer" ) + set( ANDROID_CXX_FLAGS_DEBUG "-fno-omit-frame-pointer" ) + if( NOT ANDROID_COMPILER_IS_CLANG ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fno-inline-functions-called-once -fgcse-after-reload -frerun-cse-after-loop -frename-registers" ) + set( ANDROID_CXX_FLAGS_RELEASE "${ANDROID_CXX_FLAGS_RELEASE} -funswitch-loops -finline-limit=300" ) + endif() +elseif() + set( ANDROID_CXX_FLAGS_RELEASE "" ) + set( ANDROID_CXX_FLAGS_DEBUG "" ) +endif() + +set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fsigned-char" ) # good/necessary when porting desktop libraries + +if( NOT X86 AND NOT ANDROID_COMPILER_IS_CLANG ) + set( ANDROID_CXX_FLAGS "-Wno-psabi ${ANDROID_CXX_FLAGS}" ) +endif() + +if( NOT ANDROID_COMPILER_VERSION VERSION_LESS "4.6" ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -no-canonical-prefixes" ) # see https://android-review.googlesource.com/#/c/47564/ +endif() + +# ABI-specific flags +if( ARMEABI_V7A ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -march=armv7-a -mfloat-abi=softfp" ) + if( NEON ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -mfpu=neon" ) + elseif( VFPV3 ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -mfpu=vfpv3" ) + else() + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -mfpu=vfpv3-d16" ) + endif() +elseif( ARMEABI_V6 ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -march=armv6 -mfloat-abi=softfp -mfpu=vfp" ) # vfp == vfpv2 +elseif( ARMEABI ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -march=armv5te -mtune=xscale -msoft-float" ) +endif() + +if( ANDROID_STL MATCHES "gnustl" AND (EXISTS "${__libstl}" OR EXISTS "${__libsupcxx}") ) + set( CMAKE_CXX_CREATE_SHARED_LIBRARY "<CMAKE_CXX_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" ) + set( CMAKE_CXX_CREATE_SHARED_MODULE "<CMAKE_CXX_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" ) + set( CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_CXX_COMPILER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>" ) +else() + set( CMAKE_CXX_CREATE_SHARED_LIBRARY "<CMAKE_CXX_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" ) + set( CMAKE_CXX_CREATE_SHARED_MODULE "<CMAKE_CXX_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" ) + set( CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_CXX_COMPILER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>" ) +endif() + +# STL +if( EXISTS "${__libstl}" OR EXISTS "${__libsupcxx}" ) + if( EXISTS "${__libstl}" ) + set( CMAKE_CXX_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY} \"${__libstl}\"" ) + set( CMAKE_CXX_CREATE_SHARED_MODULE "${CMAKE_CXX_CREATE_SHARED_MODULE} \"${__libstl}\"" ) + set( CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} \"${__libstl}\"" ) + endif() + if( EXISTS "${__libsupcxx}" ) + set( CMAKE_CXX_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY} \"${__libsupcxx}\"" ) + set( CMAKE_CXX_CREATE_SHARED_MODULE "${CMAKE_CXX_CREATE_SHARED_MODULE} \"${__libsupcxx}\"" ) + set( CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} \"${__libsupcxx}\"" ) + # C objects: + set( CMAKE_C_CREATE_SHARED_LIBRARY "<CMAKE_C_COMPILER> <CMAKE_SHARED_LIBRARY_C_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_C_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" ) + set( CMAKE_C_CREATE_SHARED_MODULE "<CMAKE_C_COMPILER> <CMAKE_SHARED_LIBRARY_C_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_C_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" ) + set( CMAKE_C_LINK_EXECUTABLE "<CMAKE_C_COMPILER> <FLAGS> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>" ) + set( CMAKE_C_CREATE_SHARED_LIBRARY "${CMAKE_C_CREATE_SHARED_LIBRARY} \"${__libsupcxx}\"" ) + set( CMAKE_C_CREATE_SHARED_MODULE "${CMAKE_C_CREATE_SHARED_MODULE} \"${__libsupcxx}\"" ) + set( CMAKE_C_LINK_EXECUTABLE "${CMAKE_C_LINK_EXECUTABLE} \"${__libsupcxx}\"" ) + endif() + if( ANDROID_STL MATCHES "gnustl" ) + if( NOT EXISTS "${ANDROID_LIBM_PATH}" ) + set( ANDROID_LIBM_PATH -lm ) + endif() + set( CMAKE_CXX_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY} ${ANDROID_LIBM_PATH}" ) + set( CMAKE_CXX_CREATE_SHARED_MODULE "${CMAKE_CXX_CREATE_SHARED_MODULE} ${ANDROID_LIBM_PATH}" ) + set( CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} ${ANDROID_LIBM_PATH}" ) + endif() +endif() + +# variables controlling optional build flags +if( ANDROID_NDK_RELEASE_NUM LESS 7000 ) # before r7 + # libGLESv2.so in NDK's prior to r7 refers to missing external symbols. + # So this flag option is required for all projects using OpenGL from native. + __INIT_VARIABLE( ANDROID_SO_UNDEFINED VALUES ON ) +else() + __INIT_VARIABLE( ANDROID_SO_UNDEFINED VALUES OFF ) +endif() +__INIT_VARIABLE( ANDROID_NO_UNDEFINED VALUES ON ) +__INIT_VARIABLE( ANDROID_FUNCTION_LEVEL_LINKING VALUES ON ) +__INIT_VARIABLE( ANDROID_GOLD_LINKER VALUES ON ) +__INIT_VARIABLE( ANDROID_NOEXECSTACK VALUES ON ) +__INIT_VARIABLE( ANDROID_RELRO VALUES ON ) + +set( ANDROID_NO_UNDEFINED ${ANDROID_NO_UNDEFINED} CACHE BOOL "Show all undefined symbols as linker errors" ) +set( ANDROID_SO_UNDEFINED ${ANDROID_SO_UNDEFINED} CACHE BOOL "Allows or disallows undefined symbols in shared libraries" ) +set( ANDROID_FUNCTION_LEVEL_LINKING ${ANDROID_FUNCTION_LEVEL_LINKING} CACHE BOOL "Put each function in separate section and enable garbage collection of unused input sections at link time" ) +set( ANDROID_GOLD_LINKER ${ANDROID_GOLD_LINKER} CACHE BOOL "Enables gold linker" ) +set( ANDROID_NOEXECSTACK ${ANDROID_NOEXECSTACK} CACHE BOOL "Allows or disallows undefined symbols in shared libraries" ) +set( ANDROID_RELRO ${ANDROID_RELRO} CACHE BOOL "Enables RELRO - a memory corruption mitigation technique" ) +mark_as_advanced( ANDROID_NO_UNDEFINED ANDROID_SO_UNDEFINED ANDROID_FUNCTION_LEVEL_LINKING ANDROID_GOLD_LINKER ANDROID_NOEXECSTACK ANDROID_RELRO ) + +# linker flags +set( ANDROID_LINKER_FLAGS "" ) + +if( ARMEABI_V7A ) + # this is *required* to use the following linker flags that routes around + # a CPU bug in some Cortex-A8 implementations: + set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,--fix-cortex-a8" ) +endif() + +if( ANDROID_NO_UNDEFINED ) + if( MIPS ) + # there is some sysroot-related problem in mips linker... + if( NOT ANDROID_SYSROOT MATCHES "[ ;\"]" ) + set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,--no-undefined -Wl,-rpath-link,${ANDROID_SYSROOT}/usr/lib" ) + endif() + else() + set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,--no-undefined" ) + endif() +endif() + +if( ANDROID_SO_UNDEFINED ) + set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,-allow-shlib-undefined" ) +endif() + +if( ANDROID_FUNCTION_LEVEL_LINKING ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fdata-sections -ffunction-sections" ) + set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,--gc-sections" ) +endif() + +if( ANDROID_COMPILER_VERSION VERSION_EQUAL "4.6" ) + if( ANDROID_GOLD_LINKER AND (CMAKE_HOST_UNIX OR ANDROID_NDK_RELEASE_NUM GREATER 8002) AND (ARMEABI OR ARMEABI_V7A OR X86) ) + set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -fuse-ld=gold" ) + elseif( ANDROID_NDK_RELEASE_NUM GREATER 8002 ) # after r8b + set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -fuse-ld=bfd" ) + elseif( ANDROID_NDK_RELEASE STREQUAL "r8b" AND ARMEABI AND NOT _CMAKE_IN_TRY_COMPILE ) + message( WARNING "The default bfd linker from arm GCC 4.6 toolchain can fail with 'unresolvable R_ARM_THM_CALL relocation' error message. See https://code.google.com/p/android/issues/detail?id=35342 + On Linux and OS X host platform you can workaround this problem using gold linker (default). + Rerun cmake with -DANDROID_GOLD_LINKER=ON option in case of problems. +" ) + endif() +endif() # version 4.6 + +if( ANDROID_NOEXECSTACK ) + if( ANDROID_COMPILER_IS_CLANG ) + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -Xclang -mnoexecstack" ) + else() + set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -Wa,--noexecstack" ) + endif() + set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,-z,noexecstack" ) +endif() + +if( ANDROID_RELRO ) + set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,-z,relro -Wl,-z,now" ) +endif() + +if( ANDROID_COMPILER_IS_CLANG ) + set( ANDROID_CXX_FLAGS "-target ${ANDROID_LLVM_TRIPLE} -Qunused-arguments ${ANDROID_CXX_FLAGS}" ) + if( BUILD_WITH_ANDROID_NDK ) + set( ANDROID_CXX_FLAGS "-gcc-toolchain ${ANDROID_TOOLCHAIN_ROOT} ${ANDROID_CXX_FLAGS}" ) + endif() +endif() + +# cache flags +set( CMAKE_CXX_FLAGS "" CACHE STRING "c++ flags" ) +set( CMAKE_C_FLAGS "" CACHE STRING "c flags" ) +set( CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING "c++ Release flags" ) +set( CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING "c Release flags" ) +set( CMAKE_CXX_FLAGS_DEBUG "-O0 -g -DDEBUG -D_DEBUG" CACHE STRING "c++ Debug flags" ) +set( CMAKE_C_FLAGS_DEBUG "-O0 -g -DDEBUG -D_DEBUG" CACHE STRING "c Debug flags" ) +set( CMAKE_SHARED_LINKER_FLAGS "" CACHE STRING "shared linker flags" ) +set( CMAKE_MODULE_LINKER_FLAGS "" CACHE STRING "module linker flags" ) +set( CMAKE_EXE_LINKER_FLAGS "-Wl,-z,nocopyreloc" CACHE STRING "executable linker flags" ) + +# put flags to cache (for debug purpose only) +set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS}" CACHE INTERNAL "Android specific c/c++ flags" ) +set( ANDROID_CXX_FLAGS_RELEASE "${ANDROID_CXX_FLAGS_RELEASE}" CACHE INTERNAL "Android specific c/c++ Release flags" ) +set( ANDROID_CXX_FLAGS_DEBUG "${ANDROID_CXX_FLAGS_DEBUG}" CACHE INTERNAL "Android specific c/c++ Debug flags" ) +set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS}" CACHE INTERNAL "Android specific c/c++ linker flags" ) + +# finish flags +set( CMAKE_CXX_FLAGS "${ANDROID_CXX_FLAGS} ${CMAKE_CXX_FLAGS}" ) +set( CMAKE_C_FLAGS "${ANDROID_CXX_FLAGS} ${CMAKE_C_FLAGS}" ) +set( CMAKE_CXX_FLAGS_RELEASE "${ANDROID_CXX_FLAGS_RELEASE} ${CMAKE_CXX_FLAGS_RELEASE}" ) +set( CMAKE_C_FLAGS_RELEASE "${ANDROID_CXX_FLAGS_RELEASE} ${CMAKE_C_FLAGS_RELEASE}" ) +set( CMAKE_CXX_FLAGS_DEBUG "${ANDROID_CXX_FLAGS_DEBUG} ${CMAKE_CXX_FLAGS_DEBUG}" ) +set( CMAKE_C_FLAGS_DEBUG "${ANDROID_CXX_FLAGS_DEBUG} ${CMAKE_C_FLAGS_DEBUG}" ) +set( CMAKE_SHARED_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS}" ) +set( CMAKE_MODULE_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} ${CMAKE_MODULE_LINKER_FLAGS}" ) +set( CMAKE_EXE_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}" ) + +if( MIPS AND BUILD_WITH_ANDROID_NDK AND ANDROID_NDK_RELEASE STREQUAL "r8" ) + set( CMAKE_SHARED_LINKER_FLAGS "-Wl,-T,${ANDROID_NDK_TOOLCHAINS_PATH}/${ANDROID_GCC_TOOLCHAIN_NAME}/mipself.xsc ${CMAKE_SHARED_LINKER_FLAGS}" ) + set( CMAKE_MODULE_LINKER_FLAGS "-Wl,-T,${ANDROID_NDK_TOOLCHAINS_PATH}/${ANDROID_GCC_TOOLCHAIN_NAME}/mipself.xsc ${CMAKE_MODULE_LINKER_FLAGS}" ) + set( CMAKE_EXE_LINKER_FLAGS "-Wl,-T,${ANDROID_NDK_TOOLCHAINS_PATH}/${ANDROID_GCC_TOOLCHAIN_NAME}/mipself.x ${CMAKE_EXE_LINKER_FLAGS}" ) +endif() + +# pie/pic +if( NOT (ANDROID_NATIVE_API_LEVEL LESS 16) AND (NOT DEFINED ANDROID_APP_PIE OR ANDROID_APP_PIE) AND (CMAKE_VERSION VERSION_GREATER 2.8.8) ) + set( CMAKE_POSITION_INDEPENDENT_CODE TRUE ) + set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fPIE -pie") +else() + set( CMAKE_POSITION_INDEPENDENT_CODE FALSE ) + set( CMAKE_CXX_FLAGS "-fpic ${CMAKE_CXX_FLAGS}" ) + set( CMAKE_C_FLAGS "-fpic ${CMAKE_C_FLAGS}" ) +endif() + +# configure rtti +if( DEFINED ANDROID_RTTI AND ANDROID_STL_FORCE_FEATURES ) + if( ANDROID_RTTI ) + set( CMAKE_CXX_FLAGS "-frtti ${CMAKE_CXX_FLAGS}" ) + else() + set( CMAKE_CXX_FLAGS "-fno-rtti ${CMAKE_CXX_FLAGS}" ) + endif() +endif() + +# configure exceptios +if( DEFINED ANDROID_EXCEPTIONS AND ANDROID_STL_FORCE_FEATURES ) + if( ANDROID_EXCEPTIONS ) + set( CMAKE_CXX_FLAGS "-fexceptions ${CMAKE_CXX_FLAGS}" ) + set( CMAKE_C_FLAGS "-fexceptions ${CMAKE_C_FLAGS}" ) + else() + set( CMAKE_CXX_FLAGS "-fno-exceptions ${CMAKE_CXX_FLAGS}" ) + set( CMAKE_C_FLAGS "-fno-exceptions ${CMAKE_C_FLAGS}" ) + endif() +endif() + +# global includes and link directories +include_directories( SYSTEM "${ANDROID_SYSROOT}/usr/include" ${ANDROID_STL_INCLUDE_DIRS} ) +get_filename_component(__android_install_path "${CMAKE_INSTALL_PREFIX}/libs/${ANDROID_NDK_ABI_NAME}" ABSOLUTE) # avoid CMP0015 policy warning +link_directories( "${__android_install_path}" ) + +# detect if need link crtbegin_so.o explicitly +if( NOT DEFINED ANDROID_EXPLICIT_CRT_LINK ) + set( __cmd "${CMAKE_CXX_CREATE_SHARED_LIBRARY}" ) + string( REPLACE "<CMAKE_CXX_COMPILER>" "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1}" __cmd "${__cmd}" ) + string( REPLACE "<CMAKE_C_COMPILER>" "${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_ARG1}" __cmd "${__cmd}" ) + string( REPLACE "<CMAKE_SHARED_LIBRARY_CXX_FLAGS>" "${CMAKE_CXX_FLAGS}" __cmd "${__cmd}" ) + string( REPLACE "<LANGUAGE_COMPILE_FLAGS>" "" __cmd "${__cmd}" ) + string( REPLACE "<LINK_FLAGS>" "${CMAKE_SHARED_LINKER_FLAGS}" __cmd "${__cmd}" ) + string( REPLACE "<CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS>" "-shared" __cmd "${__cmd}" ) + string( REPLACE "<CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG>" "" __cmd "${__cmd}" ) + string( REPLACE "<TARGET_SONAME>" "" __cmd "${__cmd}" ) + string( REPLACE "<TARGET>" "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/toolchain_crtlink_test.so" __cmd "${__cmd}" ) + string( REPLACE "<OBJECTS>" "\"${ANDROID_SYSROOT}/usr/lib/crtbegin_so.o\"" __cmd "${__cmd}" ) + string( REPLACE "<LINK_LIBRARIES>" "" __cmd "${__cmd}" ) + separate_arguments( __cmd ) + foreach( __var ANDROID_NDK ANDROID_NDK_TOOLCHAINS_PATH ANDROID_STANDALONE_TOOLCHAIN ) + if( ${__var} ) + set( __tmp "${${__var}}" ) + separate_arguments( __tmp ) + string( REPLACE "${__tmp}" "${${__var}}" __cmd "${__cmd}") + endif() + endforeach() + string( REPLACE "'" "" __cmd "${__cmd}" ) + string( REPLACE "\"" "" __cmd "${__cmd}" ) + execute_process( COMMAND ${__cmd} RESULT_VARIABLE __cmd_result OUTPUT_QUIET ERROR_QUIET ) + if( __cmd_result EQUAL 0 ) + set( ANDROID_EXPLICIT_CRT_LINK ON ) + else() + set( ANDROID_EXPLICIT_CRT_LINK OFF ) + endif() +endif() + +if( ANDROID_EXPLICIT_CRT_LINK ) + set( CMAKE_CXX_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY} \"${ANDROID_SYSROOT}/usr/lib/crtbegin_so.o\"" ) + set( CMAKE_CXX_CREATE_SHARED_MODULE "${CMAKE_CXX_CREATE_SHARED_MODULE} \"${ANDROID_SYSROOT}/usr/lib/crtbegin_so.o\"" ) +endif() + +# setup output directories +set( CMAKE_INSTALL_PREFIX "${ANDROID_TOOLCHAIN_ROOT}/user" CACHE STRING "path for installing" ) + +if( DEFINED LIBRARY_OUTPUT_PATH_ROOT + OR EXISTS "${CMAKE_SOURCE_DIR}/AndroidManifest.xml" + OR (EXISTS "${CMAKE_SOURCE_DIR}/../AndroidManifest.xml" AND EXISTS "${CMAKE_SOURCE_DIR}/../jni/") ) + set( LIBRARY_OUTPUT_PATH_ROOT ${CMAKE_SOURCE_DIR} CACHE PATH "Root for binaries output, set this to change where Android libs are installed to" ) + if( NOT _CMAKE_IN_TRY_COMPILE ) + if( EXISTS "${CMAKE_SOURCE_DIR}/jni/CMakeLists.txt" ) + set( EXECUTABLE_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH_ROOT}/bin/${ANDROID_NDK_ABI_NAME}" CACHE PATH "Output directory for applications" ) + else() + set( EXECUTABLE_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH_ROOT}/bin" CACHE PATH "Output directory for applications" ) + endif() + set( LIBRARY_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH_ROOT}/libs/${ANDROID_NDK_ABI_NAME}" CACHE PATH "Output directory for Android libs" ) + endif() +endif() + +# copy shaed stl library to build directory +if( NOT _CMAKE_IN_TRY_COMPILE AND __libstl MATCHES "[.]so$" AND DEFINED LIBRARY_OUTPUT_PATH ) + get_filename_component( __libstlname "${__libstl}" NAME ) + execute_process( COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${__libstl}" "${LIBRARY_OUTPUT_PATH}/${__libstlname}" RESULT_VARIABLE __fileCopyProcess ) + if( NOT __fileCopyProcess EQUAL 0 OR NOT EXISTS "${LIBRARY_OUTPUT_PATH}/${__libstlname}") + message( SEND_ERROR "Failed copying of ${__libstl} to the ${LIBRARY_OUTPUT_PATH}/${__libstlname}" ) + endif() + unset( __fileCopyProcess ) + unset( __libstlname ) +endif() + + +# set these global flags for cmake client scripts to change behavior +set( ANDROID True ) +set( BUILD_ANDROID True ) + +# where is the target environment +set( CMAKE_FIND_ROOT_PATH "${ANDROID_TOOLCHAIN_ROOT}/bin" "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}" "${ANDROID_SYSROOT}" "${CMAKE_INSTALL_PREFIX}" "${CMAKE_INSTALL_PREFIX}/share" ) + +# only search for libraries and includes in the ndk toolchain +set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY ) +set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY ) +set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY ) + + +# macro to find packages on the host OS +macro( find_host_package ) + set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER ) + set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER ) + set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER ) + if( CMAKE_HOST_WIN32 ) + SET( WIN32 1 ) + SET( UNIX ) + elseif( CMAKE_HOST_APPLE ) + SET( APPLE 1 ) + SET( UNIX ) + endif() + find_package( ${ARGN} ) + SET( WIN32 ) + SET( APPLE ) + SET( UNIX 1 ) + set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY ) + set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY ) + set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY ) +endmacro() + + +# macro to find programs on the host OS +macro( find_host_program ) + set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER ) + set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER ) + set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER ) + if( CMAKE_HOST_WIN32 ) + SET( WIN32 1 ) + SET( UNIX ) + elseif( CMAKE_HOST_APPLE ) + SET( APPLE 1 ) + SET( UNIX ) + endif() + find_program( ${ARGN} ) + SET( WIN32 ) + SET( APPLE ) + SET( UNIX 1 ) + set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY ) + set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY ) + set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY ) +endmacro() + + +# export toolchain settings for the try_compile() command +if( NOT _CMAKE_IN_TRY_COMPILE ) + set( __toolchain_config "") + foreach( __var NDK_CCACHE LIBRARY_OUTPUT_PATH_ROOT ANDROID_FORBID_SYGWIN + ANDROID_NDK_HOST_X64 + ANDROID_NDK + ANDROID_NDK_LAYOUT + ANDROID_STANDALONE_TOOLCHAIN + ANDROID_TOOLCHAIN_NAME + ANDROID_ABI + ANDROID_NATIVE_API_LEVEL + ANDROID_STL + ANDROID_STL_FORCE_FEATURES + ANDROID_FORCE_ARM_BUILD + ANDROID_NO_UNDEFINED + ANDROID_SO_UNDEFINED + ANDROID_FUNCTION_LEVEL_LINKING + ANDROID_GOLD_LINKER + ANDROID_NOEXECSTACK + ANDROID_RELRO + ANDROID_LIBM_PATH + ANDROID_EXPLICIT_CRT_LINK + ANDROID_APP_PIE + ) + if( DEFINED ${__var} ) + if( ${__var} MATCHES " ") + set( __toolchain_config "${__toolchain_config}set( ${__var} \"${${__var}}\" CACHE INTERNAL \"\" )\n" ) + else() + set( __toolchain_config "${__toolchain_config}set( ${__var} ${${__var}} CACHE INTERNAL \"\" )\n" ) + endif() + endif() + endforeach() + file( WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/android.toolchain.config.cmake" "${__toolchain_config}" ) + unset( __toolchain_config ) +endif() + + +# force cmake to produce / instead of \ in build commands for Ninja generator +if( CMAKE_GENERATOR MATCHES "Ninja" AND CMAKE_HOST_WIN32 ) + # it is a bad hack after all + # CMake generates Ninja makefiles with UNIX paths only if it thinks that we are going to build with MinGW + set( CMAKE_COMPILER_IS_MINGW TRUE ) # tell CMake that we are MinGW + set( CMAKE_CROSSCOMPILING TRUE ) # stop recursion + enable_language( C ) + enable_language( CXX ) + # unset( CMAKE_COMPILER_IS_MINGW ) # can't unset because CMake does not convert back-slashes in response files without it + unset( MINGW ) +endif() + + +# Variables controlling behavior or set by cmake toolchain: +# ANDROID_ABI : "armeabi-v7a" (default), "armeabi", "armeabi-v7a with NEON", "armeabi-v7a with VFPV3", "armeabi-v6 with VFP", "x86", "mips", "arm64-v8a", "x86_64", "mips64" +# ANDROID_NATIVE_API_LEVEL : 3,4,5,8,9,14,15,16,17,18,19,21 (depends on NDK version) +# ANDROID_STL : gnustl_static/gnustl_shared/stlport_static/stlport_shared/gabi++_static/gabi++_shared/system_re/system/none +# ANDROID_FORBID_SYGWIN : ON/OFF +# ANDROID_NO_UNDEFINED : ON/OFF +# ANDROID_SO_UNDEFINED : OFF/ON (default depends on NDK version) +# ANDROID_FUNCTION_LEVEL_LINKING : ON/OFF +# ANDROID_GOLD_LINKER : ON/OFF +# ANDROID_NOEXECSTACK : ON/OFF +# ANDROID_RELRO : ON/OFF +# ANDROID_FORCE_ARM_BUILD : ON/OFF +# ANDROID_STL_FORCE_FEATURES : ON/OFF +# ANDROID_LIBM_PATH : path to libm.so (set to something like $(TOP)/out/target/product/<product_name>/obj/lib/libm.so) to workaround unresolved `sincos` +# Can be set only at the first run: +# ANDROID_NDK : path to your NDK install +# NDK_CCACHE : path to your ccache executable +# ANDROID_TOOLCHAIN_NAME : the NDK name of compiler toolchain +# ANDROID_NDK_HOST_X64 : try to use x86_64 toolchain (default for x64 host systems) +# ANDROID_NDK_LAYOUT : the inner NDK structure (RELEASE, LINARO, ANDROID) +# LIBRARY_OUTPUT_PATH_ROOT : <any valid path> +# ANDROID_STANDALONE_TOOLCHAIN +# +# Primary read-only variables: +# ANDROID : always TRUE +# ARMEABI : TRUE for arm v6 and older devices +# ARMEABI_V6 : TRUE for arm v6 +# ARMEABI_V7A : TRUE for arm v7a +# ARM64_V8A : TRUE for arm64-v8a +# NEON : TRUE if NEON unit is enabled +# VFPV3 : TRUE if VFP version 3 is enabled +# X86 : TRUE if configured for x86 +# X86_64 : TRUE if configured for x86_64 +# MIPS : TRUE if configured for mips +# MIPS64 : TRUE if configured for mips64 +# BUILD_WITH_ANDROID_NDK : TRUE if NDK is used +# BUILD_WITH_STANDALONE_TOOLCHAIN : TRUE if standalone toolchain is used +# ANDROID_NDK_HOST_SYSTEM_NAME : "windows", "linux-x86" or "darwin-x86" depending on host platform +# ANDROID_NDK_ABI_NAME : "armeabi", "armeabi-v7a", "x86", "mips", "arm64-v8a", "x86_64", "mips64" depending on ANDROID_ABI +# ANDROID_NDK_RELEASE : from r5 to r10d; set only for NDK +# ANDROID_NDK_RELEASE_NUM : numeric ANDROID_NDK_RELEASE version (1000*major+minor) +# ANDROID_ARCH_NAME : "arm", "x86", "mips", "arm64", "x86_64", "mips64" depending on ANDROID_ABI +# ANDROID_SYSROOT : path to the compiler sysroot +# TOOL_OS_SUFFIX : "" or ".exe" depending on host platform +# ANDROID_COMPILER_IS_CLANG : TRUE if clang compiler is used +# +# Secondary (less stable) read-only variables: +# ANDROID_COMPILER_VERSION : GCC version used (not Clang version) +# ANDROID_CLANG_VERSION : version of clang compiler if clang is used +# ANDROID_CXX_FLAGS : C/C++ compiler flags required by Android platform +# ANDROID_SUPPORTED_ABIS : list of currently allowed values for ANDROID_ABI +# ANDROID_TOOLCHAIN_MACHINE_NAME : "arm-linux-androideabi", "arm-eabi" or "i686-android-linux" +# ANDROID_TOOLCHAIN_ROOT : path to the top level of toolchain (standalone or placed inside NDK) +# ANDROID_CLANG_TOOLCHAIN_ROOT : path to clang tools +# ANDROID_SUPPORTED_NATIVE_API_LEVELS : list of native API levels found inside NDK +# ANDROID_STL_INCLUDE_DIRS : stl include paths +# ANDROID_RTTI : if rtti is enabled by the runtime +# ANDROID_EXCEPTIONS : if exceptions are enabled by the runtime +# ANDROID_GCC_TOOLCHAIN_NAME : read-only, differs from ANDROID_TOOLCHAIN_NAME only if clang is used +# +# Defaults: +# ANDROID_DEFAULT_NDK_API_LEVEL +# ANDROID_DEFAULT_NDK_API_LEVEL_${ARCH} +# ANDROID_NDK_SEARCH_PATHS +# ANDROID_SUPPORTED_ABIS_${ARCH} +# ANDROID_SUPPORTED_NDK_VERSIONS diff --git a/NvCloth/Externals/CMakeModules/android/ndk_links.md b/NvCloth/Externals/CMakeModules/android/ndk_links.md new file mode 100644 index 0000000..6d93d61 --- /dev/null +++ b/NvCloth/Externals/CMakeModules/android/ndk_links.md @@ -0,0 +1,211 @@ + +============== r1 ============== (dead links) + +* http://dl.google.com/android/ndk/android-ndk-1.5_r1-windows.zip +* http://dl.google.com/android/ndk/android-ndk-1.5_r1-darwin-x86.zip +* http://dl.google.com/android/ndk/android-ndk-1.5_r1-linux-x86.zip + +============== r2 ============== + +* http://dl.google.com/android/ndk/android-ndk-1.6_r1-windows.zip +* http://dl.google.com/android/ndk/android-ndk-1.6_r1-darwin-x86.zip +* http://dl.google.com/android/ndk/android-ndk-1.6_r1-linux-x86.zip + +============== r3 ============== + +* http://dl.google.com/android/ndk/android-ndk-r3-windows.zip +* http://dl.google.com/android/ndk/android-ndk-r3-darwin-x86.zip +* http://dl.google.com/android/ndk/android-ndk-r3-linux-x86.zip + +============== r4 ============== + +* http://dl.google.com/android/ndk/android-ndk-r4-windows.zip +* http://dl.google.com/android/ndk/android-ndk-r4-darwin-x86.zip +* http://dl.google.com/android/ndk/android-ndk-r4-linux-x86.zip + +============== r4b ============== + +* http://dl.google.com/android/ndk/android-ndk-r4b-windows.zip +* http://dl.google.com/android/ndk/android-ndk-r4b-darwin-x86.zip +* http://dl.google.com/android/ndk/android-ndk-r4b-linux-x86.zip + +============== r5 ============== + +* http://dl.google.com/android/ndk/android-ndk-r5-windows.zip +* http://dl.google.com/android/ndk/android-ndk-r5-darwin-x86.tar.bz2 +* http://dl.google.com/android/ndk/android-ndk-r5-linux-x86.tar.bz2 + +============== r5b ============== + +* http://dl.google.com/android/ndk/android-ndk-r5b-windows.zip +* http://dl.google.com/android/ndk/android-ndk-r5b-darwin-x86.tar.bz2 +* http://dl.google.com/android/ndk/android-ndk-r5b-linux-x86.tar.bz2 + +============== r5c ============== + +* http://dl.google.com/android/ndk/android-ndk-r5c-windows.zip +* http://dl.google.com/android/ndk/android-ndk-r5c-darwin-x86.tar.bz2 +* http://dl.google.com/android/ndk/android-ndk-r5c-linux-x86.tar.bz2 + +============== r6 ============== + +* http://dl.google.com/android/ndk/android-ndk-r6-windows.zip +* http://dl.google.com/android/ndk/android-ndk-r6-darwin-x86.tar.bz2 +* http://dl.google.com/android/ndk/android-ndk-r6-linux-x86.tar.bz2 + +============== r6b ============== + +* http://dl.google.com/android/ndk/android-ndk-r6b-windows.zip +* http://dl.google.com/android/ndk/android-ndk-r6b-darwin-x86.tar.bz2 +* http://dl.google.com/android/ndk/android-ndk-r6b-linux-x86.tar.bz2 + +============== r7 ============== + +* http://dl.google.com/android/ndk/android-ndk-r7-windows.zip +* http://dl.google.com/android/ndk/android-ndk-r7-darwin-x86.tar.bz2 +* http://dl.google.com/android/ndk/android-ndk-r7-linux-x86.tar.bz2 + +============== r7b ============== + +* http://dl.google.com/android/ndk/android-ndk-r7b-windows.zip +* http://dl.google.com/android/ndk/android-ndk-r7b-darwin-x86.tar.bz2 +* http://dl.google.com/android/ndk/android-ndk-r7b-linux-x86.tar.bz2 + +============== r7c ============== + +* http://dl.google.com/android/ndk/android-ndk-r7c-windows.zip +* http://dl.google.com/android/ndk/android-ndk-r7c-darwin-x86.tar.bz2 +* http://dl.google.com/android/ndk/android-ndk-r7c-linux-x86.tar.bz2 + +============== r8 ============== + +* http://dl.google.com/android/ndk/android-ndk-r8-windows.zip +* http://dl.google.com/android/ndk/android-ndk-r8-darwin-x86.tar.bz2 +* http://dl.google.com/android/ndk/android-ndk-r8-linux-x86.tar.bz2 + +============== r8b ============== + +* http://dl.google.com/android/ndk/android-ndk-r8b-windows.zip +* http://dl.google.com/android/ndk/android-ndk-r8b-darwin-x86.tar.bz2 +* http://dl.google.com/android/ndk/android-ndk-r8b-linux-x86.tar.bz2 + +============== r8c ============== + +* http://dl.google.com/android/ndk/android-ndk-r8c-windows.zip +* http://dl.google.com/android/ndk/android-ndk-r8c-darwin-x86.tar.bz2 +* http://dl.google.com/android/ndk/android-ndk-r8c-linux-x86.tar.bz2 + +============== r8d ============== + +* http://dl.google.com/android/ndk/android-ndk-r8d-windows.zip +* http://dl.google.com/android/ndk/android-ndk-r8d-darwin-x86.tar.bz2 +* http://dl.google.com/android/ndk/android-ndk-r8d-linux-x86.tar.bz2 + +============== r8e ============== + +* http://dl.google.com/android/ndk/android-ndk-r8e-windows-x86.zip +* http://dl.google.com/android/ndk/android-ndk-r8e-windows-x86_64.zip +* http://dl.google.com/android/ndk/android-ndk-r8e-darwin-x86.tar.bz2 +* http://dl.google.com/android/ndk/android-ndk-r8e-darwin-x86_64.tar.bz2 +* http://dl.google.com/android/ndk/android-ndk-r8e-linux-x86.tar.bz2 +* http://dl.google.com/android/ndk/android-ndk-r8e-linux-x86_64.tar.bz2 + +============== r9 ============== + +* http://dl.google.com/android/ndk/android-ndk-r9-windows-x86.zip +* http://dl.google.com/android/ndk/android-ndk-r9-windows-x86-legacy-toolchains.zip +* http://dl.google.com/android/ndk/android-ndk-r9-windows-x86_64.zip +* http://dl.google.com/android/ndk/android-ndk-r9-windows-x86_64-legacy-toolchains.zip +* http://dl.google.com/android/ndk/android-ndk-r9-darwin-x86.tar.bz2 +* http://dl.google.com/android/ndk/android-ndk-r9-darwin-x86-legacy-toolchains.tar.bz2 +* http://dl.google.com/android/ndk/android-ndk-r9-darwin-x86_64.tar.bz2 +* http://dl.google.com/android/ndk/android-ndk-r9-darwin-x86_64-legacy-toolchains.tar.bz2 +* http://dl.google.com/android/ndk/android-ndk-r9-linux-x86.tar.bz2 +* http://dl.google.com/android/ndk/android-ndk-r9-linux-x86-legacy-toolchains.tar.bz2 +* http://dl.google.com/android/ndk/android-ndk-r9-linux-x86_64.tar.bz2 +* http://dl.google.com/android/ndk/android-ndk-r9-linux-x86_64-legacy-toolchains.tar.bz2 + +============== r9b ============== + +* http://dl.google.com/android/ndk/android-ndk-r9b-windows-x86.zip +* http://dl.google.com/android/ndk/android-ndk-r9b-windows-x86-legacy-toolchains.zip +* http://dl.google.com/android/ndk/android-ndk-r9b-windows-x86_64.zip +* http://dl.google.com/android/ndk/android-ndk-r9b-windows-x86_64-legacy-toolchains.zip +* http://dl.google.com/android/ndk/android-ndk-r9b-darwin-x86.tar.bz2 +* http://dl.google.com/android/ndk/android-ndk-r9b-darwin-x86-legacy-toolchains.tar.bz2 +* http://dl.google.com/android/ndk/android-ndk-r9b-darwin-x86_64.tar.bz2 +* http://dl.google.com/android/ndk/android-ndk-r9b-darwin-x86_64-legacy-toolchains.tar.bz2 +* http://dl.google.com/android/ndk/android-ndk-r9b-linux-x86.tar.bz2 +* http://dl.google.com/android/ndk/android-ndk-r9b-linux-x86-legacy-toolchains.tar.bz2 +* http://dl.google.com/android/ndk/android-ndk-r9b-linux-x86_64.tar.bz2 +* http://dl.google.com/android/ndk/android-ndk-r9b-linux-x86_64-legacy-toolchains.tar.bz2 + +============== r9c ============== + +* http://dl.google.com/android/ndk/android-ndk-r9c-windows-x86.zip +* http://dl.google.com/android/ndk/android-ndk-r9c-windows-x86_64.zip +* http://dl.google.com/android/ndk/android-ndk-r9c-darwin-x86.tar.bz2 +* http://dl.google.com/android/ndk/android-ndk-r9c-darwin-x86_64.tar.bz2 +* http://dl.google.com/android/ndk/android-ndk-r9c-linux-x86.tar.bz2 +* http://dl.google.com/android/ndk/android-ndk-r9c-linux-x86_64.tar.bz2 +* http://dl.google.com/android/ndk/android-ndk-r9c-cxx-stl-libs-with-debugging-info.zip + +============== r9d ============== + +* http://dl.google.com/android/ndk/android-ndk-r9d-windows-x86.zip +* http://dl.google.com/android/ndk/android-ndk-r9d-windows-x86_64.zip +* http://dl.google.com/android/ndk/android-ndk-r9d-darwin-x86.tar.bz2 +* http://dl.google.com/android/ndk/android-ndk-r9d-darwin-x86_64.tar.bz2 +* http://dl.google.com/android/ndk/android-ndk-r9d-linux-x86.tar.bz2 +* http://dl.google.com/android/ndk/android-ndk-r9d-linux-x86_64.tar.bz2 +* http://dl.google.com/android/ndk/android-ndk-r9d-cxx-stl-libs-with-debug-info.zip + +============== r10 ============== + +* http://dl.google.com/android/ndk/android-ndk32-r10-windows-x86.zip +* http://dl.google.com/android/ndk/android-ndk32-r10-windows-x86_64.zip +* http://dl.google.com/android/ndk/android-ndk32-r10-darwin-x86.tar.bz2 +* http://dl.google.com/android/ndk/android-ndk32-r10-darwin-x86_64.tar.bz2 +* http://dl.google.com/android/ndk/android-ndk32-r10-linux-x86.tar.bz2 +* http://dl.google.com/android/ndk/android-ndk32-r10-linux-x86_64.tar.bz2 +* http://dl.google.com/android/ndk/android-ndk64-r10-windows-x86.zip +* http://dl.google.com/android/ndk/android-ndk64-r10-windows-x86_64.zip +* http://dl.google.com/android/ndk/android-ndk64-r10-darwin-x86.tar.bz2 +* http://dl.google.com/android/ndk/android-ndk64-r10-darwin-x86_64.tar.bz2 +* http://dl.google.com/android/ndk/android-ndk64-r10-linux-x86.tar.bz2 +* http://dl.google.com/android/ndk/android-ndk64-r10-linux-x86_64.tar.bz2 +* http://dl.google.com/android/ndk/android-ndk-r10-cxx-stl-libs-with-debug-info.zip + +============== r10b ============== + +* http://dl.google.com/android/ndk/android-ndk32-r10b-windows-x86.zip +* http://dl.google.com/android/ndk/android-ndk32-r10b-windows-x86_64.zip +* http://dl.google.com/android/ndk/android-ndk32-r10b-darwin-x86.tar.bz2 +* http://dl.google.com/android/ndk/android-ndk32-r10b-darwin-x86_64.tar.bz2 +* http://dl.google.com/android/ndk/android-ndk32-r10b-linux-x86.tar.bz2 +* http://dl.google.com/android/ndk/android-ndk32-r10b-linux-x86_64.tar.bz2 +* http://dl.google.com/android/ndk/android-ndk64-r10b-windows-x86.zip +* http://dl.google.com/android/ndk/android-ndk64-r10b-windows-x86_64.zip +* http://dl.google.com/android/ndk/android-ndk64-r10b-darwin-x86.tar.bz2 +* http://dl.google.com/android/ndk/android-ndk64-r10b-darwin-x86_64.tar.bz2 +* http://dl.google.com/android/ndk/android-ndk64-r10b-linux-x86.tar.bz2 +* http://dl.google.com/android/ndk/android-ndk64-r10b-linux-x86_64.tar.bz2 +* http://dl.google.com/android/ndk/android-ndk-r10b-cxx-stl-libs-with-debug-info.zip + +============== r10c ============== + +* http://dl.google.com/android/ndk/android-ndk-r10c-windows-x86.exe +* http://dl.google.com/android/ndk/android-ndk-r10c-windows-x86_64.exe +* http://dl.google.com/android/ndk/android-ndk-r10c-darwin-x86.bin +* http://dl.google.com/android/ndk/android-ndk-r10c-darwin-x86_64.bin +* http://dl.google.com/android/ndk/android-ndk-r10c-linux-x86.bin +* http://dl.google.com/android/ndk/android-ndk-r10c-linux-x86_64.bin + +============== r10d ============== + +* http://dl.google.com/android/ndk/android-ndk-r10d-windows-x86.exe +* http://dl.google.com/android/ndk/android-ndk-r10d-windows-x86_64.exe +* http://dl.google.com/android/ndk/android-ndk-r10d-darwin-x86.bin +* http://dl.google.com/android/ndk/android-ndk-r10d-darwin-x86_64.bin +* http://dl.google.com/android/ndk/android-ndk-r10d-linux-x86.bin +* http://dl.google.com/android/ndk/android-ndk-r10d-linux-x86_64.bin diff --git a/NvCloth/Externals/CMakeModules/ios/ios.toolchain.cmake b/NvCloth/Externals/CMakeModules/ios/ios.toolchain.cmake new file mode 100644 index 0000000..1f6ed45 --- /dev/null +++ b/NvCloth/Externals/CMakeModules/ios/ios.toolchain.cmake @@ -0,0 +1,334 @@ +# This file is part of the ios-cmake project. It was retrieved from +# https://github.com/cristeab/ios-cmake.git, which is a fork of +# https://code.google.com/p/ios-cmake/. Which in turn is based off of +# the Platform/Darwin.cmake and Platform/UnixPaths.cmake files which +# are included with CMake 2.8.4 +# +# The ios-cmake project is licensed under the new BSD license. +# +# Copyright (c) 2014, Bogdan Cristea and LTE Engineering Software, +# Kitware, Inc., Insight Software Consortium. All rights reserved. +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +# This file is based off of the Platform/Darwin.cmake and +# Platform/UnixPaths.cmake files which are included with CMake 2.8.4 +# It has been altered for iOS development. +# +# Updated by Alex Stewart ([email protected]). +# The following variables control the behaviour of this toolchain: +# +# IOS_PLATFORM: OS (default) or SIMULATOR or SIMULATOR64 +# OS = Build for iPhoneOS. +# SIMULATOR = Build for x86 i386 iPhone Simulator. +# SIMULATOR64 = Build for x86 x86_64 iPhone Simulator. +# CMAKE_OSX_SYSROOT: Path to the iOS SDK to use. By default this is +# automatically determined from IOS_PLATFORM and xcodebuild, but +# can also be manually specified (although this should not be required). +# CMAKE_IOS_DEVELOPER_ROOT: Path to the Developer directory for the iOS platform +# being compiled for. By default this is automatically determined from +# CMAKE_OSX_SYSROOT, but can also be manually specified (although this should +# not be required). +# ENABLE_BITCODE: (true|false) Enables or disables bitcode support. Default true +# +# This toolchain defines the following variables for use externally: +# +# XCODE_VERSION: Version number (not including Build version) of Xcode detected. +# IOS_SDK_VERSION: Version of iOS SDK being used. +# CMAKE_OSX_ARCHITECTURES: Architectures being compiled for (generated from +# IOS_PLATFORM). +# +# This toolchain defines the following macros for use externally: +# +# set_xcode_property (TARGET XCODE_PROPERTY XCODE_VALUE XCODE_VARIANT) +# A convenience macro for setting xcode specific properties on targets. +# Available variants are: All, Release, RelWithDebInfo, Debug, MinSizeRel +# example: set_xcode_property (myioslib IPHONEOS_DEPLOYMENT_TARGET "3.1" "all"). +# +# find_host_package (PROGRAM ARGS) +# A macro used to find executable programs on the host system, not within the +# iOS environment. Thanks to the android-cmake project for providing the +# command. + +# Fix for PThread library not in path +set(CMAKE_THREAD_LIBS_INIT "-lpthread") +set(CMAKE_HAVE_THREADS_LIBRARY 1) +set(CMAKE_USE_WIN32_THREADS_INIT 0) +set(CMAKE_USE_PTHREADS_INIT 1) + +# Get the Xcode version being used. +execute_process(COMMAND xcodebuild -version + OUTPUT_VARIABLE XCODE_VERSION + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) +string(REGEX MATCH "Xcode [0-9\\.]+" XCODE_VERSION "${XCODE_VERSION}") +string(REGEX REPLACE "Xcode ([0-9\\.]+)" "\\1" XCODE_VERSION "${XCODE_VERSION}") +message(STATUS "Building with Xcode version: ${XCODE_VERSION}") +# Default to building for iPhoneOS if not specified otherwise, and we cannot +# determine the platform from the CMAKE_OSX_ARCHITECTURES variable. The use +# of CMAKE_OSX_ARCHITECTURES is such that try_compile() projects can correctly +# determine the value of IOS_PLATFORM from the root project, as +# CMAKE_OSX_ARCHITECTURES is propagated to them by CMake. +if (NOT DEFINED IOS_PLATFORM) + if (CMAKE_OSX_ARCHITECTURES) + if (CMAKE_OSX_ARCHITECTURES MATCHES ".*arm.*") + set(IOS_PLATFORM "OS") + elseif (CMAKE_OSX_ARCHITECTURES MATCHES "i386") + set(IOS_PLATFORM "SIMULATOR") + elseif (CMAKE_OSX_ARCHITECTURES MATCHES "x86_64") + set(IOS_PLATFORM "SIMULATOR64") + endif() + endif() + if (NOT IOS_PLATFORM) + set(IOS_PLATFORM "OS") + endif() +endif() +set(IOS_PLATFORM ${IOS_PLATFORM} CACHE STRING + "Type of iOS platform for which to build.") +# Determine the platform name and architectures for use in xcodebuild commands +# from the specified IOS_PLATFORM name. +if (IOS_PLATFORM STREQUAL "OS") + set(XCODE_IOS_PLATFORM iphoneos) + set(IOS_ARCH armv7 armv7s arm64) +elseif (IOS_PLATFORM STREQUAL "SIMULATOR") + set(XCODE_IOS_PLATFORM iphonesimulator) + set(IOS_ARCH i386) +elseif(IOS_PLATFORM STREQUAL "SIMULATOR64") + set(XCODE_IOS_PLATFORM iphonesimulator) + set(IOS_ARCH x86_64) +else() + message(FATAL_ERROR "Invalid IOS_PLATFORM: ${IOS_PLATFORM}") +endif() +message(STATUS "Configuring iOS build for platform: ${IOS_PLATFORM}, " + "architecture(s): ${IOS_ARCH}") +# If user did not specify the SDK root to use, then query xcodebuild for it. +if (NOT CMAKE_OSX_SYSROOT) + execute_process(COMMAND xcodebuild -version -sdk ${XCODE_IOS_PLATFORM} Path + OUTPUT_VARIABLE CMAKE_OSX_SYSROOT + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + message(STATUS "Using SDK: ${CMAKE_OSX_SYSROOT} for platform: ${IOS_PLATFORM}") +endif() +if (NOT EXISTS ${CMAKE_OSX_SYSROOT}) + message(FATAL_ERROR "Invalid CMAKE_OSX_SYSROOT: ${CMAKE_OSX_SYSROOT} " + "does not exist.") +endif() +# Specify minimum version of deployment target. +if (NOT DEFINED IOS_DEPLOYMENT_TARGET) + # Unless specified, SDK version 8.0 is used by default as minimum target version. + set(IOS_DEPLOYMENT_TARGET "8.0" + CACHE STRING "Minimum iOS version to build for." ) + message(STATUS "Using the default min-version since IOS_DEPLOYMENT_TARGET not provided!") +endif() +# Use bitcode or not +if (NOT DEFINED ENABLE_BITCODE) + # Unless specified, enable bitcode support by default + set(ENABLE_BITCODE FALSE CACHE BOOL "Wheter or not to enable bitcode") + message(STATUS "Disabling bitcode support by default. ENABLE_BITCODE not provided!") +endif() +# Get the SDK version information. +execute_process(COMMAND xcodebuild -sdk ${CMAKE_OSX_SYSROOT} -version SDKVersion + OUTPUT_VARIABLE IOS_SDK_VERSION + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) +# Find the Developer root for the specific iOS platform being compiled for +# from CMAKE_OSX_SYSROOT. Should be ../../ from SDK specified in +# CMAKE_OSX_SYSROOT. There does not appear to be a direct way to obtain +# this information from xcrun or xcodebuild. +if (NOT CMAKE_IOS_DEVELOPER_ROOT) + get_filename_component(IOS_PLATFORM_SDK_DIR ${CMAKE_OSX_SYSROOT} PATH) + get_filename_component(CMAKE_IOS_DEVELOPER_ROOT ${IOS_PLATFORM_SDK_DIR} PATH) +endif() +if (NOT EXISTS ${CMAKE_IOS_DEVELOPER_ROOT}) + message(FATAL_ERROR "Invalid CMAKE_IOS_DEVELOPER_ROOT: " + "${CMAKE_IOS_DEVELOPER_ROOT} does not exist.") +endif() +message("CMAKE_IOS_DEVELOPER_ROOT: ${CMAKE_IOS_DEVELOPER_ROOT}") +# Find the C & C++ compilers for the specified SDK. +if (NOT CMAKE_C_COMPILER) + execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find clang + OUTPUT_VARIABLE CMAKE_C_COMPILER + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + message(STATUS "Using C compiler: ${CMAKE_C_COMPILER}") +endif() +if (NOT CMAKE_CXX_COMPILER) + execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find clang++ + OUTPUT_VARIABLE CMAKE_CXX_COMPILER + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + message(STATUS "Using CXX compiler: ${CMAKE_CXX_COMPILER}") +endif() +# Find (Apple's) libtool. +execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find libtool + OUTPUT_VARIABLE IOS_LIBTOOL + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) +message(STATUS "Using libtool: ${IOS_LIBTOOL}") +# Configure libtool to be used instead of ar + ranlib to build static libraries. +# This is required on Xcode 7+, but should also work on previous versions of +# Xcode. +set(CMAKE_C_CREATE_STATIC_LIBRARY + "${IOS_LIBTOOL} -static -o <TARGET> <LINK_FLAGS> <OBJECTS> ") +set(CMAKE_CXX_CREATE_STATIC_LIBRARY + "${IOS_LIBTOOL} -static -o <TARGET> <LINK_FLAGS> <OBJECTS> ") +# Get the version of Darwin (OS X) of the host. +execute_process(COMMAND uname -r + OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_VERSION + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) +# Standard settings. +set(CMAKE_SYSTEM_NAME Darwin CACHE INTERNAL "") +set(CMAKE_SYSTEM_VERSION ${IOS_SDK_VERSION} CACHE INTERNAL "") +set(UNIX TRUE CACHE BOOL "") +set(APPLE TRUE CACHE BOOL "") +set(IOS TRUE CACHE BOOL "") +set(CMAKE_AR ar CACHE FILEPATH "" FORCE) +set(CMAKE_RANLIB ranlib CACHE FILEPATH "" FORCE) +# Force unset of OS X-specific deployment target (otherwise autopopulated), +# required as of cmake 2.8.10. +set(CMAKE_OSX_DEPLOYMENT_TARGET "" CACHE STRING + "Must be empty for iOS builds." FORCE) +# Set the architectures for which to build. +set(CMAKE_OSX_ARCHITECTURES ${IOS_ARCH} CACHE STRING "Build architecture for iOS") +# Skip the platform compiler checks for cross compiling. +set(CMAKE_CXX_COMPILER_FORCED TRUE) +set(CMAKE_CXX_COMPILER_WORKS TRUE) +set(CMAKE_C_COMPILER_FORCED TRUE) +set(CMAKE_C_COMPILER_WORKS TRUE) +# All iOS/Darwin specific settings - some may be redundant. +set(CMAKE_SHARED_LIBRARY_PREFIX "lib") +set(CMAKE_SHARED_LIBRARY_SUFFIX ".dylib") +set(CMAKE_SHARED_MODULE_PREFIX "lib") +set(CMAKE_SHARED_MODULE_SUFFIX ".so") +set(CMAKE_MODULE_EXISTS 1) +set(CMAKE_DL_LIBS "") +set(CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG "-compatibility_version ") +set(CMAKE_C_OSX_CURRENT_VERSION_FLAG "-current_version ") +set(CMAKE_CXX_OSX_COMPATIBILITY_VERSION_FLAG "${CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG}") +set(CMAKE_CXX_OSX_CURRENT_VERSION_FLAG "${CMAKE_C_OSX_CURRENT_VERSION_FLAG}") +message(STATUS "Building for minimum iOS version: ${IOS_DEPLOYMENT_TARGET}" + " (SDK version: ${IOS_SDK_VERSION})") +# Note that only Xcode 7+ supports the newer more specific: +# -m${XCODE_IOS_PLATFORM}-version-min flags, older versions of Xcode use: +# -m(ios/ios-simulator)-version-min instead. +if (IOS_PLATFORM STREQUAL "OS") + if (XCODE_VERSION VERSION_LESS 7.0) + set(XCODE_IOS_PLATFORM_VERSION_FLAGS + "-mios-version-min=${IOS_DEPLOYMENT_TARGET}") + else() + # Xcode 7.0+ uses flags we can build directly from XCODE_IOS_PLATFORM. + set(XCODE_IOS_PLATFORM_VERSION_FLAGS + "-m${XCODE_IOS_PLATFORM}-version-min=${IOS_DEPLOYMENT_TARGET}") + endif() +else() + # SIMULATOR or SIMULATOR64 both use -mios-simulator-version-min. + set(XCODE_IOS_PLATFORM_VERSION_FLAGS + "-mios-simulator-version-min=${IOS_DEPLOYMENT_TARGET}") +endif() +message(STATUS "Version flags set to: ${XCODE_IOS_PLATFORM_VERSION_FLAGS}") + +if (ENABLE_BITCODE) + set(BITCODE "-fembed-bitcode") + message(STATUS "Enabling bitcode support.") +else() + set(BITCODE "") + message(STATUS "Disabling bitcode support.") +endif() + +set(CMAKE_C_FLAGS +"${XCODE_IOS_PLATFORM_VERSION_FLAGS} ${BITCODE} -fobjc-abi-version=2 -fobjc-arc ${CMAKE_C_FLAGS}") +# Hidden visibilty is required for C++ on iOS. +set(CMAKE_CXX_FLAGS + "${XCODE_IOS_PLATFORM_VERSION_FLAGS} ${BITCODE} ${CMAKE_CXX_FLAGS}") +set(CMAKE_CXX_FLAGS_RELEASE "${BITCODE} ${CMAKE_CXX_FLAGS_RELEASE}") +set(CMAKE_C_LINK_FLAGS "${XCODE_IOS_PLATFORM_VERSION_FLAGS} -Wl,-search_paths_first ${CMAKE_C_LINK_FLAGS}") +set(CMAKE_CXX_LINK_FLAGS "${XCODE_IOS_PLATFORM_VERSION_FLAGS} -Wl,-search_paths_first ${CMAKE_CXX_LINK_FLAGS}") +# In order to ensure that the updated compiler flags are used in try_compile() +# tests, we have to forcibly set them in the CMake cache, not merely set them +# in the local scope. +list(APPEND VARS_TO_FORCE_IN_CACHE + CMAKE_C_FLAGS + CMAKE_CXX_FLAGS + CMAKE_CXX_RELEASE + CMAKE_C_LINK_FLAGS + CMAKE_CXX_LINK_FLAGS) +foreach(VAR_TO_FORCE ${VARS_TO_FORCE_IN_CACHE}) + set(${VAR_TO_FORCE} "${${VAR_TO_FORCE}}" CACHE STRING "" FORCE) +endforeach() +set(CMAKE_PLATFORM_HAS_INSTALLNAME 1) +set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-dynamiclib -headerpad_max_install_names") +set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS "-bundle -headerpad_max_install_names") +set(CMAKE_SHARED_MODULE_LOADER_C_FLAG "-Wl,-bundle_loader,") +set(CMAKE_SHARED_MODULE_LOADER_CXX_FLAG "-Wl,-bundle_loader,") +set(CMAKE_FIND_LIBRARY_SUFFIXES ".dylib" ".so" ".a") +# Hack: if a new cmake (which uses CMAKE_INSTALL_NAME_TOOL) runs on an old +# build tree (where install_name_tool was hardcoded) and where +# CMAKE_INSTALL_NAME_TOOL isn't in the cache and still cmake didn't fail in +# CMakeFindBinUtils.cmake (because it isn't rerun) hardcode +# CMAKE_INSTALL_NAME_TOOL here to install_name_tool, so it behaves as it did +# before, Alex. +if (NOT DEFINED CMAKE_INSTALL_NAME_TOOL) + find_program(CMAKE_INSTALL_NAME_TOOL install_name_tool) +endif (NOT DEFINED CMAKE_INSTALL_NAME_TOOL) +# Set the find root to the iOS developer roots and to user defined paths. +set(CMAKE_FIND_ROOT_PATH ${CMAKE_IOS_DEVELOPER_ROOT} ${CMAKE_OSX_SYSROOT} + ${CMAKE_PREFIX_PATH} CACHE string "iOS find search path root" FORCE) +# Default to searching for frameworks first. +set(CMAKE_FIND_FRAMEWORK FIRST) +# Set up the default search directories for frameworks. +set(CMAKE_SYSTEM_FRAMEWORK_PATH + ${CMAKE_OSX_SYSROOT}/System/Library/Frameworks + ${CMAKE_OSX_SYSROOT}/System/Library/PrivateFrameworks + ${CMAKE_OSX_SYSROOT}/Developer/Library/Frameworks) +# Only search the specified iOS SDK, not the remainder of the host filesystem. +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +# This little macro lets you set any XCode specific property. +macro(set_xcode_property TARGET XCODE_PROPERTY XCODE_VALUE XCODE_RELVERSION) + set(XCODE_RELVERSION_I "${XCODE_RELVERSION}") + if (XCODE_RELVERSION_I STREQUAL "All") + set_property(TARGET ${TARGET} PROPERTY + XCODE_ATTRIBUTE_${XCODE_PROPERTY} "${XCODE_VALUE}") + else() + set_property(TARGET ${TARGET} PROPERTY + XCODE_ATTRIBUTE_${XCODE_PROPERTY}[variant=${XCODE_RELVERSION_I}] "${XCODE_VALUE}") + endif() +endmacro(set_xcode_property) +# This macro lets you find executable programs on the host system. +macro(find_host_package) + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER) + set(IOS FALSE) + find_package(${ARGN}) + set(IOS TRUE) + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +endmacro(find_host_package) diff --git a/NvCloth/Externals/CMakeModules/linux/LinuxCrossToolchain.arm-unknown-linux-gnueabihf.cmake b/NvCloth/Externals/CMakeModules/linux/LinuxCrossToolchain.arm-unknown-linux-gnueabihf.cmake new file mode 100644 index 0000000..cfe2d64 --- /dev/null +++ b/NvCloth/Externals/CMakeModules/linux/LinuxCrossToolchain.arm-unknown-linux-gnueabihf.cmake @@ -0,0 +1,37 @@ +IF(NOT $ENV{LINUX_ROOT} EQUAL "") + SET(CMAKE_SYSTEM_NAME Linux) + + # FIXME: fix Linux toolchains to support architectures + SET(LINUX_ROOT $ENV{UE_SDKS_ROOT}/HostWin64/Linux_x64/arm-unknown-linux-gnueabihf_v5_clang-3.5.0-ld-2.23.1-glibc-2.13/toolchain) + STRING(REGEX REPLACE "\\\\" "/" LINUX_ROOT ${LINUX_ROOT}) + + message (STATUS "LINUX_ROOT is '${LINUX_ROOT}'") + SET(ARCHITECTURE_TRIPLE arm-unknown-linux-gnueabihf) + + SET(CMAKE_CROSSCOMPILING TRUE) + SET(CMAKE_SYSTEM_NAME Linux) + SET(CMAKE_SYSTEM_VERSION 1) + + # sysroot + SET(CMAKE_SYSROOT ${LINUX_ROOT}) + + SET(CMAKE_LIBRARY_ARCHITECTURE ${ARCHITECTURE_TRIPLE}) + + # specify the cross compiler + SET(CMAKE_C_COMPILER ${CMAKE_SYSROOT}/bin/clang.exe) + SET(CMAKE_C_COMPILER_TARGET ${ARCHITECTURE_TRIPLE}) + SET(CMAKE_C_FLAGS "-target ${ARCHITECTURE_TRIPLE} --sysroot ${LINUX_ROOT} ") + + SET(CMAKE_CXX_COMPILER ${CMAKE_SYSROOT}/bin/clang++.exe) + SET(CMAKE_CXX_COMPILER_TARGET ${ARCHITECTURE_TRIPLE}) + SET(CMAKE_CXX_FLAGS "-target ${ARCHITECTURE_TRIPLE} --sysroot ${LINUX_ROOT} ") + + SET(CMAKE_FIND_ROOT_PATH ${LINUX_ROOT}) + #set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY) # hoping to force it to use ar + #set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) + #set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +ELSE() + MESSAGE("LINUX_ROOT environment variable not defined!") +ENDIF() + + diff --git a/NvCloth/Externals/CMakeModules/linux/LinuxCrossToolchain.x86_64-unknown-linux-gnu.cmake b/NvCloth/Externals/CMakeModules/linux/LinuxCrossToolchain.x86_64-unknown-linux-gnu.cmake new file mode 100644 index 0000000..a82d145 --- /dev/null +++ b/NvCloth/Externals/CMakeModules/linux/LinuxCrossToolchain.x86_64-unknown-linux-gnu.cmake @@ -0,0 +1,36 @@ +IF(NOT $ENV{LINUX_ROOT} EQUAL "") + SET(CMAKE_SYSTEM_NAME Linux) + + SET(LINUX_ROOT $ENV{LINUX_ROOT}) + STRING(REGEX REPLACE "\\\\" "/" LINUX_ROOT ${LINUX_ROOT}) + + message (STATUS "LINUX_ROOT is '${LINUX_ROOT}'") + SET(ARCHITECTURE_TRIPLE x86_64-unknown-linux-gnu) + + SET(CMAKE_CROSSCOMPILING TRUE) + SET(CMAKE_SYSTEM_NAME Linux) + SET(CMAKE_SYSTEM_VERSION 1) + + # sysroot + SET(CMAKE_SYSROOT ${LINUX_ROOT}) + + SET(CMAKE_LIBRARY_ARCHITECTURE ${ARCHITECTURE_TRIPLE}) + + # specify the cross compiler + SET(CMAKE_C_COMPILER ${CMAKE_SYSROOT}/bin/clang.exe) + SET(CMAKE_C_COMPILER_TARGET ${ARCHITECTURE_TRIPLE}) + SET(CMAKE_C_FLAGS "-target ${ARCHITECTURE_TRIPLE} --sysroot ${LINUX_ROOT} ") + + SET(CMAKE_CXX_COMPILER ${CMAKE_SYSROOT}/bin/clang++.exe) + SET(CMAKE_CXX_COMPILER_TARGET ${ARCHITECTURE_TRIPLE}) + SET(CMAKE_CXX_FLAGS "-target ${ARCHITECTURE_TRIPLE} --sysroot ${LINUX_ROOT} ") + + SET(CMAKE_FIND_ROOT_PATH ${LINUX_ROOT}) + #set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY) # hoping to force it to use ar + #set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) + #set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +ELSE() + MESSAGE("LINUX_ROOT environment variable not defined!") +ENDIF() + + diff --git a/NvCloth/FindNvCloth.cmake b/NvCloth/FindNvCloth.cmake index e9966a3..6ffb0a9 100644 --- a/NvCloth/FindNvCloth.cmake +++ b/NvCloth/FindNvCloth.cmake @@ -7,7 +7,7 @@ FIND_PATH( NVCLOTH_ROOT_DIR include/NvCloth/Fabric.h HINTS ${GW_DEPS_ROOT}/NvCloth - ${GW_DEPS_ROOT}/sw/devrel/libdev/NvCloth/trunk + ${GW_DEPS_ROOT}/sw/devrel/libdev/NvCloth/trunk/NvCloth NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) diff --git a/NvCloth/GenerateProjectsIOS.sh b/NvCloth/GenerateProjectsIOS.sh index aebcb18..d4acdbe 100644 --- a/NvCloth/GenerateProjectsIOS.sh +++ b/NvCloth/GenerateProjectsIOS.sh @@ -2,12 +2,8 @@ # Make sure the various variables that we need are set -export GW_DEPS_ROOT="$PWD""/../../../../../" - -if [ -e $PWD"/../Externals/CMakeModules" ]; then - export GW_DEPS_ROOT="$PWD""/../../" -fi - +export GW_DEPS_ROOT="$PWD""/../" + [ -z "$GW_DEPS_ROOT" ] && echo "GW_DEPS_ROOT not defined." && exit 1; @@ -30,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/sw/physx/tools/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" -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 72bbdda..3be88ac 100644 --- a/NvCloth/GenerateProjectsLinux.sh +++ b/NvCloth/GenerateProjectsLinux.sh @@ -2,11 +2,7 @@ # Make sure the various variables that we need are set -export GW_DEPS_ROOT="$PWD""/../../../../../" - -if [ -e $PWD"/../Externals/CMakeModules" ]; then - export GW_DEPS_ROOT="$PWD""/../" -fi +export GW_DEPS_ROOT="$PWD""/../" [ -z "$GW_DEPS_ROOT" ] && echo "GW_DEPS_ROOT not defined." && exit 1; diff --git a/NvCloth/GenerateProjectsOsx.sh b/NvCloth/GenerateProjectsOsx.sh index c52e781..7dc9b40 100644 --- a/NvCloth/GenerateProjectsOsx.sh +++ b/NvCloth/GenerateProjectsOsx.sh @@ -2,11 +2,7 @@ # Make sure the various variables that we need are set -export GW_DEPS_ROOT="$PWD""/../../../../../" - -if [ -e $PWD"/../Externals/CMakeModules" ]; then - export GW_DEPS_ROOT="$PWD""/../../" -fi +export GW_DEPS_ROOT="$PWD""/../" [ -z "$GW_DEPS_ROOT" ] && echo "GW_DEPS_ROOT not defined." && exit 1; @@ -27,12 +23,6 @@ export USE_CUDA=0 # Generate projects here -rm -r -f compiler/osx32-cmake/ -mkdir compiler/osx32-cmake/ -cd compiler/osx32-cmake/ -$CMAKE ../cmake/mac -G Xcode -DTARGET_BUILD_PLATFORM=mac -DCMAKE_OSX_ARCHITECTURES=i386 -DPX_32BIT=1 -DNV_CLOTH_ENABLE_CUDA=$USE_CUDA -DUSE_CUDA=$USE_CUDA -DPX_GENERATE_GPU_PROJECTS=0 -DPX_OUTPUT_DLL_DIR=$PX_OUTPUT_ROOT/bin/osx32-cmake -DPX_OUTPUT_LIB_DIR=$PX_OUTPUT_ROOT/lib/osx32-cmake -DPX_OUTPUT_EXE_DIR=$PX_OUTPUT_ROOT/bin/osx32-cmake || exit 1 -cd ../../ - rm -r -f compiler/osx64-cmake/ mkdir compiler/osx64-cmake/ cd compiler/osx64-cmake/ diff --git a/NvCloth/ReleaseNotes.txt b/NvCloth/ReleaseNotes.txt index 8cc2163..4ee4d78 100644 --- a/NvCloth/ReleaseNotes.txt +++ b/NvCloth/ReleaseNotes.txt @@ -4,33 +4,45 @@ NvCloth Release notes. Release Notes *************************** -1.1.5 +1.1.6 =========================================================================================== -Supported platforms: +Compatible platforms: * Windows (CPU, CUDA, DX11) * Mac (tested on Sierra) -* iOS (tested on iOS 11) * Linux (tested on Ubuntu 16.04.1 LTS x64) -* PlayStation 4 with PS4 SDK 4.5 -* Xbox one (CPU, DX11, beta) +* PlayStation 4 with PS4 SDK 6.5 +* Xbox one (CPU, DX11) * Android (arm64-v8a, API >= 21), tested on Shield TV -* Switch (SDK 3.5.0) +* Switch (SDK 8.0.0) -Supported compilers (via cmake 3.7) +Compatible compilers (via cmake 3.7) * Windows: Visual Studio 12, 14 (2013, 2015) * Linux: gcc 5.4 (only x64) -* Mac: xcode -* iOS: tested with XCode 9 (Apple LLVM) +* Mac: XCode 10.1 +* iOS: tested with XCode 10.1 (Apple LLVM) * PlayStation 4: Visual studio 14 (2015) * Xbox one: Visual studio 14 (2015) -* Android: NDK r12b and above +* Android: NDK r15c * Switch: Visual studio 14 (2015) Fixed: +- Now compatible with the same PxShared version as PhysX 4.0 + +New: +- New setPlanes and setSpheres API. + +Known issues: +- None + +1.1.5 +=========================================================================================== + +Fixed: + - Wind simulation code could affect particle masses (especially when high drag/lift coefficients were used) - Fixed PS4 mising override error. - Fix setCapsules bug. diff --git a/NvCloth/Tools/AuthoringLibrary/CMakeLists.txt b/NvCloth/Tools/AuthoringLibrary/CMakeLists.txt index e9702e3..dcb583a 100644 --- a/NvCloth/Tools/AuthoringLibrary/CMakeLists.txt +++ b/NvCloth/Tools/AuthoringLibrary/CMakeLists.txt @@ -4,6 +4,14 @@ project(NvClothAuthoringLibrary CXX) CMAKE_POLICY(SET CMP0057 NEW) # Enable IN_LIST +SET(GW_DEPS_ROOT $ENV{GW_DEPS_ROOT}) + +SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}; $ENV{GW_DEPS_ROOT}/Externals/CMakeModules) + + +SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}; "${CMAKE_CURRENT_SOURCE_DIR}/../..") +SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}; "${CMAKE_CURRENT_SOURCE_DIR}/external/CMakeModules") + IF(NOT DEFINED AUTHORINGLIBRARY_ROOT_DIR) STRING(REPLACE "\\" "/" BRD_TEMP $ENV{AUTHORINGLIBRARY_ROOT_DIR}) @@ -17,8 +25,6 @@ IF(NOT EXISTS ${AUTHORINGLIBRARY_ROOT_DIR}) MESSAGE(FATAL_ERROR "AUTHORINGLIBRARY_ROOT_DIR environment variable wasn't set or was invalid.") ENDIF() -SET(GW_DEPS_ROOT "${AUTHORINGLIBRARY_ROOT_DIR}/external") - SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${GW_DEPS_ROOT}/CMakeModules") MESSAGE("AUTHORINGLIBRARY_ROOT_DIR:" ${AUTHORINGLIBRARY_ROOT_DIR}) diff --git a/NvCloth/Tools/AuthoringLibrary/CmakeGenerateProjects.bat b/NvCloth/Tools/AuthoringLibrary/CmakeGenerateProjects.bat index e3a297c..7b51db9 100644 --- a/NvCloth/Tools/AuthoringLibrary/CmakeGenerateProjects.bat +++ b/NvCloth/Tools/AuthoringLibrary/CmakeGenerateProjects.bat @@ -1,8 +1,10 @@ CD /D %~dp0 +set GW_DEPS_ROOT=%~dp0..\..\..\ echo "Note: You need to run this with admin rights for the first time to set GW_DEPS_ROOT globally." -call "../../scripts/locate_gw_root.bat" GW_DEPS_ROOT_F -@echo on -setx GW_DEPS_ROOT "%GW_DEPS_ROOT_F% +REM single " is not a mistake +setx GW_DEPS_ROOT "%GW_DEPS_ROOT% +REM this one is for local use +set GW_DEPS_ROOT=%GW_DEPS_ROOT% echo GW_DEPS_ROOT = %GW_DEPS_ROOT% REM Install cmake using packman @@ -27,11 +29,4 @@ pushd compiler\vc14win64-cmake\ popd -rmdir /s /q compiler\vc14win32-cmake\ -mkdir compiler\vc14win32-cmake\ -pushd compiler\vc14win32-cmake\ -%CMAKE% ..\.. -G "Visual Studio 14 2015" -AWin32 -DTARGET_BUILD_PLATFORM=windows -DSTATIC_WINCRT=0 -DBL_DLL_OUTPUT_DIR=%OUTPUT_ROOT%\bin\vc14win32-cmake -DBL_LIB_OUTPUT_DIR=%OUTPUT_ROOT%\lib\vc14win32-cmake -DBL_EXE_OUTPUT_DIR=%OUTPUT_ROOT%\bin\vc14win32-cmake - -popd - pause diff --git a/NvCloth/Tools/AuthoringLibrary/compiler/cmake/AuthoringLibrary.cmake b/NvCloth/Tools/AuthoringLibrary/compiler/cmake/AuthoringLibrary.cmake index e649116..6caab92 100644 --- a/NvCloth/Tools/AuthoringLibrary/compiler/cmake/AuthoringLibrary.cmake +++ b/NvCloth/Tools/AuthoringLibrary/compiler/cmake/AuthoringLibrary.cmake @@ -65,7 +65,6 @@ SET_TARGET_PROPERTIES(NvClothAuthoringLibrary PROPERTIES TARGET_COMPILE_OPTIONS(NvClothAuthoringLibrary PRIVATE /wd4005 /wd4244) -TARGET_LINK_LIBRARIES(NvClothAuthoringLibrary PUBLIC PxFoundation) TARGET_LINK_LIBRARIES(NvClothAuthoringLibrary PUBLIC NvCloth) SET_TARGET_PROPERTIES(NvClothAuthoringLibrary PROPERTIES LINK_FLAGS ${AUTHORINGLIBRARY_LINK_FLAGS}) diff --git a/NvCloth/Tools/AuthoringLibrary/compiler/cmake/windows/AuthoringLibrary.cmake b/NvCloth/Tools/AuthoringLibrary/compiler/cmake/windows/AuthoringLibrary.cmake index 88a3dd5..5b4c180 100644 --- a/NvCloth/Tools/AuthoringLibrary/compiler/cmake/windows/AuthoringLibrary.cmake +++ b/NvCloth/Tools/AuthoringLibrary/compiler/cmake/windows/AuthoringLibrary.cmake @@ -29,7 +29,7 @@ if (CMAKE_CL_64) SET(D3DCOMPILER_DLL "\"$(VC_ExecutablePath_x64_x64)/d3dcompiler_47.dll\"") - SET(ASSIMP_DLLS ${ASSIMP_DLL_PATH}/Release/assimp-vc140-mt.dll) +# SET(ASSIMP_DLLS ${ASSIMP_DLL_PATH}/Release/assimp-vc140-mt.dll) else() SET(SHADOW_LIB ${NVCLOTH_ROOT_DIR}/samples/external/shadow_lib/GFSDK_ShadowLib_DX11.win32.lib) SET(SHADOW_DLLS ${NVCLOTH_ROOT_DIR}/samples/external/shadow_lib/GFSDK_ShadowLib_DX11.win32.dll) @@ -39,6 +39,6 @@ else() SET(D3DCOMPILER_DLL "\"$(VC_ExecutablePath_x86_x86)/d3dcompiler_47.dll\"") - SET(ASSIMP_DLLS ${ASSIMP_DLL_PATH}/Release/assimp-vc140-mt.dll) +# SET(ASSIMP_DLLS ${ASSIMP_DLL_PATH}/Release/assimp-vc140-mt.dll) endif() diff --git a/NvCloth/Tools/AuthoringLibrary/compiler/cmake/windows/CMakeLists.txt b/NvCloth/Tools/AuthoringLibrary/compiler/cmake/windows/CMakeLists.txt index fd9d4bd..7670847 100644 --- a/NvCloth/Tools/AuthoringLibrary/compiler/cmake/windows/CMakeLists.txt +++ b/NvCloth/Tools/AuthoringLibrary/compiler/cmake/windows/CMakeLists.txt @@ -1,20 +1,5 @@ #Platform specific compile flags and project includes -SET(GW_DEPS_ROOT $ENV{GW_DEPS_ROOT}) - -SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}; $ENV{GW_DEPS_ROOT}/sw/physx/tools/CMakeModules) - -IF(EXISTS $ENV{GW_DEPS_ROOT}/Externals/CMakeModules) - SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}; $ENV{GW_DEPS_ROOT}/Externals/CMakeModules) -ENDIF() - - -IF(EXISTS $ENV{GW_DEPS_ROOT}/Externals/CMakeModules) - SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}; $ENV{GW_DEPS_ROOT}/Externals/CMakeModules) -ENDIF() - -SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}; "${CMAKE_CURRENT_SOURCE_DIR}/../..") -SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}; "${CMAKE_CURRENT_SOURCE_DIR}/external/CMakeModules") MESSAGE("CMAKE_MODULE_PATH: " ${CMAKE_MODULE_PATH}) #NOTE: Warnings lowered on the sample projects as it's got a lot of warnings. Defines below hide more. @@ -67,11 +52,6 @@ SET(PX_SELECT_COMPONENTS PxFoundation) FIND_PACKAGE(PxShared REQUIRED) FIND_PACKAGE(NvCloth REQUIRED) -# Include the PxShared-exports.cmake file that PxShared created. There's other ways to do this, but there's a bunch of issues with it in a CI environment -# such as - we don't want to be installing any built artifacts on this server, etc. So for now we hack it. - -# Add PxShared as a dependency so that we can use project references -#ADD_SUBDIRECTORY(${PXSHARED_ROOT_DIR}/src/compiler/cmake/windows "${CMAKE_CURRENT_BINARY_DIR}/pxshared_bin") #MESSAGE("NVCLOTH_ROOT_DIR = ${NVCLOTH_ROOT_DIR}") ADD_SUBDIRECTORY(${NVCLOTH_ROOT_DIR}/compiler/cmake/windows "${CMAKE_CURRENT_BINARY_DIR}/NvCloth_bin") diff --git a/NvCloth/compiler/cmake/android/CMakeLists.txt b/NvCloth/compiler/cmake/android/CMakeLists.txt index 61a6892..7ef0673 100644 --- a/NvCloth/compiler/cmake/android/CMakeLists.txt +++ b/NvCloth/compiler/cmake/android/CMakeLists.txt @@ -44,19 +44,7 @@ SET(NVCLOTH_ANDROID_RELEASE_COMPILE_DEFS NDEBUG) SET(PX_SELECT_COMPONENTS PxFoundation) FIND_PACKAGE(PxShared REQUIRED) -################################################################################ -# TODO -################################################################################ -# Include the PxShared-exports.cmake file that PxShared created. There's other ways to do this, but there's a bunch of issues with it in a CI environment -# such as - we don't want to be installing any built artifacts on this server, etc. So for now we hack it. - -# Add PxShared as a dependency so that we can use project references -#ADD_SUBDIRECTORY(${PXSHARED_ROOT_DIR}/src/compiler/cmake/android "${CMAKE_CURRENT_BINARY_DIR}/pxshared_bin") -################################################################################ - # Include all of the projects INCLUDE(NvCloth.cmake) -TARGET_LINK_LIBRARIES(NvCloth PUBLIC PxFoundation) - MESSAGE("[NvCloth]cmake/android/CMakeList.txt END")
\ No newline at end of file diff --git a/NvCloth/compiler/cmake/android/NvCloth.cmake b/NvCloth/compiler/cmake/android/NvCloth.cmake index 544a3b5..8463368 100644 --- a/NvCloth/compiler/cmake/android/NvCloth.cmake +++ b/NvCloth/compiler/cmake/android/NvCloth.cmake @@ -7,6 +7,11 @@ SET(GW_DEPS_ROOT $ENV{GW_DEPS_ROOT}) SET(NVCLOTH_SOURCE_DIR ${PROJECT_SOURCE_DIR}/../../../) 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 diff --git a/NvCloth/compiler/cmake/common/CMakeLists.txt b/NvCloth/compiler/cmake/common/CMakeLists.txt index eddb1d9..bbebc3f 100644 --- a/NvCloth/compiler/cmake/common/CMakeLists.txt +++ b/NvCloth/compiler/cmake/common/CMakeLists.txt @@ -8,18 +8,10 @@ CMAKE_POLICY(SET CMP0057 NEW) # Enable IN_LIST SET(GW_DEPS_ROOT $ENV{GW_DEPS_ROOT}) -SET(CMAKE_MODULE_PATH $ENV{GW_DEPS_ROOT}/sw/physx/tools/CMakeModules) - -IF(EXISTS $ENV{GW_DEPS_ROOT}/Externals/CMakeModules) - SET(CMAKE_MODULE_PATH $ENV{GW_DEPS_ROOT}/Externals/CMakeModules) -ENDIF() +SET(CMAKE_MODULE_PATH $ENV{GW_DEPS_ROOT}/NvCloth/Externals/CMakeModules) MESSAGE( "[NvCloth]cmake/common CMAKE_MODULE_PATH = ${CMAKE_MODULE_PATH}") -IF(EXISTS $ENV{GW_DEPS_ROOT}/Externals/CMakeModules) - SET(CMAKE_MODULE_PATH $ENV{GW_DEPS_ROOT}/Externals/CMakeModules) -ENDIF() - # Add find modules to the path IF(NOT EXISTS ${CMAKE_MODULE_PATH}) MESSAGE(FATAL_ERROR "Could not find CMakeModules at ${CMAKE_MODULE_PATH}") diff --git a/NvCloth/compiler/cmake/common/NvCloth.cmake b/NvCloth/compiler/cmake/common/NvCloth.cmake index 94b7e79..8d59261 100644 --- a/NvCloth/compiler/cmake/common/NvCloth.cmake +++ b/NvCloth/compiler/cmake/common/NvCloth.cmake @@ -20,6 +20,21 @@ SET( NV_CLOTH_SOURCE_LIST ${PROJECT_ROOT_DIR}/include/NvCloth/Range.h ${PROJECT_ROOT_DIR}/include/NvCloth/Solver.h + ${PROJECT_ROOT_DIR}/include/NvCloth/ps/Ps.h + ${PROJECT_ROOT_DIR}/include/NvCloth/ps/PsAtomic.h + ${PROJECT_ROOT_DIR}/include/NvCloth/ps/PsAlignedMalloc.h + ${PROJECT_ROOT_DIR}/include/NvCloth/ps/PsAllocator.h + ${PROJECT_ROOT_DIR}/include/NvCloth/ps/PsAllocator.cpp + ${PROJECT_ROOT_DIR}/include/NvCloth/ps/PsArray.h + ${PROJECT_ROOT_DIR}/include/NvCloth/ps/PsBasicTemplates.h + ${PROJECT_ROOT_DIR}/include/NvCloth/ps/PsBitUtils.h + ${PROJECT_ROOT_DIR}/include/NvCloth/ps/PsHash.h + ${PROJECT_ROOT_DIR}/include/NvCloth/ps/PsHashInternals.h + ${PROJECT_ROOT_DIR}/include/NvCloth/ps/PsHashMap.h + ${PROJECT_ROOT_DIR}/include/NvCloth/ps/PsIntrinsics.h + ${PROJECT_ROOT_DIR}/include/NvCloth/ps/PsUserAllocated.h + ${PROJECT_ROOT_DIR}/include/NvCloth/ps/PsMathUtils.h + ${PROJECT_ROOT_DIR}/src/Allocator.cpp ${PROJECT_ROOT_DIR}/src/BoundingBox.h ${PROJECT_ROOT_DIR}/src/Callbacks.cpp @@ -119,6 +134,13 @@ SET( NV_CLOTH_SOURCE_LIST ${PROJECT_ROOT_DIR}/src/sse2/SwCollisionHelpers.h ${PROJECT_ROOT_DIR}/src/sse2/SwSolveConstraints.h + ${PROJECT_ROOT_DIR}/src/ps/PsAlloca.h + ${PROJECT_ROOT_DIR}/src/ps/PsFPU.h + ${PROJECT_ROOT_DIR}/src/ps/PsSort.h + ${PROJECT_ROOT_DIR}/src/ps/PsSortInternals.h + ${PROJECT_ROOT_DIR}/src/ps/PsUtilities.h + ${PROJECT_ROOT_DIR}/src/ps/PxIntrinsics.h + ${PROJECT_ROOT_DIR}/extensions/include/NvClothExt/ClothFabricCooker.h ${PROJECT_ROOT_DIR}/extensions/include/NvClothExt/ClothMeshDesc.h ${PROJECT_ROOT_DIR}/extensions/include/NvClothExt/ClothMeshQuadifier.h @@ -178,4 +200,4 @@ IF(NOT ${NVCLOTH_LIBTYPE} STREQUAL "OBJECT") COMPILE_PDB_NAME_RELEASE "NvCloth${CMAKE_RELEASE_POSTFIX}" ) ENDIF() -MESSAGE("[NvCloth]cmake/common/NvCloth.cmake END")
\ No newline at end of file +MESSAGE("[NvCloth]cmake/common/NvCloth.cmake END") diff --git a/NvCloth/compiler/cmake/ios/CMakeLists.txt b/NvCloth/compiler/cmake/ios/CMakeLists.txt index c0c890e..bf36e95 100644 --- a/NvCloth/compiler/cmake/ios/CMakeLists.txt +++ b/NvCloth/compiler/cmake/ios/CMakeLists.txt @@ -13,7 +13,7 @@ IF (NOT ${TARGET_BUILD_PLATFORM} IN_LIST PLATFORM_LIST) MESSAGE(FATAL_ERROR "Invalid platform:" ${TARGET_BUILD_PLATFORM}) ENDIF() -SET(CMAKE_CXX_FLAGS "-std=c++11 -fno-rtti -fno-exceptions -ffast-math -ffunction-sections -fdata-sections -Werror -ferror-limit=0 -Wall -Wextra -fstrict-aliasing -Wstrict-aliasing=2 -Weverything -Wno-documentation-deprecated-sync -Wno-documentation-unknown-command -Wno-float-equal -Wno-padded -Wno-weak-vtables -Wno-cast-align -Wno-conversion -Wno-missing-noreturn -Wno-missing-variable-declarations -Wno-shift-sign-overflow -Wno-covered-switch-default -Wno-exit-time-destructors -Wno-global-constructors -Wno-missing-prototypes -Wno-unreachable-code -Wno-unused-macros -Wno-unused-member-function -Wno-used-but-marked-unused -Wno-weak-template-vtables -Wno-deprecated -Wno-non-virtual-dtor -Wno-invalid-noreturn -Wno-return-type-c-linkage -Wno-reserved-id-macro -Wno-c++98-compat-pedantic -Wno-unused-local-typedef -Wno-old-style-cast -Wno-newline-eof -Wno-unused-private-field -Wno-undefined-reinterpret-cast -Wno-invalid-offsetof -gdwarf-2 -Wno-unused-value -Wno-format-nonliteral -Wno-undef -Wno-double-promotion") +SET(CMAKE_CXX_FLAGS "-std=c++11 -fno-rtti -fno-exceptions -ffast-math -ffunction-sections -fdata-sections -Werror -ferror-limit=0 -Wall -Wextra -fstrict-aliasing -Wstrict-aliasing=2 -Weverything -Wno-documentation-deprecated-sync -Wno-documentation-unknown-command -Wno-float-equal -Wno-padded -Wno-weak-vtables -Wno-cast-align -Wno-conversion -Wno-missing-noreturn -Wno-missing-variable-declarations -Wno-shift-sign-overflow -Wno-covered-switch-default -Wno-exit-time-destructors -Wno-global-constructors -Wno-missing-prototypes -Wno-unreachable-code -Wno-unused-macros -Wno-unused-member-function -Wno-used-but-marked-unused -Wno-weak-template-vtables -Wno-deprecated -Wno-non-virtual-dtor -Wno-invalid-noreturn -Wno-return-type-c-linkage -Wno-reserved-id-macro -Wno-c++98-compat-pedantic -Wno-unused-local-typedef -Wno-old-style-cast -Wno-newline-eof -Wno-unused-private-field -Wno-undefined-reinterpret-cast -Wno-invalid-offsetof -gdwarf-2 -Wno-unused-value -Wno-format-nonliteral -Wno-undef -Wno-double-promotion -Wno-zero-as-null-pointer-constant") SET(CMAKE_SHARED_LINKER_FLAGS "") # Build debug info for all configurations @@ -37,12 +37,6 @@ SET(PHYSX_IOS_RELEASE_COMPILE_DEFS NDEBUG;PX_SUPPORT_PVD=0) SET(PX_SELECT_COMPONENTS PxFoundation) FIND_PACKAGE(PxShared REQUIRED) -# Include the PxShared-exports.cmake file that PxShared created. There's other ways to do this, but there's a bunch of issues with it in a CI environment -# such as - we don't want to be installing any built artifacts on this server, etc. So for now we hack it. - -# Add PxShared as a dependency so that we can use project references -ADD_SUBDIRECTORY(${PXSHARED_ROOT_DIR}/src/compiler/cmake/ios "${CMAKE_CURRENT_BINARY_DIR}/pxshared_bin") - # Include all of the projects INCLUDE(NvCloth.cmake) diff --git a/NvCloth/compiler/cmake/ios/NvCloth.cmake b/NvCloth/compiler/cmake/ios/NvCloth.cmake index e837e4a..2da5516 100644 --- a/NvCloth/compiler/cmake/ios/NvCloth.cmake +++ b/NvCloth/compiler/cmake/ios/NvCloth.cmake @@ -42,11 +42,6 @@ SET(NVCLOTH_LIBTYPE STATIC) INCLUDE(../common/NvCloth.cmake) -# Add linked libraries -# TARGET_LINK_LIBRARIES(NvCloth PUBLIC ${NVTOOLSEXT_LIBRARIES} LowLevel LowLevelAABB LowLevelCloth LowLevelDynamics LowLevelParticles PhysXCommon PhysXGpu PxFoundation PxPvdSDK PxTask SceneQuery SimulationController) - -TARGET_LINK_LIBRARIES(NvCloth PUBLIC PxFoundation) - SET_TARGET_PROPERTIES(NvCloth PROPERTIES LINK_FLAGS_DEBUG "" LINK_FLAGS_CHECKED "" diff --git a/NvCloth/compiler/cmake/linux/CMakeLists.txt b/NvCloth/compiler/cmake/linux/CMakeLists.txt index 5bd8323..f8ba400 100644 --- a/NvCloth/compiler/cmake/linux/CMakeLists.txt +++ b/NvCloth/compiler/cmake/linux/CMakeLists.txt @@ -43,12 +43,6 @@ SET(PHYSX_LINUX_RELEASE_COMPILE_DEFS NDEBUG;PX_SUPPORT_PVD=0) SET(PX_SELECT_COMPONENTS PxFoundation) FIND_PACKAGE(PxShared REQUIRED) -# Include the PxShared-exports.cmake file that PxShared created. There's other ways to do this, but there's a bunch of issues with it in a CI environment -# such as - we don't want to be installing any built artifacts on this server, etc. So for now we hack it. - -# Add PxShared as a dependency so that we can use project references -ADD_SUBDIRECTORY(${PXSHARED_ROOT_DIR}/src/compiler/cmake/linux "${CMAKE_CURRENT_BINARY_DIR}/pxshared_bin") - # Include all of the projects INCLUDE(NvCloth.cmake) diff --git a/NvCloth/compiler/cmake/linux/NvCloth.cmake b/NvCloth/compiler/cmake/linux/NvCloth.cmake index 1d53df6..64188f0 100644 --- a/NvCloth/compiler/cmake/linux/NvCloth.cmake +++ b/NvCloth/compiler/cmake/linux/NvCloth.cmake @@ -30,6 +30,8 @@ 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 @@ -128,11 +130,6 @@ ENDIF() # include common NvCloth settings INCLUDE(../common/NvCloth.cmake) - -# Add linked libraries -# TARGET_LINK_LIBRARIES(NvCloth PUBLIC ${NVTOOLSEXT_LIBRARIES} LowLevel LowLevelAABB LowLevelCloth LowLevelDynamics LowLevelParticles PhysXCommon PhysXGpu PxFoundation PxPvdSDK PxTask SceneQuery SimulationController) - -TARGET_LINK_LIBRARIES(NvCloth PUBLIC PxFoundation) TARGET_LINK_LIBRARIES(NvCloth PUBLIC ${CUDA_CUDA_LIBRARY}) SET_TARGET_PROPERTIES(NvCloth PROPERTIES @@ -144,4 +141,4 @@ SET_TARGET_PROPERTIES(NvCloth PROPERTIES # enable -fPIC so we can link static libs with the editor SET_TARGET_PROPERTIES(NvCloth PROPERTIES POSITION_INDEPENDENT_CODE TRUE) -MESSAGE("[NvCloth]cmake/linux/NvCloth.cmake END")
\ No newline at end of file +MESSAGE("[NvCloth]cmake/linux/NvCloth.cmake END") diff --git a/NvCloth/compiler/cmake/mac/CMakeLists.txt b/NvCloth/compiler/cmake/mac/CMakeLists.txt index 83ca14d..903e545 100644 --- a/NvCloth/compiler/cmake/mac/CMakeLists.txt +++ b/NvCloth/compiler/cmake/mac/CMakeLists.txt @@ -45,12 +45,6 @@ SET(PHYSX_MAC_RELEASE_COMPILE_DEFS NDEBUG;PX_SUPPORT_PVD=0) SET(PX_SELECT_COMPONENTS PxFoundation) FIND_PACKAGE(PxShared REQUIRED) -# Include the PxShared-exports.cmake file that PxShared created. There's other ways to do this, but there's a bunch of issues with it in a CI environment -# such as - we don't want to be installing any built artifacts on this server, etc. So for now we hack it. - -# Add PxShared as a dependency so that we can use project references -ADD_SUBDIRECTORY(${PXSHARED_ROOT_DIR}/src/compiler/cmake/mac "${CMAKE_CURRENT_BINARY_DIR}/pxshared_bin") - # Include all of the projects INCLUDE(NvCloth.cmake) diff --git a/NvCloth/compiler/cmake/mac/NvCloth.cmake b/NvCloth/compiler/cmake/mac/NvCloth.cmake index faea6fd..086b508 100644 --- a/NvCloth/compiler/cmake/mac/NvCloth.cmake +++ b/NvCloth/compiler/cmake/mac/NvCloth.cmake @@ -15,6 +15,8 @@ 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 @@ -42,11 +44,6 @@ SET(NVCLOTH_LIBTYPE SHARED) INCLUDE(../common/NvCloth.cmake) -# Add linked libraries -# TARGET_LINK_LIBRARIES(NvCloth PUBLIC ${NVTOOLSEXT_LIBRARIES} LowLevel LowLevelAABB LowLevelCloth LowLevelDynamics LowLevelParticles PhysXCommon PhysXGpu PxFoundation PxPvdSDK PxTask SceneQuery SimulationController) - -TARGET_LINK_LIBRARIES(NvCloth PUBLIC PxFoundation) - SET_TARGET_PROPERTIES(NvCloth PROPERTIES LINK_FLAGS_DEBUG "" LINK_FLAGS_CHECKED "" diff --git a/NvCloth/compiler/cmake/windows/CMakeLists.txt b/NvCloth/compiler/cmake/windows/CMakeLists.txt index 9e8f66b..30f2a65 100644 --- a/NvCloth/compiler/cmake/windows/CMakeLists.txt +++ b/NvCloth/compiler/cmake/windows/CMakeLists.txt @@ -69,12 +69,6 @@ SET(CMAKE_RELEASE_POSTFIX "${CMAKE_RELEASE_POSTFIX}_${LIBPATH_SUFFIX}") SET(PX_SELECT_COMPONENTS PxFoundation) FIND_PACKAGE(PxShared REQUIRED) -# Include the PxShared-exports.cmake file that PxShared created. There's other ways to do this, but there's a bunch of issues with it in a CI environment -# such as - we don't want to be installing any built artifacts on this server, etc. So for now we hack it. - -# Add PxShared as a dependency so that we can use project references -ADD_SUBDIRECTORY(${PXSHARED_ROOT_DIR}/src/compiler/cmake/windows "${CMAKE_CURRENT_BINARY_DIR}/pxshared_bin") - # Include all of the projects INCLUDE(NvCloth.cmake) IF(DEFINED PX_GENERATE_GPU_PROJECTS) diff --git a/NvCloth/compiler/cmake/windows/NvCloth.cmake b/NvCloth/compiler/cmake/windows/NvCloth.cmake index cc8ca0f..065ea18 100644 --- a/NvCloth/compiler/cmake/windows/NvCloth.cmake +++ b/NvCloth/compiler/cmake/windows/NvCloth.cmake @@ -23,7 +23,11 @@ ENDIF() SET(NVCLOTH_PLATFORM_INCLUDES PRIVATE ${CUDA_INCLUDE_DIRS}) -SET(NVCLOTH_PLATFORM_SOURCE_FILES "" ) +SET(NVCLOTH_PLATFORM_SOURCE_FILES + ${PROJECT_ROOT_DIR}/src/ps/windows/PsWindowsAtomic.cpp + ${PROJECT_ROOT_DIR}/src/ps/windows/PsWindowsFPU.h + ${PROJECT_ROOT_DIR}/src/ps/windows/PsWindowsInclude.h +) IF(${NV_CLOTH_ENABLE_CUDA}) LIST(APPEND NVCLOTH_PLATFORM_SOURCE_FILES ${PROJECT_ROOT_DIR}/src/cuda/CuCheckSuccess.h @@ -48,6 +52,7 @@ LIST(APPEND NVCLOTH_PLATFORM_SOURCE_FILES ${PROJECT_ROOT_DIR}/src/cuda/CuSolver.h ${PROJECT_ROOT_DIR}/src/cuda/CuSolverKernel.h ${PROJECT_ROOT_DIR}/src/cuda/CuSolverKernelBlob.h + ${PROJECT_ROOT_DIR}/include/NvCloth/ps/windows/PsWindowsIntrinsics.h ) ENDIF() @@ -164,13 +169,12 @@ INCLUDE(../common/NvCloth.cmake) # Add linked libraries -TARGET_LINK_LIBRARIES(NvCloth PUBLIC PxFoundation) TARGET_LINK_LIBRARIES(NvCloth PUBLIC ${CUDA_CUDA_LIBRARY}) SET_TARGET_PROPERTIES(NvCloth PROPERTIES - LINK_FLAGS_DEBUG "/DELAYLOAD:nvcuda.dll /MAP /DELAYLOAD:PxFoundationDEBUG_${LIBPATH_SUFFIX}.dll /DEBUG" - LINK_FLAGS_CHECKED "/DELAYLOAD:nvcuda.dll /MAP /DELAYLOAD:PxFoundationCHECKED_${LIBPATH_SUFFIX}.dll" - LINK_FLAGS_PROFILE "/DELAYLOAD:nvcuda.dll /MAP /DELAYLOAD:PxFoundationPROFILE_${LIBPATH_SUFFIX}.dll /INCREMENTAL:NO /DEBUG" - LINK_FLAGS_RELEASE "/DELAYLOAD:nvcuda.dll /MAP /DELAYLOAD:PxFoundation_${LIBPATH_SUFFIX}.dll /INCREMENTAL:NO" + LINK_FLAGS_DEBUG "/DELAYLOAD:nvcuda.dll /MAP /DEBUG" + LINK_FLAGS_CHECKED "/DELAYLOAD:nvcuda.dll /MAP " + LINK_FLAGS_PROFILE "/DELAYLOAD:nvcuda.dll /MAP /INCREMENTAL:NO /DEBUG" + LINK_FLAGS_RELEASE "/DELAYLOAD:nvcuda.dll /MAP /INCREMENTAL:NO" ) MESSAGE("[NvCloth]cmake/windows/NvCloth.cmake END")
\ No newline at end of file diff --git a/NvCloth/docs/documentation/CollisionDetection/Index.html b/NvCloth/docs/documentation/CollisionDetection/Index.html index b6b9501..ff23dc0 100644 --- a/NvCloth/docs/documentation/CollisionDetection/Index.html +++ b/NvCloth/docs/documentation/CollisionDetection/Index.html @@ -7,7 +7,7 @@ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="x-ua-compatible" content="IE=Edge"/> - <title>Internal collision detection documentation — NvCloth 1.1.3 documentation</title> + <title>Internal collision detection documentation — NvCloth 1.1.5 documentation</title> <link rel="stylesheet" href="../_static/default.css" type="text/css" /> <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> @@ -18,7 +18,7 @@ <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '../', - VERSION: '1.1.3', + VERSION: '1.1.5', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true @@ -31,7 +31,7 @@ <script type="text/javascript" src="../_static/bootstrap.js"></script> <script type="text/javascript" src="../_static/jquery.cookie.js"></script> <script type="text/javascript" src="../_static/jquery.storageapi.js"></script> - <link rel="top" title="NvCloth 1.1.3 documentation" href="../index.html" /> + <link rel="top" title="NvCloth 1.1.5 documentation" href="../index.html" /> <link rel="next" title="Sphere Capsule collision detection" href="SphereCapsuleCollision.html" /> <link rel="prev" title="Internal solver function/algorithm documentation" href="../Solver/Index.html" /> </head> @@ -57,7 +57,7 @@ <div class="masthead"> <div class="row"> <ul class="breadcrumb"> - <li><a href="../index.html">NvCloth 1.1.3 documentation</a></li> + <li><a href="../index.html">NvCloth 1.1.5 documentation</a></li> </ul> </div> </div> @@ -252,7 +252,7 @@ <div class="masthead"> <div class="row"> <ul class="breadcrumb"> - <li><a href="../index.html">NvCloth 1.1.3 documentation</a></li> + <li><a href="../index.html">NvCloth 1.1.5 documentation</a></li> </ul> </div> </div> @@ -261,7 +261,7 @@ <div class="footer-boilerplate"> <div class="row"> <div class="boilerplate"> - Copyright © 2014, NVIDIA Corporation | <a href="http://www.nvidia.com/object/about-nvidia.html" onclick="s_objectID="http://www.nvidia.com/object/about-nvidia.html_1";return this.s_oc?this.s_oc(e):true">About NVIDIA </a> | <a href="http://www.nvidia.com/object/legal_info.html" onclick="s_objectID="http://www.nvidia.com/object/legal_info.html_1";return this.s_oc?this.s_oc(e):true">Legal Information </a> | <a href="http://www.nvidia.com/object/privacy_policy.html" onclick="s_objectID="http://www.nvidia.com/object/privacy_policy.html_1";return this.s_oc?this.s_oc(e):true">Privacy Policy </a> + Copyright © 2019, NVIDIA Corporation | <a href="http://www.nvidia.com/object/about-nvidia.html" onclick="s_objectID="http://www.nvidia.com/object/about-nvidia.html_1";return this.s_oc?this.s_oc(e):true">About NVIDIA </a> | <a href="http://www.nvidia.com/object/legal_info.html" onclick="s_objectID="http://www.nvidia.com/object/legal_info.html_1";return this.s_oc?this.s_oc(e):true">Legal Information </a> | <a href="http://www.nvidia.com/object/privacy_policy.html" onclick="s_objectID="http://www.nvidia.com/object/privacy_policy.html_1";return this.s_oc?this.s_oc(e):true">Privacy Policy </a> </div> </div> </div> diff --git a/NvCloth/docs/documentation/CollisionDetection/InterCollision.html b/NvCloth/docs/documentation/CollisionDetection/InterCollision.html index fb561dd..9928cbe 100644 --- a/NvCloth/docs/documentation/CollisionDetection/InterCollision.html +++ b/NvCloth/docs/documentation/CollisionDetection/InterCollision.html @@ -7,7 +7,7 @@ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="x-ua-compatible" content="IE=Edge"/> - <title>Inter Collision — NvCloth 1.1.3 documentation</title> + <title>Inter Collision — NvCloth 1.1.5 documentation</title> <link rel="stylesheet" href="../_static/default.css" type="text/css" /> <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> @@ -18,7 +18,7 @@ <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '../', - VERSION: '1.1.3', + VERSION: '1.1.5', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true @@ -31,7 +31,7 @@ <script type="text/javascript" src="../_static/bootstrap.js"></script> <script type="text/javascript" src="../_static/jquery.cookie.js"></script> <script type="text/javascript" src="../_static/jquery.storageapi.js"></script> - <link rel="top" title="NvCloth 1.1.3 documentation" href="../index.html" /> + <link rel="top" title="NvCloth 1.1.5 documentation" href="../index.html" /> <link rel="up" title="Internal collision detection documentation" href="Index.html" /> <link rel="next" title="Internal cooking documentation" href="../Cooking/Index.html" /> <link rel="prev" title="Self Collision" href="SelfCollision.html" /> @@ -58,7 +58,7 @@ <div class="masthead"> <div class="row"> <ul class="breadcrumb"> - <li><a href="../index.html">NvCloth 1.1.3 documentation</a></li> + <li><a href="../index.html">NvCloth 1.1.5 documentation</a></li> <li><a href="Index.html" accesskey="U">Internal collision detection documentation</a></li> </ul> </div> @@ -281,7 +281,7 @@ Now the narrow phase only has to deal with the particles in those lists.</p> <div class="masthead"> <div class="row"> <ul class="breadcrumb"> - <li><a href="../index.html">NvCloth 1.1.3 documentation</a></li> + <li><a href="../index.html">NvCloth 1.1.5 documentation</a></li> <li><a href="Index.html" >Internal collision detection documentation</a></li> </ul> </div> @@ -291,7 +291,7 @@ Now the narrow phase only has to deal with the particles in those lists.</p> <div class="footer-boilerplate"> <div class="row"> <div class="boilerplate"> - Copyright © 2014, NVIDIA Corporation | <a href="http://www.nvidia.com/object/about-nvidia.html" onclick="s_objectID="http://www.nvidia.com/object/about-nvidia.html_1";return this.s_oc?this.s_oc(e):true">About NVIDIA </a> | <a href="http://www.nvidia.com/object/legal_info.html" onclick="s_objectID="http://www.nvidia.com/object/legal_info.html_1";return this.s_oc?this.s_oc(e):true">Legal Information </a> | <a href="http://www.nvidia.com/object/privacy_policy.html" onclick="s_objectID="http://www.nvidia.com/object/privacy_policy.html_1";return this.s_oc?this.s_oc(e):true">Privacy Policy </a> + Copyright © 2019, NVIDIA Corporation | <a href="http://www.nvidia.com/object/about-nvidia.html" onclick="s_objectID="http://www.nvidia.com/object/about-nvidia.html_1";return this.s_oc?this.s_oc(e):true">About NVIDIA </a> | <a href="http://www.nvidia.com/object/legal_info.html" onclick="s_objectID="http://www.nvidia.com/object/legal_info.html_1";return this.s_oc?this.s_oc(e):true">Legal Information </a> | <a href="http://www.nvidia.com/object/privacy_policy.html" onclick="s_objectID="http://www.nvidia.com/object/privacy_policy.html_1";return this.s_oc?this.s_oc(e):true">Privacy Policy </a> </div> </div> </div> diff --git a/NvCloth/docs/documentation/CollisionDetection/SelfCollision.html b/NvCloth/docs/documentation/CollisionDetection/SelfCollision.html index 9427251..37416c6 100644 --- a/NvCloth/docs/documentation/CollisionDetection/SelfCollision.html +++ b/NvCloth/docs/documentation/CollisionDetection/SelfCollision.html @@ -7,7 +7,7 @@ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="x-ua-compatible" content="IE=Edge"/> - <title>Self Collision — NvCloth 1.1.3 documentation</title> + <title>Self Collision — NvCloth 1.1.5 documentation</title> <link rel="stylesheet" href="../_static/default.css" type="text/css" /> <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> @@ -18,7 +18,7 @@ <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '../', - VERSION: '1.1.3', + VERSION: '1.1.5', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true @@ -31,7 +31,7 @@ <script type="text/javascript" src="../_static/bootstrap.js"></script> <script type="text/javascript" src="../_static/jquery.cookie.js"></script> <script type="text/javascript" src="../_static/jquery.storageapi.js"></script> - <link rel="top" title="NvCloth 1.1.3 documentation" href="../index.html" /> + <link rel="top" title="NvCloth 1.1.5 documentation" href="../index.html" /> <link rel="up" title="Internal collision detection documentation" href="Index.html" /> <link rel="next" title="Inter Collision" href="InterCollision.html" /> <link rel="prev" title="Sphere Capsule collision detection" href="SphereCapsuleCollision.html" /> @@ -58,7 +58,7 @@ <div class="masthead"> <div class="row"> <ul class="breadcrumb"> - <li><a href="../index.html">NvCloth 1.1.3 documentation</a></li> + <li><a href="../index.html">NvCloth 1.1.5 documentation</a></li> <li><a href="Index.html" accesskey="U">Internal collision detection documentation</a></li> </ul> </div> @@ -309,7 +309,7 @@ p1 -= delta * w1</pre> <div class="masthead"> <div class="row"> <ul class="breadcrumb"> - <li><a href="../index.html">NvCloth 1.1.3 documentation</a></li> + <li><a href="../index.html">NvCloth 1.1.5 documentation</a></li> <li><a href="Index.html" >Internal collision detection documentation</a></li> </ul> </div> @@ -319,7 +319,7 @@ p1 -= delta * w1</pre> <div class="footer-boilerplate"> <div class="row"> <div class="boilerplate"> - Copyright © 2014, NVIDIA Corporation | <a href="http://www.nvidia.com/object/about-nvidia.html" onclick="s_objectID="http://www.nvidia.com/object/about-nvidia.html_1";return this.s_oc?this.s_oc(e):true">About NVIDIA </a> | <a href="http://www.nvidia.com/object/legal_info.html" onclick="s_objectID="http://www.nvidia.com/object/legal_info.html_1";return this.s_oc?this.s_oc(e):true">Legal Information </a> | <a href="http://www.nvidia.com/object/privacy_policy.html" onclick="s_objectID="http://www.nvidia.com/object/privacy_policy.html_1";return this.s_oc?this.s_oc(e):true">Privacy Policy </a> + Copyright © 2019, NVIDIA Corporation | <a href="http://www.nvidia.com/object/about-nvidia.html" onclick="s_objectID="http://www.nvidia.com/object/about-nvidia.html_1";return this.s_oc?this.s_oc(e):true">About NVIDIA </a> | <a href="http://www.nvidia.com/object/legal_info.html" onclick="s_objectID="http://www.nvidia.com/object/legal_info.html_1";return this.s_oc?this.s_oc(e):true">Legal Information </a> | <a href="http://www.nvidia.com/object/privacy_policy.html" onclick="s_objectID="http://www.nvidia.com/object/privacy_policy.html_1";return this.s_oc?this.s_oc(e):true">Privacy Policy </a> </div> </div> </div> diff --git a/NvCloth/docs/documentation/CollisionDetection/SphereCapsuleCollision.html b/NvCloth/docs/documentation/CollisionDetection/SphereCapsuleCollision.html index 8caa955..78d5841 100644 --- a/NvCloth/docs/documentation/CollisionDetection/SphereCapsuleCollision.html +++ b/NvCloth/docs/documentation/CollisionDetection/SphereCapsuleCollision.html @@ -7,7 +7,7 @@ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="x-ua-compatible" content="IE=Edge"/> - <title>Sphere Capsule collision detection — NvCloth 1.1.3 documentation</title> + <title>Sphere Capsule collision detection — NvCloth 1.1.5 documentation</title> <link rel="stylesheet" href="../_static/default.css" type="text/css" /> <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> @@ -18,7 +18,7 @@ <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '../', - VERSION: '1.1.3', + VERSION: '1.1.5', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true @@ -31,7 +31,7 @@ <script type="text/javascript" src="../_static/bootstrap.js"></script> <script type="text/javascript" src="../_static/jquery.cookie.js"></script> <script type="text/javascript" src="../_static/jquery.storageapi.js"></script> - <link rel="top" title="NvCloth 1.1.3 documentation" href="../index.html" /> + <link rel="top" title="NvCloth 1.1.5 documentation" href="../index.html" /> <link rel="up" title="Internal collision detection documentation" href="Index.html" /> <link rel="next" title="Self Collision" href="SelfCollision.html" /> <link rel="prev" title="Internal collision detection documentation" href="Index.html" /> @@ -58,7 +58,7 @@ <div class="masthead"> <div class="row"> <ul class="breadcrumb"> - <li><a href="../index.html">NvCloth 1.1.3 documentation</a></li> + <li><a href="../index.html">NvCloth 1.1.5 documentation</a></li> <li><a href="Index.html" accesskey="U">Internal collision detection documentation</a></li> </ul> </div> @@ -555,7 +555,7 @@ The friction impulse magnitude is proportional to the friction coefficient and t <div class="masthead"> <div class="row"> <ul class="breadcrumb"> - <li><a href="../index.html">NvCloth 1.1.3 documentation</a></li> + <li><a href="../index.html">NvCloth 1.1.5 documentation</a></li> <li><a href="Index.html" >Internal collision detection documentation</a></li> </ul> </div> @@ -565,7 +565,7 @@ The friction impulse magnitude is proportional to the friction coefficient and t <div class="footer-boilerplate"> <div class="row"> <div class="boilerplate"> - Copyright © 2014, NVIDIA Corporation | <a href="http://www.nvidia.com/object/about-nvidia.html" onclick="s_objectID="http://www.nvidia.com/object/about-nvidia.html_1";return this.s_oc?this.s_oc(e):true">About NVIDIA </a> | <a href="http://www.nvidia.com/object/legal_info.html" onclick="s_objectID="http://www.nvidia.com/object/legal_info.html_1";return this.s_oc?this.s_oc(e):true">Legal Information </a> | <a href="http://www.nvidia.com/object/privacy_policy.html" onclick="s_objectID="http://www.nvidia.com/object/privacy_policy.html_1";return this.s_oc?this.s_oc(e):true">Privacy Policy </a> + Copyright © 2019, NVIDIA Corporation | <a href="http://www.nvidia.com/object/about-nvidia.html" onclick="s_objectID="http://www.nvidia.com/object/about-nvidia.html_1";return this.s_oc?this.s_oc(e):true">About NVIDIA </a> | <a href="http://www.nvidia.com/object/legal_info.html" onclick="s_objectID="http://www.nvidia.com/object/legal_info.html_1";return this.s_oc?this.s_oc(e):true">Legal Information </a> | <a href="http://www.nvidia.com/object/privacy_policy.html" onclick="s_objectID="http://www.nvidia.com/object/privacy_policy.html_1";return this.s_oc?this.s_oc(e):true">Privacy Policy </a> </div> </div> </div> diff --git a/NvCloth/docs/documentation/Compiling/index.html b/NvCloth/docs/documentation/Compiling/index.html index 1900835..ecef8e7 100644 --- a/NvCloth/docs/documentation/Compiling/index.html +++ b/NvCloth/docs/documentation/Compiling/index.html @@ -7,7 +7,7 @@ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="x-ua-compatible" content="IE=Edge"/> - <title>Compiling — NvCloth 1.1.3 documentation</title> + <title>Compiling — NvCloth 1.1.5 documentation</title> <link rel="stylesheet" href="../_static/default.css" type="text/css" /> <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> @@ -18,7 +18,7 @@ <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '../', - VERSION: '1.1.3', + VERSION: '1.1.5', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true @@ -31,7 +31,7 @@ <script type="text/javascript" src="../_static/bootstrap.js"></script> <script type="text/javascript" src="../_static/jquery.cookie.js"></script> <script type="text/javascript" src="../_static/jquery.storageapi.js"></script> - <link rel="top" title="NvCloth 1.1.3 documentation" href="../index.html" /> + <link rel="top" title="NvCloth 1.1.5 documentation" href="../index.html" /> <link rel="next" title="Modules" href="../Modules/Index.html" /> <link rel="prev" title="Release Notes" href="../ReleaseNotes/index.html" /> </head> @@ -57,7 +57,7 @@ <div class="masthead"> <div class="row"> <ul class="breadcrumb"> - <li><a href="../index.html">NvCloth 1.1.3 documentation</a></li> + <li><a href="../index.html">NvCloth 1.1.5 documentation</a></li> </ul> </div> </div> @@ -320,7 +320,7 @@ Specifically, you need to create a symlink/copy/rename:</p> <div class="masthead"> <div class="row"> <ul class="breadcrumb"> - <li><a href="../index.html">NvCloth 1.1.3 documentation</a></li> + <li><a href="../index.html">NvCloth 1.1.5 documentation</a></li> </ul> </div> </div> @@ -329,7 +329,7 @@ Specifically, you need to create a symlink/copy/rename:</p> <div class="footer-boilerplate"> <div class="row"> <div class="boilerplate"> - Copyright © 2014, NVIDIA Corporation | <a href="http://www.nvidia.com/object/about-nvidia.html" onclick="s_objectID="http://www.nvidia.com/object/about-nvidia.html_1";return this.s_oc?this.s_oc(e):true">About NVIDIA </a> | <a href="http://www.nvidia.com/object/legal_info.html" onclick="s_objectID="http://www.nvidia.com/object/legal_info.html_1";return this.s_oc?this.s_oc(e):true">Legal Information </a> | <a href="http://www.nvidia.com/object/privacy_policy.html" onclick="s_objectID="http://www.nvidia.com/object/privacy_policy.html_1";return this.s_oc?this.s_oc(e):true">Privacy Policy </a> + Copyright © 2019, NVIDIA Corporation | <a href="http://www.nvidia.com/object/about-nvidia.html" onclick="s_objectID="http://www.nvidia.com/object/about-nvidia.html_1";return this.s_oc?this.s_oc(e):true">About NVIDIA </a> | <a href="http://www.nvidia.com/object/legal_info.html" onclick="s_objectID="http://www.nvidia.com/object/legal_info.html_1";return this.s_oc?this.s_oc(e):true">Legal Information </a> | <a href="http://www.nvidia.com/object/privacy_policy.html" onclick="s_objectID="http://www.nvidia.com/object/privacy_policy.html_1";return this.s_oc?this.s_oc(e):true">Privacy Policy </a> </div> </div> </div> diff --git a/NvCloth/docs/documentation/Cooking/Index.html b/NvCloth/docs/documentation/Cooking/Index.html index 03e56ca..40f9596 100644 --- a/NvCloth/docs/documentation/Cooking/Index.html +++ b/NvCloth/docs/documentation/Cooking/Index.html @@ -7,7 +7,7 @@ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="x-ua-compatible" content="IE=Edge"/> - <title>Internal cooking documentation — NvCloth 1.1.3 documentation</title> + <title>Internal cooking documentation — NvCloth 1.1.5 documentation</title> <link rel="stylesheet" href="../_static/default.css" type="text/css" /> <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> @@ -18,7 +18,7 @@ <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '../', - VERSION: '1.1.3', + VERSION: '1.1.5', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true @@ -31,7 +31,7 @@ <script type="text/javascript" src="../_static/bootstrap.js"></script> <script type="text/javascript" src="../_static/jquery.cookie.js"></script> <script type="text/javascript" src="../_static/jquery.storageapi.js"></script> - <link rel="top" title="NvCloth 1.1.3 documentation" href="../index.html" /> + <link rel="top" title="NvCloth 1.1.5 documentation" href="../index.html" /> <link rel="next" title="TripletScheduler" href="TripletScheduler.html" /> <link rel="prev" title="Inter Collision" href="../CollisionDetection/InterCollision.html" /> </head> @@ -57,7 +57,7 @@ <div class="masthead"> <div class="row"> <ul class="breadcrumb"> - <li><a href="../index.html">NvCloth 1.1.3 documentation</a></li> + <li><a href="../index.html">NvCloth 1.1.5 documentation</a></li> </ul> </div> </div> @@ -242,7 +242,7 @@ <div class="masthead"> <div class="row"> <ul class="breadcrumb"> - <li><a href="../index.html">NvCloth 1.1.3 documentation</a></li> + <li><a href="../index.html">NvCloth 1.1.5 documentation</a></li> </ul> </div> </div> @@ -251,7 +251,7 @@ <div class="footer-boilerplate"> <div class="row"> <div class="boilerplate"> - Copyright © 2014, NVIDIA Corporation | <a href="http://www.nvidia.com/object/about-nvidia.html" onclick="s_objectID="http://www.nvidia.com/object/about-nvidia.html_1";return this.s_oc?this.s_oc(e):true">About NVIDIA </a> | <a href="http://www.nvidia.com/object/legal_info.html" onclick="s_objectID="http://www.nvidia.com/object/legal_info.html_1";return this.s_oc?this.s_oc(e):true">Legal Information </a> | <a href="http://www.nvidia.com/object/privacy_policy.html" onclick="s_objectID="http://www.nvidia.com/object/privacy_policy.html_1";return this.s_oc?this.s_oc(e):true">Privacy Policy </a> + Copyright © 2019, NVIDIA Corporation | <a href="http://www.nvidia.com/object/about-nvidia.html" onclick="s_objectID="http://www.nvidia.com/object/about-nvidia.html_1";return this.s_oc?this.s_oc(e):true">About NVIDIA </a> | <a href="http://www.nvidia.com/object/legal_info.html" onclick="s_objectID="http://www.nvidia.com/object/legal_info.html_1";return this.s_oc?this.s_oc(e):true">Legal Information </a> | <a href="http://www.nvidia.com/object/privacy_policy.html" onclick="s_objectID="http://www.nvidia.com/object/privacy_policy.html_1";return this.s_oc?this.s_oc(e):true">Privacy Policy </a> </div> </div> </div> diff --git a/NvCloth/docs/documentation/Cooking/TripletScheduler.html b/NvCloth/docs/documentation/Cooking/TripletScheduler.html index fef2bfb..0954f40 100644 --- a/NvCloth/docs/documentation/Cooking/TripletScheduler.html +++ b/NvCloth/docs/documentation/Cooking/TripletScheduler.html @@ -7,7 +7,7 @@ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="x-ua-compatible" content="IE=Edge"/> - <title>TripletScheduler — NvCloth 1.1.3 documentation</title> + <title>TripletScheduler — NvCloth 1.1.5 documentation</title> <link rel="stylesheet" href="../_static/default.css" type="text/css" /> <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> @@ -18,7 +18,7 @@ <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '../', - VERSION: '1.1.3', + VERSION: '1.1.5', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true @@ -31,7 +31,7 @@ <script type="text/javascript" src="../_static/bootstrap.js"></script> <script type="text/javascript" src="../_static/jquery.cookie.js"></script> <script type="text/javascript" src="../_static/jquery.storageapi.js"></script> - <link rel="top" title="NvCloth 1.1.3 documentation" href="../index.html" /> + <link rel="top" title="NvCloth 1.1.5 documentation" href="../index.html" /> <link rel="up" title="Internal cooking documentation" href="Index.html" /> <link rel="prev" title="Internal cooking documentation" href="Index.html" /> </head> @@ -57,7 +57,7 @@ <div class="masthead"> <div class="row"> <ul class="breadcrumb"> - <li><a href="../index.html">NvCloth 1.1.3 documentation</a></li> + <li><a href="../index.html">NvCloth 1.1.5 documentation</a></li> <li><a href="Index.html" accesskey="U">Internal cooking documentation</a></li> </ul> </div> @@ -267,7 +267,7 @@ It also optimizes the sets to have the least amount of bank conflicts possible.< <div class="masthead"> <div class="row"> <ul class="breadcrumb"> - <li><a href="../index.html">NvCloth 1.1.3 documentation</a></li> + <li><a href="../index.html">NvCloth 1.1.5 documentation</a></li> <li><a href="Index.html" >Internal cooking documentation</a></li> </ul> </div> @@ -277,7 +277,7 @@ It also optimizes the sets to have the least amount of bank conflicts possible.< <div class="footer-boilerplate"> <div class="row"> <div class="boilerplate"> - Copyright © 2014, NVIDIA Corporation | <a href="http://www.nvidia.com/object/about-nvidia.html" onclick="s_objectID="http://www.nvidia.com/object/about-nvidia.html_1";return this.s_oc?this.s_oc(e):true">About NVIDIA </a> | <a href="http://www.nvidia.com/object/legal_info.html" onclick="s_objectID="http://www.nvidia.com/object/legal_info.html_1";return this.s_oc?this.s_oc(e):true">Legal Information </a> | <a href="http://www.nvidia.com/object/privacy_policy.html" onclick="s_objectID="http://www.nvidia.com/object/privacy_policy.html_1";return this.s_oc?this.s_oc(e):true">Privacy Policy </a> + Copyright © 2019, NVIDIA Corporation | <a href="http://www.nvidia.com/object/about-nvidia.html" onclick="s_objectID="http://www.nvidia.com/object/about-nvidia.html_1";return this.s_oc?this.s_oc(e):true">About NVIDIA </a> | <a href="http://www.nvidia.com/object/legal_info.html" onclick="s_objectID="http://www.nvidia.com/object/legal_info.html_1";return this.s_oc?this.s_oc(e):true">Legal Information </a> | <a href="http://www.nvidia.com/object/privacy_policy.html" onclick="s_objectID="http://www.nvidia.com/object/privacy_policy.html_1";return this.s_oc?this.s_oc(e):true">Privacy Policy </a> </div> </div> </div> diff --git a/NvCloth/docs/documentation/CopyRight/Index.html b/NvCloth/docs/documentation/CopyRight/Index.html index becc894..9122110 100644 --- a/NvCloth/docs/documentation/CopyRight/Index.html +++ b/NvCloth/docs/documentation/CopyRight/Index.html @@ -7,7 +7,7 @@ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="x-ua-compatible" content="IE=Edge"/> - <title>NVIDIA Copyright Notice — NvCloth 1.1.3 documentation</title> + <title>NVIDIA Copyright Notice — NvCloth 1.1.5 documentation</title> <link rel="stylesheet" href="../_static/default.css" type="text/css" /> <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> @@ -18,7 +18,7 @@ <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '../', - VERSION: '1.1.3', + VERSION: '1.1.5', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true @@ -31,7 +31,7 @@ <script type="text/javascript" src="../_static/bootstrap.js"></script> <script type="text/javascript" src="../_static/jquery.cookie.js"></script> <script type="text/javascript" src="../_static/jquery.storageapi.js"></script> - <link rel="top" title="NvCloth 1.1.3 documentation" href="../index.html" /> + <link rel="top" title="NvCloth 1.1.5 documentation" href="../index.html" /> <link rel="next" title="Internal solver function/algorithm documentation" href="../Solver/Index.html" /> <link rel="prev" title="User Guide" href="../UserGuide/Index.html" /> </head> @@ -57,7 +57,7 @@ <div class="masthead"> <div class="row"> <ul class="breadcrumb"> - <li><a href="../index.html">NvCloth 1.1.3 documentation</a></li> + <li><a href="../index.html">NvCloth 1.1.5 documentation</a></li> </ul> </div> </div> @@ -240,7 +240,7 @@ license agreement from NVIDIA CORPORATION is strictly prohibited.</p> <div class="masthead"> <div class="row"> <ul class="breadcrumb"> - <li><a href="../index.html">NvCloth 1.1.3 documentation</a></li> + <li><a href="../index.html">NvCloth 1.1.5 documentation</a></li> </ul> </div> </div> @@ -249,7 +249,7 @@ license agreement from NVIDIA CORPORATION is strictly prohibited.</p> <div class="footer-boilerplate"> <div class="row"> <div class="boilerplate"> - Copyright © 2014, NVIDIA Corporation | <a href="http://www.nvidia.com/object/about-nvidia.html" onclick="s_objectID="http://www.nvidia.com/object/about-nvidia.html_1";return this.s_oc?this.s_oc(e):true">About NVIDIA </a> | <a href="http://www.nvidia.com/object/legal_info.html" onclick="s_objectID="http://www.nvidia.com/object/legal_info.html_1";return this.s_oc?this.s_oc(e):true">Legal Information </a> | <a href="http://www.nvidia.com/object/privacy_policy.html" onclick="s_objectID="http://www.nvidia.com/object/privacy_policy.html_1";return this.s_oc?this.s_oc(e):true">Privacy Policy </a> + Copyright © 2019, NVIDIA Corporation | <a href="http://www.nvidia.com/object/about-nvidia.html" onclick="s_objectID="http://www.nvidia.com/object/about-nvidia.html_1";return this.s_oc?this.s_oc(e):true">About NVIDIA </a> | <a href="http://www.nvidia.com/object/legal_info.html" onclick="s_objectID="http://www.nvidia.com/object/legal_info.html_1";return this.s_oc?this.s_oc(e):true">Legal Information </a> | <a href="http://www.nvidia.com/object/privacy_policy.html" onclick="s_objectID="http://www.nvidia.com/object/privacy_policy.html_1";return this.s_oc?this.s_oc(e):true">Privacy Policy </a> </div> </div> </div> diff --git a/NvCloth/docs/documentation/Modules/Index.html b/NvCloth/docs/documentation/Modules/Index.html index bc2271c..b6c6a23 100644 --- a/NvCloth/docs/documentation/Modules/Index.html +++ b/NvCloth/docs/documentation/Modules/Index.html @@ -7,7 +7,7 @@ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="x-ua-compatible" content="IE=Edge"/> - <title>Modules — NvCloth 1.1.3 documentation</title> + <title>Modules — NvCloth 1.1.5 documentation</title> <link rel="stylesheet" href="../_static/default.css" type="text/css" /> <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> @@ -18,7 +18,7 @@ <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '../', - VERSION: '1.1.3', + VERSION: '1.1.5', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true @@ -31,7 +31,7 @@ <script type="text/javascript" src="../_static/bootstrap.js"></script> <script type="text/javascript" src="../_static/jquery.cookie.js"></script> <script type="text/javascript" src="../_static/jquery.storageapi.js"></script> - <link rel="top" title="NvCloth 1.1.3 documentation" href="../index.html" /> + <link rel="top" title="NvCloth 1.1.5 documentation" href="../index.html" /> <link rel="next" title="User Guide" href="../UserGuide/Index.html" /> <link rel="prev" title="Compiling" href="../Compiling/index.html" /> </head> @@ -57,7 +57,7 @@ <div class="masthead"> <div class="row"> <ul class="breadcrumb"> - <li><a href="../index.html">NvCloth 1.1.3 documentation</a></li> + <li><a href="../index.html">NvCloth 1.1.5 documentation</a></li> </ul> </div> </div> @@ -242,7 +242,7 @@ Users that want to use their own cooking or offline cooking can bypass these fun <div class="masthead"> <div class="row"> <ul class="breadcrumb"> - <li><a href="../index.html">NvCloth 1.1.3 documentation</a></li> + <li><a href="../index.html">NvCloth 1.1.5 documentation</a></li> </ul> </div> </div> @@ -251,7 +251,7 @@ Users that want to use their own cooking or offline cooking can bypass these fun <div class="footer-boilerplate"> <div class="row"> <div class="boilerplate"> - Copyright © 2014, NVIDIA Corporation | <a href="http://www.nvidia.com/object/about-nvidia.html" onclick="s_objectID="http://www.nvidia.com/object/about-nvidia.html_1";return this.s_oc?this.s_oc(e):true">About NVIDIA </a> | <a href="http://www.nvidia.com/object/legal_info.html" onclick="s_objectID="http://www.nvidia.com/object/legal_info.html_1";return this.s_oc?this.s_oc(e):true">Legal Information </a> | <a href="http://www.nvidia.com/object/privacy_policy.html" onclick="s_objectID="http://www.nvidia.com/object/privacy_policy.html_1";return this.s_oc?this.s_oc(e):true">Privacy Policy </a> + Copyright © 2019, NVIDIA Corporation | <a href="http://www.nvidia.com/object/about-nvidia.html" onclick="s_objectID="http://www.nvidia.com/object/about-nvidia.html_1";return this.s_oc?this.s_oc(e):true">About NVIDIA </a> | <a href="http://www.nvidia.com/object/legal_info.html" onclick="s_objectID="http://www.nvidia.com/object/legal_info.html_1";return this.s_oc?this.s_oc(e):true">Legal Information </a> | <a href="http://www.nvidia.com/object/privacy_policy.html" onclick="s_objectID="http://www.nvidia.com/object/privacy_policy.html_1";return this.s_oc?this.s_oc(e):true">Privacy Policy </a> </div> </div> </div> diff --git a/NvCloth/docs/documentation/ReleaseNotes/index.html b/NvCloth/docs/documentation/ReleaseNotes/index.html index fb5bfc5..ba5ac7b 100644 --- a/NvCloth/docs/documentation/ReleaseNotes/index.html +++ b/NvCloth/docs/documentation/ReleaseNotes/index.html @@ -7,7 +7,7 @@ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="x-ua-compatible" content="IE=Edge"/> - <title>Release Notes — NvCloth 1.1.3 documentation</title> + <title>Release Notes — NvCloth 1.1.5 documentation</title> <link rel="stylesheet" href="../_static/default.css" type="text/css" /> <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> @@ -18,7 +18,7 @@ <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '../', - VERSION: '1.1.3', + VERSION: '1.1.5', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true @@ -31,7 +31,7 @@ <script type="text/javascript" src="../_static/bootstrap.js"></script> <script type="text/javascript" src="../_static/jquery.cookie.js"></script> <script type="text/javascript" src="../_static/jquery.storageapi.js"></script> - <link rel="top" title="NvCloth 1.1.3 documentation" href="../index.html" /> + <link rel="top" title="NvCloth 1.1.5 documentation" href="../index.html" /> <link rel="next" title="Compiling" href="../Compiling/index.html" /> <link rel="prev" title="NvCloth" href="../index.html" /> </head> @@ -57,7 +57,7 @@ <div class="masthead"> <div class="row"> <ul class="breadcrumb"> - <li><a href="../index.html">NvCloth 1.1.3 documentation</a></li> + <li><a href="../index.html">NvCloth 1.1.5 documentation</a></li> </ul> </div> </div> @@ -369,7 +369,7 @@ <div class="masthead"> <div class="row"> <ul class="breadcrumb"> - <li><a href="../index.html">NvCloth 1.1.3 documentation</a></li> + <li><a href="../index.html">NvCloth 1.1.5 documentation</a></li> </ul> </div> </div> @@ -378,7 +378,7 @@ <div class="footer-boilerplate"> <div class="row"> <div class="boilerplate"> - Copyright © 2014, NVIDIA Corporation | <a href="http://www.nvidia.com/object/about-nvidia.html" onclick="s_objectID="http://www.nvidia.com/object/about-nvidia.html_1";return this.s_oc?this.s_oc(e):true">About NVIDIA </a> | <a href="http://www.nvidia.com/object/legal_info.html" onclick="s_objectID="http://www.nvidia.com/object/legal_info.html_1";return this.s_oc?this.s_oc(e):true">Legal Information </a> | <a href="http://www.nvidia.com/object/privacy_policy.html" onclick="s_objectID="http://www.nvidia.com/object/privacy_policy.html_1";return this.s_oc?this.s_oc(e):true">Privacy Policy </a> + Copyright © 2019, NVIDIA Corporation | <a href="http://www.nvidia.com/object/about-nvidia.html" onclick="s_objectID="http://www.nvidia.com/object/about-nvidia.html_1";return this.s_oc?this.s_oc(e):true">About NVIDIA </a> | <a href="http://www.nvidia.com/object/legal_info.html" onclick="s_objectID="http://www.nvidia.com/object/legal_info.html_1";return this.s_oc?this.s_oc(e):true">Legal Information </a> | <a href="http://www.nvidia.com/object/privacy_policy.html" onclick="s_objectID="http://www.nvidia.com/object/privacy_policy.html_1";return this.s_oc?this.s_oc(e):true">Privacy Policy </a> </div> </div> </div> diff --git a/NvCloth/docs/documentation/Solver/Index.html b/NvCloth/docs/documentation/Solver/Index.html index db5e227..8277796 100644 --- a/NvCloth/docs/documentation/Solver/Index.html +++ b/NvCloth/docs/documentation/Solver/Index.html @@ -7,7 +7,7 @@ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="x-ua-compatible" content="IE=Edge"/> - <title>Internal solver function/algorithm documentation — NvCloth 1.1.3 documentation</title> + <title>Internal solver function/algorithm documentation — NvCloth 1.1.5 documentation</title> <link rel="stylesheet" href="../_static/default.css" type="text/css" /> <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> @@ -18,7 +18,7 @@ <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '../', - VERSION: '1.1.3', + VERSION: '1.1.5', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true @@ -31,7 +31,7 @@ <script type="text/javascript" src="../_static/bootstrap.js"></script> <script type="text/javascript" src="../_static/jquery.cookie.js"></script> <script type="text/javascript" src="../_static/jquery.storageapi.js"></script> - <link rel="top" title="NvCloth 1.1.3 documentation" href="../index.html" /> + <link rel="top" title="NvCloth 1.1.5 documentation" href="../index.html" /> <link rel="next" title="Internal collision detection documentation" href="../CollisionDetection/Index.html" /> <link rel="prev" title="NVIDIA Copyright Notice" href="../CopyRight/Index.html" /> </head> @@ -57,7 +57,7 @@ <div class="masthead"> <div class="row"> <ul class="breadcrumb"> - <li><a href="../index.html">NvCloth 1.1.3 documentation</a></li> + <li><a href="../index.html">NvCloth 1.1.5 documentation</a></li> </ul> </div> </div> @@ -507,7 +507,7 @@ The first rest value of set s is mRestvalues[mSets[s]] and the last is mRestvalu <div class="masthead"> <div class="row"> <ul class="breadcrumb"> - <li><a href="../index.html">NvCloth 1.1.3 documentation</a></li> + <li><a href="../index.html">NvCloth 1.1.5 documentation</a></li> </ul> </div> </div> @@ -516,7 +516,7 @@ The first rest value of set s is mRestvalues[mSets[s]] and the last is mRestvalu <div class="footer-boilerplate"> <div class="row"> <div class="boilerplate"> - Copyright © 2014, NVIDIA Corporation | <a href="http://www.nvidia.com/object/about-nvidia.html" onclick="s_objectID="http://www.nvidia.com/object/about-nvidia.html_1";return this.s_oc?this.s_oc(e):true">About NVIDIA </a> | <a href="http://www.nvidia.com/object/legal_info.html" onclick="s_objectID="http://www.nvidia.com/object/legal_info.html_1";return this.s_oc?this.s_oc(e):true">Legal Information </a> | <a href="http://www.nvidia.com/object/privacy_policy.html" onclick="s_objectID="http://www.nvidia.com/object/privacy_policy.html_1";return this.s_oc?this.s_oc(e):true">Privacy Policy </a> + Copyright © 2019, NVIDIA Corporation | <a href="http://www.nvidia.com/object/about-nvidia.html" onclick="s_objectID="http://www.nvidia.com/object/about-nvidia.html_1";return this.s_oc?this.s_oc(e):true">About NVIDIA </a> | <a href="http://www.nvidia.com/object/legal_info.html" onclick="s_objectID="http://www.nvidia.com/object/legal_info.html_1";return this.s_oc?this.s_oc(e):true">Legal Information </a> | <a href="http://www.nvidia.com/object/privacy_policy.html" onclick="s_objectID="http://www.nvidia.com/object/privacy_policy.html_1";return this.s_oc?this.s_oc(e):true">Privacy Policy </a> </div> </div> </div> diff --git a/NvCloth/docs/documentation/UserGuide/Index.html b/NvCloth/docs/documentation/UserGuide/Index.html index 3a465d6..5f6dd0d 100644 --- a/NvCloth/docs/documentation/UserGuide/Index.html +++ b/NvCloth/docs/documentation/UserGuide/Index.html @@ -7,7 +7,7 @@ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="x-ua-compatible" content="IE=Edge"/> - <title>User Guide — NvCloth 1.1.3 documentation</title> + <title>User Guide — NvCloth 1.1.5 documentation</title> <link rel="stylesheet" href="../_static/default.css" type="text/css" /> <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> @@ -18,7 +18,7 @@ <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '../', - VERSION: '1.1.3', + VERSION: '1.1.5', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true @@ -31,7 +31,7 @@ <script type="text/javascript" src="../_static/bootstrap.js"></script> <script type="text/javascript" src="../_static/jquery.cookie.js"></script> <script type="text/javascript" src="../_static/jquery.storageapi.js"></script> - <link rel="top" title="NvCloth 1.1.3 documentation" href="../index.html" /> + <link rel="top" title="NvCloth 1.1.5 documentation" href="../index.html" /> <link rel="next" title="NVIDIA Copyright Notice" href="../CopyRight/Index.html" /> <link rel="prev" title="Modules" href="../Modules/Index.html" /> </head> @@ -57,7 +57,7 @@ <div class="masthead"> <div class="row"> <ul class="breadcrumb"> - <li><a href="../index.html">NvCloth 1.1.3 documentation</a></li> + <li><a href="../index.html">NvCloth 1.1.5 documentation</a></li> </ul> </div> </div> @@ -687,7 +687,7 @@ This helps for both decreasing collision shape penetration and improving cloth s <div class="masthead"> <div class="row"> <ul class="breadcrumb"> - <li><a href="../index.html">NvCloth 1.1.3 documentation</a></li> + <li><a href="../index.html">NvCloth 1.1.5 documentation</a></li> </ul> </div> </div> @@ -696,7 +696,7 @@ This helps for both decreasing collision shape penetration and improving cloth s <div class="footer-boilerplate"> <div class="row"> <div class="boilerplate"> - Copyright © 2014, NVIDIA Corporation | <a href="http://www.nvidia.com/object/about-nvidia.html" onclick="s_objectID="http://www.nvidia.com/object/about-nvidia.html_1";return this.s_oc?this.s_oc(e):true">About NVIDIA </a> | <a href="http://www.nvidia.com/object/legal_info.html" onclick="s_objectID="http://www.nvidia.com/object/legal_info.html_1";return this.s_oc?this.s_oc(e):true">Legal Information </a> | <a href="http://www.nvidia.com/object/privacy_policy.html" onclick="s_objectID="http://www.nvidia.com/object/privacy_policy.html_1";return this.s_oc?this.s_oc(e):true">Privacy Policy </a> + Copyright © 2019, NVIDIA Corporation | <a href="http://www.nvidia.com/object/about-nvidia.html" onclick="s_objectID="http://www.nvidia.com/object/about-nvidia.html_1";return this.s_oc?this.s_oc(e):true">About NVIDIA </a> | <a href="http://www.nvidia.com/object/legal_info.html" onclick="s_objectID="http://www.nvidia.com/object/legal_info.html_1";return this.s_oc?this.s_oc(e):true">Legal Information </a> | <a href="http://www.nvidia.com/object/privacy_policy.html" onclick="s_objectID="http://www.nvidia.com/object/privacy_policy.html_1";return this.s_oc?this.s_oc(e):true">Privacy Policy </a> </div> </div> </div> diff --git a/NvCloth/docs/documentation/genindex.html b/NvCloth/docs/documentation/genindex.html index b2db867..2fd9659 100644 --- a/NvCloth/docs/documentation/genindex.html +++ b/NvCloth/docs/documentation/genindex.html @@ -8,7 +8,7 @@ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="x-ua-compatible" content="IE=Edge"/> - <title>Index — NvCloth 1.1.3 documentation</title> + <title>Index — NvCloth 1.1.5 documentation</title> <link rel="stylesheet" href="_static/default.css" type="text/css" /> <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> @@ -19,7 +19,7 @@ <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: './', - VERSION: '1.1.3', + VERSION: '1.1.5', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true @@ -32,7 +32,7 @@ <script type="text/javascript" src="_static/bootstrap.js"></script> <script type="text/javascript" src="_static/jquery.cookie.js"></script> <script type="text/javascript" src="_static/jquery.storageapi.js"></script> - <link rel="top" title="NvCloth 1.1.3 documentation" href="index.html" /> + <link rel="top" title="NvCloth 1.1.5 documentation" href="index.html" /> </head> <body> <nav class="navbar navbar-inverse navbar-default"> @@ -56,7 +56,7 @@ <div class="masthead"> <div class="row"> <ul class="breadcrumb"> - <li><a href="index.html">NvCloth 1.1.3 documentation</a></li> + <li><a href="index.html">NvCloth 1.1.5 documentation</a></li> </ul> </div> </div> @@ -231,7 +231,7 @@ <div class="masthead"> <div class="row"> <ul class="breadcrumb"> - <li><a href="index.html">NvCloth 1.1.3 documentation</a></li> + <li><a href="index.html">NvCloth 1.1.5 documentation</a></li> </ul> </div> </div> @@ -240,7 +240,7 @@ <div class="footer-boilerplate"> <div class="row"> <div class="boilerplate"> - Copyright © 2014, NVIDIA Corporation | <a href="http://www.nvidia.com/object/about-nvidia.html" onclick="s_objectID="http://www.nvidia.com/object/about-nvidia.html_1";return this.s_oc?this.s_oc(e):true">About NVIDIA </a> | <a href="http://www.nvidia.com/object/legal_info.html" onclick="s_objectID="http://www.nvidia.com/object/legal_info.html_1";return this.s_oc?this.s_oc(e):true">Legal Information </a> | <a href="http://www.nvidia.com/object/privacy_policy.html" onclick="s_objectID="http://www.nvidia.com/object/privacy_policy.html_1";return this.s_oc?this.s_oc(e):true">Privacy Policy </a> + Copyright © 2019, NVIDIA Corporation | <a href="http://www.nvidia.com/object/about-nvidia.html" onclick="s_objectID="http://www.nvidia.com/object/about-nvidia.html_1";return this.s_oc?this.s_oc(e):true">About NVIDIA </a> | <a href="http://www.nvidia.com/object/legal_info.html" onclick="s_objectID="http://www.nvidia.com/object/legal_info.html_1";return this.s_oc?this.s_oc(e):true">Legal Information </a> | <a href="http://www.nvidia.com/object/privacy_policy.html" onclick="s_objectID="http://www.nvidia.com/object/privacy_policy.html_1";return this.s_oc?this.s_oc(e):true">Privacy Policy </a> </div> </div> </div> diff --git a/NvCloth/docs/documentation/index.html b/NvCloth/docs/documentation/index.html index aa85e92..c6495b9 100644 --- a/NvCloth/docs/documentation/index.html +++ b/NvCloth/docs/documentation/index.html @@ -7,7 +7,7 @@ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="x-ua-compatible" content="IE=Edge"/> - <title>NvCloth — NvCloth 1.1.3 documentation</title> + <title>NvCloth — NvCloth 1.1.5 documentation</title> <link rel="stylesheet" href="_static/default.css" type="text/css" /> <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> @@ -18,7 +18,7 @@ <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: './', - VERSION: '1.1.3', + VERSION: '1.1.5', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true @@ -31,7 +31,7 @@ <script type="text/javascript" src="_static/bootstrap.js"></script> <script type="text/javascript" src="_static/jquery.cookie.js"></script> <script type="text/javascript" src="_static/jquery.storageapi.js"></script> - <link rel="top" title="NvCloth 1.1.3 documentation" href="#" /> + <link rel="top" title="NvCloth 1.1.5 documentation" href="#" /> <link rel="next" title="Release Notes" href="ReleaseNotes/index.html" /> </head> <body> @@ -56,7 +56,7 @@ <div class="masthead"> <div class="row"> <ul class="breadcrumb"> - <li><a href="#">NvCloth 1.1.3 documentation</a></li> + <li><a href="#">NvCloth 1.1.5 documentation</a></li> </ul> </div> </div> @@ -227,7 +227,7 @@ <div class="section" id="learn-more-about-productname"> <h2>Learn more about NvCloth<a class="headerlink" href="#learn-more-about-productname" title="Permalink to this headline">¶</a></h2> <ul class="simple"> -<li>Visit the <a class="reference external" href="https://github.com/NVIDIAGameWorks/NvCloth">product home page</a> on <a class="reference external" href="http://developer.nvidia.com">NVIDIA Developer</a></li> +<li>Visit the <a class="reference external" href="https://github.com/NVIDIAGameWorks/NvCloth">NvCloth git repo</a>, note that you need to sign the <a class="reference external" href="https://developer.nvidia.com/gameworks-source-github">EULA</a> to access this page.</li> <li>View Documentation <a class="reference internal" href="search.html"><em>Search Page</em></a></li> </ul> <p><strong>Browse Documentation</strong></p> @@ -255,7 +255,7 @@ <div class="masthead"> <div class="row"> <ul class="breadcrumb"> - <li><a href="#">NvCloth 1.1.3 documentation</a></li> + <li><a href="#">NvCloth 1.1.5 documentation</a></li> </ul> </div> </div> @@ -264,7 +264,7 @@ <div class="footer-boilerplate"> <div class="row"> <div class="boilerplate"> - Copyright © 2014, NVIDIA Corporation | <a href="http://www.nvidia.com/object/about-nvidia.html" onclick="s_objectID="http://www.nvidia.com/object/about-nvidia.html_1";return this.s_oc?this.s_oc(e):true">About NVIDIA </a> | <a href="http://www.nvidia.com/object/legal_info.html" onclick="s_objectID="http://www.nvidia.com/object/legal_info.html_1";return this.s_oc?this.s_oc(e):true">Legal Information </a> | <a href="http://www.nvidia.com/object/privacy_policy.html" onclick="s_objectID="http://www.nvidia.com/object/privacy_policy.html_1";return this.s_oc?this.s_oc(e):true">Privacy Policy </a> + Copyright © 2019, NVIDIA Corporation | <a href="http://www.nvidia.com/object/about-nvidia.html" onclick="s_objectID="http://www.nvidia.com/object/about-nvidia.html_1";return this.s_oc?this.s_oc(e):true">About NVIDIA </a> | <a href="http://www.nvidia.com/object/legal_info.html" onclick="s_objectID="http://www.nvidia.com/object/legal_info.html_1";return this.s_oc?this.s_oc(e):true">Legal Information </a> | <a href="http://www.nvidia.com/object/privacy_policy.html" onclick="s_objectID="http://www.nvidia.com/object/privacy_policy.html_1";return this.s_oc?this.s_oc(e):true">Privacy Policy </a> </div> </div> </div> diff --git a/NvCloth/docs/documentation/objects.inv b/NvCloth/docs/documentation/objects.inv Binary files differindex 6f36075..7443e96 100644 --- a/NvCloth/docs/documentation/objects.inv +++ b/NvCloth/docs/documentation/objects.inv diff --git a/NvCloth/docs/documentation/search.html b/NvCloth/docs/documentation/search.html index 3f23fd5..acd0163 100644 --- a/NvCloth/docs/documentation/search.html +++ b/NvCloth/docs/documentation/search.html @@ -7,7 +7,7 @@ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="x-ua-compatible" content="IE=Edge"/> - <title>Search — NvCloth 1.1.3 documentation</title> + <title>Search — NvCloth 1.1.5 documentation</title> <link rel="stylesheet" href="_static/default.css" type="text/css" /> <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> @@ -18,7 +18,7 @@ <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: './', - VERSION: '1.1.3', + VERSION: '1.1.5', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true @@ -32,7 +32,7 @@ <script type="text/javascript" src="_static/bootstrap.js"></script> <script type="text/javascript" src="_static/jquery.cookie.js"></script> <script type="text/javascript" src="_static/jquery.storageapi.js"></script> - <link rel="top" title="NvCloth 1.1.3 documentation" href="index.html" /> + <link rel="top" title="NvCloth 1.1.5 documentation" href="index.html" /> <script type="text/javascript"> jQuery(function() { Search.loadIndex("searchindex.js"); }); </script> @@ -52,7 +52,7 @@ <div class="masthead"> <div class="row"> <ul class="breadcrumb"> - <li><a href="index.html">NvCloth 1.1.3 documentation</a></li> + <li><a href="index.html">NvCloth 1.1.5 documentation</a></li> </ul> </div> </div> @@ -225,7 +225,7 @@ <div class="masthead"> <div class="row"> <ul class="breadcrumb"> - <li><a href="index.html">NvCloth 1.1.3 documentation</a></li> + <li><a href="index.html">NvCloth 1.1.5 documentation</a></li> </ul> </div> </div> @@ -234,7 +234,7 @@ <div class="footer-boilerplate"> <div class="row"> <div class="boilerplate"> - Copyright © 2014, NVIDIA Corporation | <a href="http://www.nvidia.com/object/about-nvidia.html" onclick="s_objectID="http://www.nvidia.com/object/about-nvidia.html_1";return this.s_oc?this.s_oc(e):true">About NVIDIA </a> | <a href="http://www.nvidia.com/object/legal_info.html" onclick="s_objectID="http://www.nvidia.com/object/legal_info.html_1";return this.s_oc?this.s_oc(e):true">Legal Information </a> | <a href="http://www.nvidia.com/object/privacy_policy.html" onclick="s_objectID="http://www.nvidia.com/object/privacy_policy.html_1";return this.s_oc?this.s_oc(e):true">Privacy Policy </a> + Copyright © 2019, NVIDIA Corporation | <a href="http://www.nvidia.com/object/about-nvidia.html" onclick="s_objectID="http://www.nvidia.com/object/about-nvidia.html_1";return this.s_oc?this.s_oc(e):true">About NVIDIA </a> | <a href="http://www.nvidia.com/object/legal_info.html" onclick="s_objectID="http://www.nvidia.com/object/legal_info.html_1";return this.s_oc?this.s_oc(e):true">Legal Information </a> | <a href="http://www.nvidia.com/object/privacy_policy.html" onclick="s_objectID="http://www.nvidia.com/object/privacy_policy.html_1";return this.s_oc?this.s_oc(e):true">Privacy Policy </a> </div> </div> </div> diff --git a/NvCloth/docs/documentation/searchindex.js b/NvCloth/docs/documentation/searchindex.js index ca646a5..0a5c06b 100644 --- a/NvCloth/docs/documentation/searchindex.js +++ b/NvCloth/docs/documentation/searchindex.js @@ -1 +1 @@ -Search.setIndex({envversion:42,terms:{represent:2,all:[1,2,9,4,5,6,8,10,3],code:[5,6,7,2,11,12],edg:1,orthogon:12,skip:[2,6],lack:5,yellow:1,minusa:2,signific:1,sleep:12,per:[1,12,6],capsul:11,skin:[2,6],follow:[12,9,4,6,2,3],calculatepotentialcollid:4,mupper:4,minusk:2,content:[7,11],depend:[9,1,12,6],sensit:6,adjacencycount:3,negativescal:2,setselfcollisiondist:1,program:9,gsimd4fon:2,those:[2,4],q_0:2,text:[2,9,12],vcxxwinxx:9,sens:2,leav:2,introduc:5,everyth:[9,6],certain:9,generateprojectsio:9,sourc:12,everi:[2,1,4],lrg:12,reproduct:8,far:2,than:[2,1,3,6],incompat:5,offlin:10,vertex:[2,6],assimp:9,volum:[2,4,12,6],friction:[2,5,6],setplan:6,fall:2,veri:[2,4,6],affect:[12,5],ajust:12,brows:0,tri:[1,4],pbw:12,info:2,dampen:6,doesn:[2,5,6],stiff:1,did:5,list:[3,4,12,6,10],prefix:3,iter:[2,4,12,6],readabl:2,"try":6,tunnel:6,race:3,swcollis:[2,1],d_o:2,sqdeltalegnth:2,small:[2,12],setdragcoeffici:6,playstat:5,freed:6,dir:12,setmotionconstraintstiff:6,upper:1,smaller:[1,12,6],p_j:12,unnorm:12,mdeltaxyz:2,natur:6,compens:12,direct:[2,12,6],transform:[4,12,6],batch:[3,5],past:2,particle_invmass:12,second:[2,12],cost:2,design:0,pass:6,download:9,massscal:12,p_t:12,setstiffnessfrequ:12,currentparticlekei:1,index:[3,1,9,12,6],lastkei:1,r15c:9,neg:[2,6],section:[3,12,6,2],prevradiu:2,abl:9,sln:9,access:[0,1,4],delet:6,version:9,run:[2,9,6],linux64:9,intersect:[2,1,4,6],"new":[3,12,5,6],impuls:[2,12,6],method:[2,5,6],movement:[2,12,6],cull:[2,1,4],mlower:4,intellectu:8,hash:1,mergeacceler:2,locate_cuda:9,cellcount:1,curradiu:2,getsimulationchunkcount:6,never:2,dotcurcur:2,onli:[1,4,5,6,2,3],here:[2,12,6,10],shape:[5,6],tangent:2,sortedindic:4,trunk:9,path:9,along:[2,1,6],vertic:[12,6],p_2:12,sinc:6,valu:[3,1,12,6,2],p_1:[2,12],box:4,x86_64:9,convert:[2,1],shift:6,anymor:5,larger:1,bot:2,later:[9,3,6],precis:6,bitmask:2,r12b:[9,5],setposit:6,pick:[1,12,6],clearmotionconstraint:6,chang:[2,9,5,6],narrow:4,magnitud:2,overrid:5,eshear:6,via:5,sskeletonwidth:2,triplet:3,extra:[3,12],appli:[2,12,6],approxim:2,sphereradiu:[2,6],linearli:[2,5],c_1:[2,12],c_0:[2,12],c_2:[2,12],clothfabriccook:6,sr_0:2,integrateparticl:12,instabl:[12,6],instal:9,decrement:3,total:3,unit:[2,5],from:[1,2,3,4,5,6,8,9,10,12],describ:[1,12,6,7,2,11,3],would:[2,5],memori:[4,6],fill:[2,3,6],give:[12,4,6,2,10,3],regist:2,two:[2,1,6],madjac:3,next:[3,1,9,12,2],live:5,solvefabr:12,call:6,shortest:1,taken:[1,6],suppos:1,type:[12,6],tell:6,reorder:3,"const":6,sort:4,flat:[2,5],desir:6,settetherconstraintstiff:[12,6],c_i:2,c_j:12,p_0p_1:2,finit:2,warn:5,pxprofilercallback:6,visual:[9,5],mparticleindic:4,c_t:12,"4ac":2,known:[1,5],ebend:6,hold:6,oldradiu:6,logarithm:12,madjacencyindeci:3,none:5,graphic:6,left:[2,12],stretchlimit:12,local:[4,12],prepar:10,work:[5,6,7,2,11,12],uniqu:3,swcloth:3,remain:[1,12,6],pxquat:6,vertexcount:6,can:[1,12,4,6,2,9,10,3],particledelta:2,collidespher:2,d3d11:6,root:9,veloc:[2,12,6],tripletschedul:7,control:[9,6],nearest:12,overlapbound:4,process:[9,1,3],lock:6,share:[3,6],calcul:[1,12,4,5,6,2,3],gsimd4fepsilon:2,high:[12,5],sphere:11,minimum:[2,1,4],proprietari:8,bend:12,want:[1,12,6,10],setvirtualparticl:3,setconvex:6,simul:5,occur:2,getparticl:4,alwai:6,differenti:[12,6],multipl:[3,4,12,5,6],parralel:3,divid:[3,1,12,6,2],divis:12,how:[3,1,12,6],enforc:12,low:0,env:9,instead:[1,12,4,6,2,3],q_0q_1:2,config:[12,6],sin:[2,12],updat:[12,6],product:[2,0],collisionshap:6,frac:[2,12],clothdata:1,referenc:3,teleport:[5,6],tetherconstraintstiff:12,max:12,after:[12,9,4,6,2,3],tool:5,surfac:[2,12],usabl:2,constraint:1,diagram:[2,1],befor:[2,9,6],mesh:[1,6,10],generatecon:2,buildacceler:2,mai:[12,6],end:[2,9,12,6],data:[2,10],parallel:[9,3],averag:2,stabil:6,alloc:[3,5,6],setwindveloc:6,interpol:[2,12],"6th":2,createcloth:6,favorit:9,correspond:[2,6],processor:9,issu:[5,6],inform:[12,6],"switch":[5,6],combin:[3,1,12,6,2],allow:[5,6],nvidia:9,exclus:3,attachmentvertic:6,"253x253":1,order:[3,1,12,6,2],wind:5,vc14win64:9,oper:1,p_0c_0:2,help:[9,12,6],v_r:2,routin:2,gradual:6,over:[2,4,6],move:[2,12,5,6],becaus:[2,1,12],meter:6,cross:2,sphere_radiu:12,nv_cloth_delet:6,paper:12,through:[2,3,6],sqrt:[2,12],evert:6,v_l:2,still:[3,12,6],pointer:1,directx:5,paramet:[12,5,6],snippet:6,typedef:5,outer:2,render:6,apex:5,fix:[9,12,5,6],constrainsepar:12,better:[5,6],platform:[9,12,5,6],pend:6,mrestvalu:12,requir:[1,9,6],bypass:10,clothimpl:[12,5],featurelevel:6,might:[9,12,6],arrai:[3,1,4,12,6],recip:2,non:[2,1,6],good:[2,6],crash:5,thei:[2,1,6],handl:[2,6,10],"2q_0":2,deiniti:6,sooner:12,number:[5,6],"break":6,mappedrang:6,asr_0:2,intercollis:4,now:[1,4,5,6,2,3],discuss:2,bigger:2,makefil:9,somewher:6,name:12,anyth:6,edit:9,simpl:6,solver:[2,9,5],separ:3,easili:6,mode:5,ratio:1,each:[1,12,4,6,2,3],debug:[9,5],ndk:[9,5],penetr:[2,6],complet:5,out:[3,6],mtriplet:3,mean:[12,6],clamp:[2,6],prohibit:8,devrel:9,cudacontext:6,weight:12,replac:[12,6],individu:[1,4,3,6],continu:[2,1,3,6],realli:2,path_to_android_ndk:9,dx11:[9,5,6],"static":[5,6],connect:[9,12,6],someth:6,fluctuat:12,happen:[2,12],thing:6,firstkei:1,variabl:[2,1,9],getnumcloth:5,won:2,space:[2,4,12],goe:12,open:9,develop:[0,9],profil:6,rewrit:[2,12],adjust:[12,6],suitabl:0,rel:[2,1,6],internet:9,hardwar:5,formula:2,gridbia:1,correct:[3,2,12,5,6],red:2,mphase:12,log2:12,linear:[2,6],insid:[2,9,3,5,6],advanc:6,midpoint:2,inclus:3,selfcollideparticl:12,reason:[1,12],base:[9,1,4,12,6],discrimin:2,removecloth:6,releas:9,org:9,"byte":[1,6],compressionlimitc:12,refer:[2,12,6],bash:9,care:[4,6],setliftcoeffici:6,reusabl:6,r_0r_1:2,thread:6,buildprojectsio:9,angl:12,frequenc:[12,6],could:[3,5,6],omit:2,put:9,keep:[1,12,4,6,2,3],recov:[12,6],stride:6,length:[2,1,12,6],plane:[11,3,12,6,2],place:[9,3],outsid:12,nvcloth:[1,2,9,4,7,8,11,3],retain:8,onto:2,licens:8,first:[1,12,4,6,2,9],origin:[12,6],softwar:8,obviou:4,curesult:6,cuda_success:6,mise:5,independ:12,scene:[5,6],sometim:6,pop:12,alreadi:[5,6],done:[1,12,4,2,9,3],least:[1,3,6],robust:0,setcapsul:[5,6],thick:2,miss:6,primari:2,mpaddedtriplet:3,helper:[3,5,6],given:[3,1,12,2],optim:[1,3,5],script:9,exp2:2,interact:0,flag:5,system:6,construct:[2,1,6],toi:2,too:[1,12,6],circl:2,sear:12,gpu:[3,5,6],dt1:12,dt0:12,store:[1,12,4,6,2,3],includ:[9,12,6,10],dampexpon:12,getnumtriangl:6,option:[9,6],especi:[5,6],namespac:5,aabb:[1,5],copi:[9,3],lower:[1,4,6],specifi:[1,12,6],clothmeshdesc:6,part:[2,12,10],enclos:4,mostli:12,quad:[6,10],exactli:[2,12],t4f:[2,1],ehorizont:6,f_d:12,prune:2,provid:[0,1,6,10],remov:[5,6],onc:1,rate:[2,12,6],horizont:[12,6],project:[2,9],matter:6,reus:[2,1,12],were:[2,5],posit:[2,1,12,6],amount:[1,3],dxcontextmanagercallback:6,expf:12,lowest:2,vector:[12,6],comput:2,behavior:[12,5,6],nicer:1,explicit:12,c_0c_1:2,getclothlist:5,ani:[8,4,6],nvclothcookfabricfrommesh:6,dash:2,necessari:6,thereto:8,constrainteth:12,have:[3,12,6,2],reserv:[8,1,3],need:[1,12,4,6,2,9,3],seen:12,mset:12,border:2,cmakegenerateal:9,polynomi:2,caus:[12,5,6],rmin:2,strength:6,engin:6,squar:3,lib:[9,10],min:[2,1,12],r_p:2,destroi:6,self:11,endsimul:6,mid:2,accuraci:6,note:[2,1,9],also:[3,1,12,6,2],discret:2,take:4,indic:[2,1,4,12,6],environ:9,graviti:6,singl:12,clearinertia:6,compat:6,begin:[3,1,12,6,2],sure:9,android_ndk_root:9,packman:9,though:[2,1,12],multipli:[2,12,6],dxdevic:6,previou:[2,1,12,6],compress:6,what:2,react:[5,6],most:[12,6],beta:5,regular:[2,1],cucontext:6,rho:12,thi:[1,2,3,4,6,7,8,9,10,11,12],pair:[2,1,4,12,6],alpha:2,cap:2,"8x8x8":2,getmotionconstraint:6,worldspac:4,don:[2,1,3],r_0:2,r_1:2,clear:6,r_3:2,cover:1,collisionmask:2,doe:[2,1,4,12,6],settetherconstraintscal:6,zero:[12,6],runtim:[10,5,6],determin:[2,4,3],occasion:12,constrain:[12,6],impulseaccumul:2,blend:6,sum:[2,3],dot:2,slope:2,settodefault:6,radix:1,getcurrentparticl:6,show:6,opposit:12,xcode:[9,5],beginsimul:6,stiffnessexpon:12,radiu:[2,12,6],brief:10,directli:[2,1,4,6,10],concurr:6,dxdevicecontext:6,unchang:6,threshold:12,unfinish:12,find:3,setintercollisiondist:4,impact:2,current:[2,1,12,6,10],id3d11devic:6,slow:[1,12],locat:[3,6],a_1:2,simulatechunk:6,explain:[2,12],configur:[9,6],solut:[9,12],"2r_0":2,should:[3,9,12,6],computebound:[1,12],experiment:5,black:2,undesir:6,factor:[12,6],sierra:5,physx:[12,5,6],folder:9,libdev:9,dotprevcur:2,count:[3,1,12,6,2],unus:5,variou:9,get:[12,6],pxallocatorcallback:6,stomp:3,express:8,stop:2,fluid:[12,5,6],newradiu:6,bucketmask:1,cannot:[1,4,3,6],phasetypeinfo:6,longest:1,progress:12,increas:[12,6],sqrconehalflength:2,deploy:9,clothbound:4,target:[9,12,6],bat:9,enabl:[2,9,5,6],artist:6,a_0a_:2,gust:6,v8a:[9,5],"2m_":2,f_l:12,setlinearinertia:6,contain:[12,1,9,6,2,3],cudevicegetcount:6,where:[2,1,12,5],view:0,set:[1,12,4,6,2,9,3],sampl:[9,5],d3d11createdevic:6,frame:[2,12],maximum:[2,12],graphicscontextmanag:6,d3d_driver_type_hardwar:6,see:[2,9],sed:9,einvalid:6,result:[3,2,12,5,6],sqraxishalflength:2,mstiff:6,close:1,xxxxx:9,particl:4,deriv:2,closer:12,setangularinertia:6,pxerrorcallback:6,collisiondist:1,correctli:2,sphere_cent:12,vari:6,boundari:4,dll:10,enough:1,devicecount:6,"2r_1r_0":2,dynam:[5,6],movingaverag:5,between:[2,1,12,6],prebuilt:9,theta:12,awai:[1,4],previous:6,approach:2,across:6,altern:[9,3],oscil:6,attachmentposit:6,extend:2,osx64:9,coeffici:[2,12,5,6],flow:[12,5],condit:[3,12,2],rapidli:6,nvclothdestroyfactori:6,job:9,vc14winxx:9,solv:[2,12,6],group:6,come:6,inertia:6,addit:[4,12,5,6],mstretchlimit:6,both:[2,12,6],locate_cmak:9,last:[3,1,12,6],planesr:6,similar:[2,4,6],howev:2,equal:[12,6],against:[2,1,4],nearbi:1,etc:6,instanc:[12,6],equat:[2,12],context:6,stiffnessc:12,whole:[1,6],multithreadedsolverhelp:5,comment:[2,12],springi:6,simpli:9,author:5,point:[3,9,12,6,2],within:[2,1,6],schedul:3,int32_t:6,decrefcount:6,sweep:4,chmod:9,addcloth:[5,6],written:[3,12],cuctxdestroi:6,"4asr_0":2,sentinel:1,trianglecount:6,assum:2,duplic:[1,3],coupl:6,engwiki:2,aarch64:9,simdwidth:3,damp:[12,6],infinit:2,devic:6,invers:[12,6],setspher:6,mark:[2,1,4],proport:2,accumul:2,trigger:6,p_0:[2,12],modif:8,trajectori:2,dure:2,quickli:1,radii:[2,6],sphererang:6,clothfabricphasetyp:6,imag:2,densiti:[12,5,6],search:0,unnecessarili:2,argument:[9,6],assert:[5,6],r_2:2,lift:[12,5],togeth:6,oneminustoi:2,tangenti:2,nvclothcreatefactorydx11:6,"2q_0q_1":2,present:[5,6],"case":[2,9,12,6],highest:2,look:[2,6],influenc:[12,6],align:[2,12,6],properti:[8,4],mcloth:6,setgrav:6,air:[12,5,6],log_2:12,defin:[12,6],"while":[2,12,5,6],match:12,mindic:12,error:[9,12,5,6],report:6,"2r_0r_1":2,anchor:12,loop:[1,3],subsect:2,propag:12,use_dx11:9,stiffnessfrequ:12,cell:[2,1],mcompressionlimit:6,almost:5,getnumconvex:6,made:2,initializenvcloth:6,them:6,physic:[5,6],particle_posit:12,"default":[9,6],itself:6,setsolverfrequ:6,abov:[1,12,5,6,2,9],quadrat:2,primit:6,around:1,sap:2,let:6,paw:12,perform:[5,6],make:[1,12,5,6,2,9,3],belong:12,x64:5,same:[3,10,12,6,2],binari:[2,9],when:[1,12,5,6,2,3],html:9,pad:3,split:2,largest:1,automat:9,dimensionless:6,triangler:6,start:[1,12,5,6,2,3],conflict:3,higher:6,nvclothcreatefactorycuda:6,http:9,x86:9,unwant:6,again:[2,6],nvclothext:6,blue:2,effect:6,kit:9,getnorm:6,temporari:4,user:[2,1,12,10],mani:[1,12,6],extern:9,buildprojectsosx:9,bia:[1,12,6],respons:4,implement:[12,5,6],expand:2,sqrlength:12,usemultipli:12,task:10,equival:4,older:5,cuctxcreat:6,com:9,usual:[12,6],well:5,know:6,without:[8,1,12,3,6],exampl:[9,3,6],command:9,uint32_t:[3,6],choos:9,model:[12,5],powf:12,dimension:12,ubuntu:5,cmakegenerateproject:9,explan:12,distanc:[2,1,4],identifi:1,getnumphas:6,just:9,a_0:2,deltax:6,collidecon:2,deltaz:6,exclud:9,obtain:[2,1,9],"4th":6,detail:[2,1,12,6],mvelxyz:2,particleposit:6,"2q_1q_0":2,licensor:8,touch:2,deltai:6,rest:[2,1,12,6],roughli:2,speed:[12,5],yet:5,ps4:5,settransl:6,motionconstraint:6,element:[3,12],struct:6,easi:[0,6],r_i:2,iterationst:12,had:5,except:9,littl:0,add:6,other:[2,1,4,12,6],r13b:9,bank:3,timestep:12,els:12,hat:12,euler:12,build:[9,5],bin:[1,9],applic:[0,6],numteth:12,which:[1,12,4,5,6,2,10,3],format:1,meshdesc:6,fast:[0,5,6],"4m_":2,d3d_feature_level_11_0:6,game:[0,6],tabl:3,dxcontextmanagercallbackimpl:6,vacuum:6,pxvec4:[12,6],world:[4,6],bit:[2,1,9,6],a_l:2,you:[9,6],lowerbound:1,pxvec3:6,insert:6,like:[3,9,12,6,2],specif:[9,1,12],arbitrari:[1,6],cdot:[2,1,12],realtim:0,manual:[1,6],stiffnessmultipli:12,xbox:5,api:5,setfrict:6,use_cuda:9,corpor:8,resiz:3,architectur:5,r_m:2,manag:6,right:[8,12,2],old:5,often:[3,12,6],deal:4,simplifi:[2,6],flt_max_exp:12,numsweepcel:1,some:[2,9,4,12,6],back:[4,6],global:6,s_ok:6,llvm:5,csigg:2,mask:[2,6],diff:1,setrot:6,sizeof:6,successfulli:3,librari:[9,5,10],distribut:[8,9],mclothindic:4,scale:[2,1,12,5],mattachmentvertexoriginalposit:6,avoid:[2,3,5,6],size:[3,1,12,6],definit:2,overlap:[2,4],studio:[9,5],circ:12,compressionlimit:12,larg:[1,12,6],"__t100":5,visit:0,complic:6,constraintmot:12,spherecent:[2,6],core:10,particular:12,object:[4,6],tmin:2,reach:[12,6],locate_win8sdk:9,updatesleepst:12,agreement:8,symlink:9,interfac:[0,5,6],ltoi:2,broken:6,step:[2,12,6],durat:2,although:12,offset:[2,1,12],getnumplan:6,subtract:1,d3d11_sdk_version:6,stage:6,about:6,inter:11,toolchain:9,particlecount:6,applywind:12,deltatim:6,createsolv:6,shield:5,page:[0,12],stretch:[12,6],disclosur:8,cuda:[9,3,5,6],neighbor:1,span:2,t_2:2,t_3:2,underwat:6,t_1:2,disabl:[2,9,5,6],produc:3,particle_position1:12,setcentrifugalinertia:6,own:[1,6,10],liveli:6,centimet:6,d3d_feature_level:6,stretchi:[12,6],xyz:[2,12,6],"float":[12,6],bound:[2,1,4,3],particle_position0:12,due:[12,5,6],diagon:3,nullptr:6,framer:12,been:[2,6],vertexarrai:6,ensur:[3,1,12,6,2],mphaseindex:6,destructor:6,precomput:2,your:[9,6],setmotionconstraintscalebia:6,sqrtd:2,straightforward:6,accordingli:6,strechlimitc:12,triangl:[12,5,6,2,10,11,3],fabric:[1,10],wai:[3,4,12,6,2],area:[12,6],execut:[2,9,6],support:[9,5,10],rotat:[12,5],depenetr:2,"long":6,createfabr:6,avail:1,getnumspher:6,adjac:3,appl:5,restlength:12,editor:9,spring:6,twice:2,overhead:0,strictli:8,chunk:5,"function":[2,4,3,5,10],properli:6,setfluiddens:5,form:12,forc:[2,12,6],epsilon:[2,1,12],basic:[1,12],refcount:6,idea:6,a_1a_:2,cloth:[1,12,4,5,2,3],state:12,link:5,newer:9,scope:6,renam:9,line:[2,9],level:0,"true":4,bug:5,sdk:[9,5],reset:6,notat:12,numparticl:12,tetherlength:12,input:3,consist:6,possibl:[1,3,5],whether:9,cooker:6,displai:6,less:[2,12,6],directori:9,below:[2,1,12,6],limit:[12,6],arm64:[9,5],unlock:6,cit:2,getnumcapsul:6,otherwis:12,problem:[2,12,6],more:[2,1,3,5,6],even:[2,12,6],motion:12,featur:[0,12,6,10],constant:[2,12],creat:[3,9,12,6],"int":6,descript:10,inv:12,convex:[11,6],dotprevprev:2,stretchlimitc:12,mstiffnessmultipli:6,repres:6,time:[3,12,6,2],decreas:6,rule:6,file:9,home:0,improv:[5,6],check:[2,1,12,6],piw:12,incorrect:5,constrainmot:12,collid:[2,1,12,6],cmake:[9,5],nx0:9,buffer:1,plausibl:6,setdamp:[12,6],nan:6,green:2,virtual:5,generateprojectslinux:9,cleanup:6,capsuleindic:6,generateprojectsosx:9,normal:[2,12],setphaseconfig:6,test:[2,1,4,9,5],ignor:2,buildprojectslinux:9,logdamp:12,p_0c_1:2,multiplierc:12,relat:[7,8,10],regardless:6,symbol:12,center:[2,12,6],phaseconfig:[12,6],"return":6,pxasserthandl:6,gcc:5,"class":[3,6],drag:[12,5],track:[2,3],q_1:2,gridscal:1,halfb:2,doubl:[2,12],nvclothcreatefactorycpu:6,c_0p_1:2,cmakegenerateandroid:9,stai:[2,6],reduc:[2,12,6],axi:[2,1,4],id3d11devicecontext:6,featurelevelresult:6,algorithm:[7,3],coordin:[1,6],inaccuraci:12,callback:6,pseudo:12,indirectli:6,probabl:[12,6],microsoft:9,hresult:6,delta:[2,1,12,6],safe:6,mass:[2,12,5,6],potenti:6,settriangl:6,"export":9,mathrm:12,cpu:[3,5,6],stick:2},objtypes:{},objnames:{},filenames:["index","CollisionDetection/SelfCollision","CollisionDetection/SphereCapsuleCollision","Cooking/TripletScheduler","CollisionDetection/InterCollision","ReleaseNotes/index","UserGuide/Index","Cooking/Index","CopyRight/Index","Compiling/index","Modules/Index","CollisionDetection/Index","Solver/Index"],titles:["NvCloth","Self Collision","Sphere Capsule collision detection","TripletScheduler","Inter Collision","Release Notes","User Guide","Internal cooking documentation","NVIDIA Copyright Notice","Compiling","Modules","Internal collision detection documentation","Internal solver function/algorithm documentation"],objects:{},titleterms:{distanc:[12,6],edg:12,acceler:[2,1,4],capsul:2,simd:3,tripletschedul:3,copyright:8,window:9,local:6,adjacencyqueri:3,anim:6,initi:6,grid:1,cook:7,solver:[12,6],troubleshoot:6,stiff:12,calculatefrictionimpuls:2,separ:12,integr:12,inter:4,compil:9,frame:6,intern:[7,11,12],respons:1,tether:[12,6],todo:11,particl:[1,12],scale:6,space:6,broad:4,factori:6,common:6,kei:1,gener:2,usag:6,extens:10,releas:5,log:12,about:0,constraint:[12,6],mac:9,simul:[12,6],motion:6,nvcloth:[0,10],rang:1,overview:[7,11,1,4,12],modul:[7,11,10],sweep:1,linux:9,guid:6,unit:6,differ:[7,11,4],fabric:[12,6],compon:12,attach:6,warp:3,more:0,"function":12,notic:8,cloth:6,lift:6,retriev:6,slack:12,setup:[1,6],properti:6,structur:[2,1,4,12],charact:6,learn:0,sort:1,sphere:2,cone:2,invmass:12,disappear:6,self:[1,4],note:5,collis:[11,2,1,4,6],librari:6,android:9,document:[7,11,12],singl:6,drag:6,detect:[11,2,1,4,6],user:6,phase:4,collideparticl:2,data:[12,6],algorithm:12,part:6,nvidia:8,ccd:2,wind:[12,6]}})
\ No newline at end of file +Search.setIndex({envversion:42,terms:{represent:2,all:[1,2,5,4,6,7,9,10,12],code:[6,7,8,2,11,3],edg:[],orthogon:3,skip:[2,7],lack:6,yellow:1,minusa:2,signific:1,sleep:3,per:[1,3,7],capsul:[],skin:[2,7],follow:[12,4,5,7,2,3],calculatepotentialcollid:4,mupper:4,minusk:2,content:[8,11],depend:[3,1,12,7],sensit:7,adjacencycount:5,negativescal:2,setselfcollisiondist:1,program:12,gsimd4fon:2,those:[2,4],q_0:2,text:[3,12,2],vcxxwinxx:12,sens:2,setfrict:7,introduc:6,everyth:[12,7],certain:12,generateprojectsio:12,sourc:3,everi:[2,1,4],lrg:3,reproduct:9,far:2,offlin:10,strechlimitc:3,vertex:[2,7],assimp:12,volum:[2,4,3,7],friction:[2,6,7],setplan:7,fall:2,veri:[2,4,7],affect:[3,6],ajust:3,brows:0,tri:[1,4],pbw:3,info:2,dampen:7,doesn:[2,6,7],stiff:[],did:6,list:[5,4,3,7,10],prefix:5,iter:[2,4,3,7],"try":7,tunnel:7,race:5,swcollis:[2,1],d_o:2,sqdeltalegnth:2,small:[2,3],setdragcoeffici:7,freed:7,dir:3,setmotionconstraintstiff:7,upper:1,smaller:[1,3,7],p_j:3,unnorm:3,mdeltaxyz:2,natur:7,compens:3,direct:[2,3,7],transform:[4,3,7],sign:0,past:2,second:[2,3],cost:2,design:0,pass:7,download:12,massscal:3,p_t:3,setstiffnessfrequ:3,currentparticlekei:1,index:[3,1,12,7,5],lastkei:1,r15c:12,neg:[2,7],section:[2,3,7,5],prevradiu:2,abl:12,brief:10,access:[0,1,4],delet:7,version:12,run:[2,12,7],linux64:12,intersect:[2,1,4,7],"new":[5,3,6,7],impuls:[2,3,7],method:[2,6,7],movement:[2,3,7],cull:[2,1,4],mlower:4,intellectu:9,hash:1,mergeacceler:2,locate_cuda:12,cellcount:1,curradiu:2,getsimulationchunkcount:7,never:2,dotcurcur:2,onli:[1,4,6,7,2,5],here:[2,3,7,10],shape:[6,7],tangent:2,sortedindic:4,trunk:12,path:12,along:[2,1,7],vertic:[3,7],p_2:3,sinc:7,valu:[2,1,3,7,5],p_1:[2,3],box:4,x86_64:12,convert:[2,1],shift:7,anymor:6,larger:1,bot:2,precis:7,bitmask:2,r12b:[12,6],setposit:7,pick:[1,3,7],clearmotionconstraint:7,chang:[2,12,6,7],narrow:4,magnitud:2,overrid:6,eshear:7,via:6,sskeletonwidth:2,triplet:5,extra:[5,3],readabl:2,approxim:2,sphereradiu:[2,7],linearli:[2,6],c_1:[2,3],c_0:[2,3],c_2:[2,3],clothfabriccook:7,sr_0:2,instabl:[3,7],instal:12,decrement:5,total:5,unit:[],leav:2,from:[1,2,3,4,5,6,7,9,10,12],describ:[1,5,7,8,2,11,3],would:[2,6],memori:[4,7],subtract:1,fill:[2,5,7],give:[5,4,7,2,10,3],regist:2,two:[2,1,7],madjac:5,next:[3,1,12,5,2],live:6,solvefabr:3,call:7,shortest:1,taken:[1,7],suppos:1,type:[3,7],tell:7,reorder:5,"const":7,sort:[],flat:[2,6],desir:7,settetherconstraintstiff:[3,7],c_i:2,detail:[2,1,3,7],c_j:3,p_0p_1:2,finit:2,warn:6,packman:12,visual:[12,6],mparticleindic:4,c_t:3,"4ac":2,known:[1,6],ebend:7,hold:7,oldradiu:7,logarithm:3,madjacencyindeci:5,none:6,graphic:7,left:[2,3],stretchlimit:3,local:[],prepar:10,work:[6,7,8,2,11,3],uniqu:5,swcloth:5,remain:[1,3,7],pxquat:7,vertexcount:7,can:[1,12,4,5,7,2,10,3],particledelta:2,collidespher:2,d3d11:7,root:12,veloc:[2,3,7],tripletschedul:[],control:[12,7],nearest:3,overlapbound:4,process:[5,1,12],lock:7,share:[5,7],sln:12,gsimd4fepsilon:2,high:[3,6],sphere:[],minimum:[2,1,4],proprietari:9,bend:3,want:[1,3,7,10],setvirtualparticl:5,setconvex:7,simul:[],occur:2,q_0q_1:2,alwai:7,differenti:[3,7],multipl:[5,4,3,6,7],parralel:5,divid:[2,1,3,7,5],snippet:7,how:[5,1,3,7],low:0,env:12,instead:[1,5,4,7,2,3],getparticl:4,config:[3,7],sin:[2,3],updat:[3,7],product:2,collisionshap:7,frac:[2,3],clothdata:1,referenc:5,teleport:[6,7],tetherconstraintstiff:3,max:3,after:[12,4,5,7,2,3],surfac:[2,3],usabl:2,constraint:[],diagram:[2,1],befor:[2,12,7],mesh:[1,7,10],generatecon:2,buildacceler:2,mai:[3,7],end:[3,12,7,2],data:[],parallel:[5,12],averag:2,stabil:7,alloc:[5,6,7],setwindveloc:7,interpol:[2,3],"6th":2,createcloth:7,favorit:12,correspond:[2,7],exclud:12,issu:[6,7],inform:[3,7],"switch":[6,7],combin:[2,1,3,7,5],allow:[6,7],nvidia:[],exclus:5,attachmentvertic:7,"253x253":1,when:[1,5,6,7,2,3],order:[2,1,3,7,5],wind:[],vc14win64:12,oper:1,p_0c_0:2,help:[3,12,7],v_r:2,routin:2,gradual:7,over:[2,4,7],move:[2,3,6,7],becaus:[2,1,3],meter:7,cross:2,sphere_radiu:3,nv_cloth_delet:7,paper:3,through:[2,5,7],sqrt:[2,3],evert:7,v_l:2,still:[5,3,7],pointer:1,directx:6,paramet:[3,6,7],divis:3,typedef:6,outer:2,render:7,apex:6,fix:[3,12,6,7],constrainsepar:3,better:[6,7],platform:[3,12,6,7],pend:7,mrestvalu:3,requir:[1,12,7],bypass:10,clothimpl:[3,6],featurelevel:7,might:[3,12,7],arrai:[5,1,4,3,7],recip:2,non:[2,1,7],good:[2,7],crash:6,thei:[2,1,7],handl:[2,7,10],"2q_0":2,deiniti:7,sooner:3,number:[6,7],"break":7,mappedrang:7,intercollis:4,now:[1,4,6,7,2,5],"class":[5,7],discuss:2,bigger:2,makefil:12,somewher:7,name:3,anyth:7,edit:12,simpl:7,solver:[],mphaseindex:7,separ:[],easili:7,mode:6,ratio:1,each:[1,5,4,7,2,3],debug:[12,6],ndk:[12,6],penetr:[2,7],complet:6,mtriplet:5,mean:[3,7],clamp:[2,7],prohibit:9,eula:0,devrel:12,cudacontext:7,weight:3,replac:[3,7],individu:[1,4,5,7],continu:[2,1,5,7],realli:2,playstat:6,dx11:[12,6,7],"static":[6,7],connect:[3,12,7],someth:7,fluctuat:3,happen:[2,3],out:[5,7],variabl:[2,1,12],getnumcloth:6,won:2,space:[],goe:3,open:12,your:[12,7],profil:7,rewrit:[2,3],adjust:[3,7],suitabl:0,rel:[2,1,7],internet:12,hardwar:6,formula:2,chmod:12,gridbia:1,correct:[2,3,6,5,7],red:2,mphase:3,log2:3,linear:[2,7],insid:[2,12,6,5,7],advanc:7,midpoint:2,inclus:5,selfcollideparticl:3,reason:[1,3],base:[3,1,4,12,7],discrimin:2,removecloth:7,releas:[],org:12,"byte":[1,7],compressionlimitc:3,refer:[2,3,7],bash:12,care:[4,7],setliftcoeffici:7,reusabl:7,r_0r_1:2,thread:7,buildprojectsio:12,angl:3,frequenc:[3,7],could:[5,6,7],omit:2,put:12,keep:[1,5,4,7,2,3],recov:[3,7],thing:7,length:[2,1,3,7],enforc:3,place:[5,12],outsid:3,nvcloth:[],retain:9,onto:2,licens:9,first:[1,12,4,7,2,3],origin:[3,7],softwar:9,obviou:4,curesult:7,cuda_success:7,mise:6,independ:3,scene:[6,7],sometim:7,clear:7,alreadi:[6,7],done:[1,12,4,5,2,3],least:[1,5,7],setcapsul:[6,7],thick:2,miss:7,primari:2,mpaddedtriplet:5,given:[2,1,3,5],optim:[1,5,6],script:12,exp2:2,interact:0,flag:6,system:7,construct:[2,1,7],toi:2,halfb:2,circl:2,time:[2,3,7,5],gpu:[5,6,7],dt1:3,dt0:3,store:[1,5,4,7,2,3],too:[1,3,7],dampexpon:3,getnumtriangl:7,option:[12,7],especi:[6,7],namespac:6,tool:6,copi:[5,12],lower:[1,4,7],plane:[11,2,3,7,5],part:[],enclos:4,mostli:3,quad:[7,10],exactli:[2,3],than:[2,1,5,7],ehorizont:7,f_d:3,prune:2,provid:[0,1,7,10],remov:[6,7],d3d11createdevic:7,rate:[2,3,7],horizont:[3,7],project:[2,12],matter:7,reus:[2,1,3],includ:[3,12,7,10],were:[2,6],posit:[2,1,3,7],amount:[1,5],dxcontextmanagercallback:7,expf:3,lowest:2,vector:[3,7],comput:2,abov:[1,12,6,7,2,3],nicer:1,explicit:3,c_0c_1:2,getclothlist:6,ani:[9,4,7],nvclothcookfabricfrommesh:7,dash:2,thereto:9,constrainteth:3,have:[2,3,7,5],tabl:5,need:[0,1,3,4,5,7,2,12],clothmeshdesc:7,incompat:6,border:2,probabl:[3,7],caus:[3,6,7],rmin:2,strength:7,engin:7,squar:5,lib:[12,10],min:[2,1,3],r_p:2,destroi:7,self:[],endsimul:7,mid:2,accuraci:7,note:[],also:[2,1,3,7,5],discret:2,take:4,which:[1,5,4,6,7,2,10,3],environ:12,graviti:7,singl:[],clearinertia:7,compat:7,begin:[2,1,3,7,5],sure:12,android_ndk_root:12,thi:[0,1,2,3,4,5,7,8,9,10,11,12],safe:7,though:[2,1,3],multipli:[2,3,7],dxdevic:7,previou:[2,1,3,7],compress:7,what:2,react:[6,7],most:[3,7],beta:6,regular:[2,1],cucontext:7,specifi:[1,3,7],rho:3,pair:[2,1,4,3,7],alpha:2,cap:2,ltoi:2,"8x8x8":2,worldspac:4,cmakegenerateal:12,r_0:2,r_1:2,particle_invmass:3,later:[5,12,7],cover:1,collisionmask:2,doe:[2,1,4,3,7],settetherconstraintscal:7,runtim:[10,6,7],determin:[2,4,5],occasion:3,constrain:[3,7],unchang:7,blend:7,sum:[2,5],dot:2,slope:2,settodefault:7,radix:1,getcurrentparticl:7,show:7,opposit:3,xcode:[12,6],beginsimul:7,concurr:7,stiffnessexpon:3,radiu:[2,3,7],getnumcapsul:7,directli:[2,1,4,7,10],aabb:[1,6],dxdevicecontext:7,threshold:3,trianglecount:7,unfinish:3,find:5,setintercollisiondist:4,impact:2,current:[2,1,3,7,10],id3d11devic:7,slow:[1,3],locat:[5,7],a_1:2,simulatechunk:7,explain:[2,3],configur:[12,7],solut:[3,12],"2r_0":2,t4f:[2,1],computebound:[1,3],experiment:6,black:2,undesir:7,factor:[3,7],sierra:6,physx:[3,6,7],folder:12,libdev:12,dotprevcur:2,count:[2,1,3,7,5],unus:6,variou:12,get:[3,7],pxallocatorcallback:7,stomp:5,express:9,stop:2,fluid:[3,6,7],newradiu:7,bucketmask:1,getnumplan:7,cannot:[1,4,5,7],phasetypeinfo:7,longest:1,progress:3,increas:[3,7],sqrconehalflength:2,deploy:12,clothbound:4,target:[3,12,7],triangl:[5,6,7,2,10,11,3],bat:12,enabl:[2,12,6,7],artist:7,a_0a_:2,gust:7,v8a:[12,6],"2m_":2,f_l:3,contain:[1,12,5,7,2,3],cudevicegetcount:7,where:[2,1,3,6],view:0,set:[1,12,4,5,7,2,3],sampl:[12,6],sear:3,frame:[],maximum:[2,3],graphicscontextmanag:7,d3d_driver_type_hardwar:7,see:[2,12],sed:12,einvalid:7,result:[2,3,6,5,7],sqraxishalflength:2,reserv:[9,1,5],xxxxx:12,particl:[],deriv:2,closer:3,setangularinertia:7,pxerrorcallback:7,collisiondist:1,correctli:2,sphere_cent:3,vari:7,boundari:4,dll:10,enough:1,devicecount:7,"2r_1r_0":2,dynam:[6,7],movingaverag:6,between:[2,1,3,7],prebuilt:12,theta:3,awai:[1,4],settransl:7,approach:2,across:7,altern:[5,12],oscil:7,attachmentposit:7,numparticl:3,extend:2,osx64:12,coeffici:[2,3,6,7],close:1,flow:[3,6],condit:[2,3,5],nvclothdestroyfactori:7,job:12,vc14winxx:12,solv:[2,3,7],group:7,let:7,come:7,inertia:7,addit:[4,3,6,7],mstretchlimit:7,both:[2,3,7],locate_cmak:12,last:[5,1,3,7],planesr:7,avoid:[2,5,6,7],similar:[2,4,7],howev:2,equal:[3,7],against:[2,1,4],nearbi:1,etc:7,instanc:[3,7],processor:12,equat:[2,3],context:7,stiffnessc:3,whole:[1,7],multithreadedsolverhelp:6,comment:[2,3],springi:7,simpli:12,point:[3,12,7,5,2],within:[2,1,7],schedul:5,int32_t:7,decrefcount:7,sweep:[],pop:3,addcloth:[6,7],batch:[5,6],written:[5,3],"4asr_0":2,sentinel:1,diff:1,assum:2,duplic:[1,5],size:[5,1,3,7],coupl:7,engwiki:2,aarch64:12,simdwidth:5,damp:[3,7],infinit:2,devic:7,due:[3,6,7],been:[2,7],mark:[2,1,4],proport:2,accumul:2,trigger:7,setrot:7,p_0:[2,3],modif:9,trajectori:2,dure:2,quickli:1,radii:[2,7],sphererang:7,stride:7,clothfabricphasetyp:7,imag:2,densiti:[3,6,7],search:0,unnecessarili:2,argument:[12,7],assert:[6,7],coordin:[1,7],zero:[3,7],togeth:7,oneminustoi:2,tangenti:2,nvclothcreatefactorydx11:7,getmotionconstraint:7,present:[6,7],"case":[3,12,7,2],look:[2,7],influenc:[3,7],align:[2,3,7],properti:[],mcloth:7,setgrav:7,air:[3,6,7],log_2:3,defin:[3,7],calcul:[1,5,4,6,7,2,3],asr_0:2,mindic:3,error:[3,12,6,7],"2q_0q_1":2,"2r_0r_1":2,anchor:3,loop:[1,5],subsect:2,propag:3,use_dx11:12,stiffnessfrequ:3,helper:[5,6,7],mcompressionlimit:7,almost:6,getnumconvex:7,initializenvcloth:7,them:7,physic:[6,7],particle_posit:3,"default":[12,7],itself:7,r_2:2,setsolverfrequ:7,seen:3,quadrat:2,primit:7,mset:3,develop:12,author:6,perform:[6,7],make:[1,12,5,6,7,2,3],belong:3,x64:6,same:[2,3,7,5,10],"while":[2,3,6,7],binari:[2,12],report:7,html:12,pad:5,split:2,largest:1,automat:12,paw:3,dimensionless:7,triangler:7,start:[1,5,6,7,2,3],conflict:5,higher:7,nvclothcreatefactorycuda:7,http:12,x86:12,unwant:7,again:[2,7],nvclothext:7,blue:2,effect:7,kit:12,getnorm:7,temporari:4,user:[],mani:[1,3,7],extern:12,robust:0,particle_position1:3,bia:[1,3,7],respons:[],implement:[3,6,7],expand:2,sqrlength:3,usemultipli:3,task:10,equival:4,older:6,cuctxcreat:7,com:12,usual:[3,7],well:6,know:7,without:[9,1,3,7,5],exampl:[5,12,7],command:12,uint32_t:[5,7],choos:12,model:[3,6],powf:3,dimension:3,ubuntu:6,impulseaccumul:2,explan:3,distanc:[],identifi:1,getnumphas:7,just:12,a_0:2,deltax:7,collidecon:2,deltaz:7,obtain:[2,1,12],"4th":7,indic:[2,1,4,3,7],mvelxyz:2,should:[3,12,7,5],particleposit:7,"2q_1q_0":2,licensor:9,touch:2,deltai:7,rest:[2,1,3,7],roughli:2,speed:[3,6],yet:6,ps4:6,mstiff:7,motionconstraint:7,element:[5,3],struct:7,easi:[0,7],r_i:2,r_3:2,iterationst:3,had:6,except:12,littl:0,add:7,other:[2,1,4,3,7],r13b:12,bank:5,timestep:3,els:3,path_to_android_ndk:12,match:3,hat:3,euler:3,build:[12,6],bin:[1,12],applic:[0,7],numteth:3,sap:2,around:1,format:1,meshdesc:7,fast:[0,6,7],"4m_":2,game:[0,7],cell:[2,1],dxcontextmanagercallbackimpl:7,vacuum:7,pxvec4:[3,7],world:[4,7],bit:[2,1,12,7],a_l:2,you:[0,12,7],lowerbound:1,pxvec3:7,insert:7,ignor:2,like:[3,12,7,5,2],specif:[3,1,12],arbitrari:[1,7],cdot:[2,1,3],corpor:9,manual:[1,7],stiffnessmultipli:3,xbox:6,api:6,necessari:7,use_cuda:12,realtim:0,resiz:5,architectur:6,r_m:2,manag:7,right:[9,3,2],old:6,often:[5,3,7],deal:4,simplifi:[2,7],flt_max_exp:3,numsweepcel:1,some:[3,4,12,7,2],back:[4,7],global:7,s_ok:7,llvm:6,csigg:2,mask:[2,7],cmakegenerateproject:12,home:[],sizeof:7,successfulli:5,librari:[],distribut:[9,12],mclothindic:4,scale:[],mattachmentvertexoriginalposit:7,highest:2,setlinearinertia:7,definit:2,overlap:[2,4],rapidli:7,circ:3,compressionlimit:3,larg:[1,3,7],"__t100":6,visit:0,complic:7,constraintmot:3,spherecent:[2,7],core:10,particular:3,object:[4,7],tmin:2,reach:[3,7],locate_win8sdk:12,updatesleepst:3,agreement:9,symlink:12,interfac:[0,6,7],c_0p_1:2,broken:7,step:[2,3,7],durat:2,although:3,offset:[2,1,3],renam:12,appli:[2,3,7],don:[2,1,5],d3d11_sdk_version:7,stage:7,about:[],inter:[],toolchain:12,particlecount:7,applywind:3,deltatim:7,createsolv:7,shield:6,firstkei:1,page:[0,3],stretch:[3,7],disclosur:9,cuda:[5,12,6,7],neighbor:1,t_2:2,t_3:2,underwat:7,t_1:2,disabl:[2,12,6,7],produc:5,d3d_feature_level_11_0:7,setcentrifugalinertia:7,own:[1,7,10],liveli:7,centimet:7,d3d_feature_level:7,stretchi:[3,7],xyz:[2,3,7],"float":[3,7],bound:[2,1,4,5],particle_position0:3,invers:[3,7],diagon:5,nullptr:7,integrateparticl:3,vertexarrai:7,ensur:[2,1,3,7,5],framer:3,destructor:7,precomput:2,setspher:7,setmotionconstraintscalebia:7,sqrtd:2,straightforward:7,accordingli:7,git:0,span:2,fabric:[],wai:[2,4,3,7,5],area:[3,7],buildprojectsosx:12,execut:[2,12,7],support:[12,6,10],rotat:[3,6],depenetr:2,"long":7,createfabr:7,avail:1,getnumspher:7,adjac:5,appl:6,restlength:3,editor:12,spring:7,twice:2,overhead:0,strictli:9,chunk:6,"function":[],properli:7,setfluiddens:6,form:3,forc:[2,3,7],epsilon:[2,1,3],basic:[1,3],refcount:7,idea:7,a_1a_:2,cloth:[],state:3,link:6,newer:12,scope:7,id3d11devicecontext:7,line:[2,12],level:0,"true":4,bug:6,sdk:[12,6],reset:7,notat:3,made:2,tetherlength:3,input:5,consist:7,possibl:[1,5,6],whether:12,displai:7,directori:12,below:[2,1,3,7],limit:[3,7],arm64:[12,6],unlock:7,cit:2,pxprofilercallback:7,otherwis:3,problem:[2,3,7],more:[],even:[2,3,7],motion:[],featur:[0,3,7,10],constant:[2,3],creat:[3,12,7,5],"int":7,descript:10,inv:3,convex:[11,7],dotprevprev:2,stretchlimitc:3,mstiffnessmultipli:7,repres:7,decreas:7,file:12,behavior:[3,6,7],improv:[6,7],check:[2,1,3,7],piw:3,incorrect:6,constrainmot:3,collid:[2,1,3,7],cmake:[12,6],nx0:12,buffer:1,plausibl:7,setdamp:[3,7],nan:7,green:2,virtual:6,cuctxdestroi:7,cleanup:7,capsuleindic:7,generateprojectsosx:12,normal:[2,3],setphaseconfig:7,test:[2,1,4,12,6],generateprojectslinux:12,buildprojectslinux:12,logdamp:3,p_0c_1:2,multiplierc:3,relat:[8,9,10],regardless:7,repo:0,symbol:3,center:[2,3,7],phaseconfig:[3,7],"return":7,pxasserthandl:7,gcc:6,polynomi:2,drag:[],gridscal:1,track:[2,5],q_1:2,less:[2,3,7],previous:7,doubl:[2,3],nvclothcreatefactorycpu:7,cmakegenerateandroid:12,stai:[2,7],reduc:[2,3,7],axi:[2,1,4],studio:[12,6],featurelevelresult:7,algorithm:[],cooker:7,inaccuraci:3,callback:7,pseudo:3,indirectli:7,rule:7,microsoft:12,hresult:7,delta:[2,1,3,7],lift:[],mass:[2,3,6,7],potenti:7,settriangl:7,onc:1,"export":12,mathrm:3,cpu:[5,6,7],stick:2},objtypes:{},objnames:{},filenames:["index","CollisionDetection/SelfCollision","CollisionDetection/SphereCapsuleCollision","Solver/Index","CollisionDetection/InterCollision","Cooking/TripletScheduler","ReleaseNotes/index","UserGuide/Index","Cooking/Index","CopyRight/Index","Modules/Index","CollisionDetection/Index","Compiling/index"],titles:["NvCloth","Self Collision","Sphere Capsule collision detection","Internal solver function/algorithm documentation","Inter Collision","TripletScheduler","Release Notes","User Guide","Internal cooking documentation","NVIDIA Copyright Notice","Modules","Internal collision detection documentation","Compiling"],objects:{},titleterms:{distanc:[3,7],edg:3,acceler:[2,1,4],capsul:2,simd:5,tripletschedul:5,copyright:9,window:12,local:7,adjacencyqueri:5,anim:7,initi:7,grid:1,cook:8,solver:[3,7],troubleshoot:7,stiff:3,calculatefrictionimpuls:2,separ:3,integr:3,inter:4,compil:12,frame:7,intern:[8,11,3],respons:1,tether:[3,7],todo:11,particl:[1,3],scale:7,space:7,broad:4,factori:7,common:7,kei:1,gener:2,usag:7,extens:10,releas:6,log:3,about:0,constraint:[3,7],mac:12,simul:[3,7],motion:7,nvcloth:[0,10],rang:1,overview:[8,11,1,4,3],modul:[8,11,10],sweep:1,linux:12,guid:7,unit:7,differ:[8,11,4],fabric:[3,7],compon:3,attach:7,warp:5,more:0,"function":3,notic:9,cloth:7,lift:7,retriev:7,slack:3,setup:[1,7],properti:7,structur:[2,1,4,3],charact:7,learn:0,sort:1,sphere:2,cone:2,invmass:3,disappear:7,self:[1,4],note:6,collis:[11,2,1,4,7],librari:7,android:12,document:[8,11,3],singl:7,drag:7,detect:[11,2,1,4,7],user:7,phase:4,collideparticl:2,data:[3,7],algorithm:3,part:7,nvidia:9,ccd:2,wind:[3,7]}})
\ No newline at end of file diff --git a/NvCloth/extensions/include/NvClothExt/ClothFabricCooker.h b/NvCloth/extensions/include/NvClothExt/ClothFabricCooker.h index f2dada0..e01d72d 100644 --- a/NvCloth/extensions/include/NvClothExt/ClothFabricCooker.h +++ b/NvCloth/extensions/include/NvClothExt/ClothFabricCooker.h @@ -194,6 +194,7 @@ public: /** \brief Returns the fabric descriptor to create the fabric. */ virtual ClothFabricDesc getDescriptor() const = 0; + /** \brief Saves the fabric data to a platform and version dependent stream. */ virtual void save(physx::PxOutputStream& stream, bool platformMismatch) const = 0; }; diff --git a/NvCloth/extensions/src/ClothFabricCooker.cpp b/NvCloth/extensions/src/ClothFabricCooker.cpp index c6d0103..eda73de 100644 --- a/NvCloth/extensions/src/ClothFabricCooker.cpp +++ b/NvCloth/extensions/src/ClothFabricCooker.cpp @@ -30,9 +30,8 @@ #include "foundation/PxVec4.h" #include "foundation/PxIO.h" #include "foundation/PxStrideIterator.h" -#include "PsSort.h" -#include "PsMathUtils.h" - +#include "ps/PsSort.h" +#include "NvCloth/ps/PsMathUtils.h" #include "NvClothExt/ClothFabricCooker.h" #include "NvClothExt/ClothTetherCooker.h" #include "NvCloth/Fabric.h" diff --git a/NvCloth/extensions/src/ClothGeodesicTetherCooker.cpp b/NvCloth/extensions/src/ClothGeodesicTetherCooker.cpp index 65e2a3f..7557389 100644 --- a/NvCloth/extensions/src/ClothGeodesicTetherCooker.cpp +++ b/NvCloth/extensions/src/ClothGeodesicTetherCooker.cpp @@ -33,8 +33,8 @@ #include "NvClothExt/ClothTetherCooker.h" // from shared foundation -#include <PsSort.h> -#include <PsMathUtils.h> +#include "../../src/ps/PsSort.h" +#include "NvCloth/ps/PsMathUtils.h" #include "NvCloth/Allocator.h" using namespace physx; diff --git a/NvCloth/extensions/src/ClothMeshQuadifier.cpp b/NvCloth/extensions/src/ClothMeshQuadifier.cpp index 4ae081e..2250c09 100644 --- a/NvCloth/extensions/src/ClothMeshQuadifier.cpp +++ b/NvCloth/extensions/src/ClothMeshQuadifier.cpp @@ -31,9 +31,9 @@ #include "NvClothExt/ClothMeshQuadifier.h" // from shared foundation -#include <PsSort.h> -#include <Ps.h> -#include <PsMathUtils.h> +#include "../../src/ps/PsSort.h" +#include "NvCloth/ps/Ps.h" +#include "NvCloth/ps/PsMathUtils.h" #include "NvCloth/Allocator.h" using namespace physx; diff --git a/NvCloth/include/NvCloth/Allocator.h b/NvCloth/include/NvCloth/Allocator.h index ade0698..e66f34a 100644 --- a/NvCloth/include/NvCloth/Allocator.h +++ b/NvCloth/include/NvCloth/Allocator.h @@ -35,10 +35,10 @@ /** \cond HIDDEN_SYMBOLS */ #pragma once -#include <PsArray.h> -#include <PsHashMap.h> -#include <PsAlignedMalloc.h> +#include "NvCloth/ps/PsArray.h" +#include "NvCloth/ps/PsHashMap.h" #include "NvCloth/Callbacks.h" +#include "NvCloth/ps/PsAlignedMalloc.h" namespace nv { diff --git a/NvCloth/include/NvCloth/Callbacks.h b/NvCloth/include/NvCloth/Callbacks.h index 72ebe24..f5b54a9 100644 --- a/NvCloth/include/NvCloth/Callbacks.h +++ b/NvCloth/include/NvCloth/Callbacks.h @@ -36,7 +36,7 @@ #pragma once #include <foundation/PxPreprocessor.h> #include <foundation/PxProfiler.h> -#include <foundation/PxAssert.h> +#include <foundation/PxAllocatorCallback.h> #ifndef NV_CLOTH_IMPORT #define NV_CLOTH_IMPORT PX_DLL_IMPORT #endif @@ -79,6 +79,25 @@ NV_CLOTH_API(void) //Allocator NV_CLOTH_API(physx::PxAllocatorCallback*) GetNvClothAllocator(); //Only use internally +#if !PX_DOXYGEN +namespace physx +{ +#endif + +/* Base class to handle assert failures */ +class PxAssertHandler +{ +public: + virtual ~PxAssertHandler() + { + } + virtual void operator()(const char* exp, const char* file, int line, bool& ignore) = 0; +}; + +#if !PX_DOXYGEN +} // namespace physx +#endif + namespace nv { namespace cloth @@ -107,7 +126,7 @@ NV_CLOTH_API(physx::PxAssertHandler*) GetNvClothAssertHandler(); //This function #else #if PX_VC #define PX_CODE_ANALYSIS_ASSUME(exp) \ - __analysis_assume(!!(exp)) // This macro will be used to get rid of analysis warning messages if a PX_ASSERT is used + __analysis_assume(!!(exp)) // This macro will be used to get rid of analysis warning messages if a NV_CLOTH_ASSERT is used // to "guard" illegal mem access, for example. #else #define PX_CODE_ANALYSIS_ASSUME(exp) @@ -121,7 +140,7 @@ NV_CLOTH_API(physx::PxAssertHandler*) GetNvClothAssertHandler(); //This function #define NV_CLOTH_ASSERT_WITH_MESSAGE(message, exp) \ { \ static bool _ignore = false; \ - ((void)((!!(exp)) || (!_ignore && (physx::PxGetAssertHandler()(message, __FILE__, __LINE__, _ignore), false)))); \ + ((void)((!!(exp)) || (!_ignore && ((*nv::cloth::GetNvClothAssertHandler())(message, __FILE__, __LINE__, _ignore), false)))); \ PX_CODE_ANALYSIS_ASSUME(exp); \ } #endif diff --git a/NvCloth/include/NvCloth/Fabric.h b/NvCloth/include/NvCloth/Fabric.h index 02b1140..eb0fc5e 100644 --- a/NvCloth/include/NvCloth/Fabric.h +++ b/NvCloth/include/NvCloth/Fabric.h @@ -31,7 +31,7 @@ #include "NvCloth/Callbacks.h" #include "NvCloth/Allocator.h" -#include <PsAtomic.h> +#include "NvCloth/ps/PsAtomic.h" namespace nv { diff --git a/NvCloth/include/NvCloth/Solver.h b/NvCloth/include/NvCloth/Solver.h index 2ff0e9c..7ebe290 100644 --- a/NvCloth/include/NvCloth/Solver.h +++ b/NvCloth/include/NvCloth/Solver.h @@ -31,7 +31,7 @@ #include "NvCloth/Allocator.h" #include "NvCloth/Range.h" -#include "PsArray.h" +#include "NvCloth/ps/PsArray.h" namespace nv { diff --git a/NvCloth/include/NvCloth/ps/Ps.h b/NvCloth/include/NvCloth/ps/Ps.h new file mode 100644 index 0000000..89fc9c7 --- /dev/null +++ b/NvCloth/include/NvCloth/ps/Ps.h @@ -0,0 +1,70 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved. +// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. +// Copyright (c) 2001-2004 NovodeX AG. All rights reserved. + +#ifndef PSFOUNDATION_PS_H +#define PSFOUNDATION_PS_H + +/*! \file top level include file for shared foundation */ + +#include "foundation/Px.h" + +/** +Platform specific defines +*/ +#if PX_WINDOWS_FAMILY || PX_XBOXONE +#pragma intrinsic(memcmp) +#pragma intrinsic(memcpy) +#pragma intrinsic(memset) +#pragma intrinsic(abs) +#pragma intrinsic(labs) +#endif + +// An expression that should expand to nothing in non PX_CHECKED builds. +// We currently use this only for tagging the purpose of containers for memory use tracking. +#if PX_CHECKED +#define PX_DEBUG_EXP(x) (x) +#else +#define PX_DEBUG_EXP(x) +#endif + +#define PX_SIGN_BITMASK 0x80000000 + +namespace physx +{ +namespace shdfnd +{ +// Int-as-bool type - has some uses for efficiency and with SIMD +typedef int IntBool; +static const IntBool IntFalse = 0; +static const IntBool IntTrue = 1; +} + +} // namespace physx + +#endif // #ifndef PSFOUNDATION_PS_H diff --git a/NvCloth/include/NvCloth/ps/PsAlignedMalloc.h b/NvCloth/include/NvCloth/ps/PsAlignedMalloc.h new file mode 100644 index 0000000..4be8409 --- /dev/null +++ b/NvCloth/include/NvCloth/ps/PsAlignedMalloc.h @@ -0,0 +1,88 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved. +// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. +// Copyright (c) 2001-2004 NovodeX AG. All rights reserved. + +#ifndef PSFOUNDATION_PSALIGNEDMALLOC_H +#define PSFOUNDATION_PSALIGNEDMALLOC_H + +#include "PsUserAllocated.h" + +/*! +Allocate aligned memory. +Alignment must be a power of 2! +-- should be templated by a base allocator +*/ + +namespace physx +{ +namespace shdfnd +{ +/** +Allocator, which is used to access the global PxAllocatorCallback instance +(used for dynamic data types template instantiation), which can align memory +*/ + +// SCS: AlignedMalloc with 3 params not found, seems not used on PC either +// disabled for now to avoid GCC error + +template <uint32_t N, typename BaseAllocator = NonTrackingAllocator> +class AlignedAllocator : public BaseAllocator +{ + public: + AlignedAllocator(const BaseAllocator& base = BaseAllocator()) : BaseAllocator(base) + { + } + + void* allocate(size_t size, const char* file, int line) + { + size_t pad = N - 1 + sizeof(size_t); // store offset for delete. + uint8_t* base = reinterpret_cast<uint8_t*>(BaseAllocator::allocate(size + pad, file, line)); + if(!base) + return NULL; + + uint8_t* ptr = reinterpret_cast<uint8_t*>(size_t(base + pad) & ~(size_t(N) - 1)); // aligned pointer, ensuring N + // is a size_t + // wide mask + reinterpret_cast<size_t*>(ptr)[-1] = size_t(ptr - base); // store offset + + return ptr; + } + void deallocate(void* ptr) + { + if(ptr == NULL) + return; + + uint8_t* base = reinterpret_cast<uint8_t*>(ptr) - reinterpret_cast<size_t*>(ptr)[-1]; + BaseAllocator::deallocate(base); + } +}; + +} // namespace shdfnd +} // namespace physx + +#endif // #ifndef PSFOUNDATION_PSALIGNEDMALLOC_H diff --git a/NvCloth/include/NvCloth/ps/PsAllocator.cpp b/NvCloth/include/NvCloth/ps/PsAllocator.cpp new file mode 100644 index 0000000..4e6514f --- /dev/null +++ b/NvCloth/include/NvCloth/ps/PsAllocator.cpp @@ -0,0 +1,51 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved. +// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. +// Copyright (c) 2001-2004 NovodeX AG. All rights reserved. + +#include "PsAllocator.h" +#include "NvCloth/Callbacks.h" + +namespace physx +{ +namespace shdfnd +{ + +void* Allocator::allocate(size_t size, const char* file, int line) +{ + if(!size) + return 0; + return GetNvClothAllocator()->allocate(size, "", file, line); +} +void Allocator::deallocate(void* ptr) +{ + if(ptr) + GetNvClothAllocator()->deallocate(ptr); +} + +} // namespace shdfnd +} // namespace physx diff --git a/NvCloth/include/NvCloth/ps/PsAllocator.h b/NvCloth/include/NvCloth/ps/PsAllocator.h new file mode 100644 index 0000000..37605ee --- /dev/null +++ b/NvCloth/include/NvCloth/ps/PsAllocator.h @@ -0,0 +1,343 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved. +// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. +// Copyright (c) 2001-2004 NovodeX AG. All rights reserved. + +#ifndef PSFOUNDATION_PSALLOCATOR_H +#define PSFOUNDATION_PSALLOCATOR_H + +#include "foundation/PxAllocatorCallback.h" +//#include "foundation/PxFoundation.h" +#include "Ps.h" +#include "../Callbacks.h" + +#if(PX_WINDOWS_FAMILY || PX_XBOXONE) +#include <exception> +#include <typeinfo.h> +#endif +#if(PX_APPLE_FAMILY) +#include <typeinfo> +#endif + +#include <new> + +// Allocation macros going through user allocator +#define PX_ALLOC(n, name) physx::shdfnd::NonTrackingAllocator().allocate(n, __FILE__, __LINE__) +#define PX_ALLOC_TEMP(n, name) PX_ALLOC(n, name) +#define PX_FREE(x) physx::shdfnd::NonTrackingAllocator().deallocate(x) +#define PX_FREE_AND_RESET(x) \ + { \ + PX_FREE(x); \ + x = 0; \ + } + +// The following macros support plain-old-types and classes derived from UserAllocated. +#define PX_NEW(T) new (physx::shdfnd::ReflectionAllocator<T>(), __FILE__, __LINE__) T +#define PX_NEW_TEMP(T) PX_NEW(T) +#define PX_DELETE(x) delete x +#define PX_DELETE_AND_RESET(x) \ + { \ + PX_DELETE(x); \ + x = 0; \ + } +#define PX_DELETE_POD(x) \ + { \ + PX_FREE(x); \ + x = 0; \ + } +#define PX_DELETE_ARRAY(x) \ + { \ + PX_DELETE([] x); \ + x = 0; \ + } + +// aligned allocation +#define PX_ALIGNED16_ALLOC(n) physx::shdfnd::AlignedAllocator<16>().allocate(n, __FILE__, __LINE__) +#define PX_ALIGNED16_FREE(x) physx::shdfnd::AlignedAllocator<16>().deallocate(x) + +//! placement new macro to make it easy to spot bad use of 'new' +#define PX_PLACEMENT_NEW(p, T) new (p) T + +#if PX_DEBUG || PX_CHECKED +#define PX_USE_NAMED_ALLOCATOR 1 +#else +#define PX_USE_NAMED_ALLOCATOR 0 +#endif + +// Don't use inline for alloca !!! +#if PX_WINDOWS_FAMILY +#include <malloc.h> +#define PxAlloca(x) _alloca(x) +#elif PX_LINUX || PX_ANDROID +#include <malloc.h> +#define PxAlloca(x) alloca(x) +#elif PX_APPLE_FAMILY +#include <alloca.h> +#define PxAlloca(x) alloca(x) +#elif PX_PS4 +#include <memory.h> +#define PxAlloca(x) alloca(x) +#elif PX_XBOXONE +#include <malloc.h> +#define PxAlloca(x) alloca(x) +#elif PX_SWITCH +#include <malloc.h> +#define PxAlloca(x) alloca(x) +#endif + +#define PxAllocaAligned(x, alignment) ((size_t(PxAlloca(x + alignment)) + (alignment - 1)) & ~size_t(alignment - 1)) + +namespace physx +{ +namespace shdfnd +{ + +//NV_CLOTH_IMPORT PxAllocatorCallback& getAllocator(); + +/** +Allocator used to access the global PxAllocatorCallback instance without providing additional information. +*/ + +class NV_CLOTH_IMPORT Allocator +{ + public: + Allocator(const char* = 0) + { + } + void* allocate(size_t size, const char* file, int line); + void deallocate(void* ptr); +}; + +/* + * Bootstrap allocator using malloc/free. + * Don't use unless your objects get allocated before foundation is initialized. + */ +class RawAllocator +{ + public: + RawAllocator(const char* = 0) + { + } + void* allocate(size_t size, const char*, int) + { + // malloc returns valid pointer for size==0, no need to check + return ::malloc(size); + } + void deallocate(void* ptr) + { + // free(0) is guaranteed to have no side effect, no need to check + ::free(ptr); + } +}; + +/* + * Allocator that simply calls straight back to the application without tracking. + * This is used by the heap (Foundation::mNamedAllocMap) that tracks allocations + * because it needs to be able to grow as a result of an allocation. + * Making the hash table re-entrant to deal with this may not make sense. + */ +class NonTrackingAllocator +{ + public: + PX_FORCE_INLINE NonTrackingAllocator(const char* = 0) + { + } + PX_FORCE_INLINE void* allocate(size_t size, const char* file, int line) + { + return !size ? 0 : GetNvClothAllocator()->allocate(size, "NonTrackedAlloc", file, line); + } + PX_FORCE_INLINE void deallocate(void* ptr) + { + if(ptr) + GetNvClothAllocator()->deallocate(ptr); + } +}; + +/* +\brief Virtual allocator callback used to provide run-time defined allocators to foundation types like Array or Bitmap. + This is used by VirtualAllocator +*/ +class VirtualAllocatorCallback +{ + public: + VirtualAllocatorCallback() + { + } + virtual ~VirtualAllocatorCallback() + { + } + virtual void* allocate(const size_t size, const char* file, const int line) = 0; + virtual void deallocate(void* ptr) = 0; +}; + +/* +\brief Virtual allocator to be used by foundation types to provide run-time defined allocators. +Due to the fact that Array extends its allocator, rather than contains a reference/pointer to it, the VirtualAllocator +must +be a concrete type containing a pointer to a virtual callback. The callback may not be available at instantiation time, +therefore +methods are provided to set the callback later. +*/ +class VirtualAllocator +{ + public: + VirtualAllocator(VirtualAllocatorCallback* callback = NULL) : mCallback(callback) + { + } + + void* allocate(const size_t size, const char* file, const int line) + { + NV_CLOTH_ASSERT(mCallback); + if(size) + return mCallback->allocate(size, file, line); + return NULL; + } + void deallocate(void* ptr) + { + NV_CLOTH_ASSERT(mCallback); + if(ptr) + mCallback->deallocate(ptr); + } + + void setCallback(VirtualAllocatorCallback* callback) + { + mCallback = callback; + } + VirtualAllocatorCallback* getCallback() + { + return mCallback; + } + + private: + VirtualAllocatorCallback* mCallback; + VirtualAllocator& operator=(const VirtualAllocator&); +}; + +/** +Allocator used to access the global PxAllocatorCallback instance using a static name derived from T. +*/ + +template <typename T> +class ReflectionAllocator +{ + static const char* getName() + { + if(true) + return "<allocation names disabled>"; +#if PX_GCC_FAMILY + return __PRETTY_FUNCTION__; +#else + // name() calls malloc(), raw_name() wouldn't + return typeid(T).name(); +#endif + } + + public: + ReflectionAllocator(const PxEMPTY) + { + } + ReflectionAllocator(const char* = 0) + { + } + inline ReflectionAllocator(const ReflectionAllocator&) + { + } + void* allocate(size_t size, const char* filename, int line) + { + return size ? GetNvClothAllocator()->allocate(size, getName(), filename, line) : 0; + } + void deallocate(void* ptr) + { + if(ptr) + GetNvClothAllocator()->deallocate(ptr); + } +}; + +template <typename T> +struct AllocatorTraits +{ + typedef ReflectionAllocator<T> Type; +}; + +// if you get a build error here, you are trying to PX_NEW a class +// that is neither plain-old-type nor derived from UserAllocated +template <typename T, typename X> +union EnableIfPod +{ + int i; + T t; + typedef X Type; +}; + +} // namespace shdfnd +} // namespace physx + +// Global placement new for ReflectionAllocator templated by +// plain-old-type. Allows using PX_NEW for pointers and built-in-types. +// +// ATTENTION: You need to use PX_DELETE_POD or PX_FREE to deallocate +// memory, not PX_DELETE. PX_DELETE_POD redirects to PX_FREE. +// +// Rationale: PX_DELETE uses global operator delete(void*), which we dont' want to overload. +// Any other definition of PX_DELETE couldn't support array syntax 'PX_DELETE([]a);'. +// PX_DELETE_POD was preferred over PX_DELETE_ARRAY because it is used +// less often and applies to both single instances and arrays. +template <typename T> +PX_INLINE void* operator new(size_t size, physx::shdfnd::ReflectionAllocator<T> alloc, const char* fileName, + typename physx::shdfnd::EnableIfPod<T, int>::Type line) +{ + return alloc.allocate(size, fileName, line); +} + +template <typename T> +PX_INLINE void* operator new [](size_t size, physx::shdfnd::ReflectionAllocator<T> alloc, const char* fileName, + typename physx::shdfnd::EnableIfPod<T, int>::Type line) +{ return alloc.allocate(size, fileName, line); } + +// If construction after placement new throws, this placement delete is being called. +template <typename T> +PX_INLINE void operator delete(void* ptr, physx::shdfnd::ReflectionAllocator<T> alloc, const char* fileName, + typename physx::shdfnd::EnableIfPod<T, int>::Type line) +{ + PX_UNUSED(fileName); + PX_UNUSED(line); + + alloc.deallocate(ptr); +} + +// If construction after placement new throws, this placement delete is being called. +template <typename T> +PX_INLINE void operator delete [](void* ptr, physx::shdfnd::ReflectionAllocator<T> alloc, const char* fileName, + typename physx::shdfnd::EnableIfPod<T, int>::Type line) +{ + PX_UNUSED(fileName); + PX_UNUSED(line); + + alloc.deallocate(ptr); +} + +#endif // #ifndef PSFOUNDATION_PSALLOCATOR_H diff --git a/NvCloth/include/NvCloth/ps/PsArray.h b/NvCloth/include/NvCloth/ps/PsArray.h new file mode 100644 index 0000000..e5f6698 --- /dev/null +++ b/NvCloth/include/NvCloth/ps/PsArray.h @@ -0,0 +1,721 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved. +// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. +// Copyright (c) 2001-2004 NovodeX AG. All rights reserved. + +#ifndef PSFOUNDATION_PSARRAY_H +#define PSFOUNDATION_PSARRAY_H + +#include "../Callbacks.h" +#include "foundation/PxIntrinsics.h" +#include "PsBasicTemplates.h" +#include "NvCloth/ps/PsAllocator.h" + +namespace physx +{ +namespace shdfnd +{ +template <class Serializer> +void exportArray(Serializer& stream, const void* data, uint32_t size, uint32_t sizeOfElement, uint32_t capacity); +char* importArray(char* address, void** data, uint32_t size, uint32_t sizeOfElement, uint32_t capacity); + +/*! +An array is a sequential container. + +Implementation note +* entries between 0 and size are valid objects +* we use inheritance to build this because the array is included inline in a lot + of objects and we want the allocator to take no space if it's not stateful, which + aggregation doesn't allow. Also, we want the metadata at the front for the inline + case where the allocator contains some inline storage space +*/ +template <class T, class Alloc = typename AllocatorTraits<T>::Type> +class Array : protected Alloc +{ + public: + typedef T* Iterator; + typedef const T* ConstIterator; + + explicit Array(const PxEMPTY v) : Alloc(v) + { + if(mData) + mCapacity |= PX_SIGN_BITMASK; + } + + /*! + Default array constructor. Initialize an empty array + */ + PX_INLINE explicit Array(const Alloc& alloc = Alloc()) : Alloc(alloc), mData(0), mSize(0), mCapacity(0) + { + } + + /*! + Initialize array with given capacity + */ + PX_INLINE explicit Array(uint32_t size, const T& a = T(), const Alloc& alloc = Alloc()) + : Alloc(alloc), mData(0), mSize(0), mCapacity(0) + { + resize(size, a); + } + + /*! + Copy-constructor. Copy all entries from other array + */ + template <class A> + PX_INLINE explicit Array(const Array<T, A>& other, const Alloc& alloc = Alloc()) + : Alloc(alloc) + { + copy(other); + } + + // This is necessary else the basic default copy constructor is used in the case of both arrays being of the same + // template instance + // The C++ standard clearly states that a template constructor is never a copy constructor [2]. In other words, + // the presence of a template constructor does not suppress the implicit declaration of the copy constructor. + // Also never make a copy constructor explicit, or copy-initialization* will no longer work. This is because + // 'binding an rvalue to a const reference requires an accessible copy constructor' (http://gcc.gnu.org/bugs/) + // *http://stackoverflow.com/questions/1051379/is-there-a-difference-in-c-between-copy-initialization-and-assignment-initializ + PX_INLINE Array(const Array& other, const Alloc& alloc = Alloc()) : Alloc(alloc) + { + copy(other); + } + + /*! + Initialize array with given length + */ + PX_INLINE explicit Array(const T* first, const T* last, const Alloc& alloc = Alloc()) + : Alloc(alloc), mSize(last < first ? 0 : uint32_t(last - first)), mCapacity(mSize) + { + mData = allocate(mSize); + copy(mData, mData + mSize, first); + } + + /*! + Destructor + */ + PX_INLINE ~Array() + { + destroy(mData, mData + mSize); + + if(capacity() && !isInUserMemory()) + deallocate(mData); + } + + /*! + Assignment operator. Copy content (deep-copy) + */ + template <class A> + PX_INLINE Array& operator=(const Array<T, A>& rhs) + { + if(&rhs == this) + return *this; + + clear(); + reserve(rhs.mSize); + copy(mData, mData + rhs.mSize, rhs.mData); + + mSize = rhs.mSize; + return *this; + } + + PX_INLINE Array& operator=(const Array& t) // Needs to be declared, see comment at copy-constructor + { + return operator=<Alloc>(t); + } + + /*! + Array indexing operator. + \param i + The index of the element that will be returned. + \return + The element i in the array. + */ + PX_FORCE_INLINE const T& operator[](uint32_t i) const + { + NV_CLOTH_ASSERT(i < mSize); + return mData[i]; + } + + /*! + Array indexing operator. + \param i + The index of the element that will be returned. + \return + The element i in the array. + */ + PX_FORCE_INLINE T& operator[](uint32_t i) + { + NV_CLOTH_ASSERT(i < mSize); + return mData[i]; + } + + /*! + Returns a pointer to the initial element of the array. + \return + a pointer to the initial element of the array. + */ + PX_FORCE_INLINE ConstIterator begin() const + { + return mData; + } + + PX_FORCE_INLINE Iterator begin() + { + return mData; + } + + /*! + Returns an iterator beyond the last element of the array. Do not dereference. + \return + a pointer to the element beyond the last element of the array. + */ + + PX_FORCE_INLINE ConstIterator end() const + { + return mData + mSize; + } + + PX_FORCE_INLINE Iterator end() + { + return mData + mSize; + } + + /*! + Returns a reference to the first element of the array. Undefined if the array is empty. + \return a reference to the first element of the array + */ + + PX_FORCE_INLINE const T& front() const + { + NV_CLOTH_ASSERT(mSize); + return mData[0]; + } + + PX_FORCE_INLINE T& front() + { + NV_CLOTH_ASSERT(mSize); + return mData[0]; + } + + /*! + Returns a reference to the last element of the array. Undefined if the array is empty + \return a reference to the last element of the array + */ + + PX_FORCE_INLINE const T& back() const + { + NV_CLOTH_ASSERT(mSize); + return mData[mSize - 1]; + } + + PX_FORCE_INLINE T& back() + { + NV_CLOTH_ASSERT(mSize); + return mData[mSize - 1]; + } + + /*! + Returns the number of entries in the array. This can, and probably will, + differ from the array capacity. + \return + The number of of entries in the array. + */ + PX_FORCE_INLINE uint32_t size() const + { + return mSize; + } + + /*! + Clears the array. + */ + PX_INLINE void clear() + { + destroy(mData, mData + mSize); + mSize = 0; + } + + /*! + Returns whether the array is empty (i.e. whether its size is 0). + \return + true if the array is empty + */ + PX_FORCE_INLINE bool empty() const + { + return mSize == 0; + } + + /*! + Finds the first occurrence of an element in the array. + \param a + The element to find. + */ + + PX_INLINE Iterator find(const T& a) + { + uint32_t index; + for(index = 0; index < mSize && mData[index] != a; index++) + ; + return mData + index; + } + + PX_INLINE ConstIterator find(const T& a) const + { + uint32_t index; + for(index = 0; index < mSize && mData[index] != a; index++) + ; + return mData + index; + } + + ///////////////////////////////////////////////////////////////////////// + /*! + Adds one element to the end of the array. Operation is O(1). + \param a + The element that will be added to this array. + */ + ///////////////////////////////////////////////////////////////////////// + + PX_FORCE_INLINE T& pushBack(const T& a) + { + if(capacity() <= mSize) + return growAndPushBack(a); + + PX_PLACEMENT_NEW(reinterpret_cast<void*>(mData + mSize), T)(a); + + return mData[mSize++]; + } + + ///////////////////////////////////////////////////////////////////////// + /*! + Returns the element at the end of the array. Only legal if the array is non-empty. + */ + ///////////////////////////////////////////////////////////////////////// + PX_INLINE T popBack() + { + NV_CLOTH_ASSERT(mSize); + T t = mData[mSize - 1]; + + mData[--mSize].~T(); + + return t; + } + + ///////////////////////////////////////////////////////////////////////// + /*! + Construct one element at the end of the array. Operation is O(1). + */ + ///////////////////////////////////////////////////////////////////////// + PX_INLINE T& insert() + { + if(capacity() <= mSize) + grow(capacityIncrement()); + + T* ptr = mData + mSize++; + new (ptr) T; // not 'T()' because PODs should not get default-initialized. + return *ptr; + } + + ///////////////////////////////////////////////////////////////////////// + /*! + Subtracts the element on position i from the array and replace it with + the last element. + Operation is O(1) + \param i + The position of the element that will be subtracted from this array. + */ + ///////////////////////////////////////////////////////////////////////// + PX_INLINE void replaceWithLast(uint32_t i) + { + NV_CLOTH_ASSERT(i < mSize); + mData[i] = mData[--mSize]; + + mData[mSize].~T(); + } + + PX_INLINE void replaceWithLast(Iterator i) + { + replaceWithLast(static_cast<uint32_t>(i - mData)); + } + + ///////////////////////////////////////////////////////////////////////// + /*! + Replaces the first occurrence of the element a with the last element + Operation is O(n) + \param a + The position of the element that will be subtracted from this array. + \return true if the element has been removed. + */ + ///////////////////////////////////////////////////////////////////////// + + PX_INLINE bool findAndReplaceWithLast(const T& a) + { + uint32_t index = 0; + while(index < mSize && mData[index] != a) + ++index; + if(index == mSize) + return false; + replaceWithLast(index); + return true; + } + + ///////////////////////////////////////////////////////////////////////// + /*! + Subtracts the element on position i from the array. Shift the entire + array one step. + Operation is O(n) + \param i + The position of the element that will be subtracted from this array. + */ + ///////////////////////////////////////////////////////////////////////// + PX_INLINE void remove(uint32_t i) + { + NV_CLOTH_ASSERT(i < mSize); + + T* it = mData + i; + it->~T(); + while (++i < mSize) + { + new (it) T(mData[i]); + ++it; + it->~T(); + } + --mSize; + } + + ///////////////////////////////////////////////////////////////////////// + /*! + Removes a range from the array. Shifts the array so order is maintained. + Operation is O(n) + \param begin + The starting position of the element that will be subtracted from this array. + \param count + The number of elments that will be subtracted from this array. + */ + ///////////////////////////////////////////////////////////////////////// + PX_INLINE void removeRange(uint32_t begin, uint32_t count) + { + NV_CLOTH_ASSERT(begin < mSize); + NV_CLOTH_ASSERT((begin + count) <= mSize); + + for(uint32_t i = 0; i < count; i++) + mData[begin + i].~T(); // call the destructor on the ones being removed first. + + T* dest = &mData[begin]; // location we are copying the tail end objects to + T* src = &mData[begin + count]; // start of tail objects + uint32_t move_count = mSize - (begin + count); // compute remainder that needs to be copied down + + for(uint32_t i = 0; i < move_count; i++) + { + new (dest) T(*src); // copy the old one to the new location + src->~T(); // call the destructor on the old location + dest++; + src++; + } + mSize -= count; + } + + ////////////////////////////////////////////////////////////////////////// + /*! + Resize array + */ + ////////////////////////////////////////////////////////////////////////// + PX_NOINLINE void resize(const uint32_t size, const T& a = T()); + + PX_NOINLINE void resizeUninitialized(const uint32_t size); + + ////////////////////////////////////////////////////////////////////////// + /*! + Resize array such that only as much memory is allocated to hold the + existing elements + */ + ////////////////////////////////////////////////////////////////////////// + PX_INLINE void shrink() + { + recreate(mSize); + } + + ////////////////////////////////////////////////////////////////////////// + /*! + Deletes all array elements and frees memory. + */ + ////////////////////////////////////////////////////////////////////////// + PX_INLINE void reset() + { + resize(0); + shrink(); + } + + ////////////////////////////////////////////////////////////////////////// + /*! + Ensure that the array has at least size capacity. + */ + ////////////////////////////////////////////////////////////////////////// + PX_INLINE void reserve(const uint32_t capacity) + { + if(capacity > this->capacity()) + grow(capacity); + } + + ////////////////////////////////////////////////////////////////////////// + /*! + Query the capacity(allocated mem) for the array. + */ + ////////////////////////////////////////////////////////////////////////// + PX_FORCE_INLINE uint32_t capacity() const + { + return mCapacity & ~PX_SIGN_BITMASK; + } + + ////////////////////////////////////////////////////////////////////////// + /*! + Unsafe function to force the size of the array + */ + ////////////////////////////////////////////////////////////////////////// + PX_FORCE_INLINE void forceSize_Unsafe(uint32_t size) + { + NV_CLOTH_ASSERT(size <= mCapacity); + mSize = size; + } + + ////////////////////////////////////////////////////////////////////////// + /*! + Swap contents of an array without allocating temporary storage + */ + ////////////////////////////////////////////////////////////////////////// + PX_INLINE void swap(Array<T, Alloc>& other) + { + shdfnd::swap(mData, other.mData); + shdfnd::swap(mSize, other.mSize); + shdfnd::swap(mCapacity, other.mCapacity); + } + + ////////////////////////////////////////////////////////////////////////// + /*! + Assign a range of values to this vector (resizes to length of range) + */ + ////////////////////////////////////////////////////////////////////////// + PX_INLINE void assign(const T* first, const T* last) + { + resizeUninitialized(uint32_t(last - first)); + copy(begin(), end(), first); + } + + // We need one bit to mark arrays that have been deserialized from a user-provided memory block. + // For alignment & memory saving purpose we store that bit in the rarely used capacity member. + PX_FORCE_INLINE uint32_t isInUserMemory() const + { + return mCapacity & PX_SIGN_BITMASK; + } + + /// return reference to allocator + PX_INLINE Alloc& getAllocator() + { + return *this; + } + + protected: + // constructor for where we don't own the memory + Array(T* memory, uint32_t size, uint32_t capacity, const Alloc& alloc = Alloc()) + : Alloc(alloc), mData(memory), mSize(size), mCapacity(capacity | PX_SIGN_BITMASK) + { + } + + template <class A> + PX_NOINLINE void copy(const Array<T, A>& other); + + PX_INLINE T* allocate(uint32_t size) + { + if(size > 0) + { + T* p = reinterpret_cast<T*>(Alloc::allocate(sizeof(T) * size, __FILE__, __LINE__)); +/** +Mark a specified amount of memory with 0xcd pattern. This is used to check that the meta data +definition for serialized classes is complete in checked builds. +*/ +#if PX_CHECKED + if(p) + { + for(uint32_t i = 0; i < (sizeof(T) * size); ++i) + reinterpret_cast<uint8_t*>(p)[i] = 0xcd; + } +#endif + return p; + } + return 0; + } + + PX_INLINE void deallocate(void* mem) + { + Alloc::deallocate(mem); + } + + static PX_INLINE void create(T* first, T* last, const T& a) + { + for(; first < last; ++first) + ::new (first) T(a); + } + + static PX_INLINE void copy(T* first, T* last, const T* src) + { + if(last <= first) + return; + + for(; first < last; ++first, ++src) + ::new (first) T(*src); + } + + static PX_INLINE void destroy(T* first, T* last) + { + for(; first < last; ++first) + first->~T(); + } + + /*! + Called when pushBack() needs to grow the array. + \param a The element that will be added to this array. + */ + PX_NOINLINE T& growAndPushBack(const T& a); + + /*! + Resizes the available memory for the array. + + \param capacity + The number of entries that the set should be able to hold. + */ + PX_INLINE void grow(uint32_t capacity) + { + NV_CLOTH_ASSERT(this->capacity() < capacity); + recreate(capacity); + } + + /*! + Creates a new memory block, copies all entries to the new block and destroys old entries. + + \param capacity + The number of entries that the set should be able to hold. + */ + PX_NOINLINE void recreate(uint32_t capacity); + + // The idea here is to prevent accidental bugs with pushBack or insert. Unfortunately + // it interacts badly with InlineArrays with smaller inline allocations. + // TODO(dsequeira): policy template arg, this is exactly what they're for. + PX_INLINE uint32_t capacityIncrement() const + { + const uint32_t capacity = this->capacity(); + return capacity == 0 ? 1 : capacity * 2; + } + + T* mData; + uint32_t mSize; + uint32_t mCapacity; +}; + +template <class T, class Alloc> +PX_NOINLINE void Array<T, Alloc>::resize(const uint32_t size, const T& a) +{ + reserve(size); + create(mData + mSize, mData + size, a); + destroy(mData + size, mData + mSize); + mSize = size; +} + +template <class T, class Alloc> +template <class A> +PX_NOINLINE void Array<T, Alloc>::copy(const Array<T, A>& other) +{ + if(!other.empty()) + { + mData = allocate(mSize = mCapacity = other.size()); + copy(mData, mData + mSize, other.begin()); + } + else + { + mData = NULL; + mSize = 0; + mCapacity = 0; + } + + // mData = allocate(other.mSize); + // mSize = other.mSize; + // mCapacity = other.mSize; + // copy(mData, mData + mSize, other.mData); +} + +template <class T, class Alloc> +PX_NOINLINE void Array<T, Alloc>::resizeUninitialized(const uint32_t size) +{ + reserve(size); + mSize = size; +} + +template <class T, class Alloc> +PX_NOINLINE T& Array<T, Alloc>::growAndPushBack(const T& a) +{ + uint32_t capacity = capacityIncrement(); + + T* newData = allocate(capacity); + NV_CLOTH_ASSERT((!capacity) || (newData && (newData != mData))); + copy(newData, newData + mSize, mData); + + // inserting element before destroying old array + // avoids referencing destroyed object when duplicating array element. + PX_PLACEMENT_NEW(reinterpret_cast<void*>(newData + mSize), T)(a); + + destroy(mData, mData + mSize); + if(!isInUserMemory()) + deallocate(mData); + + mData = newData; + mCapacity = capacity; + + return mData[mSize++]; +} + +template <class T, class Alloc> +PX_NOINLINE void Array<T, Alloc>::recreate(uint32_t capacity) +{ + T* newData = allocate(capacity); + NV_CLOTH_ASSERT((!capacity) || (newData && (newData != mData))); + + copy(newData, newData + mSize, mData); + destroy(mData, mData + mSize); + if(!isInUserMemory()) + deallocate(mData); + + mData = newData; + mCapacity = capacity; +} + +template <class T, class Alloc> +PX_INLINE void swap(Array<T, Alloc>& x, Array<T, Alloc>& y) +{ + x.swap(y); +} + +} // namespace shdfnd +} // namespace physx + +#endif // #ifndef PSFOUNDATION_PSARRAY_H diff --git a/NvCloth/include/NvCloth/ps/PsAtomic.h b/NvCloth/include/NvCloth/ps/PsAtomic.h new file mode 100644 index 0000000..dad18fc --- /dev/null +++ b/NvCloth/include/NvCloth/ps/PsAtomic.h @@ -0,0 +1,64 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved. +// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. +// Copyright (c) 2001-2004 NovodeX AG. All rights reserved. + +#ifndef PSFOUNDATION_PSATOMIC_H +#define PSFOUNDATION_PSATOMIC_H + +#include "NvCloth/ps/Ps.h" +#include "NvCloth/Callbacks.h" + +namespace physx +{ +namespace shdfnd +{ +/* set *dest equal to val. Return the old value of *dest */ +NV_CLOTH_IMPORT int32_t atomicExchange(volatile int32_t* dest, int32_t val); + +/* if *dest == comp, replace with exch. Return original value of *dest */ +NV_CLOTH_IMPORT int32_t atomicCompareExchange(volatile int32_t* dest, int32_t exch, int32_t comp); + +/* if *dest == comp, replace with exch. Return original value of *dest */ +NV_CLOTH_IMPORT void* atomicCompareExchangePointer(volatile void** dest, void* exch, void* comp); + +/* increment the specified location. Return the incremented value */ +NV_CLOTH_IMPORT int32_t atomicIncrement(volatile int32_t* val); + +/* decrement the specified location. Return the decremented value */ +NV_CLOTH_IMPORT int32_t atomicDecrement(volatile int32_t* val); + +/* add delta to *val. Return the new value */ +NV_CLOTH_IMPORT int32_t atomicAdd(volatile int32_t* val, int32_t delta); + +/* compute the maximum of dest and val. Return the new value */ +NV_CLOTH_IMPORT int32_t atomicMax(volatile int32_t* val, int32_t val2); + +} // namespace shdfnd +} // namespace physx + +#endif // #ifndef PSFOUNDATION_PSATOMIC_H diff --git a/NvCloth/include/NvCloth/ps/PsBasicTemplates.h b/NvCloth/include/NvCloth/ps/PsBasicTemplates.h new file mode 100644 index 0000000..514da05 --- /dev/null +++ b/NvCloth/include/NvCloth/ps/PsBasicTemplates.h @@ -0,0 +1,146 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved. +// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. +// Copyright (c) 2001-2004 NovodeX AG. All rights reserved. + +#ifndef PSFOUNDATION_PSBASICTEMPLATES_H +#define PSFOUNDATION_PSBASICTEMPLATES_H + +#include "Ps.h" + +namespace physx +{ +namespace shdfnd +{ +template <typename A> +struct Equal +{ + bool operator()(const A& a, const A& b) const + { + return a == b; + } +}; + +template <typename A> +struct Less +{ + bool operator()(const A& a, const A& b) const + { + return a < b; + } +}; + +template <typename A> +struct Greater +{ + bool operator()(const A& a, const A& b) const + { + return a > b; + } +}; + +template <class F, class S> +class Pair +{ + public: + F first; + S second; + Pair() : first(F()), second(S()) + { + } + Pair(const F& f, const S& s) : first(f), second(s) + { + } + Pair(const Pair& p) : first(p.first), second(p.second) + { + } + // CN - fix for /.../PsBasicTemplates.h(61) : warning C4512: 'physx::shdfnd::Pair<F,S>' : assignment operator could + // not be generated + Pair& operator=(const Pair& p) + { + first = p.first; + second = p.second; + return *this; + } + bool operator==(const Pair& p) const + { + return first == p.first && second == p.second; + } + bool operator<(const Pair& p) const + { + if(first < p.first) + return true; + else + return !(p.first < first) && (second < p.second); + } +}; + +template <unsigned int A> +struct LogTwo +{ + static const unsigned int value = LogTwo<(A >> 1)>::value + 1; +}; +template <> +struct LogTwo<1> +{ + static const unsigned int value = 0; +}; + +template <typename T> +struct UnConst +{ + typedef T Type; +}; +template <typename T> +struct UnConst<const T> +{ + typedef T Type; +}; + +template <typename T> +T pointerOffset(void* p, ptrdiff_t offset) +{ + return reinterpret_cast<T>(reinterpret_cast<char*>(p) + offset); +} +template <typename T> +T pointerOffset(const void* p, ptrdiff_t offset) +{ + return reinterpret_cast<T>(reinterpret_cast<const char*>(p) + offset); +} + +template <class T> +PX_CUDA_CALLABLE PX_INLINE void swap(T& x, T& y) +{ + const T tmp = x; + x = y; + y = tmp; +} + +} // namespace shdfnd +} // namespace physx + +#endif // #ifndef PSFOUNDATION_PSBASICTEMPLATES_H diff --git a/NvCloth/include/NvCloth/ps/PsBitUtils.h b/NvCloth/include/NvCloth/ps/PsBitUtils.h new file mode 100644 index 0000000..3d901ed --- /dev/null +++ b/NvCloth/include/NvCloth/ps/PsBitUtils.h @@ -0,0 +1,109 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved. +// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. +// Copyright (c) 2001-2004 NovodeX AG. All rights reserved. + +#ifndef PSFOUNDATION_PSBITUTILS_H +#define PSFOUNDATION_PSBITUTILS_H + +#include "foundation/PxIntrinsics.h" +#include "../Callbacks.h" +#include "PsIntrinsics.h" +#include "Ps.h" + +namespace physx +{ +namespace shdfnd +{ +PX_INLINE uint32_t bitCount(uint32_t v) +{ + // from http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel + uint32_t const w = v - ((v >> 1) & 0x55555555); + uint32_t const x = (w & 0x33333333) + ((w >> 2) & 0x33333333); + return (((x + (x >> 4)) & 0xF0F0F0F) * 0x1010101) >> 24; +} + +PX_INLINE bool isPowerOfTwo(uint32_t x) +{ + return x != 0 && (x & (x - 1)) == 0; +} + +// "Next Largest Power of 2 +// Given a binary integer value x, the next largest power of 2 can be computed by a SWAR algorithm +// that recursively "folds" the upper bits into the lower bits. This process yields a bit vector with +// the same most significant 1 as x, but all 1's below it. Adding 1 to that value yields the next +// largest power of 2. For a 32-bit value:" +PX_INLINE uint32_t nextPowerOfTwo(uint32_t x) +{ + x |= (x >> 1); + x |= (x >> 2); + x |= (x >> 4); + x |= (x >> 8); + x |= (x >> 16); + return x + 1; +} + +/*! +Return the index of the highest set bit. Not valid for zero arg. +*/ + +PX_INLINE uint32_t lowestSetBit(uint32_t x) +{ + NV_CLOTH_ASSERT(x); + return lowestSetBitUnsafe(x); +} + +/*! +Return the index of the highest set bit. Not valid for zero arg. +*/ + +PX_INLINE uint32_t highestSetBit(uint32_t x) +{ + NV_CLOTH_ASSERT(x); + return highestSetBitUnsafe(x); +} + +// Helper function to approximate log2 of an integer value +// assumes that the input is actually power of two. +// todo: replace 2 usages with 'highestSetBit' +PX_INLINE uint32_t ilog2(uint32_t num) +{ + for(uint32_t i = 0; i < 32; i++) + { + num >>= 1; + if(num == 0) + return i; + } + + NV_CLOTH_ASSERT(0); + return uint32_t(-1); +} + +} // namespace shdfnd +} // namespace physx + +#endif // #ifndef PSFOUNDATION_PSBITUTILS_H diff --git a/NvCloth/include/NvCloth/ps/PsHash.h b/NvCloth/include/NvCloth/ps/PsHash.h new file mode 100644 index 0000000..6b74fb2 --- /dev/null +++ b/NvCloth/include/NvCloth/ps/PsHash.h @@ -0,0 +1,162 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved. +// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. +// Copyright (c) 2001-2004 NovodeX AG. All rights reserved. + +#ifndef PSFOUNDATION_PSHASH_H +#define PSFOUNDATION_PSHASH_H + +#include "Ps.h" +#include "PsBasicTemplates.h" + +#if PX_VC +#pragma warning(push) +#pragma warning(disable : 4302) +#endif + +#if PX_LINUX +#include "foundation/PxSimpleTypes.h" +#endif + +/*! +Central definition of hash functions +*/ + +namespace physx +{ +namespace shdfnd +{ +// Hash functions + +// Thomas Wang's 32 bit mix +// http://www.cris.com/~Ttwang/tech/inthash.htm +PX_FORCE_INLINE uint32_t hash(const uint32_t key) +{ + uint32_t k = key; + k += ~(k << 15); + k ^= (k >> 10); + k += (k << 3); + k ^= (k >> 6); + k += ~(k << 11); + k ^= (k >> 16); + return uint32_t(k); +} + +PX_FORCE_INLINE uint32_t hash(const int32_t key) +{ + return hash(uint32_t(key)); +} + +// Thomas Wang's 64 bit mix +// http://www.cris.com/~Ttwang/tech/inthash.htm +PX_FORCE_INLINE uint32_t hash(const uint64_t key) +{ + uint64_t k = key; + k += ~(k << 32); + k ^= (k >> 22); + k += ~(k << 13); + k ^= (k >> 8); + k += (k << 3); + k ^= (k >> 15); + k += ~(k << 27); + k ^= (k >> 31); + return uint32_t(UINT32_MAX & k); +} + +#if PX_APPLE_FAMILY +// hash for size_t, to make gcc happy +PX_INLINE uint32_t hash(const size_t key) +{ +#if PX_P64_FAMILY + return hash(uint64_t(key)); +#else + return hash(uint32_t(key)); +#endif +} +#endif + +// Hash function for pointers +PX_INLINE uint32_t hash(const void* ptr) +{ +#if PX_P64_FAMILY + return hash(uint64_t(ptr)); +#else + return hash(uint32_t(UINT32_MAX & size_t(ptr))); +#endif +} + +// Hash function for pairs +template <typename F, typename S> +PX_INLINE uint32_t hash(const Pair<F, S>& p) +{ + uint32_t seed = 0x876543; + uint32_t m = 1000007; + return hash(p.second) ^ (m * (hash(p.first) ^ (m * seed))); +} + +// hash object for hash map template parameter +template <class Key> +struct Hash +{ + uint32_t operator()(const Key& k) const + { + return hash(k); + } + bool equal(const Key& k0, const Key& k1) const + { + return k0 == k1; + } +}; + +// specialization for strings +template <> +struct Hash<const char*> +{ + public: + uint32_t operator()(const char* _string) const + { + // "DJB" string hash + const uint8_t* string = reinterpret_cast<const uint8_t*>(_string); + uint32_t h = 5381; + for(const uint8_t* ptr = string; *ptr; ptr++) + h = ((h << 5) + h) ^ uint32_t(*ptr); + return h; + } + bool equal(const char* string0, const char* string1) const + { + return !strcmp(string0, string1); + } +}; + +} // namespace shdfnd +} // namespace physx + +#if PX_VC +#pragma warning(pop) +#endif + +#endif // #ifndef PSFOUNDATION_PSHASH_H diff --git a/NvCloth/include/NvCloth/ps/PsHashInternals.h b/NvCloth/include/NvCloth/ps/PsHashInternals.h new file mode 100644 index 0000000..ec0d3dd --- /dev/null +++ b/NvCloth/include/NvCloth/ps/PsHashInternals.h @@ -0,0 +1,795 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved. +// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. +// Copyright (c) 2001-2004 NovodeX AG. All rights reserved. + +#ifndef PSFOUNDATION_PSHASHINTERNALS_H +#define PSFOUNDATION_PSHASHINTERNALS_H + +#include "PsBasicTemplates.h" +#include "PsArray.h" +#include "PsBitUtils.h" +#include "PsHash.h" +#include "foundation/PxIntrinsics.h" + +#if PX_VC +#pragma warning(push) +#pragma warning(disable : 4127) // conditional expression is constant +#endif +namespace physx +{ +namespace shdfnd +{ +namespace internal +{ +template <class Entry, class Key, class HashFn, class GetKey, class Allocator, bool compacting> +class HashBase : private Allocator +{ + void init(uint32_t initialTableSize, float loadFactor) + { + mBuffer = NULL; + mEntries = NULL; + mEntriesNext = NULL; + mHash = NULL; + mEntriesCapacity = 0; + mHashSize = 0; + mLoadFactor = loadFactor; + mFreeList = uint32_t(EOL); + mTimestamp = 0; + mEntriesCount = 0; + + if(initialTableSize) + reserveInternal(initialTableSize); + } + + public: + typedef Entry EntryType; + + HashBase(uint32_t initialTableSize = 64, float loadFactor = 0.75f) : Allocator(PX_DEBUG_EXP("hashBase")) + { + init(initialTableSize, loadFactor); + } + + HashBase(uint32_t initialTableSize, float loadFactor, const Allocator& alloc) : Allocator(alloc) + { + init(initialTableSize, loadFactor); + } + + HashBase(const Allocator& alloc) : Allocator(alloc) + { + init(64, 0.75f); + } + + ~HashBase() + { + destroy(); // No need to clear() + + if(mBuffer) + Allocator::deallocate(mBuffer); + } + + static const uint32_t EOL = 0xffffffff; + + PX_INLINE Entry* create(const Key& k, bool& exists) + { + uint32_t h = 0; + if(mHashSize) + { + h = hash(k); + uint32_t index = mHash[h]; + while(index != EOL && !HashFn().equal(GetKey()(mEntries[index]), k)) + index = mEntriesNext[index]; + exists = index != EOL; + if(exists) + return mEntries + index; + } + else + exists = false; + + if(freeListEmpty()) + { + grow(); + h = hash(k); + } + + uint32_t entryIndex = freeListGetNext(); + + mEntriesNext[entryIndex] = mHash[h]; + mHash[h] = entryIndex; + + mEntriesCount++; + mTimestamp++; + + return mEntries + entryIndex; + } + + PX_INLINE const Entry* find(const Key& k) const + { + if(!mEntriesCount) + return NULL; + + const uint32_t h = hash(k); + uint32_t index = mHash[h]; + while(index != EOL && !HashFn().equal(GetKey()(mEntries[index]), k)) + index = mEntriesNext[index]; + return index != EOL ? mEntries + index : NULL; + } + + PX_INLINE bool erase(const Key& k, Entry& e) + { + if(!mEntriesCount) + return false; + + const uint32_t h = hash(k); + uint32_t* ptr = mHash + h; + while(*ptr != EOL && !HashFn().equal(GetKey()(mEntries[*ptr]), k)) + ptr = mEntriesNext + *ptr; + + if(*ptr == EOL) + return false; + + PX_PLACEMENT_NEW(&e, Entry)(mEntries[*ptr]); + + return eraseInternal(ptr); + } + + PX_INLINE bool erase(const Key& k) + { + if(!mEntriesCount) + return false; + + const uint32_t h = hash(k); + uint32_t* ptr = mHash + h; + while(*ptr != EOL && !HashFn().equal(GetKey()(mEntries[*ptr]), k)) + ptr = mEntriesNext + *ptr; + + if(*ptr == EOL) + return false; + + return eraseInternal(ptr); + } + + PX_INLINE uint32_t size() const + { + return mEntriesCount; + } + + PX_INLINE uint32_t capacity() const + { + return mHashSize; + } + + void clear() + { + if(!mHashSize || mEntriesCount == 0) + return; + + destroy(); + + intrinsics::memSet(mHash, EOL, mHashSize * sizeof(uint32_t)); + + const uint32_t sizeMinus1 = mEntriesCapacity - 1; + for(uint32_t i = 0; i < sizeMinus1; i++) + { + prefetchLine(mEntriesNext + i, 128); + mEntriesNext[i] = i + 1; + } + mEntriesNext[mEntriesCapacity - 1] = uint32_t(EOL); + mFreeList = 0; + mEntriesCount = 0; + } + + void reserve(uint32_t size) + { + if(size > mHashSize) + reserveInternal(size); + } + + PX_INLINE const Entry* getEntries() const + { + return mEntries; + } + + PX_INLINE Entry* insertUnique(const Key& k) + { + NV_CLOTH_ASSERT(find(k) == NULL); + uint32_t h = hash(k); + + uint32_t entryIndex = freeListGetNext(); + + mEntriesNext[entryIndex] = mHash[h]; + mHash[h] = entryIndex; + + mEntriesCount++; + mTimestamp++; + + return mEntries + entryIndex; + } + + private: + void destroy() + { + for(uint32_t i = 0; i < mHashSize; i++) + { + for(uint32_t j = mHash[i]; j != EOL; j = mEntriesNext[j]) + mEntries[j].~Entry(); + } + } + + template <typename HK, typename GK, class A, bool comp> + PX_NOINLINE void copy(const HashBase<Entry, Key, HK, GK, A, comp>& other); + + // free list management - if we're coalescing, then we use mFreeList to hold + // the top of the free list and it should always be equal to size(). Otherwise, + // we build a free list in the next() pointers. + + PX_INLINE void freeListAdd(uint32_t index) + { + if(compacting) + { + mFreeList--; + NV_CLOTH_ASSERT(mFreeList == mEntriesCount); + } + else + { + mEntriesNext[index] = mFreeList; + mFreeList = index; + } + } + + PX_INLINE void freeListAdd(uint32_t start, uint32_t end) + { + if(!compacting) + { + for(uint32_t i = start; i < end - 1; i++) // add the new entries to the free list + mEntriesNext[i] = i + 1; + + // link in old free list + mEntriesNext[end - 1] = mFreeList; + NV_CLOTH_ASSERT(mFreeList != end - 1); + mFreeList = start; + } + else if(mFreeList == EOL) // don't reset the free ptr for the compacting hash unless it's empty + mFreeList = start; + } + + PX_INLINE uint32_t freeListGetNext() + { + NV_CLOTH_ASSERT(!freeListEmpty()); + if(compacting) + { + NV_CLOTH_ASSERT(mFreeList == mEntriesCount); + return mFreeList++; + } + else + { + uint32_t entryIndex = mFreeList; + mFreeList = mEntriesNext[mFreeList]; + return entryIndex; + } + } + + PX_INLINE bool freeListEmpty() const + { + if(compacting) + return mEntriesCount == mEntriesCapacity; + else + return mFreeList == EOL; + } + + PX_INLINE void replaceWithLast(uint32_t index) + { + PX_PLACEMENT_NEW(mEntries + index, Entry)(mEntries[mEntriesCount]); + mEntries[mEntriesCount].~Entry(); + mEntriesNext[index] = mEntriesNext[mEntriesCount]; + + uint32_t h = hash(GetKey()(mEntries[index])); + uint32_t* ptr; + for(ptr = mHash + h; *ptr != mEntriesCount; ptr = mEntriesNext + *ptr) + NV_CLOTH_ASSERT(*ptr != EOL); + *ptr = index; + } + + PX_INLINE uint32_t hash(const Key& k, uint32_t hashSize) const + { + return HashFn()(k) & (hashSize - 1); + } + + PX_INLINE uint32_t hash(const Key& k) const + { + return hash(k, mHashSize); + } + + PX_INLINE bool eraseInternal(uint32_t* ptr) + { + const uint32_t index = *ptr; + + *ptr = mEntriesNext[index]; + + mEntries[index].~Entry(); + + mEntriesCount--; + mTimestamp++; + + if (compacting && index != mEntriesCount) + replaceWithLast(index); + + freeListAdd(index); + return true; + } + + void reserveInternal(uint32_t size) + { + if(!isPowerOfTwo(size)) + size = nextPowerOfTwo(size); + + NV_CLOTH_ASSERT(!(size & (size - 1))); + + // decide whether iteration can be done on the entries directly + bool resizeCompact = compacting || freeListEmpty(); + + // define new table sizes + uint32_t oldEntriesCapacity = mEntriesCapacity; + uint32_t newEntriesCapacity = uint32_t(float(size) * mLoadFactor); + uint32_t newHashSize = size; + + // allocate new common buffer and setup pointers to new tables + uint8_t* newBuffer; + uint32_t* newHash; + uint32_t* newEntriesNext; + Entry* newEntries; + { + uint32_t newHashByteOffset = 0; + uint32_t newEntriesNextBytesOffset = newHashByteOffset + newHashSize * sizeof(uint32_t); + uint32_t newEntriesByteOffset = newEntriesNextBytesOffset + newEntriesCapacity * sizeof(uint32_t); + newEntriesByteOffset += (16 - (newEntriesByteOffset & 15)) & 15; + uint32_t newBufferByteSize = newEntriesByteOffset + newEntriesCapacity * sizeof(Entry); + + newBuffer = reinterpret_cast<uint8_t*>(Allocator::allocate(newBufferByteSize, __FILE__, __LINE__)); + NV_CLOTH_ASSERT(newBuffer); + + newHash = reinterpret_cast<uint32_t*>(newBuffer + newHashByteOffset); + newEntriesNext = reinterpret_cast<uint32_t*>(newBuffer + newEntriesNextBytesOffset); + newEntries = reinterpret_cast<Entry*>(newBuffer + newEntriesByteOffset); + } + + // initialize new hash table + intrinsics::memSet(newHash, uint32_t(EOL), newHashSize * sizeof(uint32_t)); + + // iterate over old entries, re-hash and create new entries + if(resizeCompact) + { + // check that old free list is empty - we don't need to copy the next entries + NV_CLOTH_ASSERT(compacting || mFreeList == EOL); + + for(uint32_t index = 0; index < mEntriesCount; ++index) + { + uint32_t h = hash(GetKey()(mEntries[index]), newHashSize); + newEntriesNext[index] = newHash[h]; + newHash[h] = index; + + PX_PLACEMENT_NEW(newEntries + index, Entry)(mEntries[index]); + mEntries[index].~Entry(); + } + } + else + { + // copy old free list, only required for non compact resizing + intrinsics::memCopy(newEntriesNext, mEntriesNext, mEntriesCapacity * sizeof(uint32_t)); + + for(uint32_t bucket = 0; bucket < mHashSize; bucket++) + { + uint32_t index = mHash[bucket]; + while(index != EOL) + { + uint32_t h = hash(GetKey()(mEntries[index]), newHashSize); + newEntriesNext[index] = newHash[h]; + NV_CLOTH_ASSERT(index != newHash[h]); + + newHash[h] = index; + + PX_PLACEMENT_NEW(newEntries + index, Entry)(mEntries[index]); + mEntries[index].~Entry(); + + index = mEntriesNext[index]; + } + } + } + + // swap buffer and pointers + Allocator::deallocate(mBuffer); + mBuffer = newBuffer; + mHash = newHash; + mHashSize = newHashSize; + mEntriesNext = newEntriesNext; + mEntries = newEntries; + mEntriesCapacity = newEntriesCapacity; + + freeListAdd(oldEntriesCapacity, newEntriesCapacity); + } + + void grow() + { + NV_CLOTH_ASSERT((mFreeList == EOL) || (compacting && (mEntriesCount == mEntriesCapacity))); + + uint32_t size = mHashSize == 0 ? 16 : mHashSize * 2; + reserve(size); + } + + uint8_t* mBuffer; + Entry* mEntries; + uint32_t* mEntriesNext; // same size as mEntries + uint32_t* mHash; + uint32_t mEntriesCapacity; + uint32_t mHashSize; + float mLoadFactor; + uint32_t mFreeList; + uint32_t mTimestamp; + uint32_t mEntriesCount; // number of entries + + public: + class Iter + { + public: + PX_INLINE Iter(HashBase& b) : mBucket(0), mEntry(uint32_t(b.EOL)), mTimestamp(b.mTimestamp), mBase(b) + { + if(mBase.mEntriesCapacity > 0) + { + mEntry = mBase.mHash[0]; + skip(); + } + } + + PX_INLINE void check() const + { + NV_CLOTH_ASSERT(mTimestamp == mBase.mTimestamp); + } + PX_INLINE const Entry& operator*() const + { + check(); + return mBase.mEntries[mEntry]; + } + PX_INLINE Entry& operator*() + { + check(); + return mBase.mEntries[mEntry]; + } + PX_INLINE const Entry* operator->() const + { + check(); + return mBase.mEntries + mEntry; + } + PX_INLINE Entry* operator->() + { + check(); + return mBase.mEntries + mEntry; + } + PX_INLINE Iter operator++() + { + check(); + advance(); + return *this; + } + PX_INLINE Iter operator++(int) + { + check(); + Iter i = *this; + advance(); + return i; + } + PX_INLINE bool done() const + { + check(); + return mEntry == mBase.EOL; + } + + private: + PX_INLINE void advance() + { + mEntry = mBase.mEntriesNext[mEntry]; + skip(); + } + PX_INLINE void skip() + { + while(mEntry == mBase.EOL) + { + if(++mBucket == mBase.mHashSize) + break; + mEntry = mBase.mHash[mBucket]; + } + } + + Iter& operator=(const Iter&); + + uint32_t mBucket; + uint32_t mEntry; + uint32_t mTimestamp; + HashBase& mBase; + }; + + /*! + Iterate over entries in a hash base and allow entry erase while iterating + */ + class EraseIterator + { + public: + PX_INLINE EraseIterator(HashBase& b): mBase(b) + { + reset(); + } + + PX_INLINE Entry* eraseCurrentGetNext(bool eraseCurrent) + { + if(eraseCurrent && mCurrentEntryIndexPtr) + { + mBase.eraseInternal(mCurrentEntryIndexPtr); + // if next was valid return the same ptr, if next was EOL search new hash entry + if(*mCurrentEntryIndexPtr != mBase.EOL) + return mBase.mEntries + *mCurrentEntryIndexPtr; + else + return traverseHashEntries(); + } + + // traverse mHash to find next entry + if(mCurrentEntryIndexPtr == NULL) + return traverseHashEntries(); + + const uint32_t index = *mCurrentEntryIndexPtr; + if(mBase.mEntriesNext[index] == mBase.EOL) + { + return traverseHashEntries(); + } + else + { + mCurrentEntryIndexPtr = mBase.mEntriesNext + index; + return mBase.mEntries + *mCurrentEntryIndexPtr; + } + } + + PX_INLINE void reset() + { + mCurrentHashIndex = 0; + mCurrentEntryIndexPtr = NULL; + } + + private: + PX_INLINE Entry* traverseHashEntries() + { + mCurrentEntryIndexPtr = NULL; + while (mCurrentEntryIndexPtr == NULL && mCurrentHashIndex < mBase.mHashSize) + { + if (mBase.mHash[mCurrentHashIndex] != mBase.EOL) + { + mCurrentEntryIndexPtr = mBase.mHash + mCurrentHashIndex; + mCurrentHashIndex++; + return mBase.mEntries + *mCurrentEntryIndexPtr; + } + else + { + mCurrentHashIndex++; + } + } + return NULL; + } + + EraseIterator& operator=(const EraseIterator&); + private: + uint32_t* mCurrentEntryIndexPtr; + uint32_t mCurrentHashIndex; + HashBase& mBase; + }; +}; + +template <class Entry, class Key, class HashFn, class GetKey, class Allocator, bool compacting> +template <typename HK, typename GK, class A, bool comp> +PX_NOINLINE void +HashBase<Entry, Key, HashFn, GetKey, Allocator, compacting>::copy(const HashBase<Entry, Key, HK, GK, A, comp>& other) +{ + reserve(other.mEntriesCount); + + for(uint32_t i = 0; i < other.mEntriesCount; i++) + { + for(uint32_t j = other.mHash[i]; j != EOL; j = other.mEntriesNext[j]) + { + const Entry& otherEntry = other.mEntries[j]; + + bool exists; + Entry* newEntry = create(GK()(otherEntry), exists); + NV_CLOTH_ASSERT(!exists); + + PX_PLACEMENT_NEW(newEntry, Entry)(otherEntry); + } + } +} + +template <class Key, class HashFn, class Allocator = typename AllocatorTraits<Key>::Type, bool Coalesced = false> +class HashSetBase +{ + PX_NOCOPY(HashSetBase) + public: + struct GetKey + { + PX_INLINE const Key& operator()(const Key& e) + { + return e; + } + }; + + typedef HashBase<Key, Key, HashFn, GetKey, Allocator, Coalesced> BaseMap; + typedef typename BaseMap::Iter Iterator; + + HashSetBase(uint32_t initialTableSize, float loadFactor, const Allocator& alloc) + : mBase(initialTableSize, loadFactor, alloc) + { + } + + HashSetBase(const Allocator& alloc) : mBase(64, 0.75f, alloc) + { + } + + HashSetBase(uint32_t initialTableSize = 64, float loadFactor = 0.75f) : mBase(initialTableSize, loadFactor) + { + } + + bool insert(const Key& k) + { + bool exists; + Key* e = mBase.create(k, exists); + if(!exists) + PX_PLACEMENT_NEW(e, Key)(k); + return !exists; + } + + PX_INLINE bool contains(const Key& k) const + { + return mBase.find(k) != 0; + } + PX_INLINE bool erase(const Key& k) + { + return mBase.erase(k); + } + PX_INLINE uint32_t size() const + { + return mBase.size(); + } + PX_INLINE uint32_t capacity() const + { + return mBase.capacity(); + } + PX_INLINE void reserve(uint32_t size) + { + mBase.reserve(size); + } + PX_INLINE void clear() + { + mBase.clear(); + } + + protected: + BaseMap mBase; +}; + +template <class Key, class Value, class HashFn, class Allocator = typename AllocatorTraits<Pair<const Key, Value> >::Type> +class HashMapBase +{ + PX_NOCOPY(HashMapBase) + public: + typedef Pair<const Key, Value> Entry; + + struct GetKey + { + PX_INLINE const Key& operator()(const Entry& e) + { + return e.first; + } + }; + + typedef HashBase<Entry, Key, HashFn, GetKey, Allocator, true> BaseMap; + typedef typename BaseMap::Iter Iterator; + typedef typename BaseMap::EraseIterator EraseIterator; + + HashMapBase(uint32_t initialTableSize, float loadFactor, const Allocator& alloc) + : mBase(initialTableSize, loadFactor, alloc) + { + } + + HashMapBase(const Allocator& alloc) : mBase(64, 0.75f, alloc) + { + } + + HashMapBase(uint32_t initialTableSize = 64, float loadFactor = 0.75f) : mBase(initialTableSize, loadFactor) + { + } + + bool insert(const Key /*&*/ k, const Value /*&*/ v) + { + bool exists; + Entry* e = mBase.create(k, exists); + if(!exists) + PX_PLACEMENT_NEW(e, Entry)(k, v); + return !exists; + } + + Value& operator[](const Key& k) + { + bool exists; + Entry* e = mBase.create(k, exists); + if(!exists) + PX_PLACEMENT_NEW(e, Entry)(k, Value()); + + return e->second; + } + + PX_INLINE const Entry* find(const Key& k) const + { + return mBase.find(k); + } + PX_INLINE bool erase(const Key& k) + { + return mBase.erase(k); + } + PX_INLINE bool erase(const Key& k, Entry& e) + { + return mBase.erase(k, e); + } + PX_INLINE uint32_t size() const + { + return mBase.size(); + } + PX_INLINE uint32_t capacity() const + { + return mBase.capacity(); + } + PX_INLINE Iterator getIterator() + { + return Iterator(mBase); + } + PX_INLINE EraseIterator getEraseIterator() + { + return EraseIterator(mBase); + } + PX_INLINE void reserve(uint32_t size) + { + mBase.reserve(size); + } + PX_INLINE void clear() + { + mBase.clear(); + } + + protected: + BaseMap mBase; +}; +} + +} // namespace shdfnd +} // namespace physx + +#if PX_VC +#pragma warning(pop) +#endif +#endif // #ifndef PSFOUNDATION_PSHASHINTERNALS_H diff --git a/NvCloth/include/NvCloth/ps/PsHashMap.h b/NvCloth/include/NvCloth/ps/PsHashMap.h new file mode 100644 index 0000000..5091dee --- /dev/null +++ b/NvCloth/include/NvCloth/ps/PsHashMap.h @@ -0,0 +1,118 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved. +// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. +// Copyright (c) 2001-2004 NovodeX AG. All rights reserved. + +#ifndef PSFOUNDATION_PSHASHMAP_H +#define PSFOUNDATION_PSHASHMAP_H + +#include "PsHashInternals.h" + +// TODO: make this doxy-format +// +// This header defines two hash maps. Hash maps +// * support custom initial table sizes (rounded up internally to power-of-2) +// * support custom static allocator objects +// * auto-resize, based on a load factor (i.e. a 64-entry .75 load factor hash will resize +// when the 49th element is inserted) +// * are based on open hashing +// * have O(1) contains, erase +// +// Maps have STL-like copying semantics, and properly initialize and destruct copies of objects +// +// There are two forms of map: coalesced and uncoalesced. Coalesced maps keep the entries in the +// initial segment of an array, so are fast to iterate over; however deletion is approximately +// twice as expensive. +// +// HashMap<T>: +// bool insert(const Key& k, const Value& v) O(1) amortized (exponential resize policy) +// Value & operator[](const Key& k) O(1) for existing objects, else O(1) amortized +// const Entry * find(const Key& k); O(1) +// bool erase(const T& k); O(1) +// uint32_t size(); constant +// void reserve(uint32_t size); O(MAX(currentOccupancy,size)) +// void clear(); O(currentOccupancy) (with zero constant for objects +// without +// destructors) +// Iterator getIterator(); +// +// operator[] creates an entry if one does not exist, initializing with the default constructor. +// CoalescedHashMap<T> does not support getIterator, but instead supports +// const Key *getEntries(); +// +// Use of iterators: +// +// for(HashMap::Iterator iter = test.getIterator(); !iter.done(); ++iter) +// myFunction(iter->first, iter->second); + +namespace physx +{ +namespace shdfnd +{ +template <class Key, class Value, class HashFn = Hash<Key>, class Allocator = NonTrackingAllocator> +class HashMap : public internal::HashMapBase<Key, Value, HashFn, Allocator> +{ + public: + typedef internal::HashMapBase<Key, Value, HashFn, Allocator> HashMapBase; + typedef typename HashMapBase::Iterator Iterator; + + HashMap(uint32_t initialTableSize = 64, float loadFactor = 0.75f) : HashMapBase(initialTableSize, loadFactor) + { + } + HashMap(uint32_t initialTableSize, float loadFactor, const Allocator& alloc) + : HashMapBase(initialTableSize, loadFactor, alloc) + { + } + HashMap(const Allocator& alloc) : HashMapBase(64, 0.75f, alloc) + { + } + Iterator getIterator() + { + return Iterator(HashMapBase::mBase); + } +}; + +template <class Key, class Value, class HashFn = Hash<Key>, class Allocator = NonTrackingAllocator> +class CoalescedHashMap : public internal::HashMapBase<Key, Value, HashFn, Allocator> +{ + public: + typedef internal::HashMapBase<Key, Value, HashFn, Allocator> HashMapBase; + + CoalescedHashMap(uint32_t initialTableSize = 64, float loadFactor = 0.75f) + : HashMapBase(initialTableSize, loadFactor) + { + } + const Pair<const Key, Value>* getEntries() const + { + return HashMapBase::mBase.getEntries(); + } +}; + +} // namespace shdfnd +} // namespace physx + +#endif // #ifndef PSFOUNDATION_PSHASHMAP_H diff --git a/NvCloth/include/NvCloth/ps/PsIntrinsics.h b/NvCloth/include/NvCloth/ps/PsIntrinsics.h new file mode 100644 index 0000000..38b91ba --- /dev/null +++ b/NvCloth/include/NvCloth/ps/PsIntrinsics.h @@ -0,0 +1,47 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved. +// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. +// Copyright (c) 2001-2004 NovodeX AG. All rights reserved. + +#ifndef PSFOUNDATION_PSINTRINSICS_H +#define PSFOUNDATION_PSINTRINSICS_H + +#include "foundation/PxPreprocessor.h" + +#if PX_WINDOWS_FAMILY +#include "windows/PsWindowsIntrinsics.h" +#elif(PX_LINUX || PX_ANDROID || PX_APPLE_FAMILY || PX_PS4) +#include "unix/PsUnixIntrinsics.h" +#elif PX_XBOXONE +#include "XboxOne/PsXboxOneIntrinsics.h" +#elif PX_SWITCH +#include "switch/PsSwitchIntrinsics.h" +#else +#error "Platform not supported!" +#endif + +#endif // #ifndef PSFOUNDATION_PSINTRINSICS_H diff --git a/NvCloth/include/NvCloth/ps/PsMathUtils.h b/NvCloth/include/NvCloth/ps/PsMathUtils.h new file mode 100644 index 0000000..aeaeb93 --- /dev/null +++ b/NvCloth/include/NvCloth/ps/PsMathUtils.h @@ -0,0 +1,695 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved. +// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. +// Copyright (c) 2001-2004 NovodeX AG. All rights reserved. + +#ifndef PSFOUNDATION_PSMATHUTILS_H +#define PSFOUNDATION_PSMATHUTILS_H + +#include "foundation/PxPreprocessor.h" +#include "foundation/PxTransform.h" +#include "foundation/PxMat33.h" +#include "NvCloth/ps/Ps.h" +#include "NvCloth/ps/PsIntrinsics.h" +#include "NvCloth/Callbacks.h" + +// General guideline is: if it's an abstract math function, it belongs here. +// If it's a math function where the inputs have specific semantics (e.g. +// separateSwingTwist) it doesn't. + +namespace physx +{ +namespace shdfnd +{ +/** +\brief sign returns the sign of its argument. The sign of zero is undefined. +*/ +PX_CUDA_CALLABLE PX_FORCE_INLINE PxF32 sign(const PxF32 a) +{ + return intrinsics::sign(a); +} + +/** +\brief sign returns the sign of its argument. The sign of zero is undefined. +*/ +PX_CUDA_CALLABLE PX_FORCE_INLINE PxF64 sign(const PxF64 a) +{ + return (a >= 0.0) ? 1.0 : -1.0; +} + +/** +\brief sign returns the sign of its argument. The sign of zero is undefined. +*/ +PX_CUDA_CALLABLE PX_FORCE_INLINE PxI32 sign(const PxI32 a) +{ + return (a >= 0) ? 1 : -1; +} + +/** +\brief Returns true if the two numbers are within eps of each other. +*/ +PX_CUDA_CALLABLE PX_FORCE_INLINE bool equals(const PxF32 a, const PxF32 b, const PxF32 eps) +{ + return (PxAbs(a - b) < eps); +} + +/** +\brief Returns true if the two numbers are within eps of each other. +*/ +PX_CUDA_CALLABLE PX_FORCE_INLINE bool equals(const PxF64 a, const PxF64 b, const PxF64 eps) +{ + return (PxAbs(a - b) < eps); +} + +/** +\brief The floor function returns a floating-point value representing the largest integer that is less than or equal to +x. +*/ +PX_CUDA_CALLABLE PX_FORCE_INLINE PxF32 floor(const PxF32 a) +{ + return floatFloor(a); +} + +/** +\brief The floor function returns a floating-point value representing the largest integer that is less than or equal to +x. +*/ +PX_CUDA_CALLABLE PX_FORCE_INLINE PxF64 floor(const PxF64 a) +{ + return ::floor(a); +} + +/** +\brief The ceil function returns a single value representing the smallest integer that is greater than or equal to x. +*/ +PX_CUDA_CALLABLE PX_FORCE_INLINE PxF32 ceil(const PxF32 a) +{ + return ::ceilf(a); +} + +/** +\brief The ceil function returns a double value representing the smallest integer that is greater than or equal to x. +*/ +PX_CUDA_CALLABLE PX_FORCE_INLINE PxF64 ceil(const PxF64 a) +{ + return ::ceil(a); +} + +/** +\brief mod returns the floating-point remainder of x / y. + +If the value of y is 0.0, mod returns a quiet NaN. +*/ +PX_CUDA_CALLABLE PX_FORCE_INLINE PxF32 mod(const PxF32 x, const PxF32 y) +{ + return PxF32(::fmodf(x, y)); +} + +/** +\brief mod returns the floating-point remainder of x / y. + +If the value of y is 0.0, mod returns a quiet NaN. +*/ +PX_CUDA_CALLABLE PX_FORCE_INLINE PxF64 mod(const PxF64 x, const PxF64 y) +{ + return ::fmod(x, y); +} + +/** +\brief Square. +*/ +PX_CUDA_CALLABLE PX_FORCE_INLINE PxF32 sqr(const PxF32 a) +{ + return a * a; +} + +/** +\brief Square. +*/ +PX_CUDA_CALLABLE PX_FORCE_INLINE PxF64 sqr(const PxF64 a) +{ + return a * a; +} + +/** +\brief Calculates x raised to the power of y. +*/ +PX_CUDA_CALLABLE PX_FORCE_INLINE PxF32 pow(const PxF32 x, const PxF32 y) +{ + return ::powf(x, y); +} + +/** +\brief Calculates x raised to the power of y. +*/ +PX_CUDA_CALLABLE PX_FORCE_INLINE PxF64 pow(const PxF64 x, const PxF64 y) +{ + return ::pow(x, y); +} + +/** +\brief Calculates e^n +*/ +PX_CUDA_CALLABLE PX_FORCE_INLINE PxF32 exp(const PxF32 a) +{ + return ::expf(a); +} +/** + +\brief Calculates e^n +*/ +PX_CUDA_CALLABLE PX_FORCE_INLINE PxF64 exp(const PxF64 a) +{ + return ::exp(a); +} + +/** +\brief Calculates 2^n +*/ +PX_CUDA_CALLABLE PX_FORCE_INLINE PxF32 exp2(const PxF32 a) +{ + return ::expf(a * 0.693147180559945309417f); +} +/** + +\brief Calculates 2^n +*/ +PX_CUDA_CALLABLE PX_FORCE_INLINE PxF64 exp2(const PxF64 a) +{ + return ::exp(a * 0.693147180559945309417); +} + +/** +\brief Calculates logarithms. +*/ +PX_CUDA_CALLABLE PX_FORCE_INLINE PxF32 logE(const PxF32 a) +{ + return ::logf(a); +} + +/** +\brief Calculates logarithms. +*/ +PX_CUDA_CALLABLE PX_FORCE_INLINE PxF64 logE(const PxF64 a) +{ + return ::log(a); +} + +/** +\brief Calculates logarithms. +*/ +PX_CUDA_CALLABLE PX_FORCE_INLINE PxF32 log2(const PxF32 a) +{ + return ::logf(a) / 0.693147180559945309417f; +} + +/** +\brief Calculates logarithms. +*/ +PX_CUDA_CALLABLE PX_FORCE_INLINE PxF64 log2(const PxF64 a) +{ + return ::log(a) / 0.693147180559945309417; +} + +/** +\brief Calculates logarithms. +*/ +PX_CUDA_CALLABLE PX_FORCE_INLINE PxF32 log10(const PxF32 a) +{ + return ::log10f(a); +} + +/** +\brief Calculates logarithms. +*/ +PX_CUDA_CALLABLE PX_FORCE_INLINE PxF64 log10(const PxF64 a) +{ + return ::log10(a); +} + +/** +\brief Converts degrees to radians. +*/ +PX_CUDA_CALLABLE PX_FORCE_INLINE PxF32 degToRad(const PxF32 a) +{ + return 0.01745329251994329547f * a; +} + +/** +\brief Converts degrees to radians. +*/ +PX_CUDA_CALLABLE PX_FORCE_INLINE PxF64 degToRad(const PxF64 a) +{ + return 0.01745329251994329547 * a; +} + +/** +\brief Converts radians to degrees. +*/ +PX_CUDA_CALLABLE PX_FORCE_INLINE PxF32 radToDeg(const PxF32 a) +{ + return 57.29577951308232286465f * a; +} + +/** +\brief Converts radians to degrees. +*/ +PX_CUDA_CALLABLE PX_FORCE_INLINE PxF64 radToDeg(const PxF64 a) +{ + return 57.29577951308232286465 * a; +} + +//! \brief compute sine and cosine at the same time. There is a 'fsincos' on PC that we probably want to use here +PX_CUDA_CALLABLE PX_FORCE_INLINE void sincos(const PxF32 radians, PxF32& sin, PxF32& cos) +{ + /* something like: + _asm fld Local + _asm fsincos + _asm fstp LocalCos + _asm fstp LocalSin + */ + sin = PxSin(radians); + cos = PxCos(radians); +} + +/** +\brief uniform random number in [a,b] +*/ +PX_FORCE_INLINE PxI32 rand(const PxI32 a, const PxI32 b) +{ + return a + PxI32(::rand() % (b - a + 1)); +} + +/** +\brief uniform random number in [a,b] +*/ +PX_FORCE_INLINE PxF32 rand(const PxF32 a, const PxF32 b) +{ + return a + (b - a) * ::rand() / RAND_MAX; +} + +//! \brief return angle between two vectors in radians +PX_CUDA_CALLABLE PX_FORCE_INLINE PxF32 angle(const PxVec3& v0, const PxVec3& v1) +{ + const PxF32 cos = v0.dot(v1); // |v0|*|v1|*Cos(Angle) + const PxF32 sin = (v0.cross(v1)).magnitude(); // |v0|*|v1|*Sin(Angle) + return PxAtan2(sin, cos); +} + +//! If possible use instead fsel on the dot product /*fsel(d.dot(p),onething,anotherthing);*/ +//! Compares orientations (more readable, user-friendly function) +PX_CUDA_CALLABLE PX_FORCE_INLINE bool sameDirection(const PxVec3& d, const PxVec3& p) +{ + return d.dot(p) >= 0.0f; +} + +//! Checks 2 values have different signs +PX_CUDA_CALLABLE PX_FORCE_INLINE IntBool differentSign(PxReal f0, PxReal f1) +{ +#if !PX_EMSCRIPTEN + union + { + PxU32 u; + PxReal f; + } u1, u2; + u1.f = f0; + u2.f = f1; + return IntBool((u1.u ^ u2.u) & PX_SIGN_BITMASK); +#else + // javascript floats are 64-bits... + return IntBool( (f0*f1) < 0.0f ); +#endif +} + +PX_CUDA_CALLABLE PX_FORCE_INLINE PxMat33 star(const PxVec3& v) +{ + return PxMat33(PxVec3(0, v.z, -v.y), PxVec3(-v.z, 0, v.x), PxVec3(v.y, -v.x, 0)); +} + +PX_CUDA_CALLABLE PX_INLINE PxVec3 log(const PxQuat& q) +{ + const PxReal s = q.getImaginaryPart().magnitude(); + if(s < 1e-12f) + return PxVec3(0.0f); + // force the half-angle to have magnitude <= pi/2 + PxReal halfAngle = q.w < 0 ? PxAtan2(-s, -q.w) : PxAtan2(s, q.w); + NV_CLOTH_ASSERT(halfAngle >= -PxPi / 2 && halfAngle <= PxPi / 2); + + return q.getImaginaryPart().getNormalized() * 2.f * halfAngle; +} + +PX_CUDA_CALLABLE PX_INLINE PxQuat exp(const PxVec3& v) +{ + const PxReal m = v.magnitudeSquared(); + return m < 1e-24f ? PxQuat(PxIdentity) : PxQuat(PxSqrt(m), v * PxRecipSqrt(m)); +} + +// quat to rotate v0 t0 v1 +PX_CUDA_CALLABLE PX_INLINE PxQuat rotationArc(const PxVec3& v0, const PxVec3& v1) +{ + const PxVec3 cross = v0.cross(v1); + const PxReal d = v0.dot(v1); + if(d <= -0.99999f) + return (PxAbs(v0.x) < 0.1f ? PxQuat(0.0f, v0.z, -v0.y, 0.0f) : PxQuat(v0.y, -v0.x, 0.0, 0.0)).getNormalized(); + + const PxReal s = PxSqrt((1 + d) * 2), r = 1 / s; + + return PxQuat(cross.x * r, cross.y * r, cross.z * r, s * 0.5f).getNormalized(); +} + +/** +\brief returns largest axis +*/ +PX_CUDA_CALLABLE PX_FORCE_INLINE PxU32 largestAxis(const PxVec3& v) +{ + PxU32 m = PxU32(v.y > v.x ? 1 : 0); + return v.z > v[m] ? 2 : m; +} + +/** +\brief returns indices for the largest axis and 2 other axii +*/ +PX_CUDA_CALLABLE PX_FORCE_INLINE PxU32 largestAxis(const PxVec3& v, PxU32& other1, PxU32& other2) +{ + if(v.x >= PxMax(v.y, v.z)) + { + other1 = 1; + other2 = 2; + return 0; + } + else if(v.y >= v.z) + { + other1 = 0; + other2 = 2; + return 1; + } + else + { + other1 = 0; + other2 = 1; + return 2; + } +} + +/** +\brief returns axis with smallest absolute value +*/ +PX_CUDA_CALLABLE PX_FORCE_INLINE PxU32 closestAxis(const PxVec3& v) +{ + PxU32 m = PxU32(PxAbs(v.y) > PxAbs(v.x) ? 1 : 0); + return PxAbs(v.z) > PxAbs(v[m]) ? 2 : m; +} + +PX_CUDA_CALLABLE PX_INLINE PxU32 closestAxis(const PxVec3& v, PxU32& j, PxU32& k) +{ + // find largest 2D plane projection + const PxF32 absPx = PxAbs(v.x); + const PxF32 absNy = PxAbs(v.y); + const PxF32 absNz = PxAbs(v.z); + + PxU32 m = 0; // x biggest axis + j = 1; + k = 2; + if(absNy > absPx && absNy > absNz) + { + // y biggest + j = 2; + k = 0; + m = 1; + } + else if(absNz > absPx) + { + // z biggest + j = 0; + k = 1; + m = 2; + } + return m; +} + +/*! +Extend an edge along its length by a factor +*/ +PX_CUDA_CALLABLE PX_FORCE_INLINE void makeFatEdge(PxVec3& p0, PxVec3& p1, PxReal fatCoeff) +{ + PxVec3 delta = p1 - p0; + + const PxReal m = delta.magnitude(); + if(m > 0.0f) + { + delta *= fatCoeff / m; + p0 -= delta; + p1 += delta; + } +} + +//! Compute point as combination of barycentric coordinates +PX_CUDA_CALLABLE PX_FORCE_INLINE PxVec3 +computeBarycentricPoint(const PxVec3& p0, const PxVec3& p1, const PxVec3& p2, PxReal u, PxReal v) +{ + // This seems to confuse the compiler... + // return (1.0f - u - v)*p0 + u*p1 + v*p2; + const PxF32 w = 1.0f - u - v; + return PxVec3(w * p0.x + u * p1.x + v * p2.x, w * p0.y + u * p1.y + v * p2.y, w * p0.z + u * p1.z + v * p2.z); +} + +// generates a pair of quaternions (swing, twist) such that in = swing * twist, with +// swing.x = 0 +// twist.y = twist.z = 0, and twist is a unit quat +PX_FORCE_INLINE void separateSwingTwist(const PxQuat& q, PxQuat& swing, PxQuat& twist) +{ + twist = q.x != 0.0f ? PxQuat(q.x, 0, 0, q.w).getNormalized() : PxQuat(PxIdentity); + swing = q * twist.getConjugate(); +} + +// generate two tangent vectors to a given normal +PX_FORCE_INLINE void normalToTangents(const PxVec3& normal, PxVec3& tangent0, PxVec3& tangent1) +{ + tangent0 = PxAbs(normal.x) < 0.70710678f ? PxVec3(0, -normal.z, normal.y) : PxVec3(-normal.y, normal.x, 0); + tangent0.normalize(); + tangent1 = normal.cross(tangent0); +} + +/** +\brief computes a oriented bounding box around the scaled basis. +\param basis Input = skewed basis, Output = (normalized) orthogonal basis. +\return Bounding box extent. +*/ +NV_CLOTH_IMPORT PxVec3 optimizeBoundingBox(PxMat33& basis); + +NV_CLOTH_IMPORT PxQuat slerp(const PxReal t, const PxQuat& left, const PxQuat& right); + +PX_CUDA_CALLABLE PX_INLINE PxVec3 ellipseClamp(const PxVec3& point, const PxVec3& radii) +{ + // This function need to be implemented in the header file because + // it is included in a spu shader program. + + // finds the closest point on the ellipse to a given point + + // (p.y, p.z) is the input point + // (e.y, e.z) are the radii of the ellipse + + // lagrange multiplier method with Newton/Halley hybrid root-finder. + // see http://www.geometrictools.com/Documentation/DistancePointToEllipse2.pdf + // for proof of Newton step robustness and initial estimate. + // Halley converges much faster but sometimes overshoots - when that happens we take + // a newton step instead + + // converges in 1-2 iterations where D&C works well, and it's good with 4 iterations + // with any ellipse that isn't completely crazy + + const PxU32 MAX_ITERATIONS = 20; + const PxReal convergenceThreshold = 1e-4f; + + // iteration requires first quadrant but we recover generality later + + PxVec3 q(0, PxAbs(point.y), PxAbs(point.z)); + const PxReal tinyEps = 1e-6f; // very close to minor axis is numerically problematic but trivial + if(radii.y >= radii.z) + { + if(q.z < tinyEps) + return PxVec3(0, point.y > 0 ? radii.y : -radii.y, 0); + } + else + { + if(q.y < tinyEps) + return PxVec3(0, 0, point.z > 0 ? radii.z : -radii.z); + } + + PxVec3 denom, e2 = radii.multiply(radii), eq = radii.multiply(q); + + // we can use any initial guess which is > maximum(-e.y^2,-e.z^2) and for which f(t) is > 0. + // this guess works well near the axes, but is weak along the diagonals. + + PxReal t = PxMax(eq.y - e2.y, eq.z - e2.z); + + for(PxU32 i = 0; i < MAX_ITERATIONS; i++) + { + denom = PxVec3(0, 1 / (t + e2.y), 1 / (t + e2.z)); + PxVec3 denom2 = eq.multiply(denom); + + PxVec3 fv = denom2.multiply(denom2); + PxReal f = fv.y + fv.z - 1; + + // although in exact arithmetic we are guaranteed f>0, we can get here + // on the first iteration via catastrophic cancellation if the point is + // very close to the origin. In that case we just behave as if f=0 + + if(f < convergenceThreshold) + return e2.multiply(point).multiply(denom); + + PxReal df = fv.dot(denom) * -2.0f; + t = t - f / df; + } + + // we didn't converge, so clamp what we have + PxVec3 r = e2.multiply(point).multiply(denom); + return r * PxRecipSqrt(sqr(r.y / radii.y) + sqr(r.z / radii.z)); +} + +PX_CUDA_CALLABLE PX_INLINE PxReal tanHalf(PxReal sin, PxReal cos) +{ + return sin / (1 + cos); +} + +PX_INLINE PxQuat quatFromTanQVector(const PxVec3& v) +{ + PxReal v2 = v.dot(v); + if(v2 < 1e-12f) + return PxQuat(PxIdentity); + PxReal d = 1 / (1 + v2); + return PxQuat(v.x * 2, v.y * 2, v.z * 2, 1 - v2) * d; +} + +PX_FORCE_INLINE PxVec3 cross100(const PxVec3& b) +{ + return PxVec3(0.0f, -b.z, b.y); +} +PX_FORCE_INLINE PxVec3 cross010(const PxVec3& b) +{ + return PxVec3(b.z, 0.0f, -b.x); +} +PX_FORCE_INLINE PxVec3 cross001(const PxVec3& b) +{ + return PxVec3(-b.y, b.x, 0.0f); +} + +PX_INLINE void decomposeVector(PxVec3& normalCompo, PxVec3& tangentCompo, const PxVec3& outwardDir, + const PxVec3& outwardNormal) +{ + normalCompo = outwardNormal * (outwardDir.dot(outwardNormal)); + tangentCompo = outwardDir - normalCompo; +} + +//! \brief Return (i+1)%3 +// Avoid variable shift for XBox: +// PX_INLINE PxU32 Ps::getNextIndex3(PxU32 i) { return (1<<i) & 3; } +PX_INLINE PxU32 getNextIndex3(PxU32 i) +{ + return (i + 1 + (i >> 1)) & 3; +} + +PX_INLINE PxMat33 rotFrom2Vectors(const PxVec3& from, const PxVec3& to) +{ + // See bottom of http://www.euclideanspace.com/maths/algebra/matrix/orthogonal/rotation/index.htm + + // Early exit if to = from + if((from - to).magnitudeSquared() < 1e-4f) + return PxMat33(PxIdentity); + + // Early exit if to = -from + if((from + to).magnitudeSquared() < 1e-4f) + return PxMat33::createDiagonal(PxVec3(1.0f, -1.0f, -1.0f)); + + PxVec3 n = from.cross(to); + + PxReal C = from.dot(to), S = PxSqrt(1 - C * C), CC = 1 - C; + + PxReal xx = n.x * n.x, yy = n.y * n.y, zz = n.z * n.z, xy = n.x * n.y, yz = n.y * n.z, xz = n.x * n.z; + + PxMat33 R; + + R(0, 0) = 1 + CC * (xx - 1); + R(0, 1) = -n.z * S + CC * xy; + R(0, 2) = n.y * S + CC * xz; + + R(1, 0) = n.z * S + CC * xy; + R(1, 1) = 1 + CC * (yy - 1); + R(1, 2) = -n.x * S + CC * yz; + + R(2, 0) = -n.y * S + CC * xz; + R(2, 1) = n.x * S + CC * yz; + R(2, 2) = 1 + CC * (zz - 1); + + return R; +} + +NV_CLOTH_IMPORT void integrateTransform(const PxTransform& curTrans, const PxVec3& linvel, const PxVec3& angvel, + PxReal timeStep, PxTransform& result); + +PX_INLINE void computeBasis(const PxVec3& dir, PxVec3& right, PxVec3& up) +{ + // Derive two remaining vectors + if(PxAbs(dir.y) <= 0.9999f) + { + right = PxVec3(dir.z, 0.0f, -dir.x); + right.normalize(); + + // PT: normalize not needed for 'up' because dir & right are unit vectors, + // and by construction the angle between them is 90 degrees (i.e. sin(angle)=1) + up = PxVec3(dir.y * right.z, dir.z * right.x - dir.x * right.z, -dir.y * right.x); + } + else + { + right = PxVec3(1.0f, 0.0f, 0.0f); + + up = PxVec3(0.0f, dir.z, -dir.y); + up.normalize(); + } +} + +PX_INLINE void computeBasis(const PxVec3& p0, const PxVec3& p1, PxVec3& dir, PxVec3& right, PxVec3& up) +{ + // Compute the new direction vector + dir = p1 - p0; + dir.normalize(); + + // Derive two remaining vectors + computeBasis(dir, right, up); +} + +PX_FORCE_INLINE bool isAlmostZero(const PxVec3& v) +{ + if(PxAbs(v.x) > 1e-6f || PxAbs(v.y) > 1e-6f || PxAbs(v.z) > 1e-6f) + return false; + return true; +} + +} // namespace shdfnd +} // namespace physx + +#endif diff --git a/NvCloth/include/NvCloth/ps/PsUserAllocated.h b/NvCloth/include/NvCloth/ps/PsUserAllocated.h new file mode 100644 index 0000000..f41d29e --- /dev/null +++ b/NvCloth/include/NvCloth/ps/PsUserAllocated.h @@ -0,0 +1,92 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved. +// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. +// Copyright (c) 2001-2004 NovodeX AG. All rights reserved. + +#ifndef PSFOUNDATION_PSUSERALLOCATED_H +#define PSFOUNDATION_PSUSERALLOCATED_H + +#include "PsAllocator.h" + +namespace physx +{ +namespace shdfnd +{ +/** +Provides new and delete using a UserAllocator. +Guarantees that 'delete x;' uses the UserAllocator too. +*/ +class UserAllocated +{ + public: + // PX_SERIALIZATION + PX_INLINE void* operator new(size_t, void* address) + { + return address; + } + //~PX_SERIALIZATION + // Matching operator delete to the above operator new. Don't ask me + // how this makes any sense - Nuernberger. + PX_INLINE void operator delete(void*, void*) + { + } + + template <typename Alloc> + PX_INLINE void* operator new(size_t size, Alloc alloc, const char* fileName, int line) + { + return alloc.allocate(size, fileName, line); + } + template <typename Alloc> + PX_INLINE void* operator new [](size_t size, Alloc alloc, const char* fileName, int line) + { return alloc.allocate(size, fileName, line); } + + // placement delete + template <typename Alloc> + PX_INLINE void operator delete(void* ptr, Alloc alloc, const char* fileName, int line) + { + PX_UNUSED(fileName); + PX_UNUSED(line); + alloc.deallocate(ptr); + } + template <typename Alloc> + PX_INLINE void operator delete [](void* ptr, Alloc alloc, const char* fileName, int line) + { + PX_UNUSED(fileName); + PX_UNUSED(line); + alloc.deallocate(ptr); + } PX_INLINE void + operator delete(void* ptr) + { + NonTrackingAllocator().deallocate(ptr); + } + PX_INLINE void operator delete [](void* ptr) + { NonTrackingAllocator().deallocate(ptr); } +}; +} // namespace shdfnd +} // namespace physx + +#endif // #ifndef PSFOUNDATION_PSUSERALLOCATED_H diff --git a/NvCloth/include/NvCloth/ps/unix/PsUnixIntrinsics.h b/NvCloth/include/NvCloth/ps/unix/PsUnixIntrinsics.h new file mode 100644 index 0000000..93d20b5 --- /dev/null +++ b/NvCloth/include/NvCloth/ps/unix/PsUnixIntrinsics.h @@ -0,0 +1,153 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved. +// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. +// Copyright (c) 2001-2004 NovodeX AG. All rights reserved. + +#ifndef PSFOUNDATION_PSUNIXINTRINSICS_H +#define PSFOUNDATION_PSUNIXINTRINSICS_H + +#include "NvCloth/ps/Ps.h" +#include "NvCloth/Callbacks.h" +#include <math.h> + +#if PX_ANDROID || (PX_LINUX && !(PX_X64 || PX_X64)) // x86[_64] Linux uses inline assembly for debug break +#include <signal.h> // for Ns::debugBreak() { raise(SIGTRAP); } +#endif + +#if 0 +#include <libkern/OSAtomic.h> +#endif + +// this file is for internal intrinsics - that is, intrinsics that are used in +// cross platform code but do not appear in the API + +#if !(PX_LINUX || PX_ANDROID || PX_PS4 || PX_APPLE_FAMILY) +#error "This file should only be included by unix builds!!" +#endif + +namespace physx +{ +namespace shdfnd +{ + +PX_FORCE_INLINE void memoryBarrier() +{ + __sync_synchronize(); +} + +/*! +Return the index of the highest set bit. Undefined for zero arg. +*/ +PX_INLINE uint32_t highestSetBitUnsafe(uint32_t v) +{ + + return 31 - __builtin_clz(v); +} + +/*! +Return the index of the highest set bit. Undefined for zero arg. +*/ +PX_INLINE int32_t lowestSetBitUnsafe(uint32_t v) +{ + return __builtin_ctz(v); +} + +/*! +Returns the index of the highest set bit. Returns 32 for v=0. +*/ +PX_INLINE uint32_t countLeadingZeros(uint32_t v) +{ + if(v) + return __builtin_clz(v); + else + return 32; +} + +/*! +Prefetch aligned 64B x86, 32b ARM around \c ptr+offset. +*/ +PX_FORCE_INLINE void prefetchLine(const void* ptr, uint32_t offset = 0) +{ + __builtin_prefetch(reinterpret_cast<const char* PX_RESTRICT>(ptr) + offset, 0, 3); +} + +/*! +Prefetch \c count bytes starting at \c ptr. +*/ +#if PX_ANDROID || PX_IOS +PX_FORCE_INLINE void prefetch(const void* ptr, uint32_t count = 1) +{ + const char* cp = static_cast<const char*>(ptr); + size_t p = reinterpret_cast<size_t>(ptr); + uint32_t startLine = uint32_t(p >> 5), endLine = uint32_t((p + count - 1) >> 5); + uint32_t lines = endLine - startLine + 1; + do + { + prefetchLine(cp); + cp += 32; + } while(--lines); +} +#else +PX_FORCE_INLINE void prefetch(const void* ptr, uint32_t count = 1) +{ + const char* cp = reinterpret_cast<const char*>(ptr); + uint64_t p = size_t(ptr); + uint64_t startLine = p >> 6, endLine = (p + count - 1) >> 6; + uint64_t lines = endLine - startLine + 1; + do + { + prefetchLine(cp); + cp += 64; + } while(--lines); +} +#endif + +//! \brief platform-specific reciprocal +PX_CUDA_CALLABLE PX_FORCE_INLINE float recipFast(float a) +{ + return 1.0f / a; +} + +//! \brief platform-specific fast reciprocal square root +PX_CUDA_CALLABLE PX_FORCE_INLINE float recipSqrtFast(float a) +{ + return 1.0f / ::sqrtf(a); +} + +//! \brief platform-specific floor +PX_CUDA_CALLABLE PX_FORCE_INLINE float floatFloor(float x) +{ + return ::floorf(x); +} + +#define NS_EXPECT_TRUE(x) x +#define NS_EXPECT_FALSE(x) x + +} // namespace shdfnd +} // namespace physx + +#endif // #ifndef PSFOUNDATION_PSUNIXINTRINSICS_H diff --git a/NvCloth/include/NvCloth/ps/windows/PsWindowsIntrinsics.h b/NvCloth/include/NvCloth/ps/windows/PsWindowsIntrinsics.h new file mode 100644 index 0000000..ac81f02 --- /dev/null +++ b/NvCloth/include/NvCloth/ps/windows/PsWindowsIntrinsics.h @@ -0,0 +1,189 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved. +// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. +// Copyright (c) 2001-2004 NovodeX AG. All rights reserved. + +#ifndef PSFOUNDATION_PSWINDOWSINTRINSICS_H +#define PSFOUNDATION_PSWINDOWSINTRINSICS_H + +#include "Ps.h" + +// this file is for internal intrinsics - that is, intrinsics that are used in +// cross platform code but do not appear in the API + +#if !PX_WINDOWS_FAMILY +#error "This file should only be included by Windows builds!!" +#endif + +#pragma warning(push) +//'symbol' is not defined as a preprocessor macro, replacing with '0' for 'directives' +#pragma warning(disable : 4668) +#if PX_VC == 10 +#pragma warning(disable : 4987) // nonstandard extension used: 'throw (...)' +#endif +#include <intrin.h> +#pragma warning(pop) + +#pragma warning(push) +#pragma warning(disable : 4985) // 'symbol name': attributes not present on previous declaration +#include <math.h> +#pragma warning(pop) + +#include <float.h> +#include <mmintrin.h> + +#pragma intrinsic(_BitScanForward) +#pragma intrinsic(_BitScanReverse) + +namespace physx +{ +namespace shdfnd +{ + +/* +* Implements a memory barrier +*/ +PX_FORCE_INLINE void memoryBarrier() +{ + _ReadWriteBarrier(); + /* long Barrier; + __asm { + xchg Barrier, eax + }*/ +} + +/*! +Returns the index of the highest set bit. Not valid for zero arg. +*/ +PX_FORCE_INLINE uint32_t highestSetBitUnsafe(uint32_t v) +{ + unsigned long retval; + _BitScanReverse(&retval, v); + return retval; +} + +/*! +Returns the index of the highest set bit. Undefined for zero arg. +*/ +PX_FORCE_INLINE uint32_t lowestSetBitUnsafe(uint32_t v) +{ + unsigned long retval; + _BitScanForward(&retval, v); + return retval; +} + +/*! +Returns the number of leading zeros in v. Returns 32 for v=0. +*/ +PX_FORCE_INLINE uint32_t countLeadingZeros(uint32_t v) +{ + if(v) + { + unsigned long bsr = (unsigned long)-1; + _BitScanReverse(&bsr, v); + return 31 - bsr; + } + else + return 32; +} + +/*! +Prefetch aligned cache size around \c ptr+offset. +*/ +#if !PX_ARM +PX_FORCE_INLINE void prefetchLine(const void* ptr, uint32_t offset = 0) +{ + // cache line on X86/X64 is 64-bytes so a 128-byte prefetch would require 2 prefetches. + // However, we can only dispatch a limited number of prefetch instructions so we opt to prefetch just 1 cache line + /*_mm_prefetch(((const char*)ptr + offset), _MM_HINT_T0);*/ + // We get slightly better performance prefetching to non-temporal addresses instead of all cache levels + _mm_prefetch(((const char*)ptr + offset), _MM_HINT_NTA); +} +#else +PX_FORCE_INLINE void prefetchLine(const void* ptr, uint32_t offset = 0) +{ + // arm does have 32b cache line size + __prefetch(((const char*)ptr + offset)); +} +#endif + +/*! +Prefetch \c count bytes starting at \c ptr. +*/ +#if !PX_ARM +PX_FORCE_INLINE void prefetch(const void* ptr, uint32_t count = 1) +{ + const char* cp = (char*)ptr; + uint64_t p = size_t(ptr); + uint64_t startLine = p >> 6, endLine = (p + count - 1) >> 6; + uint64_t lines = endLine - startLine + 1; + do + { + prefetchLine(cp); + cp += 64; + } while(--lines); +} +#else +PX_FORCE_INLINE void prefetch(const void* ptr, uint32_t count = 1) +{ + const char* cp = (char*)ptr; + uint32_t p = size_t(ptr); + uint32_t startLine = p >> 5, endLine = (p + count - 1) >> 5; + uint32_t lines = endLine - startLine + 1; + do + { + prefetchLine(cp); + cp += 32; + } while(--lines); +} +#endif + +//! \brief platform-specific reciprocal +PX_CUDA_CALLABLE PX_FORCE_INLINE float recipFast(float a) +{ + return 1.0f / a; +} + +//! \brief platform-specific fast reciprocal square root +PX_CUDA_CALLABLE PX_FORCE_INLINE float recipSqrtFast(float a) +{ + return 1.0f / ::sqrtf(a); +} + +//! \brief platform-specific floor +PX_CUDA_CALLABLE PX_FORCE_INLINE float floatFloor(float x) +{ + return ::floorf(x); +} + +#define NS_EXPECT_TRUE(x) x +#define NS_EXPECT_FALSE(x) x + +} // namespace shdfnd +} // namespace physx + +#endif // #ifndef PSFOUNDATION_PSWINDOWSINTRINSICS_H diff --git a/NvCloth/samples/CmakeGenerateProjects.bat b/NvCloth/samples/CmakeGenerateProjects.bat index dcb2bbc..d1da2cf 100644 --- a/NvCloth/samples/CmakeGenerateProjects.bat +++ b/NvCloth/samples/CmakeGenerateProjects.bat @@ -1,11 +1,8 @@ rem @echo off CD /D %~dp0 -echo "Note: You need to run this with admin rights for the first time to set GW_DEPS_ROOT globally." -call "../scripts/locate_gw_root.bat" GW_DEPS_ROOT_F @echo on -setx GW_DEPS_ROOT "%GW_DEPS_ROOT_F% -echo GW_DEPS_ROOT = %GW_DEPS_ROOT% + REM Install cmake using packman set PACKMAN=call ../scripts/packman/packman.cmd @@ -21,9 +18,9 @@ REM Make sure the various variables that we need are set call "../scripts/locate_cuda.bat" CUDA_PATH_ echo CUDA_PATH_ = %CUDA_PATH_% -IF EXIST %~dp0..\Externals\CMakeModules ( - set GW_DEPS_ROOT=%~dp0..\ -) + +set GW_DEPS_ROOT=%~dp0..\..\ + IF NOT DEFINED GW_DEPS_ROOT GOTO GW_DEPS_ROOT_UNDEFINED @@ -34,12 +31,6 @@ set SAMPLES_ROOT_DIR=%~dp0 REM Generate projects here -rmdir /s /q compiler\vc14win32-cmake\ -mkdir compiler\vc14win32-cmake\ -pushd compiler\vc14win32-cmake\ -%CMAKE% ..\.. -G "Visual Studio 14 2015" -AWin32 -DCUDA_TOOLKIT_ROOT_DIR="%CUDA_PATH_%" -DTARGET_BUILD_PLATFORM=windows -DSTATIC_WINCRT=0 -DBL_DLL_OUTPUT_DIR=%OUTPUT_ROOT%\bin\vc14win32-cmake -DBL_LIB_OUTPUT_DIR=%OUTPUT_ROOT%\lib\vc14win32-cmake -DBL_EXE_OUTPUT_DIR=%OUTPUT_ROOT%\bin\vc14win32-cmake -popd - rmdir /s /q compiler\vc14win64-cmake\ mkdir compiler\vc14win64-cmake\ pushd compiler\vc14win64-cmake\ diff --git a/NvCloth/samples/SampleBase/renderer/Mesh.h b/NvCloth/samples/SampleBase/renderer/Mesh.h index 3a2885b..14a7081 100644 --- a/NvCloth/samples/SampleBase/renderer/Mesh.h +++ b/NvCloth/samples/SampleBase/renderer/Mesh.h @@ -12,8 +12,8 @@ #define MESH_H #include <vector> -#include "PxVec2.h" -#include "PxVec3.h" +#include <foundation/PxVec2.h> +#include <foundation/PxVec3.h> class Mesh diff --git a/NvCloth/samples/SampleBase/renderer/RenderMaterial.cpp b/NvCloth/samples/SampleBase/renderer/RenderMaterial.cpp index eb07c84..46d29dd 100644 --- a/NvCloth/samples/SampleBase/renderer/RenderMaterial.cpp +++ b/NvCloth/samples/SampleBase/renderer/RenderMaterial.cpp @@ -12,6 +12,7 @@ #include <DirectXMath.h> #include "ShaderUtils.h" #include "Renderer.h" +#include <NvCloth/Callbacks.h> /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -116,7 +117,7 @@ void RenderMaterial::setBlending(BlendMode blendMode) desc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL; break; default: - PX_ALWAYS_ASSERT_MESSAGE("Unknown blend mode"); + NV_CLOTH_ASSERT_WITH_MESSAGE(false,"Unknown blend mode"); } ID3D11Device* device = GetDeviceManager()->GetDevice(); @@ -187,7 +188,7 @@ RenderMaterial::InstancePtr RenderMaterial::getMaterialInstance(const D3D11_INPU return materialInstance; } } - PX_ALWAYS_ASSERT(); + NV_CLOTH_ASSERT(false); return NULL; } diff --git a/NvCloth/samples/SampleBase/renderer/Renderable.cpp b/NvCloth/samples/SampleBase/renderer/Renderable.cpp index c0560fd..6151bc3 100644 --- a/NvCloth/samples/SampleBase/renderer/Renderable.cpp +++ b/NvCloth/samples/SampleBase/renderer/Renderable.cpp @@ -11,6 +11,7 @@ #include "Renderable.h" #include "Renderer.h" #include "RenderUtils.h" +#include <NvCloth/Callbacks.h> const DirectX::XMFLOAT4 DEFAULT_COLOR(0.5f, 0.5f, 0.5f, 1.0f); @@ -42,7 +43,7 @@ void Renderable::render(Renderer& renderer, bool depthStencilOnly) const auto& material = m_materialInstances[submeshId%getMaterialCount()]; if(!material->isValid()) { - PX_ALWAYS_ASSERT(); + NV_CLOTH_ASSERT(false); return; } diff --git a/NvCloth/samples/SampleBase/renderer/Renderer.cpp b/NvCloth/samples/SampleBase/renderer/Renderer.cpp index dffcebd..4c6c9d5 100644 --- a/NvCloth/samples/SampleBase/renderer/Renderer.cpp +++ b/NvCloth/samples/SampleBase/renderer/Renderer.cpp @@ -14,6 +14,8 @@ #include "SampleProfiler.h" #include "PxRenderBuffer.h" + +#include <NvCloth/Callbacks.h> using namespace physx; #include <set> @@ -692,7 +694,7 @@ IRenderMesh* Renderer::getPrimitiveRenderMesh(PrimitiveRenderMeshType::Enum type m_primitiveRenderMeshes[type] = new SphereRenderMesh(); break; default: - PX_ALWAYS_ASSERT_MESSAGE("Unsupported PxGeometryType"); + NV_CLOTH_ASSERT_WITH_MESSAGE(false,"Unsupported PxGeometryType"); return NULL; } } diff --git a/NvCloth/samples/SampleBase/renderer/ResourceManager.cpp b/NvCloth/samples/SampleBase/renderer/ResourceManager.cpp index fc76e1c..b7655ea 100644 --- a/NvCloth/samples/SampleBase/renderer/ResourceManager.cpp +++ b/NvCloth/samples/SampleBase/renderer/ResourceManager.cpp @@ -9,7 +9,7 @@ */ #include "ResourceManager.h" -#include "PxAssert.h" +#include <NvCloth/Callbacks.h> #include "Utils.h" #include <windows.h> @@ -58,7 +58,7 @@ const Resource* ResourceManager::requestResource(ResourceType type, const char* } else { - PX_ALWAYS_ASSERT_MESSAGE(name); + NV_CLOTH_ASSERT_WITH_MESSAGE(false,name); } } else if (type == eTEXTURE) @@ -85,7 +85,7 @@ const Resource* ResourceManager::requestResource(ResourceType type, const char* } else { - PX_ALWAYS_ASSERT_MESSAGE("Unsupported texture extension"); + NV_CLOTH_ASSERT_WITH_MESSAGE(false,"Unsupported texture extension"); } resource = textureResource; } @@ -98,7 +98,7 @@ const Resource* ResourceManager::requestResource(ResourceType type, const char* } else { - PX_ALWAYS_ASSERT_MESSAGE(name); + NV_CLOTH_ASSERT_WITH_MESSAGE(false,name); return nullptr; } } diff --git a/NvCloth/samples/SampleBase/renderer/SkinnedRenderMesh.cpp b/NvCloth/samples/SampleBase/renderer/SkinnedRenderMesh.cpp index deb518d..99a999c 100644 --- a/NvCloth/samples/SampleBase/renderer/SkinnedRenderMesh.cpp +++ b/NvCloth/samples/SampleBase/renderer/SkinnedRenderMesh.cpp @@ -11,10 +11,11 @@ #include "SkinnedRenderMesh.h" #include "Renderer.h" +#include <NvCloth/Callbacks.h> SkinnedRenderMesh::SkinnedRenderMesh(const std::vector<const SimpleMesh*>& meshes) { - PX_ASSERT_WITH_MESSAGE(meshes.size() <= MeshesCountMax, "meshes.size() have to be <= SkinnedRenderMesh::MeshesCountMax"); + NV_CLOTH_ASSERT_WITH_MESSAGE(meshes.size() <= MeshesCountMax, "meshes.size() have to be <= SkinnedRenderMesh::MeshesCountMax"); m_device = GetDeviceManager()->GetDevice(); @@ -179,7 +180,7 @@ void SkinnedRenderMesh::updateVisibleMeshes(const std::vector<uint32_t>& visible } context->Unmap(m_indexBuffer, 0); m_indexCount = indexCount; - PX_ASSERT(m_indexCount % 3 == 0); + NV_CLOTH_ASSERT(m_indexCount % 3 == 0); } } diff --git a/NvCloth/samples/SampleBase/scene/scenes/PlaneCollisionScene.cpp b/NvCloth/samples/SampleBase/scene/scenes/PlaneCollisionScene.cpp index 8a677f1..7ab5ca0 100644 --- a/NvCloth/samples/SampleBase/scene/scenes/PlaneCollisionScene.cpp +++ b/NvCloth/samples/SampleBase/scene/scenes/PlaneCollisionScene.cpp @@ -83,7 +83,7 @@ void PlaneCollisionScene::initializeCloth(int index, physx::PxVec3 offset) //assign as collision data nv::cloth::Range<const physx::PxVec4> planesR(&planes[0], &planes[0] + planes.size()); - mClothActor[index]->mCloth->setPlanes(planesR, 0, mClothActor[index]->mCloth->getNumPlanes()); + mClothActor[index]->mCloth->setPlanes(planesR, planesR); //assign convex indices std::vector<uint32_t> indices; diff --git a/NvCloth/samples/SampleBase/scene/scenes/SphereScene.cpp b/NvCloth/samples/SampleBase/scene/scenes/SphereScene.cpp index 2e6912e..8bb004e 100644 --- a/NvCloth/samples/SampleBase/scene/scenes/SphereScene.cpp +++ b/NvCloth/samples/SampleBase/scene/scenes/SphereScene.cpp @@ -84,7 +84,9 @@ void SphereScene::initializeCloth(int index, physx::PxVec3 offset) physx::PxVec4 spheres[1] = {physx::PxVec4(physx::PxVec3(0.f, 10.f, -1.f) + offset,1.5)}; - mClothActor[index]->mCloth->setSpheres(nv::cloth::Range<physx::PxVec4>(spheres, spheres + 1), 0, mClothActor[index]->mCloth->getNumSpheres()); + //mClothActor[index]->mCloth->setSpheres(nv::cloth::Range<physx::PxVec4>(spheres, spheres + 1), 0, mClothActor[index]->mCloth->getNumSpheres()); + mClothActor[index]->mCloth->setSpheres(nv::cloth::Range<physx::PxVec4>(spheres, spheres + 1), nv::cloth::Range<physx::PxVec4>(spheres, spheres + 1)); + // Setup phase configs std::vector<nv::cloth::PhaseConfig> phases(mFabric[index]->getNumPhases()); diff --git a/NvCloth/samples/SampleBase/task/PxTask.h b/NvCloth/samples/SampleBase/task/PxTask.h index 85d91da..e2b19e2 100644 --- a/NvCloth/samples/SampleBase/task/PxTask.h +++ b/NvCloth/samples/SampleBase/task/PxTask.h @@ -32,7 +32,6 @@ #include "task/PxTaskManager.h" #include "task/PxCpuDispatcher.h" #include "task/PxGpuDispatcher.h" -#include "foundation/PxAssert.h" namespace physx { @@ -117,7 +116,7 @@ public: //! \brief Release method implementation virtual void release() { - PX_ASSERT(mTm); + NV_CLOTH_ASSERT(mTm); // clear mTm before calling taskCompleted() for safety PxTaskManager* save = mTm; @@ -129,7 +128,7 @@ public: // task is allowed to start. PX_INLINE void finishBefore( PxTaskID taskID ) { - PX_ASSERT(mTm); + NV_CLOTH_ASSERT(mTm); mTm->finishBefore( *this, taskID); } @@ -137,7 +136,7 @@ public: // task has completed. PX_INLINE void startAfter( PxTaskID taskID ) { - PX_ASSERT(mTm); + NV_CLOTH_ASSERT(mTm); mTm->startAfter( *this, taskID ); } @@ -147,7 +146,7 @@ public: */ PX_INLINE void addReference() { - PX_ASSERT(mTm); + NV_CLOTH_ASSERT(mTm); mTm->addReference( mTaskID ); } @@ -157,7 +156,7 @@ public: */ PX_INLINE void removeReference() { - PX_ASSERT(mTm); + NV_CLOTH_ASSERT(mTm); mTm->decrReference( mTaskID ); } @@ -244,7 +243,7 @@ public: */ PX_INLINE void setContinuation(PxTaskManager& tm, PxBaseTask* c) { - PX_ASSERT( mRefCount == 0 ); + NV_CLOTH_ASSERT( mRefCount == 0 ); mRefCount = 1; mCont = c; mTm = &tm; @@ -263,15 +262,15 @@ public: */ PX_INLINE void setContinuation( PxBaseTask* c ) { - PX_ASSERT( c ); - PX_ASSERT( mRefCount == 0 ); + NV_CLOTH_ASSERT( c ); + NV_CLOTH_ASSERT( mRefCount == 0 ); mRefCount = 1; mCont = c; if( mCont ) { mCont->addReference(); mTm = mCont->getTaskManager(); - PX_ASSERT( mTm ); + NV_CLOTH_ASSERT( mTm ); } } diff --git a/NvCloth/samples/SampleBase/utils/CallbackImplementations.cpp b/NvCloth/samples/SampleBase/utils/CallbackImplementations.cpp index 0a257ba..3d00961 100644 --- a/NvCloth/samples/SampleBase/utils/CallbackImplementations.cpp +++ b/NvCloth/samples/SampleBase/utils/CallbackImplementations.cpp @@ -16,8 +16,6 @@ #include <d3d11.h> //#endif -#include <PsThread.h> - NvClothEnvironment* NvClothEnvironment::sEnv = nullptr; @@ -52,9 +50,6 @@ DxContextManagerCallbackImpl::DxContextManagerCallbackImpl(ID3D11Device* device, { mDevice->AddRef(); mDevice->GetImmediateContext(&mContext); -#ifdef _DEBUG - mLockCountTls = physx::shdfnd::TlsAlloc(); -#endif } DxContextManagerCallbackImpl::~DxContextManagerCallbackImpl() { @@ -72,24 +67,15 @@ DxContextManagerCallbackImpl::~DxContextManagerCallbackImpl() mDevice->Release(); -#if _DEBUG - physx::shdfnd::TlsFree(mLockCountTls); -#endif } void DxContextManagerCallbackImpl::acquireContext() { mMutex.lock(); -#if _DEBUG - physx::shdfnd::TlsSet(mLockCountTls, reinterpret_cast<void*>(reinterpret_cast<intptr_t>(physx::shdfnd::TlsGet(mLockCountTls)) + 1)); -#endif } void DxContextManagerCallbackImpl::releaseContext() { -#if _DEBUG - physx::shdfnd::TlsSet(mLockCountTls, reinterpret_cast<void*>(reinterpret_cast<intptr_t>(physx::shdfnd::TlsGet(mLockCountTls)) - 1)); -#endif mMutex.unlock(); } ID3D11Device* DxContextManagerCallbackImpl::getDevice() const @@ -98,9 +84,6 @@ ID3D11Device* DxContextManagerCallbackImpl::getDevice() const } ID3D11DeviceContext* DxContextManagerCallbackImpl::getContext() const { -#if _DEBUG - assert(reinterpret_cast<intptr_t>(physx::shdfnd::TlsGet(mLockCountTls)) > 0); -#endif return mContext; } bool DxContextManagerCallbackImpl::synchronizeResources() const diff --git a/NvCloth/samples/SampleBase/utils/CallbackImplementations.h b/NvCloth/samples/SampleBase/utils/CallbackImplementations.h index 38a4b17..214f689 100644 --- a/NvCloth/samples/SampleBase/utils/CallbackImplementations.h +++ b/NvCloth/samples/SampleBase/utils/CallbackImplementations.h @@ -12,7 +12,6 @@ #include <NvCloth/Callbacks.h> #include <foundation/PxAllocatorCallback.h> #include <foundation/PxErrorCallback.h> -#include <foundation/PxAssert.h> #include <foundation/PxProfiler.h> #include <vector> diff --git a/NvCloth/samples/SampleBase/utils/ClothMeshGenerator.cpp b/NvCloth/samples/SampleBase/utils/ClothMeshGenerator.cpp index a0c0d3a..c3781c2 100644 --- a/NvCloth/samples/SampleBase/utils/ClothMeshGenerator.cpp +++ b/NvCloth/samples/SampleBase/utils/ClothMeshGenerator.cpp @@ -10,7 +10,7 @@ #include "ClothMeshGenerator.h" -#include "PsMathUtils.h" +#include <NvCloth/ps/PsMathUtils.h> #include <fstream> #include <iterator> diff --git a/NvCloth/samples/compiler/cmake/SampleBase.cmake b/NvCloth/samples/compiler/cmake/SampleBase.cmake index b552bb7..a1fdb67 100644 --- a/NvCloth/samples/compiler/cmake/SampleBase.cmake +++ b/NvCloth/samples/compiler/cmake/SampleBase.cmake @@ -5,6 +5,9 @@ MESSAGE("SampleBase.cmake [begin]") MESSAGE("CMAKE_MODULE_PATH: " ${CMAKE_MODULE_PATH}) +SET(NVCLOTH_ROOT_DIR ${GW_DEPS_ROOT}/NvCloth) + +MESSAGE("NVCLOTH_ROOT_DIR: " ${NVCLOTH_ROOT_DIR}) SET(SB_SOURCE_DIR ${PROJECT_SOURCE_DIR}/SampleBase) SET(SB_CORE_SOURCE_DIR ${SB_SOURCE_DIR}/core) @@ -14,7 +17,6 @@ SET(SB_UI_SOURCE_DIR ${SB_SOURCE_DIR}/ui) SET(SB_UTILS_SOURCE_DIR ${SB_SOURCE_DIR}/utils) SET(SB_TASK_SOURCE_DIR ${SB_SOURCE_DIR}/task) -FIND_PACKAGE(PxShared "1.0.21467209.1" REQUIRED) FIND_PACKAGE(DXUT "9.15.2016.1" REQUIRED) FIND_PACKAGE(DirectXTex "10.5.2016.2" REQUIRED) FIND_PACKAGE(imgui "1.49" REQUIRED) @@ -152,7 +154,8 @@ SET(UTIL_FILES ${SB_UTILS_SOURCE_DIR}/MeshGenerator.h ${SB_UTILS_SOURCE_DIR}/DataStream.cpp ${SB_UTILS_SOURCE_DIR}/DataStream.h - + ${SB_UTILS_SOURCE_DIR}/AnimatedModelUtilities.cpp + ${SB_UTILS_SOURCE_DIR}/AnimatedModelUtilities.h ) SET(TASK_FILES @@ -243,11 +246,10 @@ TARGET_LINK_LIBRARIES(SampleBase PUBLIC d3dcompiler.lib d3d11.lib dxgi.lib comctl32.lib PUBLIC ${HBAO_LIB} ${SHADOW_LIB} ${DXUT_LIBRARIES} ${DIRECTXTEX_LIBRARIES} ${ASSIMP_LIBRARIES}) -TARGET_LINK_LIBRARIES(SampleBase PUBLIC PxFoundation) TARGET_LINK_LIBRARIES(SampleBase PUBLIC NvCloth) TARGET_LINK_LIBRARIES(SampleBase PUBLIC ${CUDA_CUDA_LIBRARY}) SET_TARGET_PROPERTIES(SampleBase PROPERTIES LINK_FLAGS ${SAMPLEBASE_LINK_FLAGS}) include(${PROJECT_CMAKE_FILES_DIR}/${TARGET_BUILD_PLATFORM}/SampleBase-AT.cmake OPTIONAL) -MESSAGE("SampleBase.cmake [end]")
\ No newline at end of file +MESSAGE("SampleBase.cmake [end]") diff --git a/NvCloth/samples/compiler/cmake/windows/CMakeLists.txt b/NvCloth/samples/compiler/cmake/windows/CMakeLists.txt index a7dc6b2..906fe15 100644 --- a/NvCloth/samples/compiler/cmake/windows/CMakeLists.txt +++ b/NvCloth/samples/compiler/cmake/windows/CMakeLists.txt @@ -3,17 +3,26 @@ MESSAGE("Windows/CMakeLists.txt [begin]") SET(GW_DEPS_ROOT $ENV{GW_DEPS_ROOT}) +SET(CMAKE_MODULE_PATH $ENV{GW_DEPS_ROOT}NvCloth/Externals/CMakeModules) - -IF(EXISTS $ENV{GW_DEPS_ROOT}/Externals/CMakeModules) - SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}; $ENV{GW_DEPS_ROOT}/Externals/CMakeModules) -ELSE() - SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}; $ENV{GW_DEPS_ROOT}/sw/physx/tools/CMakeModules) +# Add find modules to the path +IF(NOT EXISTS ${CMAKE_MODULE_PATH}) + MESSAGE(FATAL_ERROR "Could not find CMakeModules at ${CMAKE_MODULE_PATH}") ENDIF() -SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}; "${CMAKE_CURRENT_SOURCE_DIR}/..") SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}; "${CMAKE_CURRENT_SOURCE_DIR}/external/CMakeModules") -MESSAGE("CMAKE_MODULE_PATH: " ${CMAKE_MODULE_PATH}) + +IF(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/external/CMakeModules") + MESSAGE(FATAL_ERROR "Could not find CMakeModules at ${CMAKE_CURRENT_SOURCE_DIR}/external/CMakeModules") +ENDIF() + +SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}; "$ENV{GW_DEPS_ROOT}/NvCloth") + +IF(NOT EXISTS "$ENV{GW_DEPS_ROOT}/NvCloth") + MESSAGE(FATAL_ERROR "Could not find CMakeModules for FindNvCloth.cmake at $ENV{GW_DEPS_ROOT}/NvCloth") +ENDIF() + +MESSAGE( "[samples]windows/CMakeLists.txt CMAKE_MODULE_PATH = ${CMAKE_MODULE_PATH}") #NOTE: Warnings lowered on the sample projects as it's got a lot of warnings. Defines below hide more. SET(CMAKE_CXX_FLAGS "/GR- /GF /MP /Gy /EHsc /d2Zi+ /errorReport:prompt /fp:fast /Gd /Gm- /GS- /nologo /W3 /WX /Zc:forScope /Zc:inline /Zc:wchar_t /Zi") @@ -59,21 +68,13 @@ SET(CMAKE_PROFILE_POSTFIX "${CMAKE_PROFILE_POSTFIX}_${LIBPATH_SUFFIX}") SET(CMAKE_CHECKED_POSTFIX "${CMAKE_CHECKED_POSTFIX}_${LIBPATH_SUFFIX}") SET(CMAKE_RELEASE_POSTFIX "${CMAKE_RELEASE_POSTFIX}_${LIBPATH_SUFFIX}") -SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}; "${CMAKE_CURRENT_SOURCE_DIR}/../../../..") +SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}; "${CMAKE_CURRENT_SOURCE_DIR}/../../../../..") SET(PX_SELECT_COMPONENTS PxFoundation) FIND_PACKAGE(PxShared REQUIRED) FIND_PACKAGE(NvCloth REQUIRED) - -# Include the PxShared-exports.cmake file that PxShared created. There's other ways to do this, but there's a bunch of issues with it in a CI environment -# such as - we don't want to be installing any built artifacts on this server, etc. So for now we hack it. - -# Add PxShared as a dependency so that we can use project references -#ADD_SUBDIRECTORY(${PXSHARED_ROOT_DIR}/src/compiler/cmake/windows "${CMAKE_CURRENT_BINARY_DIR}/pxshared_bin") -#MESSAGE("NVCLOTH_ROOT_DIR = ${NVCLOTH_ROOT_DIR}") ADD_SUBDIRECTORY(${NVCLOTH_ROOT_DIR}/compiler/cmake/windows "${CMAKE_CURRENT_BINARY_DIR}/NvCloth_bin") - # Include all of the projects INCLUDE(${PROJECT_CMAKE_FILES_DIR}/SampleBase.cmake) diff --git a/NvCloth/samples/compiler/cmake/windows/SampleBase-AT.cmake b/NvCloth/samples/compiler/cmake/windows/SampleBase-AT.cmake index 0673b96..e445e2a 100644 --- a/NvCloth/samples/compiler/cmake/windows/SampleBase-AT.cmake +++ b/NvCloth/samples/compiler/cmake/windows/SampleBase-AT.cmake @@ -16,5 +16,10 @@ ADD_CUSTOM_COMMAND(TARGET SampleBase POST_BUILD ${D3DCOMPILER_DLL} ${BL_EXE_OUTPUT_DIR} ) +#ADD_CUSTOM_COMMAND(TARGET SampleBase POST_BUILD +# COMMAND ${CMAKE_COMMAND} -E copy_if_different +# ${ASSIMP_DLLS} +# ${BL_EXE_OUTPUT_DIR} +#) -MESSAGE("Windows/SampleBase.cmake [end]")
\ No newline at end of file +MESSAGE("Windows/SampleBase.cmake [end]") diff --git a/NvCloth/samples/compiler/cmake/windows/SampleBase.cmake b/NvCloth/samples/compiler/cmake/windows/SampleBase.cmake index 46b865a..d98f49e 100644 --- a/NvCloth/samples/compiler/cmake/windows/SampleBase.cmake +++ b/NvCloth/samples/compiler/cmake/windows/SampleBase.cmake @@ -3,7 +3,7 @@ # MESSAGE("Windows/SampleBase.cmake [begin]") -FIND_PACKAGE(CUDA 8 REQUIRED) +FIND_PACKAGE(CUDA 10 REQUIRED) SET(SAMPLEBASE_PLATFORM_COMMON_FILES ) @@ -35,6 +35,7 @@ if (CMAKE_CL_64) SET(D3DCOMPILER_DLL "\"$(VC_ExecutablePath_x64_x64)/d3dcompiler_47.dll\"") +# SET(ASSIMP_DLLS ${ASSIMP_DLL_PATH}/Release/assimp-vc140-mt.dll) else() SET(SHADOW_LIB ${NVCLOTH_ROOT_DIR}/samples/external/shadow_lib/GFSDK_ShadowLib_DX11.win32.lib) SET(SHADOW_DLLS ${NVCLOTH_ROOT_DIR}/samples/external/shadow_lib/GFSDK_ShadowLib_DX11.win32.dll) @@ -44,7 +45,8 @@ else() SET(D3DCOMPILER_DLL "\"$(VC_ExecutablePath_x86_x86)/d3dcompiler_47.dll\"") +# SET(ASSIMP_DLLS ${ASSIMP_DLL_PATH}/Release/assimp-vc140-mt.dll) endif() -MESSAGE("Windows/SampleBase.cmake [end]")
\ No newline at end of file +MESSAGE("Windows/SampleBase.cmake [end]") diff --git a/NvCloth/samples/external/CMakeModules/FindPxShared.cmake b/NvCloth/samples/external/CMakeModules/FindPxShared.cmake index a252b47..3297996 100644 --- a/NvCloth/samples/external/CMakeModules/FindPxShared.cmake +++ b/NvCloth/samples/external/CMakeModules/FindPxShared.cmake @@ -10,7 +10,7 @@ FIND_PATH( PXSHARED_ROOT_DIR include/foundation/Px.h ${GW_DEPS_ROOT}/sw/physx/PxShared/1.0/trunk NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) - + INCLUDE(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(PxShared DEFAULT_MSG PXSHARED_ROOT_DIR) diff --git a/NvCloth/scripts/locate_cuda.bat b/NvCloth/scripts/locate_cuda.bat index c6d7052..8348aad 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\v8.0 +set FOLDER=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0 goto :manualfolder set FOLDER_NEEDLE=physx\externals\CUDA\8.0.44 @@ -15,4 +15,4 @@ set "returnVal=%FOLDER:\=/%" ( endlocal set "%~1=%returnVal%" ) -goto :eof
\ No newline at end of file +goto :eof diff --git a/NvCloth/scripts/locate_gw_root.bat b/NvCloth/scripts/locate_gw_root.bat index f8a9c2a..9d73032 100644 --- a/NvCloth/scripts/locate_gw_root.bat +++ b/NvCloth/scripts/locate_gw_root.bat @@ -11,9 +11,9 @@ rem set FOLDER_NEEDLE=NvCloth\src call "%~dp0/locate.bat" FOLDER %FOLDER_NEEDLE% :manualfolder -set returnVal=%FOLDER%\..\..\ +set returnVal=%FOLDER%\..\..\..\..\..\..\..\ ( endlocal set "%~1=%returnVal%" ) -goto :eof
\ No newline at end of file +goto :eof diff --git a/NvCloth/src/ClothImpl.h b/NvCloth/src/ClothImpl.h index 6686cd7..de8ac97 100644 --- a/NvCloth/src/ClothImpl.h +++ b/NvCloth/src/ClothImpl.h @@ -35,7 +35,7 @@ #include <foundation/PxVec3.h> #include "IndexPair.h" #include "MovingAverage.h" -#include <PsMathUtils.h> +#include "NvCloth/ps/PsMathUtils.h" #include <cmath> namespace nv diff --git a/NvCloth/src/IterationState.h b/NvCloth/src/IterationState.h index be046b5..85bfacc 100644 --- a/NvCloth/src/IterationState.h +++ b/NvCloth/src/IterationState.h @@ -34,9 +34,9 @@ #include <foundation/PxVec3.h> #include <foundation/PxMat44.h> #include <foundation/PxMat33.h> -#include <PsMathUtils.h> #include "Vec4T.h" #include <algorithm> +#include "NvCloth/ps/PsMathUtils.h" namespace nv { diff --git a/NvCloth/src/PhaseConfig.cpp b/NvCloth/src/PhaseConfig.cpp index b5db3b0..3397d5d 100644 --- a/NvCloth/src/PhaseConfig.cpp +++ b/NvCloth/src/PhaseConfig.cpp @@ -28,7 +28,7 @@ // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #include "NvCloth/PhaseConfig.h" -#include "PsMathUtils.h" +#include "NvCloth/ps/PsMathUtils.h" #include <algorithm> #include "ClothImpl.h" diff --git a/NvCloth/src/SwClothData.cpp b/NvCloth/src/SwClothData.cpp index 84d85d4..d346d98 100644 --- a/NvCloth/src/SwClothData.cpp +++ b/NvCloth/src/SwClothData.cpp @@ -31,7 +31,7 @@ #include "SwCloth.h" #include "SwFabric.h" #include <foundation/Px.h> -#include <PsUtilities.h> +#include "ps/PsUtilities.h" using namespace physx; using namespace nv; diff --git a/NvCloth/src/SwCollision.cpp b/NvCloth/src/SwCollision.cpp index bd6cf7a..5c1466c 100644 --- a/NvCloth/src/SwCollision.cpp +++ b/NvCloth/src/SwCollision.cpp @@ -36,7 +36,7 @@ #include "SwCollisionHelpers.h" #include <foundation/PxProfiler.h> #include <cstring> // for memset -#include <PsSort.h> +#include "ps/PsSort.h" using namespace nv; using namespace physx; diff --git a/NvCloth/src/SwFabric.cpp b/NvCloth/src/SwFabric.cpp index b8d617f..bf4b110 100644 --- a/NvCloth/src/SwFabric.cpp +++ b/NvCloth/src/SwFabric.cpp @@ -29,10 +29,10 @@ #include "SwFabric.h" #include "SwFactory.h" -#include "PsSort.h" +#include "ps/PsSort.h" #include "limits.h" // for USHRT_MAX #include <algorithm> -#include "PsUtilities.h" +#include "../../src/ps/PsUtilities.h" using namespace nv; using namespace physx; diff --git a/NvCloth/src/SwFabric.h b/NvCloth/src/SwFabric.h index 29d0921..da2b9b5 100644 --- a/NvCloth/src/SwFabric.h +++ b/NvCloth/src/SwFabric.h @@ -57,7 +57,7 @@ class SwFabric : public Fabric #endif SwFabric(SwFactory& factory, uint32_t numParticles, Range<const uint32_t> phasesIndices, Range<const uint32_t> sets, - Range<const float> restvalues, Range<const float> stiffnessValues, Range<const uint32_t> indices, Range<const uint32_t> anchors, + Range<const float> restvalues, Range<const float> stiffnessValues, Range<const uint32_t> indices, Range<const uint32_t> anchors, Range<const float> tetherLengths, Range<const uint32_t> triangles, uint32_t id); SwFabric& operator = (const SwFabric&); diff --git a/NvCloth/src/SwFactory.cpp b/NvCloth/src/SwFactory.cpp index 5c4b625..de4ff3b 100644 --- a/NvCloth/src/SwFactory.cpp +++ b/NvCloth/src/SwFactory.cpp @@ -55,12 +55,12 @@ cloth::SwFactory::~SwFactory() } cloth::Fabric* cloth::SwFactory::createFabric(uint32_t numParticles, Range<const uint32_t> phaseIndices, - Range<const uint32_t> sets, Range<const float> restvalues, Range<const float> stiffnessValues, - Range<const uint32_t> indices, Range<const uint32_t> anchors, + Range<const uint32_t> sets, Range<const float> restvalues, Range<const float> stiffnessValues, + Range<const uint32_t> indices, Range<const uint32_t> anchors, Range<const float> tetherLengths, Range<const uint32_t> triangles) { return NV_CLOTH_NEW(SwFabric)(*this, numParticles, phaseIndices, sets, restvalues, stiffnessValues, indices, anchors, tetherLengths, triangles, - getNextFabricId()); + getNextFabricId()); } cloth::Cloth* cloth::SwFactory::createCloth(Range<const PxVec4> particles, Fabric& fabric) diff --git a/NvCloth/src/SwFactory.h b/NvCloth/src/SwFactory.h index 4cbee0c..183efb9 100644 --- a/NvCloth/src/SwFactory.h +++ b/NvCloth/src/SwFactory.h @@ -56,7 +56,7 @@ class SwFactory : public Factory virtual Platform getPlatform() const { return Platform::CPU; } virtual Fabric* createFabric(uint32_t numParticles, Range<const uint32_t> phaseIndices, Range<const uint32_t> sets, - Range<const float> restvalues, Range<const float> stiffnessValues, Range<const uint32_t> indices, + Range<const float> restvalues, Range<const float> stiffnessValues, Range<const uint32_t> indices, Range<const uint32_t> anchors, Range<const float> tetherLengths, Range<const uint32_t> triangles); diff --git a/NvCloth/src/SwInterCollision.cpp b/NvCloth/src/SwInterCollision.cpp index bc46ea6..efa57ba 100644 --- a/NvCloth/src/SwInterCollision.cpp +++ b/NvCloth/src/SwInterCollision.cpp @@ -34,7 +34,7 @@ #include <foundation/PxMat44.h> #include <foundation/PxBounds3.h> #include <algorithm> -#include <PsSort.h> +#include "ps/PsSort.h" #include "NvCloth/Allocator.h" using namespace nv; diff --git a/NvCloth/src/SwSolver.cpp b/NvCloth/src/SwSolver.cpp index f0f9152..a1f0cf8 100644 --- a/NvCloth/src/SwSolver.cpp +++ b/NvCloth/src/SwSolver.cpp @@ -36,8 +36,8 @@ #include "SwClothData.h" #include "SwSolverKernel.h" #include "SwInterCollision.h" -#include <PsFPU.h> -#include <PsSort.h> +#include "ps/PsFPU.h" +#include "ps/PsSort.h" using namespace physx; diff --git a/NvCloth/src/TripletScheduler.cpp b/NvCloth/src/TripletScheduler.cpp index 0116200..10ad430 100644 --- a/NvCloth/src/TripletScheduler.cpp +++ b/NvCloth/src/TripletScheduler.cpp @@ -29,7 +29,7 @@ #include "TripletScheduler.h" #include <algorithm> -#include <PsUtilities.h> +#include "../../src/ps/PsUtilities.h" using namespace physx; using namespace nv; diff --git a/NvCloth/src/cuda/CuCollision.h b/NvCloth/src/cuda/CuCollision.h index f9b69f7..d17e735 100644 --- a/NvCloth/src/cuda/CuCollision.h +++ b/NvCloth/src/cuda/CuCollision.h @@ -310,6 +310,7 @@ __device__ void CuCollision::buildSphereAcceleration(const CollisionData& data) { if (threadIdx.x >= 192) return; + unsigned int mask = __ballot_sync(0xffffffff, !(threadIdx.x >= 192)); int32_t sphereIdx = threadIdx.x & 31; int32_t axisIdx = threadIdx.x >> 6; // coordinate index (x, y, or z) @@ -325,7 +326,7 @@ __device__ void CuCollision::buildSphereAcceleration(const CollisionData& data) Pointer<Shared, uint32_t> dst = mShapeGrid + sGridSize * axisIdx; // #pragma unroll for (int32_t i = 0; i < sGridSize; ++i, ++index) - dst[i] |= __ballot(int32_t(index) <= 0); + dst[i] |= __ballot_sync(mask, int32_t(index) <= 0); } // generate cone masks from sphere masks @@ -333,7 +334,7 @@ __device__ void CuCollision::buildConeAcceleration() { if (threadIdx.x >= 192) return; - + unsigned int mask = __ballot_sync(0xffffffff, !(threadIdx.x >= 192)); int32_t coneIdx = threadIdx.x & 31; uint32_t sphereMask = @@ -345,7 +346,7 @@ __device__ void CuCollision::buildConeAcceleration() // #pragma unroll for (int32_t i = 0; i < sGridSize; ++i) - dst[i] |= __ballot(src[i] & sphereMask); + dst[i] |= __ballot_sync(mask,src[i] & sphereMask); } // convert right/left mask arrays into single overlap array @@ -366,17 +367,17 @@ __device__ void CuCollision::mergeAcceleration() namespace { #if __CUDA_ARCH__ >= 300 -__device__ float mergeBounds(Pointer<Shared, float> buffer) +__device__ float mergeBounds(unsigned int mask, Pointer<Shared, float> buffer) { float value = *buffer; - value = max(value, __shfl_down(value, 1)); - value = max(value, __shfl_down(value, 2)); - value = max(value, __shfl_down(value, 4)); - value = max(value, __shfl_down(value, 8)); - return max(value, __shfl_down(value, 16)); + value = max(value, __shfl_down_sync(mask, value, 1)); + value = max(value, __shfl_down_sync(mask, value, 2)); + value = max(value, __shfl_down_sync(mask, value, 4)); + value = max(value, __shfl_down_sync(mask, value, 8)); + return max(value, __shfl_down_sync(mask, value, 16)); } #else -__device__ float mergeBounds(Pointer<Shared, float> buffer) +__device__ float mergeBounds(unsigned int mask, Pointer<Shared, float> buffer) { // ensure that writes to buffer are visible to all threads __threadfence_block(); @@ -393,6 +394,7 @@ __device__ float mergeBounds(Pointer<Shared, float> buffer) __device__ float computeSphereBounds(const CuCollision::CollisionData& data, Pointer<Shared, float> buffer) { assert(threadIdx.x < 192); + unsigned int mask = __ballot_sync(0xffffffff, threadIdx.x < 192); int32_t sphereIdx = min(threadIdx.x & 31, gClothData.mNumSpheres - 1); // sphere index int32_t axisIdx = threadIdx.x >> 6; // coordinate index (x, y, or z) @@ -401,7 +403,7 @@ __device__ float computeSphereBounds(const CuCollision::CollisionData& data, Poi *buffer = data.mSphereW[sphereIdx] + signf * data.mSphereX[sphereIdx + gClothData.mNumSpheres * axisIdx]; - return mergeBounds(buffer); + return mergeBounds(mask, buffer); } #if __CUDA_ARCH__ >= 300 @@ -415,6 +417,7 @@ __device__ float computeParticleBounds(const CurrentT& current, Pointer<Shared, if (threadIdxInAxis < numThreadsPerAxis) { + unsigned int mask = __ballot_sync(0xffffffff, threadIdxInAxis < numThreadsPerAxis); typename CurrentT::ConstPointerType posIt = current[axis]; int32_t i = min(threadIdxInAxis, gClothData.mNumParticles - 1); float minX = posIt[i], maxX = minX; @@ -425,16 +428,16 @@ __device__ float computeParticleBounds(const CurrentT& current, Pointer<Shared, maxX = max(maxX, posX); } - minX = min(minX, __shfl_down(minX, 1)); - maxX = max(maxX, __shfl_down(maxX, 1)); - minX = min(minX, __shfl_down(minX, 2)); - maxX = max(maxX, __shfl_down(maxX, 2)); - minX = min(minX, __shfl_down(minX, 4)); - maxX = max(maxX, __shfl_down(maxX, 4)); - minX = min(minX, __shfl_down(minX, 8)); - maxX = max(maxX, __shfl_down(maxX, 8)); - minX = min(minX, __shfl_down(minX, 16)); - maxX = max(maxX, __shfl_down(maxX, 16)); + minX = min(minX, __shfl_down_sync(mask,minX, 1)); + maxX = max(maxX, __shfl_down_sync(mask,maxX, 1)); + minX = min(minX, __shfl_down_sync(mask,minX, 2)); + maxX = max(maxX, __shfl_down_sync(mask,maxX, 2)); + minX = min(minX, __shfl_down_sync(mask,minX, 4)); + maxX = max(maxX, __shfl_down_sync(mask,maxX, 4)); + minX = min(minX, __shfl_down_sync(mask,minX, 8)); + maxX = max(maxX, __shfl_down_sync(mask,maxX, 8)); + minX = min(minX, __shfl_down_sync(mask,minX, 16)); + maxX = max(maxX, __shfl_down_sync(mask,maxX, 16)); if (!laneIdx) { @@ -448,7 +451,7 @@ __device__ float computeParticleBounds(const CurrentT& current, Pointer<Shared, if (threadIdx.x >= 192) return 0.0f; - + unsigned int mask = __ballot_sync(0xffffffff, !(threadIdx.x >= 192)); float value = *buffer; if (laneIdx >= (numThreadsPerAxis >> 5)) value = -FLT_MAX; @@ -456,10 +459,10 @@ __device__ float computeParticleBounds(const CurrentT& current, Pointer<Shared, // blockDim.x <= 3 * 512, increase to 3 * 1024 by adding a shfl by 16 assert(numThreadsPerAxis <= 16 * 32); - value = max(value, __shfl_down(value, 1)); - value = max(value, __shfl_down(value, 2)); - value = max(value, __shfl_down(value, 4)); - return max(value, __shfl_down(value, 8)); + value = max(value, __shfl_down_sync(mask,value, 1)); + value = max(value, __shfl_down_sync(mask,value, 2)); + value = max(value, __shfl_down_sync(mask,value, 4)); + return max(value, __shfl_down_sync(mask,value, 8)); } #else template <typename CurrentT> @@ -467,6 +470,7 @@ __device__ float computeParticleBounds(const CurrentT& current, Pointer<Shared, { if (threadIdx.x >= 192) return 0.0f; + unsigned int mask = __ballot_sync(0xffffffff, !(threadIdx.x >= 192)); int32_t axisIdx = threadIdx.x >> 6; // x, y, or z int32_t signi = threadIdx.x << 26; // sign bit (min or max) @@ -480,7 +484,7 @@ __device__ float computeParticleBounds(const CurrentT& current, Pointer<Shared, while (pIt += 32, pIt < pEnd) *buffer = max(*buffer, *pIt * signf); - return mergeBounds(buffer); + return mergeBounds(mask, buffer); } #endif } diff --git a/NvCloth/src/cuda/CuDeviceVector.h b/NvCloth/src/cuda/CuDeviceVector.h index 4d97e5d..0fabb66 100644 --- a/NvCloth/src/cuda/CuDeviceVector.h +++ b/NvCloth/src/cuda/CuDeviceVector.h @@ -30,8 +30,8 @@ #pragma once #include "CuDevicePointer.h" -#include "PsArray.h" -#include "PsUtilities.h" +#include "NvCloth/ps/PsArray.h" +#include "../ps/PsUtilities.h" #include <algorithm> namespace nv diff --git a/NvCloth/src/cuda/CuFabric.cpp b/NvCloth/src/cuda/CuFabric.cpp index 6794fa5..48cc0ba 100644 --- a/NvCloth/src/cuda/CuFabric.cpp +++ b/NvCloth/src/cuda/CuFabric.cpp @@ -30,7 +30,7 @@ #include "CuFabric.h" #include "CuContextLock.h" #include "CuFactory.h" -#include <PsUtilities.h> +#include "../ps/PsUtilities.h" #include <limits.h> using namespace physx; diff --git a/NvCloth/src/cuda/CuFactory.h b/NvCloth/src/cuda/CuFactory.h index 3ff5752..8fae913 100644 --- a/NvCloth/src/cuda/CuFactory.h +++ b/NvCloth/src/cuda/CuFactory.h @@ -30,7 +30,7 @@ #pragma once #include "NvCloth/Factory.h" -#include <PsArray.h> +#include "NvCloth/ps/PsArray.h" #include <foundation/PxVec4.h> #include <foundation/PxVec3.h> #include <cuda.h> diff --git a/NvCloth/src/cuda/CuSelfCollision.h b/NvCloth/src/cuda/CuSelfCollision.h index 19d2723..32aa139 100644 --- a/NvCloth/src/cuda/CuSelfCollision.h +++ b/NvCloth/src/cuda/CuSelfCollision.h @@ -39,7 +39,7 @@ namespace { -#if __CUDA_ARCH__ >= 300 +/*#if __CUDA_ARCH__ >= 300 template <int> __device__ void scanWarp(Pointer<Shared, int32_t> counts) { @@ -60,7 +60,7 @@ __device__ void scanWarp(Pointer<Shared, int32_t> counts) : "+r"(*generic(counts)) :); } -#else +#else*/ template <int stride> __device__ void scanWarp(Pointer<Shared, int32_t> counts) { @@ -77,7 +77,7 @@ __device__ void scanWarp(Pointer<Shared, int32_t> counts) if (laneIdx >= 16) *ptr += ptr[-16 * stride]; } -#endif +//#endif // sorts array by upper 16bits // [keys] must be at least 2 * n in length, in/out in first n elements @@ -112,10 +112,10 @@ __device__ void radixSort(int32_t* keys, int32_t n, Pointer<Shared, int32_t> his for (int32_t i = startIndex; i < endIndex; i += 32) { int32_t key = i < n ? srcKeys[i] >> p : 15; - uint32_t ballot1 = __ballot(key & 1); - uint32_t ballot2 = __ballot(key & 2); - uint32_t ballot4 = __ballot(key & 4); - uint32_t ballot8 = __ballot(key & 8); + uint32_t ballot1 = __ballot_sync(0xffffffff,key & 1); + uint32_t ballot2 = __ballot_sync(0xffffffff,key & 2); + uint32_t ballot4 = __ballot_sync(0xffffffff,key & 4); + uint32_t ballot8 = __ballot_sync(0xffffffff,key & 8); warpCount += __popc((mask1 ^ ballot1) & (mask2 ^ ballot2) & (mask4 ^ ballot4) & (mask8 ^ ballot8)); } @@ -147,10 +147,10 @@ __device__ void radixSort(int32_t* keys, int32_t n, Pointer<Shared, int32_t> his for (int32_t i = startIndex; i < endIndex; i += 32) { int32_t key = i < n ? srcKeys[i] >> p : 15; - uint32_t ballot1 = __ballot(key & 1); - uint32_t ballot2 = __ballot(key & 2); - uint32_t ballot4 = __ballot(key & 4); - uint32_t ballot8 = __ballot(key & 8); + uint32_t ballot1 = __ballot_sync(0xffffffff,key & 1); + uint32_t ballot2 = __ballot_sync(0xffffffff,key & 2); + uint32_t ballot4 = __ballot_sync(0xffffffff,key & 4); + uint32_t ballot8 = __ballot_sync(0xffffffff,key & 8); uint32_t bits = ((key & 1) - 1 ^ ballot1) & (!!(key & 2) - 1 ^ ballot2) & (!!(key & 4) - 1 ^ ballot4) & (!!(key & 8) - 1 ^ ballot8); int32_t index = hIt[key & 15] + __popc(bits & laneMask); diff --git a/NvCloth/src/cuda/CuSolver.cpp b/NvCloth/src/cuda/CuSolver.cpp index 7ef1d32..86f32b3 100644 --- a/NvCloth/src/cuda/CuSolver.cpp +++ b/NvCloth/src/cuda/CuSolver.cpp @@ -36,7 +36,7 @@ #include "CuContextLock.h" #include "CuCheckSuccess.h" #include "../IterationState.h" -#include <PsSort.h> +#include "../Ps/PsSort.h" #include <foundation/PxProfiler.h> #if NV_NVTX @@ -489,8 +489,9 @@ void cloth::CuSolver::beginFrame() uint32_t numThreadsPerBlock = mFactory.mMaxThreadsPerBlock / numClothsPerSM & ~31; if (mFactory.mNumThreadsPerBlock != numThreadsPerBlock) { - checkSuccess( - cuFuncSetBlockShape(mKernelFunction, int(mFactory.mNumThreadsPerBlock = numThreadsPerBlock), 1, 1)); + mFactory.mNumThreadsPerBlock = numThreadsPerBlock; + //checkSuccess( + // cuFuncSetBlockShape(mKernelFunction, int(mFactory.mNumThreadsPerBlock = numThreadsPerBlock), 1, 1)); } // remember num cloths per SM in terms of max shared memory per block diff --git a/NvCloth/src/cuda/CuSolverKernel.cu b/NvCloth/src/cuda/CuSolverKernel.cu index 1ad5896..86f038d 100644 --- a/NvCloth/src/cuda/CuSolverKernel.cu +++ b/NvCloth/src/cuda/CuSolverKernel.cu @@ -851,7 +851,7 @@ __device__ void applyImpulse(SharedParticleData::ParticleReferenceType pos, cons float scale = -pos.mReferences[3]; #if CONVERT_ADDRESSES - //Use this instead of atomicAdd function to work around compiler issue treating the pointer as global memory instead of shared memory + // Use this instead of atomicAdd function to work around compiler issue treating the pointer as global memory instead of shared memory asm("red.shared.add.f32 [%0], %1;" ::POINTER_CONSTRAINT(pos.mReferences[0].mPtr), "f"(impulse.x * scale)); asm("red.shared.add.f32 [%0], %1;" ::POINTER_CONSTRAINT(pos.mReferences[1].mPtr), "f"(impulse.y * scale)); asm("red.shared.add.f32 [%0], %1;" ::POINTER_CONSTRAINT(pos.mReferences[2].mPtr), "f"(impulse.z * scale)); @@ -1394,6 +1394,7 @@ __launch_bounds__(512, 1) for (int32_t i = threadIdx.x; i < configDataSize; i += blockDim.x) gSharedUnsigned[i] = reinterpret_cast<const uint32_t*>(gClothData.mPhaseConfigs)[i]; + Pointer<Shared, uint32_t> scratchPtr = Pointer<Shared, uint32_t>( gSharedUnsigned + configDataSize + 4 * gFrameData.mNumSharedPositions * gClothData.mNumParticles); diff --git a/NvCloth/src/dx/DxFabric.cpp b/NvCloth/src/dx/DxFabric.cpp index cf6865a..f5adeaf 100644 --- a/NvCloth/src/dx/DxFabric.cpp +++ b/NvCloth/src/dx/DxFabric.cpp @@ -31,7 +31,7 @@ #include "DxContextLock.h" #include "DxFactory.h" #include <algorithm> -#include <PsUtilities.h> +#include "ps/PsUtilities.h" #if NV_CLOTH_ENABLE_DX11 diff --git a/NvCloth/src/dx/DxSolver.cpp b/NvCloth/src/dx/DxSolver.cpp index 21caa0b..c341aa8 100644 --- a/NvCloth/src/dx/DxSolver.cpp +++ b/NvCloth/src/dx/DxSolver.cpp @@ -34,7 +34,7 @@ #include "DxFactory.h" #include "DxContextLock.h" #include "../IterationState.h" -#include <PsSort.h> +#include "../ps/PsSort.h" #include <foundation/PxProfiler.h> #if NV_CLOTH_ENABLE_DX11 diff --git a/NvCloth/src/neon/NeonSolverKernel.cpp b/NvCloth/src/neon/NeonSolverKernel.cpp index 3e16b6f..6eb26cf 100644 --- a/NvCloth/src/neon/NeonSolverKernel.cpp +++ b/NvCloth/src/neon/NeonSolverKernel.cpp @@ -33,7 +33,7 @@ #include "SwSolverKernel.cpp" -#include <cpu-features.h> +#include "../ps/android/cpu-features.h" namespace { diff --git a/NvCloth/src/ps/PsAlloca.h b/NvCloth/src/ps/PsAlloca.h new file mode 100644 index 0000000..75a7bb2 --- /dev/null +++ b/NvCloth/src/ps/PsAlloca.h @@ -0,0 +1,76 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved. +// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. +// Copyright (c) 2001-2004 NovodeX AG. All rights reserved. + +#ifndef PSFOUNDATION_PSALLOCA_H +#define PSFOUNDATION_PSALLOCA_H + +#include "NvCloth/Allocator.h" + +namespace physx +{ +namespace shdfnd +{ +template <typename T, typename Unused = void> +class ScopedPointer +{ + public: + ~ScopedPointer() + { + if(mOwned) + GetNvClothAllocator()->deallocate(mPointer); + } + + operator T*() const + { + return mPointer; + } + + T* mPointer; + bool mOwned; +}; + +} // namespace shdfnd +} // namespace physx + +/*! Stack allocation for \c count instances of \c type. Falling back to temp allocator if using more than 1kB. */ +#ifdef __SPU__ +#define PX_ALLOCA(var, type, count) type* var = reinterpret_cast<type*>(PxAlloca(sizeof(type) * (count))) +#else +#define PX_ALLOCA(var, type, count) \ + physx::shdfnd::ScopedPointer<type> var; \ + { \ + uint32_t size = sizeof(type) * (count); \ + var.mOwned = size > 1024; \ + if(var.mOwned) \ + var.mPointer = reinterpret_cast<type*>(GetNvClothAllocator()->allocate(size,#type,__FILE__,__LINE__)); \ + else \ + var.mPointer = reinterpret_cast<type*>(PxAlloca(size)); \ + } +#endif +#endif // #ifndef PSFOUNDATION_PSALLOCA_H diff --git a/NvCloth/src/ps/PsFPU.h b/NvCloth/src/ps/PsFPU.h new file mode 100644 index 0000000..82b7ff2 --- /dev/null +++ b/NvCloth/src/ps/PsFPU.h @@ -0,0 +1,103 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved. +// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. +// Copyright (c) 2001-2004 NovodeX AG. All rights reserved. + +#ifndef PSFOUNDATION_PSFPU_H +#define PSFOUNDATION_PSFPU_H + +#include "NvCloth/ps/Ps.h" +#include "NvCloth/ps/PsIntrinsics.h" + +#define PX_IR(x) ((uint32_t&)(x)) +#define PX_SIR(x) ((int32_t&)(x)) +#define PX_FR(x) ((float&)(x)) + +// signed integer representation of a floating-point value. + +// Floating-point representation of a integer value. + +#define PX_SIGN_BITMASK 0x80000000 + +#define PX_FPU_GUARD shdfnd::FPUGuard scopedFpGuard; +#define PX_SIMD_GUARD shdfnd::SIMDGuard scopedFpGuard; + +#define PX_SUPPORT_GUARDS (PX_WINDOWS_FAMILY || PX_XBOXONE || (PX_LINUX && (PX_X86 || PX_X64)) || PX_PS4 || PX_OSX) + +namespace physx +{ +namespace shdfnd +{ +// sets the default SDK state for scalar and SIMD units +class NV_CLOTH_IMPORT FPUGuard +{ + public: + FPUGuard(); // set fpu control word for PhysX + ~FPUGuard(); // restore fpu control word + private: + uint32_t mControlWords[8]; +}; + +// sets default SDK state for simd unit only, lighter weight than FPUGuard +class SIMDGuard +{ + public: + PX_INLINE SIMDGuard(); // set simd control word for PhysX + PX_INLINE ~SIMDGuard(); // restore simd control word + private: +#if PX_SUPPORT_GUARDS + uint32_t mControlWord; +#endif +}; + +/** +\brief Enables floating point exceptions for the scalar and SIMD unit +*/ +NV_CLOTH_IMPORT void enableFPExceptions(); + +/** +\brief Disables floating point exceptions for the scalar and SIMD unit +*/ +NV_CLOTH_IMPORT void disableFPExceptions(); + +} // namespace shdfnd +} // namespace physx + +#if PX_WINDOWS_FAMILY || PX_XBOXONE +#include "windows/PsWindowsFPU.h" +#elif (PX_LINUX && PX_SSE2) || PX_PS4 || PX_OSX +#include "unix/PsUnixFPU.h" +#else +PX_INLINE physx::shdfnd::SIMDGuard::SIMDGuard() +{ +} +PX_INLINE physx::shdfnd::SIMDGuard::~SIMDGuard() +{ +} +#endif + +#endif // #ifndef PSFOUNDATION_PSFPU_H diff --git a/NvCloth/src/ps/PsSort.h b/NvCloth/src/ps/PsSort.h new file mode 100644 index 0000000..8667244 --- /dev/null +++ b/NvCloth/src/ps/PsSort.h @@ -0,0 +1,130 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved. +// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. +// Copyright (c) 2001-2004 NovodeX AG. All rights reserved. + +#ifndef PSFOUNDATION_PSSORT_H +#define PSFOUNDATION_PSSORT_H + +/** \addtogroup foundation +@{ +*/ + +#include "PsSortInternals.h" +#include "PsAlloca.h" + +#define PX_SORT_PARANOIA PX_DEBUG + +/** +\brief Sorts an array of objects in ascending order, assuming +that the predicate implements the < operator: + +\see Less, Greater +*/ + +#if PX_VC +#pragma warning(push) +#pragma warning(disable : 4706) // disable the warning that we did an assignment within a conditional expression, as +// this was intentional. +#endif + +namespace physx +{ +namespace shdfnd +{ +template <class T, class Predicate, class Allocator> +void sort(T* elements, uint32_t count, const Predicate& compare, const Allocator& inAllocator, + const uint32_t initialStackSize = 32) +{ + static const uint32_t SMALL_SORT_CUTOFF = 5; // must be >= 3 since we need 3 for median + + PX_ALLOCA(stackMem, int32_t, initialStackSize); + internal::Stack<Allocator> stack(stackMem, initialStackSize, inAllocator); + + int32_t first = 0, last = int32_t(count - 1); + if(last > first) + { + for(;;) + { + while(last > first) + { + NV_CLOTH_ASSERT(first >= 0 && last < int32_t(count)); + if(uint32_t(last - first) < SMALL_SORT_CUTOFF) + { + internal::smallSort(elements, first, last, compare); + break; + } + else + { + const int32_t partIndex = internal::partition(elements, first, last, compare); + + // push smaller sublist to minimize stack usage + if((partIndex - first) < (last - partIndex)) + { + stack.push(first, partIndex - 1); + first = partIndex + 1; + } + else + { + stack.push(partIndex + 1, last); + last = partIndex - 1; + } + } + } + + if(stack.empty()) + break; + + stack.pop(first, last); + } + } +#if PX_SORT_PARANOIA + for(uint32_t i = 1; i < count; i++) + NV_CLOTH_ASSERT(!compare(elements[i], elements[i - 1])); +#endif +} + +template <class T, class Predicate> +void sort(T* elements, uint32_t count, const Predicate& compare) +{ + sort(elements, count, compare, typename shdfnd::AllocatorTraits<T>::Type()); +} + +template <class T> +void sort(T* elements, uint32_t count) +{ + sort(elements, count, shdfnd::Less<T>(), typename shdfnd::AllocatorTraits<T>::Type()); +} + +} // namespace shdfnd +} // namespace physx + +#if PX_VC +#pragma warning(pop) +#endif + +#endif // #ifndef PSFOUNDATION_PSSORT_H diff --git a/NvCloth/src/ps/PsSortInternals.h b/NvCloth/src/ps/PsSortInternals.h new file mode 100644 index 0000000..c7a7703 --- /dev/null +++ b/NvCloth/src/ps/PsSortInternals.h @@ -0,0 +1,187 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved. +// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. +// Copyright (c) 2001-2004 NovodeX AG. All rights reserved. + +#ifndef PSFOUNDATION_PSSORTINTERNALS_H +#define PSFOUNDATION_PSSORTINTERNALS_H + +/** \addtogroup foundation +@{ +*/ + +#include "ps/PxIntrinsics.h" +#include "NvCloth/ps/PsBasicTemplates.h" +#include "NvCloth/ps/PsUserAllocated.h" + +namespace physx +{ +namespace shdfnd +{ +namespace internal +{ +template <class T, class Predicate> +PX_INLINE void median3(T* elements, int32_t first, int32_t last, Predicate& compare) +{ + /* + This creates sentinels because we know there is an element at the start minimum(or equal) + than the pivot and an element at the end greater(or equal) than the pivot. Plus the + median of 3 reduces the chance of degenerate behavour. + */ + + int32_t mid = (first + last) / 2; + + if(compare(elements[mid], elements[first])) + swap(elements[first], elements[mid]); + + if(compare(elements[last], elements[first])) + swap(elements[first], elements[last]); + + if(compare(elements[last], elements[mid])) + swap(elements[mid], elements[last]); + + // keep the pivot at last-1 + swap(elements[mid], elements[last - 1]); +} + +template <class T, class Predicate> +PX_INLINE int32_t partition(T* elements, int32_t first, int32_t last, Predicate& compare) +{ + median3(elements, first, last, compare); + + /* + WARNING: using the line: + + T partValue = elements[last-1]; + + and changing the scan loops to: + + while(comparator.greater(partValue, elements[++i])); + while(comparator.greater(elements[--j], partValue); + + triggers a compiler optimizer bug on xenon where it stores a double to the stack for partValue + then loads it as a single...:-( + */ + + int32_t i = first; // we know first is less than pivot(but i gets pre incremented) + int32_t j = last - 1; // pivot is in last-1 (but j gets pre decremented) + + for(;;) + { + while(compare(elements[++i], elements[last - 1])) + ; + while(compare(elements[last - 1], elements[--j])) + ; + + if(i >= j) + break; + + NV_CLOTH_ASSERT(i <= last && j >= first); + swap(elements[i], elements[j]); + } + // put the pivot in place + + NV_CLOTH_ASSERT(i <= last && first <= (last - 1)); + swap(elements[i], elements[last - 1]); + + return i; +} + +template <class T, class Predicate> +PX_INLINE void smallSort(T* elements, int32_t first, int32_t last, Predicate& compare) +{ + // selection sort - could reduce to fsel on 360 with floats. + + for(int32_t i = first; i < last; i++) + { + int32_t m = i; + for(int32_t j = i + 1; j <= last; j++) + if(compare(elements[j], elements[m])) + m = j; + + if(m != i) + swap(elements[m], elements[i]); + } +} + +template <class Allocator> +class Stack +{ + Allocator mAllocator; + uint32_t mSize, mCapacity; + int32_t* mMemory; + bool mRealloc; + + public: + Stack(int32_t* memory, uint32_t capacity, const Allocator& inAllocator) + : mAllocator(inAllocator), mSize(0), mCapacity(capacity), mMemory(memory), mRealloc(false) + { + } + ~Stack() + { + if(mRealloc) + mAllocator.deallocate(mMemory); + } + + void grow() + { + mCapacity *= 2; + int32_t* newMem = + reinterpret_cast<int32_t*>(mAllocator.allocate(sizeof(int32_t) * mCapacity, __FILE__, __LINE__)); + intrinsics::memCopy(newMem, mMemory, mSize * sizeof(int32_t)); + if(mRealloc) + mAllocator.deallocate(mMemory); + mRealloc = true; + mMemory = newMem; + } + + PX_INLINE void push(int32_t start, int32_t end) + { + if(mSize >= mCapacity - 1) + grow(); + mMemory[mSize++] = start; + mMemory[mSize++] = end; + } + + PX_INLINE void pop(int32_t& start, int32_t& end) + { + NV_CLOTH_ASSERT(!empty()); + end = mMemory[--mSize]; + start = mMemory[--mSize]; + } + + PX_INLINE bool empty() + { + return mSize == 0; + } +}; +} // namespace internal + +} // namespace shdfnd +} // namespace physx + +#endif // #ifndef PSFOUNDATION_PSSORTINTERNALS_H diff --git a/NvCloth/src/ps/PsUtilities.h b/NvCloth/src/ps/PsUtilities.h new file mode 100644 index 0000000..4e59ddc --- /dev/null +++ b/NvCloth/src/ps/PsUtilities.h @@ -0,0 +1,169 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved. +// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. +// Copyright (c) 2001-2004 NovodeX AG. All rights reserved. + +#ifndef PSFOUNDATION_PSUTILITIES_H +#define PSFOUNDATION_PSUTILITIES_H + +#include "foundation/PxVec3.h" +#include "NvCloth/ps/Ps.h" +#include "NvCloth/ps/PsIntrinsics.h" +#include "NvCloth/ps/PsBasicTemplates.h" +#include "NvCloth/Callbacks.h" + +namespace physx +{ +namespace shdfnd +{ +PX_INLINE char littleEndian() +{ + int i = 1; + return *(reinterpret_cast<char*>(&i)); +} + +// PT: checked casts +PX_CUDA_CALLABLE PX_FORCE_INLINE PxU32 to32(PxU64 value) +{ + NV_CLOTH_ASSERT(value <= 0xffffffff); + return PxU32(value); +} +PX_CUDA_CALLABLE PX_FORCE_INLINE PxU16 to16(PxU32 value) +{ + NV_CLOTH_ASSERT(value <= 0xffff); + return PxU16(value); +} +PX_CUDA_CALLABLE PX_FORCE_INLINE PxU8 to8(PxU16 value) +{ + NV_CLOTH_ASSERT(value <= 0xff); + return PxU8(value); +} +PX_CUDA_CALLABLE PX_FORCE_INLINE PxU8 to8(PxU32 value) +{ + NV_CLOTH_ASSERT(value <= 0xff); + return PxU8(value); +} +PX_CUDA_CALLABLE PX_FORCE_INLINE PxU8 to8(PxI32 value) +{ + NV_CLOTH_ASSERT(value <= 0xff); + NV_CLOTH_ASSERT(value >= 0); + return PxU8(value); +} +PX_CUDA_CALLABLE PX_FORCE_INLINE PxI8 toI8(PxU32 value) +{ + NV_CLOTH_ASSERT(value <= 0x7f); + return PxI8(value); +} + +/*! +Get number of elements in array +*/ +template <typename T, size_t N> +char (&ArraySizeHelper(T (&array)[N]))[N]; +#define PX_ARRAY_SIZE(_array) (sizeof(physx::shdfnd::ArraySizeHelper(_array))) + +/*! +Sort two elements using operator< + +On return x will be the smaller of the two +*/ +template <class T> +PX_CUDA_CALLABLE PX_FORCE_INLINE void order(T& x, T& y) +{ + if(y < x) + swap(x, y); +} + +// most architectures can do predication on real comparisons, and on VMX, it matters + +PX_CUDA_CALLABLE PX_FORCE_INLINE void order(PxReal& x, PxReal& y) +{ + PxReal newX = PxMin(x, y); + PxReal newY = PxMax(x, y); + x = newX; + y = newY; +} + +/*! +Sort two elements using operator< and also keep order +of any extra data +*/ +template <class T, class E1> +PX_CUDA_CALLABLE PX_FORCE_INLINE void order(T& x, T& y, E1& xe1, E1& ye1) +{ + if(y < x) + { + swap(x, y); + swap(xe1, ye1); + } +} + +#if PX_GCC_FAMILY && !PX_EMSCRIPTEN && !PX_LINUX +__attribute__((noreturn)) +#endif + PX_INLINE void debugBreak() +{ +#if PX_WINDOWS || PX_XBOXONE + __debugbreak(); +#elif PX_ANDROID + raise(SIGTRAP); // works better than __builtin_trap. Proper call stack and can be continued. +#elif PX_LINUX + #if (PX_X64 || PX_X64) + asm("int $3"); + #else + raise(SIGTRAP); + #endif +#elif PX_GCC_FAMILY + __builtin_trap(); +#else + NV_CLOTH_ASSERT(false); +#endif +} + +bool checkValid(const float&); +bool checkValid(const PxVec3&); +bool checkValid(const PxQuat&); +bool checkValid(const PxMat33&); +bool checkValid(const PxTransform&); +bool checkValid(const char*); + +// equivalent to std::max_element +template <typename T> +inline const T* maxElement(const T* first, const T* last) +{ + const T* m = first; + for(const T* it = first + 1; it < last; ++it) + if(*m < *it) + m = it; + + return m; +} + +} // namespace shdfnd +} // namespace physx + +#endif diff --git a/NvCloth/src/ps/PxIntrinsics.h b/NvCloth/src/ps/PxIntrinsics.h new file mode 100644 index 0000000..b4aff28 --- /dev/null +++ b/NvCloth/src/ps/PxIntrinsics.h @@ -0,0 +1,47 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved. +// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. +// Copyright (c) 2001-2004 NovodeX AG. All rights reserved. + +#ifndef PXFOUNDATION_PXINTRINSICS_H +#define PXFOUNDATION_PXINTRINSICS_H + +#include "foundation/PxPreprocessor.h" + +#if PX_WINDOWS_FAMILY +#include "foundation/windows/PxWindowsIntrinsics.h" +#elif(PX_LINUX || PX_ANDROID || PX_APPLE_FAMILY || PX_PS4) +#include "foundation/unix/PxUnixIntrinsics.h" +#elif PX_XBOXONE +#include "foundation/XboxOne/PxXboxOneIntrinsics.h" +#elif PX_SWITCH +#include "foundation/switch/PxSwitchIntrinsics.h" +#else +#error "Platform not supported!" +#endif + +#endif // #ifndef PXFOUNDATION_PXINTRINSICS_H diff --git a/NvCloth/src/ps/android/cpu-features.c b/NvCloth/src/ps/android/cpu-features.c new file mode 100644 index 0000000..4754c46 --- /dev/null +++ b/NvCloth/src/ps/android/cpu-features.c @@ -0,0 +1,1082 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* ChangeLog for this library: + * + * NDK r8d: Add android_setCpu(). + * + * NDK r8c: Add new ARM CPU features: VFPv2, VFP_D32, VFP_FP16, + * VFP_FMA, NEON_FMA, IDIV_ARM, IDIV_THUMB2 and iWMMXt. + * + * Rewrite the code to parse /proc/self/auxv instead of + * the "Features" field in /proc/cpuinfo. + * + * Dynamically allocate the buffer that hold the content + * of /proc/cpuinfo to deal with newer hardware. + * + * NDK r7c: Fix CPU count computation. The old method only reported the + * number of _active_ CPUs when the library was initialized, + * which could be less than the real total. + * + * NDK r5: Handle buggy kernels which report a CPU Architecture number of 7 + * for an ARMv6 CPU (see below). + * + * Handle kernels that only report 'neon', and not 'vfpv3' + * (VFPv3 is mandated by the ARM architecture is Neon is implemented) + * + * Handle kernels that only report 'vfpv3d16', and not 'vfpv3' + * + * Fix x86 compilation. Report ANDROID_CPU_FAMILY_X86 in + * android_getCpuFamily(). + * + * NDK r4: Initial release + */ + +#if defined(__le32__) + +// When users enter this, we should only provide interface and +// libportable will give the implementations. + +#else // !__le32__ + +#include <sys/system_properties.h> +#include <pthread.h> +#include "cpu-features.h" +#include <stdio.h> +#include <stdlib.h> +#include <fcntl.h> +#include <errno.h> + +static pthread_once_t g_once; +static int g_inited; +static AndroidCpuFamily g_cpuFamily; +static uint64_t g_cpuFeatures; +static int g_cpuCount; + +#ifdef __arm__ +static uint32_t g_cpuIdArm; +#endif + +static const int android_cpufeatures_debug = 0; + +#ifdef __arm__ +# define DEFAULT_CPU_FAMILY ANDROID_CPU_FAMILY_ARM +#elif defined __i386__ +# define DEFAULT_CPU_FAMILY ANDROID_CPU_FAMILY_X86 +#else +# define DEFAULT_CPU_FAMILY ANDROID_CPU_FAMILY_UNKNOWN +#endif + +#define D(...) \ + do { \ + if (android_cpufeatures_debug) { \ + printf(__VA_ARGS__); fflush(stdout); \ + } \ + } while (0) + +#ifdef __i386__ +static __inline__ void x86_cpuid(int func, int values[4]) +{ + int a, b, c, d; + /* We need to preserve ebx since we're compiling PIC code */ + /* this means we can't use "=b" for the second output register */ + __asm__ __volatile__ ( \ + "push %%ebx\n" + "cpuid\n" \ + "mov %%ebx, %1\n" + "pop %%ebx\n" + : "=a" (a), "=r" (b), "=c" (c), "=d" (d) \ + : "a" (func) \ + ); + values[0] = a; + values[1] = b; + values[2] = c; + values[3] = d; +} +#endif + +/* Get the size of a file by reading it until the end. This is needed + * because files under /proc do not always return a valid size when + * using fseek(0, SEEK_END) + ftell(). Nor can they be mmap()-ed. + */ +static int +get_file_size(const char* pathname) +{ + int fd, ret, result = 0; + char buffer[256]; + + fd = open(pathname, O_RDONLY); + if (fd < 0) { + D("Can't open %s: %s\n", pathname, strerror(errno)); + return -1; + } + + for (;;) { + int ret = read(fd, buffer, sizeof buffer); + if (ret < 0) { + if (errno == EINTR) + continue; + D("Error while reading %s: %s\n", pathname, strerror(errno)); + break; + } + if (ret == 0) + break; + + result += ret; + } + close(fd); + return result; +} + +/* Read the content of /proc/cpuinfo into a user-provided buffer. + * Return the length of the data, or -1 on error. Does *not* + * zero-terminate the content. Will not read more + * than 'buffsize' bytes. + */ +static int +read_file(const char* pathname, char* buffer, size_t buffsize) +{ + int fd, count; + + fd = open(pathname, O_RDONLY); + if (fd < 0) { + D("Could not open %s: %s\n", pathname, strerror(errno)); + return -1; + } + count = 0; + while (count < (int)buffsize) { + int ret = read(fd, buffer + count, buffsize - count); + if (ret < 0) { + if (errno == EINTR) + continue; + D("Error while reading from %s: %s\n", pathname, strerror(errno)); + if (count == 0) + count = -1; + break; + } + if (ret == 0) + break; + count += ret; + } + close(fd); + return count; +} + +/* Extract the content of a the first occurence of a given field in + * the content of /proc/cpuinfo and return it as a heap-allocated + * string that must be freed by the caller. + * + * Return NULL if not found + */ +static char* +extract_cpuinfo_field(const char* buffer, int buflen, const char* field) +{ + int fieldlen = strlen(field); + const char* bufend = buffer + buflen; + char* result = NULL; + int len, ignore; + const char *p, *q; + + /* Look for first field occurence, and ensures it starts the line. */ + p = buffer; + for (;;) { + p = memmem(p, bufend-p, field, fieldlen); + if (p == NULL) + goto EXIT; + + if (p == buffer || p[-1] == '\n') + break; + + p += fieldlen; + } + + /* Skip to the first column followed by a space */ + p += fieldlen; + p = memchr(p, ':', bufend-p); + if (p == NULL || p[1] != ' ') + goto EXIT; + + /* Find the end of the line */ + p += 2; + q = memchr(p, '\n', bufend-p); + if (q == NULL) + q = bufend; + + /* Copy the line into a heap-allocated buffer */ + len = q-p; + result = malloc(len+1); + if (result == NULL) + goto EXIT; + + memcpy(result, p, len); + result[len] = '\0'; + +EXIT: + return result; +} + +/* Checks that a space-separated list of items contains one given 'item'. + * Returns 1 if found, 0 otherwise. + */ +static int +has_list_item(const char* list, const char* item) +{ + const char* p = list; + int itemlen = strlen(item); + + if (list == NULL) + return 0; + + while (*p) { + const char* q; + + /* skip spaces */ + while (*p == ' ' || *p == '\t') + p++; + + /* find end of current list item */ + q = p; + while (*q && *q != ' ' && *q != '\t') + q++; + + if (itemlen == q-p && !memcmp(p, item, itemlen)) + return 1; + + /* skip to next item */ + p = q; + } + return 0; +} + +/* Parse a number starting from 'input', but not going further + * than 'limit'. Return the value into '*result'. + * + * NOTE: Does not skip over leading spaces, or deal with sign characters. + * NOTE: Ignores overflows. + * + * The function returns NULL in case of error (bad format), or the new + * position after the decimal number in case of success (which will always + * be <= 'limit'). + */ +static const char* +parse_number(const char* input, const char* limit, int base, int* result) +{ + const char* p = input; + int val = 0; + while (p < limit) { + int d = (*p - '0'); + if ((unsigned)d >= 10U) { + d = (*p - 'a'); + if ((unsigned)d >= 6U) + d = (*p - 'A'); + if ((unsigned)d >= 6U) + break; + d += 10; + } + if (d >= base) + break; + val = val*base + d; + p++; + } + if (p == input) + return NULL; + + *result = val; + return p; +} + +static const char* +parse_decimal(const char* input, const char* limit, int* result) +{ + return parse_number(input, limit, 10, result); +} + +static const char* +parse_hexadecimal(const char* input, const char* limit, int* result) +{ + return parse_number(input, limit, 16, result); +} + +/* This small data type is used to represent a CPU list / mask, as read + * from sysfs on Linux. See http://www.kernel.org/doc/Documentation/cputopology.txt + * + * For now, we don't expect more than 32 cores on mobile devices, so keep + * everything simple. + */ +typedef struct { + uint32_t mask; +} CpuList; + +static __inline__ void +cpulist_init(CpuList* list) { + list->mask = 0; +} + +static __inline__ void +cpulist_and(CpuList* list1, CpuList* list2) { + list1->mask &= list2->mask; +} + +static __inline__ void +cpulist_set(CpuList* list, int index) { + if ((unsigned)index < 32) { + list->mask |= (uint32_t)(1U << index); + } +} + +static __inline__ int +cpulist_count(CpuList* list) { + return __builtin_popcount(list->mask); +} + +/* Parse a textual list of cpus and store the result inside a CpuList object. + * Input format is the following: + * - comma-separated list of items (no spaces) + * - each item is either a single decimal number (cpu index), or a range made + * of two numbers separated by a single dash (-). Ranges are inclusive. + * + * Examples: 0 + * 2,4-127,128-143 + * 0-1 + */ +static void +cpulist_parse(CpuList* list, const char* line, int line_len) +{ + const char* p = line; + const char* end = p + line_len; + const char* q; + + /* NOTE: the input line coming from sysfs typically contains a + * trailing newline, so take care of it in the code below + */ + while (p < end && *p != '\n') + { + int val, start_value, end_value; + + /* Find the end of current item, and put it into 'q' */ + q = memchr(p, ',', end-p); + if (q == NULL) { + q = end; + } + + /* Get first value */ + p = parse_decimal(p, q, &start_value); + if (p == NULL) + goto BAD_FORMAT; + + end_value = start_value; + + /* If we're not at the end of the item, expect a dash and + * and integer; extract end value. + */ + if (p < q && *p == '-') { + p = parse_decimal(p+1, q, &end_value); + if (p == NULL) + goto BAD_FORMAT; + } + + /* Set bits CPU list bits */ + for (val = start_value; val <= end_value; val++) { + cpulist_set(list, val); + } + + /* Jump to next item */ + p = q; + if (p < end) + p++; + } + +BAD_FORMAT: + ; +} + +/* Read a CPU list from one sysfs file */ +static void +cpulist_read_from(CpuList* list, const char* filename) +{ + char file[64]; + int filelen; + + cpulist_init(list); + + filelen = read_file(filename, file, sizeof file); + if (filelen < 0) { + D("Could not read %s: %s\n", filename, strerror(errno)); + return; + } + + cpulist_parse(list, file, filelen); +} + +// See <asm/hwcap.h> kernel header. +#define HWCAP_VFP (1 << 6) +#define HWCAP_IWMMXT (1 << 9) +#define HWCAP_NEON (1 << 12) +#define HWCAP_VFPv3 (1 << 13) +#define HWCAP_VFPv3D16 (1 << 14) +#define HWCAP_VFPv4 (1 << 16) +#define HWCAP_IDIVA (1 << 17) +#define HWCAP_IDIVT (1 << 18) + +#define AT_HWCAP 16 + +#if defined(__arm__) +/* Compute the ELF HWCAP flags. + */ +static uint32_t +get_elf_hwcap(const char* cpuinfo, int cpuinfo_len) +{ + /* IMPORTANT: + * Accessing /proc/self/auxv doesn't work anymore on all + * platform versions. More specifically, when running inside + * a regular application process, most of /proc/self/ will be + * non-readable, including /proc/self/auxv. This doesn't + * happen however if the application is debuggable, or when + * running under the "shell" UID, which is why this was not + * detected appropriately. + */ +#if 0 + uint32_t result = 0; + const char filepath[] = "/proc/self/auxv"; + int fd = open(filepath, O_RDONLY); + if (fd < 0) { + D("Could not open %s: %s\n", filepath, strerror(errno)); + return 0; + } + + struct { uint32_t tag; uint32_t value; } entry; + + for (;;) { + int ret = read(fd, (char*)&entry, sizeof entry); + if (ret < 0) { + if (errno == EINTR) + continue; + D("Error while reading %s: %s\n", filepath, strerror(errno)); + break; + } + // Detect end of list. + if (ret == 0 || (entry.tag == 0 && entry.value == 0)) + break; + if (entry.tag == AT_HWCAP) { + result = entry.value; + break; + } + } + close(fd); + return result; +#else + // Recreate ELF hwcaps by parsing /proc/cpuinfo Features tag. + uint32_t hwcaps = 0; + + char* cpuFeatures = extract_cpuinfo_field(cpuinfo, cpuinfo_len, "Features"); + + if (cpuFeatures != NULL) { + D("Found cpuFeatures = '%s'\n", cpuFeatures); + + if (has_list_item(cpuFeatures, "vfp")) + hwcaps |= HWCAP_VFP; + if (has_list_item(cpuFeatures, "vfpv3")) + hwcaps |= HWCAP_VFPv3; + if (has_list_item(cpuFeatures, "vfpv3d16")) + hwcaps |= HWCAP_VFPv3D16; + if (has_list_item(cpuFeatures, "vfpv4")) + hwcaps |= HWCAP_VFPv4; + if (has_list_item(cpuFeatures, "neon")) + hwcaps |= HWCAP_NEON; + if (has_list_item(cpuFeatures, "idiva")) + hwcaps |= HWCAP_IDIVA; + if (has_list_item(cpuFeatures, "idivt")) + hwcaps |= HWCAP_IDIVT; + if (has_list_item(cpuFeatures, "idiv")) + hwcaps |= HWCAP_IDIVA | HWCAP_IDIVT; + if (has_list_item(cpuFeatures, "iwmmxt")) + hwcaps |= HWCAP_IWMMXT; + + free(cpuFeatures); + } + return hwcaps; +#endif +} +#endif /* __arm__ */ + +/* Return the number of cpus present on a given device. + * + * To handle all weird kernel configurations, we need to compute the + * intersection of the 'present' and 'possible' CPU lists and count + * the result. + */ +static int +get_cpu_count(void) +{ + CpuList cpus_present[1]; + CpuList cpus_possible[1]; + + cpulist_read_from(cpus_present, "/sys/devices/system/cpu/present"); + cpulist_read_from(cpus_possible, "/sys/devices/system/cpu/possible"); + + /* Compute the intersection of both sets to get the actual number of + * CPU cores that can be used on this device by the kernel. + */ + cpulist_and(cpus_present, cpus_possible); + + return cpulist_count(cpus_present); +} + +static void +android_cpuInitFamily(void) +{ +#if defined(__arm__) + g_cpuFamily = ANDROID_CPU_FAMILY_ARM; +#elif defined(__i386__) + g_cpuFamily = ANDROID_CPU_FAMILY_X86; +#elif defined(__mips__) + g_cpuFamily = ANDROID_CPU_FAMILY_MIPS; +#else + g_cpuFamily = ANDROID_CPU_FAMILY_UNKNOWN; +#endif +} + +static void +android_cpuInit(void) +{ + char* cpuinfo = NULL; + int cpuinfo_len; + + android_cpuInitFamily(); + + g_cpuFeatures = 0; + g_cpuCount = 1; + g_inited = 1; + + cpuinfo_len = get_file_size("/proc/cpuinfo"); + if (cpuinfo_len < 0) { + D("cpuinfo_len cannot be computed!"); + return; + } + cpuinfo = malloc(cpuinfo_len); + if (cpuinfo == NULL) { + D("cpuinfo buffer could not be allocated"); + return; + } + cpuinfo_len = read_file("/proc/cpuinfo", cpuinfo, cpuinfo_len); + D("cpuinfo_len is (%d):\n%.*s\n", cpuinfo_len, + cpuinfo_len >= 0 ? cpuinfo_len : 0, cpuinfo); + + if (cpuinfo_len < 0) /* should not happen */ { + free(cpuinfo); + return; + } + + /* Count the CPU cores, the value may be 0 for single-core CPUs */ + g_cpuCount = get_cpu_count(); + if (g_cpuCount == 0) { + g_cpuCount = 1; + } + + D("found cpuCount = %d\n", g_cpuCount); + +#ifdef __arm__ + { + char* features = NULL; + char* architecture = NULL; + + /* Extract architecture from the "CPU Architecture" field. + * The list is well-known, unlike the the output of + * the 'Processor' field which can vary greatly. + * + * See the definition of the 'proc_arch' array in + * $KERNEL/arch/arm/kernel/setup.c and the 'c_show' function in + * same file. + */ + char* cpuArch = extract_cpuinfo_field(cpuinfo, cpuinfo_len, "CPU architecture"); + + if (cpuArch != NULL) { + char* end; + long archNumber; + int hasARMv7 = 0; + + D("found cpuArch = '%s'\n", cpuArch); + + /* read the initial decimal number, ignore the rest */ + archNumber = strtol(cpuArch, &end, 10); + + /* Here we assume that ARMv8 will be upwards compatible with v7 + * in the future. Unfortunately, there is no 'Features' field to + * indicate that Thumb-2 is supported. + */ + if (end > cpuArch && archNumber >= 7) { + hasARMv7 = 1; + } + + /* Unfortunately, it seems that certain ARMv6-based CPUs + * report an incorrect architecture number of 7! + * + * See http://code.google.com/p/android/issues/detail?id=10812 + * + * We try to correct this by looking at the 'elf_format' + * field reported by the 'Processor' field, which is of the + * form of "(v7l)" for an ARMv7-based CPU, and "(v6l)" for + * an ARMv6-one. + */ + if (hasARMv7) { + char* cpuProc = extract_cpuinfo_field(cpuinfo, cpuinfo_len, + "Processor"); + if (cpuProc != NULL) { + D("found cpuProc = '%s'\n", cpuProc); + if (has_list_item(cpuProc, "(v6l)")) { + D("CPU processor and architecture mismatch!!\n"); + hasARMv7 = 0; + } + free(cpuProc); + } + } + + if (hasARMv7) { + g_cpuFeatures |= ANDROID_CPU_ARM_FEATURE_ARMv7; + } + + /* The LDREX / STREX instructions are available from ARMv6 */ + if (archNumber >= 6) { + g_cpuFeatures |= ANDROID_CPU_ARM_FEATURE_LDREX_STREX; + } + + free(cpuArch); + } + + /* Extract the list of CPU features from ELF hwcaps */ + uint32_t hwcaps = get_elf_hwcap(cpuinfo, cpuinfo_len); + + if (hwcaps != 0) { + int has_vfp = (hwcaps & HWCAP_VFP); + int has_vfpv3 = (hwcaps & HWCAP_VFPv3); + int has_vfpv3d16 = (hwcaps & HWCAP_VFPv3D16); + int has_vfpv4 = (hwcaps & HWCAP_VFPv4); + int has_neon = (hwcaps & HWCAP_NEON); + int has_idiva = (hwcaps & HWCAP_IDIVA); + int has_idivt = (hwcaps & HWCAP_IDIVT); + int has_iwmmxt = (hwcaps & HWCAP_IWMMXT); + + // The kernel does a poor job at ensuring consistency when + // describing CPU features. So lots of guessing is needed. + + // 'vfpv4' implies VFPv3|VFP_FMA|FP16 + if (has_vfpv4) + g_cpuFeatures |= ANDROID_CPU_ARM_FEATURE_VFPv3 | + ANDROID_CPU_ARM_FEATURE_VFP_FP16 | + ANDROID_CPU_ARM_FEATURE_VFP_FMA; + + // 'vfpv3' or 'vfpv3d16' imply VFPv3. Note that unlike GCC, + // a value of 'vfpv3' doesn't necessarily mean that the D32 + // feature is present, so be conservative. All CPUs in the + // field that support D32 also support NEON, so this should + // not be a problem in practice. + if (has_vfpv3 || has_vfpv3d16) + g_cpuFeatures |= ANDROID_CPU_ARM_FEATURE_VFPv3; + + // 'vfp' is super ambiguous. Depending on the kernel, it can + // either mean VFPv2 or VFPv3. Make it depend on ARMv7. + if (has_vfp) { + if (g_cpuFeatures & ANDROID_CPU_ARM_FEATURE_ARMv7) + g_cpuFeatures |= ANDROID_CPU_ARM_FEATURE_VFPv3; + else + g_cpuFeatures |= ANDROID_CPU_ARM_FEATURE_VFPv2; + } + + // Neon implies VFPv3|D32, and if vfpv4 is detected, NEON_FMA + if (has_neon) { + g_cpuFeatures |= ANDROID_CPU_ARM_FEATURE_VFPv3 | + ANDROID_CPU_ARM_FEATURE_NEON | + ANDROID_CPU_ARM_FEATURE_VFP_D32; + if (has_vfpv4) + g_cpuFeatures |= ANDROID_CPU_ARM_FEATURE_NEON_FMA; + } + + // VFPv3 implies VFPv2 and ARMv7 + if (g_cpuFeatures & ANDROID_CPU_ARM_FEATURE_VFPv3) + g_cpuFeatures |= ANDROID_CPU_ARM_FEATURE_VFPv2 | + ANDROID_CPU_ARM_FEATURE_ARMv7; + + if (has_idiva) + g_cpuFeatures |= ANDROID_CPU_ARM_FEATURE_IDIV_ARM; + if (has_idivt) + g_cpuFeatures |= ANDROID_CPU_ARM_FEATURE_IDIV_THUMB2; + + if (has_iwmmxt) + g_cpuFeatures |= ANDROID_CPU_ARM_FEATURE_iWMMXt; + } + + /* Extract the cpuid value from various fields */ + // The CPUID value is broken up in several entries in /proc/cpuinfo. + // This table is used to rebuild it from the entries. + static const struct CpuIdEntry { + const char* field; + char format; + char bit_lshift; + char bit_length; + } cpu_id_entries[] = { + { "CPU implementer", 'x', 24, 8 }, + { "CPU variant", 'x', 20, 4 }, + { "CPU part", 'x', 4, 12 }, + { "CPU revision", 'd', 0, 4 }, + }; + size_t i; + D("Parsing /proc/cpuinfo to recover CPUID\n"); + for (i = 0; + i < sizeof(cpu_id_entries)/sizeof(cpu_id_entries[0]); + ++i) { + const struct CpuIdEntry* entry = &cpu_id_entries[i]; + char* value = extract_cpuinfo_field(cpuinfo, + cpuinfo_len, + entry->field); + if (value == NULL) + continue; + + D("field=%s value='%s'\n", entry->field, value); + char* value_end = value + strlen(value); + int val = 0; + const char* start = value; + const char* p; + if (value[0] == '0' && (value[1] == 'x' || value[1] == 'X')) { + start += 2; + p = parse_hexadecimal(start, value_end, &val); + } else if (entry->format == 'x') + p = parse_hexadecimal(value, value_end, &val); + else + p = parse_decimal(value, value_end, &val); + + if (p > (const char*)start) { + val &= ((1 << entry->bit_length)-1); + val <<= entry->bit_lshift; + g_cpuIdArm |= (uint32_t) val; + } + + free(value); + } + + // Handle kernel configuration bugs that prevent the correct + // reporting of CPU features. + static const struct CpuFix { + uint32_t cpuid; + uint64_t or_flags; + } cpu_fixes[] = { + /* The Nexus 4 (Qualcomm Krait) kernel configuration + * forgets to report IDIV support. */ + { 0x510006f2, ANDROID_CPU_ARM_FEATURE_IDIV_ARM | + ANDROID_CPU_ARM_FEATURE_IDIV_THUMB2 }, + { 0x510006f3, ANDROID_CPU_ARM_FEATURE_IDIV_ARM | + ANDROID_CPU_ARM_FEATURE_IDIV_THUMB2 }, + }; + size_t n; + for (n = 0; n < sizeof(cpu_fixes)/sizeof(cpu_fixes[0]); ++n) { + const struct CpuFix* entry = &cpu_fixes[n]; + + if (g_cpuIdArm == entry->cpuid) + g_cpuFeatures |= entry->or_flags; + } + + } +#endif /* __arm__ */ + +#ifdef __i386__ + int regs[4]; + +/* According to http://en.wikipedia.org/wiki/CPUID */ +#define VENDOR_INTEL_b 0x756e6547 +#define VENDOR_INTEL_c 0x6c65746e +#define VENDOR_INTEL_d 0x49656e69 + + x86_cpuid(0, regs); + int vendorIsIntel = (regs[1] == VENDOR_INTEL_b && + regs[2] == VENDOR_INTEL_c && + regs[3] == VENDOR_INTEL_d); + + x86_cpuid(1, regs); + if ((regs[2] & (1 << 9)) != 0) { + g_cpuFeatures |= ANDROID_CPU_X86_FEATURE_SSSE3; + } + if ((regs[2] & (1 << 23)) != 0) { + g_cpuFeatures |= ANDROID_CPU_X86_FEATURE_POPCNT; + } + if (vendorIsIntel && (regs[2] & (1 << 22)) != 0) { + g_cpuFeatures |= ANDROID_CPU_X86_FEATURE_MOVBE; + } +#endif + + free(cpuinfo); +} + + +AndroidCpuFamily +android_getCpuFamily(void) +{ + pthread_once(&g_once, android_cpuInit); + return g_cpuFamily; +} + + +uint64_t +android_getCpuFeatures(void) +{ + pthread_once(&g_once, android_cpuInit); + return g_cpuFeatures; +} + + +int +android_getCpuCount(void) +{ + pthread_once(&g_once, android_cpuInit); + return g_cpuCount; +} + +static void +android_cpuInitDummy(void) +{ + g_inited = 1; +} + +int +android_setCpu(int cpu_count, uint64_t cpu_features) +{ + /* Fail if the library was already initialized. */ + if (g_inited) + return 0; + + android_cpuInitFamily(); + g_cpuCount = (cpu_count <= 0 ? 1 : cpu_count); + g_cpuFeatures = cpu_features; + pthread_once(&g_once, android_cpuInitDummy); + + return 1; +} + +#ifdef __arm__ +uint32_t +android_getCpuIdArm(void) +{ + pthread_once(&g_once, android_cpuInit); + return g_cpuIdArm; +} + +int +android_setCpuArm(int cpu_count, uint64_t cpu_features, uint32_t cpu_id) +{ + if (!android_setCpu(cpu_count, cpu_features)) + return 0; + + g_cpuIdArm = cpu_id; + return 1; +} +#endif /* __arm__ */ + +/* + * Technical note: Making sense of ARM's FPU architecture versions. + * + * FPA was ARM's first attempt at an FPU architecture. There is no Android + * device that actually uses it since this technology was already obsolete + * when the project started. If you see references to FPA instructions + * somewhere, you can be sure that this doesn't apply to Android at all. + * + * FPA was followed by "VFP", soon renamed "VFPv1" due to the emergence of + * new versions / additions to it. ARM considers this obsolete right now, + * and no known Android device implements it either. + * + * VFPv2 added a few instructions to VFPv1, and is an *optional* extension + * supported by some ARMv5TE, ARMv6 and ARMv6T2 CPUs. Note that a device + * supporting the 'armeabi' ABI doesn't necessarily support these. + * + * VFPv3-D16 adds a few instructions on top of VFPv2 and is typically used + * on ARMv7-A CPUs which implement a FPU. Note that it is also mandated + * by the Android 'armeabi-v7a' ABI. The -D16 suffix in its name means + * that it provides 16 double-precision FPU registers (d0-d15) and 32 + * single-precision ones (s0-s31) which happen to be mapped to the same + * register banks. + * + * VFPv3-D32 is the name of an extension to VFPv3-D16 that provides 16 + * additional double precision registers (d16-d31). Note that there are + * still only 32 single precision registers. + * + * VFPv3xD is a *subset* of VFPv3-D16 that only provides single-precision + * registers. It is only used on ARMv7-M (i.e. on micro-controllers) which + * are not supported by Android. Note that it is not compatible with VFPv2. + * + * NOTE: The term 'VFPv3' usually designate either VFPv3-D16 or VFPv3-D32 + * depending on context. For example GCC uses it for VFPv3-D32, but + * the Linux kernel code uses it for VFPv3-D16 (especially in + * /proc/cpuinfo). Always try to use the full designation when + * possible. + * + * NEON, a.k.a. "ARM Advanced SIMD" is an extension that provides + * instructions to perform parallel computations on vectors of 8, 16, + * 32, 64 and 128 bit quantities. NEON requires VFPv32-D32 since all + * NEON registers are also mapped to the same register banks. + * + * VFPv4-D16, adds a few instructions on top of VFPv3-D16 in order to + * perform fused multiply-accumulate on VFP registers, as well as + * half-precision (16-bit) conversion operations. + * + * VFPv4-D32 is VFPv4-D16 with 32, instead of 16, FPU double precision + * registers. + * + * VPFv4-NEON is VFPv4-D32 with NEON instructions. It also adds fused + * multiply-accumulate instructions that work on the NEON registers. + * + * NOTE: Similarly, "VFPv4" might either reference VFPv4-D16 or VFPv4-D32 + * depending on context. + * + * The following information was determined by scanning the binutils-2.22 + * sources: + * + * Basic VFP instruction subsets: + * + * #define FPU_VFP_EXT_V1xD 0x08000000 // Base VFP instruction set. + * #define FPU_VFP_EXT_V1 0x04000000 // Double-precision insns. + * #define FPU_VFP_EXT_V2 0x02000000 // ARM10E VFPr1. + * #define FPU_VFP_EXT_V3xD 0x01000000 // VFPv3 single-precision. + * #define FPU_VFP_EXT_V3 0x00800000 // VFPv3 double-precision. + * #define FPU_NEON_EXT_V1 0x00400000 // Neon (SIMD) insns. + * #define FPU_VFP_EXT_D32 0x00200000 // Registers D16-D31. + * #define FPU_VFP_EXT_FP16 0x00100000 // Half-precision extensions. + * #define FPU_NEON_EXT_FMA 0x00080000 // Neon fused multiply-add + * #define FPU_VFP_EXT_FMA 0x00040000 // VFP fused multiply-add + * + * FPU types (excluding NEON) + * + * FPU_VFP_V1xD (EXT_V1xD) + * | + * +--------------------------+ + * | | + * FPU_VFP_V1 (+EXT_V1) FPU_VFP_V3xD (+EXT_V2+EXT_V3xD) + * | | + * | | + * FPU_VFP_V2 (+EXT_V2) FPU_VFP_V4_SP_D16 (+EXT_FP16+EXT_FMA) + * | + * FPU_VFP_V3D16 (+EXT_Vx3D+EXT_V3) + * | + * +--------------------------+ + * | | + * FPU_VFP_V3 (+EXT_D32) FPU_VFP_V4D16 (+EXT_FP16+EXT_FMA) + * | | + * | FPU_VFP_V4 (+EXT_D32) + * | + * FPU_VFP_HARD (+EXT_FMA+NEON_EXT_FMA) + * + * VFP architectures: + * + * ARCH_VFP_V1xD (EXT_V1xD) + * | + * +------------------+ + * | | + * | ARCH_VFP_V3xD (+EXT_V2+EXT_V3xD) + * | | + * | ARCH_VFP_V3xD_FP16 (+EXT_FP16) + * | | + * | ARCH_VFP_V4_SP_D16 (+EXT_FMA) + * | + * ARCH_VFP_V1 (+EXT_V1) + * | + * ARCH_VFP_V2 (+EXT_V2) + * | + * ARCH_VFP_V3D16 (+EXT_V3xD+EXT_V3) + * | + * +-------------------+ + * | | + * | ARCH_VFP_V3D16_FP16 (+EXT_FP16) + * | + * +-------------------+ + * | | + * | ARCH_VFP_V4_D16 (+EXT_FP16+EXT_FMA) + * | | + * | ARCH_VFP_V4 (+EXT_D32) + * | | + * | ARCH_NEON_VFP_V4 (+EXT_NEON+EXT_NEON_FMA) + * | + * ARCH_VFP_V3 (+EXT_D32) + * | + * +-------------------+ + * | | + * | ARCH_VFP_V3_FP16 (+EXT_FP16) + * | + * ARCH_VFP_V3_PLUS_NEON_V1 (+EXT_NEON) + * | + * ARCH_NEON_FP16 (+EXT_FP16) + * + * -fpu=<name> values and their correspondance with FPU architectures above: + * + * {"vfp", FPU_ARCH_VFP_V2}, + * {"vfp9", FPU_ARCH_VFP_V2}, + * {"vfp3", FPU_ARCH_VFP_V3}, // For backwards compatbility. + * {"vfp10", FPU_ARCH_VFP_V2}, + * {"vfp10-r0", FPU_ARCH_VFP_V1}, + * {"vfpxd", FPU_ARCH_VFP_V1xD}, + * {"vfpv2", FPU_ARCH_VFP_V2}, + * {"vfpv3", FPU_ARCH_VFP_V3}, + * {"vfpv3-fp16", FPU_ARCH_VFP_V3_FP16}, + * {"vfpv3-d16", FPU_ARCH_VFP_V3D16}, + * {"vfpv3-d16-fp16", FPU_ARCH_VFP_V3D16_FP16}, + * {"vfpv3xd", FPU_ARCH_VFP_V3xD}, + * {"vfpv3xd-fp16", FPU_ARCH_VFP_V3xD_FP16}, + * {"neon", FPU_ARCH_VFP_V3_PLUS_NEON_V1}, + * {"neon-fp16", FPU_ARCH_NEON_FP16}, + * {"vfpv4", FPU_ARCH_VFP_V4}, + * {"vfpv4-d16", FPU_ARCH_VFP_V4D16}, + * {"fpv4-sp-d16", FPU_ARCH_VFP_V4_SP_D16}, + * {"neon-vfpv4", FPU_ARCH_NEON_VFP_V4}, + * + * + * Simplified diagram that only includes FPUs supported by Android: + * Only ARCH_VFP_V3D16 is actually mandated by the armeabi-v7a ABI, + * all others are optional and must be probed at runtime. + * + * ARCH_VFP_V3D16 (EXT_V1xD+EXT_V1+EXT_V2+EXT_V3xD+EXT_V3) + * | + * +-------------------+ + * | | + * | ARCH_VFP_V3D16_FP16 (+EXT_FP16) + * | + * +-------------------+ + * | | + * | ARCH_VFP_V4_D16 (+EXT_FP16+EXT_FMA) + * | | + * | ARCH_VFP_V4 (+EXT_D32) + * | | + * | ARCH_NEON_VFP_V4 (+EXT_NEON+EXT_NEON_FMA) + * | + * ARCH_VFP_V3 (+EXT_D32) + * | + * +-------------------+ + * | | + * | ARCH_VFP_V3_FP16 (+EXT_FP16) + * | + * ARCH_VFP_V3_PLUS_NEON_V1 (+EXT_NEON) + * | + * ARCH_NEON_FP16 (+EXT_FP16) + * + */ + +#endif // defined(__le32__) diff --git a/NvCloth/src/ps/android/cpu-features.h b/NvCloth/src/ps/android/cpu-features.h new file mode 100644 index 0000000..89f7666 --- /dev/null +++ b/NvCloth/src/ps/android/cpu-features.h @@ -0,0 +1,208 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ +#ifndef CPU_FEATURES_H +#define CPU_FEATURES_H + +#include <sys/cdefs.h> +#include <stdint.h> + +__BEGIN_DECLS + +typedef enum +{ + ANDROID_CPU_FAMILY_UNKNOWN = 0, + ANDROID_CPU_FAMILY_ARM, + ANDROID_CPU_FAMILY_X86, + ANDROID_CPU_FAMILY_MIPS, + ANDROID_CPU_FAMILY_MAX /* do not remove */ +} AndroidCpuFamily; + +/* Return family of the device's CPU */ +extern AndroidCpuFamily android_getCpuFamily(void); + +/* The list of feature flags for ARM CPUs that can be recognized by the + * library. Value details are: + * + * VFPv2: + * CPU supports the VFPv2 instruction set. Many, but not all, ARMv6 CPUs + * support these instructions. VFPv2 is a subset of VFPv3 so this will + * be set whenever VFPv3 is set too. + * + * ARMv7: + * CPU supports the ARMv7-A basic instruction set. + * This feature is mandated by the 'armeabi-v7a' ABI. + * + * VFPv3: + * CPU supports the VFPv3-D16 instruction set, providing hardware FPU + * support for single and double precision floating point registers. + * Note that only 16 FPU registers are available by default, unless + * the D32 bit is set too. This feature is also mandated by the + * 'armeabi-v7a' ABI. + * + * VFP_D32: + * CPU VFP optional extension that provides 32 FPU registers, + * instead of 16. Note that ARM mandates this feature is the 'NEON' + * feature is implemented by the CPU. + * + * NEON: + * CPU FPU supports "ARM Advanced SIMD" instructions, also known as + * NEON. Note that this mandates the VFP_D32 feature as well, per the + * ARM Architecture specification. + * + * VFP_FP16: + * Half-width floating precision VFP extension. If set, the CPU + * supports instructions to perform floating-point operations on + * 16-bit registers. This is part of the VFPv4 specification, but + * not mandated by any Android ABI. + * + * VFP_FMA: + * Fused multiply-accumulate VFP instructions extension. Also part of + * the VFPv4 specification, but not mandated by any Android ABI. + * + * NEON_FMA: + * Fused multiply-accumulate NEON instructions extension. Optional + * extension from the VFPv4 specification, but not mandated by any + * Android ABI. + * + * IDIV_ARM: + * Integer division available in ARM mode. Only available + * on recent CPUs (e.g. Cortex-A15). + * + * IDIV_THUMB2: + * Integer division available in Thumb-2 mode. Only available + * on recent CPUs (e.g. Cortex-A15). + * + * iWMMXt: + * Optional extension that adds MMX registers and operations to an + * ARM CPU. This is only available on a few XScale-based CPU designs + * sold by Marvell. Pretty rare in practice. + * + * If you want to tell the compiler to generate code that targets one of + * the feature set above, you should probably use one of the following + * flags (for more details, see technical note at the end of this file): + * + * -mfpu=vfp + * -mfpu=vfpv2 + * These are equivalent and tell GCC to use VFPv2 instructions for + * floating-point operations. Use this if you want your code to + * run on *some* ARMv6 devices, and any ARMv7-A device supported + * by Android. + * + * Generated code requires VFPv2 feature. + * + * -mfpu=vfpv3-d16 + * Tell GCC to use VFPv3 instructions (using only 16 FPU registers). + * This should be generic code that runs on any CPU that supports the + * 'armeabi-v7a' Android ABI. Note that no ARMv6 CPU supports this. + * + * Generated code requires VFPv3 feature. + * + * -mfpu=vfpv3 + * Tell GCC to use VFPv3 instructions with 32 FPU registers. + * Generated code requires VFPv3|VFP_D32 features. + * + * -mfpu=neon + * Tell GCC to use VFPv3 instructions with 32 FPU registers, and + * also support NEON intrinsics (see <arm_neon.h>). + * Generated code requires VFPv3|VFP_D32|NEON features. + * + * -mfpu=vfpv4-d16 + * Generated code requires VFPv3|VFP_FP16|VFP_FMA features. + * + * -mfpu=vfpv4 + * Generated code requires VFPv3|VFP_FP16|VFP_FMA|VFP_D32 features. + * + * -mfpu=neon-vfpv4 + * Generated code requires VFPv3|VFP_FP16|VFP_FMA|VFP_D32|NEON|NEON_FMA + * features. + * + * -mcpu=cortex-a7 + * -mcpu=cortex-a15 + * Generated code requires VFPv3|VFP_FP16|VFP_FMA|VFP_D32| + * NEON|NEON_FMA|IDIV_ARM|IDIV_THUMB2 + * This flag implies -mfpu=neon-vfpv4. + * + * -mcpu=iwmmxt + * Allows the use of iWMMXt instrinsics with GCC. + */ +enum +{ + ANDROID_CPU_ARM_FEATURE_ARMv7 = (1 << 0), + ANDROID_CPU_ARM_FEATURE_VFPv3 = (1 << 1), + ANDROID_CPU_ARM_FEATURE_NEON = (1 << 2), + ANDROID_CPU_ARM_FEATURE_LDREX_STREX = (1 << 3), + ANDROID_CPU_ARM_FEATURE_VFPv2 = (1 << 4), + ANDROID_CPU_ARM_FEATURE_VFP_D32 = (1 << 5), + ANDROID_CPU_ARM_FEATURE_VFP_FP16 = (1 << 6), + ANDROID_CPU_ARM_FEATURE_VFP_FMA = (1 << 7), + ANDROID_CPU_ARM_FEATURE_NEON_FMA = (1 << 8), + ANDROID_CPU_ARM_FEATURE_IDIV_ARM = (1 << 9), + ANDROID_CPU_ARM_FEATURE_IDIV_THUMB2 = (1 << 10), + ANDROID_CPU_ARM_FEATURE_iWMMXt = (1 << 11), +}; + +enum +{ + ANDROID_CPU_X86_FEATURE_SSSE3 = (1 << 0), + ANDROID_CPU_X86_FEATURE_POPCNT = (1 << 1), + ANDROID_CPU_X86_FEATURE_MOVBE = (1 << 2), +}; + +extern uint64_t android_getCpuFeatures(void); + +/* Return the number of CPU cores detected on this device. */ +extern int android_getCpuCount(void); + +/* The following is used to force the CPU count and features + * mask in sandboxed processes. Under 4.1 and higher, these processes + * cannot access /proc, which is the only way to get information from + * the kernel about the current hardware (at least on ARM). + * + * It _must_ be called only once, and before any android_getCpuXXX + * function, any other case will fail. + * + * This function return 1 on success, and 0 on failure. + */ +extern int android_setCpu(int cpu_count, uint64_t cpu_features); + +#ifdef __arm__ +/* Retrieve the ARM 32-bit CPUID value from the kernel. + * Note that this cannot work on sandboxed processes under 4.1 and + * higher, unless you called android_setCpuArm() before. + */ +extern uint32_t android_getCpuIdArm(void); + +/* An ARM-specific variant of android_setCpu() that also allows you + * to set the ARM CPUID field. + */ +extern int android_setCpuArm(int cpu_count, uint64_t cpu_features, uint32_t cpu_id); +#endif + +__END_DECLS + +#endif /* CPU_FEATURES_H */ diff --git a/NvCloth/src/ps/unix/PsUnixAtomic.cpp b/NvCloth/src/ps/unix/PsUnixAtomic.cpp new file mode 100644 index 0000000..376f795 --- /dev/null +++ b/NvCloth/src/ps/unix/PsUnixAtomic.cpp @@ -0,0 +1,102 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved. +// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. +// Copyright (c) 2001-2004 NovodeX AG. All rights reserved. +#include "NvCloth/ps/Ps.h" +#include "NvCloth/ps/PsAtomic.h" + +#if ! PX_EMSCRIPTEN +#define PAUSE() asm("nop") +#else +#define PAUSE() +#endif + +namespace physx +{ +namespace shdfnd +{ + +void* atomicCompareExchangePointer(volatile void** dest, void* exch, void* comp) +{ + return __sync_val_compare_and_swap(const_cast<void**>(dest), comp, exch); +} + +int32_t atomicCompareExchange(volatile int32_t* dest, int32_t exch, int32_t comp) +{ + return __sync_val_compare_and_swap(dest, comp, exch); +} + +int32_t atomicIncrement(volatile int32_t* val) +{ + return __sync_add_and_fetch(val, 1); +} + +int32_t atomicDecrement(volatile int32_t* val) +{ + return __sync_sub_and_fetch(val, 1); +} + +int32_t atomicAdd(volatile int32_t* val, int32_t delta) +{ + return __sync_add_and_fetch(val, delta); +} + +int32_t atomicMax(volatile int32_t* val, int32_t val2) +{ + int32_t oldVal, newVal; + + do + { + PAUSE(); + oldVal = *val; + + if(val2 > oldVal) + newVal = val2; + else + newVal = oldVal; + + } while(atomicCompareExchange(val, newVal, oldVal) != oldVal); + + return *val; +} + +int32_t atomicExchange(volatile int32_t* val, int32_t val2) +{ + int32_t newVal, oldVal; + + do + { + PAUSE(); + oldVal = *val; + newVal = val2; + } while(atomicCompareExchange(val, newVal, oldVal) != oldVal); + + return oldVal; +} + +} // namespace shdfnd +} // namespace physx diff --git a/NvCloth/src/ps/unix/PsUnixFPU.h b/NvCloth/src/ps/unix/PsUnixFPU.h new file mode 100644 index 0000000..edd5522 --- /dev/null +++ b/NvCloth/src/ps/unix/PsUnixFPU.h @@ -0,0 +1,69 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved. +// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. +// Copyright (c) 2001-2004 NovodeX AG. All rights reserved. + +#ifndef PSFOUNDATION_PSUNIXFPU_H +#define PSFOUNDATION_PSUNIXFPU_H + +#include "foundation/PxPreprocessor.h" + +#if PX_LINUX || PX_PS4 || PX_OSX + +#if PX_X86 || PX_X64 +#if PX_EMSCRIPTEN +#include <emmintrin.h> +#endif +#include <xmmintrin.h> +#elif PX_NEON +#include <arm_neon.h> +#endif + + +PX_INLINE physx::shdfnd::SIMDGuard::SIMDGuard() +{ +#if !PX_EMSCRIPTEN && (PX_X86 || PX_X64) + mControlWord = _mm_getcsr(); + // set default (disable exceptions: _MM_MASK_MASK) and FTZ (_MM_FLUSH_ZERO_ON), DAZ (_MM_DENORMALS_ZERO_ON: (1<<6)) + _mm_setcsr(_MM_MASK_MASK | _MM_FLUSH_ZERO_ON | (1 << 6)); +#endif +} + +PX_INLINE physx::shdfnd::SIMDGuard::~SIMDGuard() +{ +#if !PX_EMSCRIPTEN && (PX_X86 || PX_X64) + // restore control word and clear exception flags + // (setting exception state flags cause exceptions on the first following fp operation) + _mm_setcsr(mControlWord & ~_MM_EXCEPT_MASK); +#endif +} + +#else +#error No SIMD implementation for this unix platform. +#endif // PX_LINUX || PX_PS4 || PX_OSX + +#endif // #ifndef PSFOUNDATION_PSUNIXFPU_H diff --git a/NvCloth/src/ps/unix/PsUnixMutex.cpp b/NvCloth/src/ps/unix/PsUnixMutex.cpp new file mode 100644 index 0000000..23b6549 --- /dev/null +++ b/NvCloth/src/ps/unix/PsUnixMutex.cpp @@ -0,0 +1,170 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved. +// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. +// Copyright (c) 2001-2004 NovodeX AG. All rights reserved. + +#include "foundation/PxAssert.h" +#include "foundation/PxErrorCallback.h" + +#include "Ps.h" +#include "PsFoundation.h" +#include "PsUserAllocated.h" +#include "PsMutex.h" +#include "PsAtomic.h" +#include "PsThread.h" + +#include <pthread.h> + +namespace physx +{ +namespace shdfnd +{ + +namespace +{ +struct MutexUnixImpl +{ + pthread_mutex_t lock; + Thread::Id owner; +}; + +MutexUnixImpl* getMutex(MutexImpl* impl) +{ + return reinterpret_cast<MutexUnixImpl*>(impl); +} +} + +MutexImpl::MutexImpl() +{ + pthread_mutexattr_t attr; + pthread_mutexattr_init(&attr); + pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); +#if !PX_ANDROID + // mimic default windows behavior where applicable + pthread_mutexattr_setprotocol(&attr, PTHREAD_PRIO_INHERIT); +#endif + pthread_mutex_init(&getMutex(this)->lock, &attr); + pthread_mutexattr_destroy(&attr); +} + +MutexImpl::~MutexImpl() +{ + pthread_mutex_destroy(&getMutex(this)->lock); +} + +void MutexImpl::lock() +{ + int err = pthread_mutex_lock(&getMutex(this)->lock); + PX_ASSERT(!err); + PX_UNUSED(err); + +#if PX_DEBUG + getMutex(this)->owner = Thread::getId(); +#endif +} + +bool MutexImpl::trylock() +{ + bool success = !pthread_mutex_trylock(&getMutex(this)->lock); +#if PX_DEBUG + if(success) + getMutex(this)->owner = Thread::getId(); +#endif + return success; +} + +void MutexImpl::unlock() +{ +#if PX_DEBUG + if(getMutex(this)->owner != Thread::getId()) + { + shdfnd::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, + "Mutex must be unlocked only by thread that has already acquired lock"); + return; + } +#endif + + int err = pthread_mutex_unlock(&getMutex(this)->lock); + PX_ASSERT(!err); + PX_UNUSED(err); +} + +uint32_t MutexImpl::getSize() +{ + return sizeof(MutexUnixImpl); +} + +class ReadWriteLockImpl +{ + public: + Mutex mutex; + volatile int readerCounter; +}; + +ReadWriteLock::ReadWriteLock() +{ + mImpl = reinterpret_cast<ReadWriteLockImpl*>(PX_ALLOC(sizeof(ReadWriteLockImpl), "ReadWriteLockImpl")); + PX_PLACEMENT_NEW(mImpl, ReadWriteLockImpl); + + mImpl->readerCounter = 0; +} + +ReadWriteLock::~ReadWriteLock() +{ + mImpl->~ReadWriteLockImpl(); + PX_FREE(mImpl); +} + +void ReadWriteLock::lockReader() +{ + mImpl->mutex.lock(); + + atomicIncrement(&mImpl->readerCounter); + + mImpl->mutex.unlock(); +} + +void ReadWriteLock::lockWriter() +{ + mImpl->mutex.lock(); + + while(mImpl->readerCounter != 0) + ; +} + +void ReadWriteLock::unlockReader() +{ + atomicDecrement(&mImpl->readerCounter); +} + +void ReadWriteLock::unlockWriter() +{ + mImpl->mutex.unlock(); +} + +} // namespace shdfnd +} // namespace physx diff --git a/NvCloth/src/ps/windows/PsWindowsAtomic.cpp b/NvCloth/src/ps/windows/PsWindowsAtomic.cpp new file mode 100644 index 0000000..c78728f --- /dev/null +++ b/NvCloth/src/ps/windows/PsWindowsAtomic.cpp @@ -0,0 +1,96 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved. +// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. +// Copyright (c) 2001-2004 NovodeX AG. All rights reserved. + +#include "PsWindowsInclude.h" +#include "NvCloth/ps/PsAtomic.h" + +namespace physx +{ +namespace shdfnd +{ + +int32_t atomicExchange(volatile int32_t* val, int32_t val2) +{ + return (int32_t)InterlockedExchange((volatile LONG*)val, (LONG)val2); +} + +int32_t atomicCompareExchange(volatile int32_t* dest, int32_t exch, int32_t comp) +{ + return (int32_t)InterlockedCompareExchange((volatile LONG*)dest, exch, comp); +} + +void* atomicCompareExchangePointer(volatile void** dest, void* exch, void* comp) +{ + return InterlockedCompareExchangePointer((volatile PVOID*)dest, exch, comp); +} + +int32_t atomicIncrement(volatile int32_t* val) +{ + return (int32_t)InterlockedIncrement((volatile LONG*)val); +} + +int32_t atomicDecrement(volatile int32_t* val) +{ + return (int32_t)InterlockedDecrement((volatile LONG*)val); +} + +int32_t atomicAdd(volatile int32_t* val, int32_t delta) +{ + LONG newValue, oldValue; + do + { + oldValue = *val; + newValue = oldValue + delta; + } while(InterlockedCompareExchange((volatile LONG*)val, newValue, oldValue) != oldValue); + + return newValue; +} + +int32_t atomicMax(volatile int32_t* val, int32_t val2) +{ + // Could do this more efficiently in asm... + + LONG newValue, oldValue; + + do + { + oldValue = *val; + + if(val2 > oldValue) + newValue = val2; + else + newValue = oldValue; + + } while(InterlockedCompareExchange((volatile LONG*)val, newValue, oldValue) != oldValue); + + return newValue; +} + +} // namespace shdfnd +} // namespace physx diff --git a/NvCloth/src/ps/windows/PsWindowsFPU.h b/NvCloth/src/ps/windows/PsWindowsFPU.h new file mode 100644 index 0000000..d85e531 --- /dev/null +++ b/NvCloth/src/ps/windows/PsWindowsFPU.h @@ -0,0 +1,51 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved. +// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. +// Copyright (c) 2001-2004 NovodeX AG. All rights reserved. + +#ifndef PSFOUNDATION_PSWINDOWSFPU_H +#define PSFOUNDATION_PSWINDOWSFPU_H + +PX_INLINE physx::shdfnd::SIMDGuard::SIMDGuard() +{ +#if !PX_ARM + mControlWord = _mm_getcsr(); + // set default (disable exceptions: _MM_MASK_MASK) and FTZ (_MM_FLUSH_ZERO_ON), DAZ (_MM_DENORMALS_ZERO_ON: (1<<6)) + _mm_setcsr(_MM_MASK_MASK | _MM_FLUSH_ZERO_ON | (1 << 6)); +#endif +} + +PX_INLINE physx::shdfnd::SIMDGuard::~SIMDGuard() +{ +#if !PX_ARM + // restore control word and clear any exception flags + // (setting exception state flags cause exceptions on the first following fp operation) + _mm_setcsr(mControlWord & ~_MM_EXCEPT_MASK); +#endif +} + +#endif // #ifndef PSFOUNDATION_PSWINDOWSFPU_H diff --git a/NvCloth/src/ps/windows/PsWindowsInclude.h b/NvCloth/src/ps/windows/PsWindowsInclude.h new file mode 100644 index 0000000..066abe7 --- /dev/null +++ b/NvCloth/src/ps/windows/PsWindowsInclude.h @@ -0,0 +1,96 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved. +// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. +// Copyright (c) 2001-2004 NovodeX AG. All rights reserved. + +#ifndef PSFOUNDATION_PSWINDOWSINCLUDE_H +#define PSFOUNDATION_PSWINDOWSINCLUDE_H + +#include "NvCloth/ps/Ps.h" + +#ifndef _WIN32 +#error "This file should only be included by Windows builds!!" +#endif + +#ifdef _WINDOWS_ // windows already included +#error "Only include windows.h through this file!!" +#endif + +// We only support >= Windows XP, and we need this for critical section and +#define _WIN32_WINNT 0x0501 + +// turn off as much as we can for windows. All we really need is the thread functions(critical sections/Interlocked* +// etc) +#define NOGDICAPMASKS +#define NOVIRTUALKEYCODES +#define NOWINMESSAGES +#define NOWINSTYLES +#define NOSYSMETRICS +#define NOMENUS +#define NOICONS +#define NOKEYSTATES +#define NOSYSCOMMANDS +#define NORASTEROPS +#define NOSHOWWINDOW +#define NOATOM +#define NOCLIPBOARD +#define NOCOLOR +#define NOCTLMGR +#define NODRAWTEXT +#define NOGDI +#define NOMB +#define NOMEMMGR +#define NOMETAFILE +#define NOMINMAX +#define NOOPENFILE +#define NOSCROLL +#define NOSERVICE +#define NOSOUND +#define NOTEXTMETRIC +#define NOWH +#define NOWINOFFSETS +#define NOCOMM +#define NOKANJI +#define NOHELP +#define NOPROFILER +#define NODEFERWINDOWPOS +#define NOMCX +#define WIN32_LEAN_AND_MEAN +#define NOUSER +#define NONLS +#define NOMSG + +#pragma warning(push) +#pragma warning(disable : 4668) //'symbol' is not defined as a preprocessor macro, replacing with '0' for 'directives' +#include <windows.h> +#pragma warning(pop) + +#if PX_SSE2 +#include <xmmintrin.h> +#endif + +#endif // #ifndef PSFOUNDATION_PSWINDOWSINCLUDE_H diff --git a/NvCloth/src/scalar/SwCollisionHelpers.h b/NvCloth/src/scalar/SwCollisionHelpers.h index c86d939..cad06e3 100644 --- a/NvCloth/src/scalar/SwCollisionHelpers.h +++ b/NvCloth/src/scalar/SwCollisionHelpers.h @@ -29,7 +29,7 @@ #pragma once -#include "PsMathUtils.h" +#include "NvCloth/ps/PsMathUtils.h" namespace nv { |