diff options
| author | Marijn Tamis <[email protected]> | 2017-10-20 14:30:56 +0200 |
|---|---|---|
| committer | Marijn Tamis <[email protected]> | 2017-10-20 14:36:12 +0200 |
| commit | fabb251458f4a2d6d4f87dd36038fac2774b378c (patch) | |
| tree | 68a4a0ecd940dc949e0477d521d8c159968cfcd5 /NvCloth/compiler | |
| parent | NvCloth 1.1.2 Release. (22576033) (diff) | |
| download | nvcloth-1.1.3.tar.xz nvcloth-1.1.3.zip | |
NvCloth 1.1.3 Release. (23014067)v1.1.3
Diffstat (limited to 'NvCloth/compiler')
| -rw-r--r-- | NvCloth/compiler/cmake/Linux/NvCloth.cmake | 86 | ||||
| -rw-r--r-- | NvCloth/compiler/cmake/android/CMakeLists.txt | 62 | ||||
| -rw-r--r-- | NvCloth/compiler/cmake/android/NvCloth.cmake | 39 | ||||
| -rw-r--r-- | NvCloth/compiler/cmake/windows/NvCloth.cmake | 2 |
4 files changed, 188 insertions, 1 deletions
diff --git a/NvCloth/compiler/cmake/Linux/NvCloth.cmake b/NvCloth/compiler/cmake/Linux/NvCloth.cmake index 19038c6..323efd5 100644 --- a/NvCloth/compiler/cmake/Linux/NvCloth.cmake +++ b/NvCloth/compiler/cmake/Linux/NvCloth.cmake @@ -7,11 +7,26 @@ MESSAGE("[NvCloth]cmake/linux/NvCloth.cmake") SET(GW_DEPS_ROOT $ENV{GW_DEPS_ROOT}) FIND_PACKAGE(PxShared REQUIRED) +IF(NOT DEFINED NV_CLOTH_ENABLE_CUDA) +MESSAGE("NV_CLOTH_ENABLE_CUDA is not defined, setting to 0") +SET(NV_CLOTH_ENABLE_CUDA 0) +ENDIF() +IF(NOT DEFINED NV_CLOTH_ENABLE_DX11) +SET(NV_CLOTH_ENABLE_DX11 0) +ENDIF() + +MESSAGE("NV_CLOTH_ENABLE_CUDA = " ${NV_CLOTH_ENABLE_CUDA}) + +IF(${NV_CLOTH_ENABLE_CUDA}) +FIND_PACKAGE(CUDA 8 REQUIRED) +MESSAGE("Found CUDA:" ${CUDA_INCLUDE_DIRS}) +ENDIF() #FIND_PACKAGE(nvToolsExt REQUIRED) SET(NVCLOTH_PLATFORM_INCLUDES ${NVTOOLSEXT_INCLUDE_DIRS} + PRIVATE ${CUDA_INCLUDE_DIRS} ) SET(NVCLOTH_PLATFORM_SOURCE_FILES @@ -20,12 +35,71 @@ SET(NVCLOTH_PLATFORM_SOURCE_FILES #${PROJECT_ROOT_DIR}/src/neon/NeonSolverKernel.cpp #${PROJECT_ROOT_DIR}/src/neon/SwCollisionHelpers.h ) +IF(${NV_CLOTH_ENABLE_CUDA}) +LIST(APPEND NVCLOTH_PLATFORM_SOURCE_FILES + ${PROJECT_ROOT_DIR}/src/cuda/CuCheckSuccess.h + ${PROJECT_ROOT_DIR}/src/cuda/CuCloth.cpp + ${PROJECT_ROOT_DIR}/src/cuda/CuCloth.h + ${PROJECT_ROOT_DIR}/src/cuda/CuClothClone.cpp + ${PROJECT_ROOT_DIR}/src/cuda/CuClothData.cpp + ${PROJECT_ROOT_DIR}/src/cuda/CuClothData.h + ${PROJECT_ROOT_DIR}/src/cuda/CuCollision.h + ${PROJECT_ROOT_DIR}/src/cuda/CuContextLock.cpp + ${PROJECT_ROOT_DIR}/src/cuda/CuContextLock.h + ${PROJECT_ROOT_DIR}/src/cuda/CuDevicePointer.h + ${PROJECT_ROOT_DIR}/src/cuda/CuDeviceVector.h + ${PROJECT_ROOT_DIR}/src/cuda/CuFabric.cpp + ${PROJECT_ROOT_DIR}/src/cuda/CuFabric.h + ${PROJECT_ROOT_DIR}/src/cuda/CuFactory.cpp + ${PROJECT_ROOT_DIR}/src/cuda/CuFactory.h + ${PROJECT_ROOT_DIR}/src/cuda/CuPhaseConfig.h + ${PROJECT_ROOT_DIR}/src/cuda/CuPinnedAllocator.h + ${PROJECT_ROOT_DIR}/src/cuda/CuSelfCollision.h + ${PROJECT_ROOT_DIR}/src/cuda/CuSolver.cpp + ${PROJECT_ROOT_DIR}/src/cuda/CuSolver.h + ${PROJECT_ROOT_DIR}/src/cuda/CuSolverKernel.h + ${PROJECT_ROOT_DIR}/src/cuda/CuSolverKernelBlob.h +) +ENDIF() + + +IF(${NV_CLOTH_ENABLE_CUDA}) +set( + CUDA_NVCC_FLAGS + ${CUDA_NVCC_FLAGS}; + + # Options are documented on http://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html#command-option-types-and-notation + # Important: to be able to debug CUDA kernel (correct stepping and workable warp watches), + # you should add the -G (short for --device-debug) option to the line below. + # Don't forget to remove it afterwards, since the code execution will be very slow with this flag. + -use_fast_math -ftz=true -prec-div=false -prec-sqrt=false -lineinfo -gencode arch=compute_20,code=sm_20 -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_50,code=compute_50 -D_USE_MATH_DEFINES -DNDEBUG -DPX_PROFILE=1 +) +SET(NVCLOTH_CUDA_FILES + ${PROJECT_ROOT_DIR}/src/cuda/CuSolverKernel.cu +) +set(CUDA_BLOB "${PROJECT_ROOT_DIR}/src/cuda/CuSolverKernelBlob.h") +cuda_include_directories( + ${PXSHARED_ROOT_DIR}/include + ${PXSHARED_ROOT_DIR}/src/foundation/include + ${PROJECT_ROOT_DIR}/include/NvCloth +) +cuda_compile_fatbin(CUDA_FATBIN ${NVCLOTH_CUDA_FILES}) +SET(NVCLOTH_PLATFORM_SOURCE_FILES ${NVCLOTH_PLATFORM_SOURCE_FILES} ${CUDA_BLOB} ${NVCLOTH_CUDA_FILES}) +add_custom_command( + OUTPUT ${CUDA_BLOB} +COMMAND ${CUDA_TOOLKIT_ROOT_DIR}/bin/bin2c --name kCuSolverKernel ${CUDA_FATBIN} > ${CUDA_BLOB} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} +DEPENDS ${CUDA_FATBIN} + VERBATIM +) +ENDIF() + + # Use generator expressions to set config specific preprocessor definitions SET(NVCLOTH_COMPILE_DEFS NV_CLOTH_IMPORT=PX_DLL_EXPORT NV_CLOTH_ENABLE_DX11=0 - NV_CLOTH_ENABLE_CUDA=0 # Common to all configurations ${PHYSX_LINUX_COMPILE_DEFS};PX_PHYSX_CORE_EXPORTS @@ -35,6 +109,15 @@ SET(NVCLOTH_COMPILE_DEFS $<$<CONFIG:profile>:${PHYSX_LINUX_PROFILE_COMPILE_DEFS};PX_PHYSX_DLL_NAME_POSTFIX=PROFILE;> $<$<CONFIG:release>:${PHYSX_LINUX_RELEASE_COMPILE_DEFS};> ) +IF(${NV_CLOTH_ENABLE_CUDA}) +LIST(APPEND NVCLOTH_COMPILE_DEFS + NV_CLOTH_ENABLE_CUDA=1 +) +ELSE() +LIST(APPEND NVCLOTH_COMPILE_DEFS + NV_CLOTH_ENABLE_CUDA=0 +) +ENDIF() SET(NVCLOTH_LIBTYPE SHARED) @@ -46,6 +129,7 @@ INCLUDE(../common/NvCloth.cmake) # 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 LINK_FLAGS_DEBUG "" diff --git a/NvCloth/compiler/cmake/android/CMakeLists.txt b/NvCloth/compiler/cmake/android/CMakeLists.txt new file mode 100644 index 0000000..61a6892 --- /dev/null +++ b/NvCloth/compiler/cmake/android/CMakeLists.txt @@ -0,0 +1,62 @@ +cmake_minimum_required(VERSION 3.3) +MESSAGE("[NvCloth]cmake/android/CMakeList.txt") +include(../common/CMakeLists.txt) + +STRING(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LOWERCASE) + +IF(NOT DEFINED TARGET_BUILD_PLATFORM) # Not defined, default to android + SET(TARGET_BUILD_PLATFORM "android") +ENDIF() + +SET(PLATFORM_LIST android) + +IF (NOT ${TARGET_BUILD_PLATFORM} IN_LIST PLATFORM_LIST) + MESSAGE(FATAL_ERROR "Invalid platform:" ${TARGET_BUILD_PLATFORM}) +ENDIF() + +if(${ANDROID_ABI} STREQUAL "armeabi-v7a") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-rtti -fno-exceptions -ffunction-sections -fdata-sections -funwind-tables -fomit-frame-pointer -funswitch-loops -finline-limit=300 -fno-strict-aliasing -fstack-protector -Wno-invalid-offsetof ") +elseif(${ANDROID_ABI} STREQUAL "armeabi-v7a with NEON") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-rtti -ffast-math -fno-exceptions -ffunction-sections -funwind-tables -fomit-frame-pointer -funswitch-loops -finline-limit=300 -fno-strict-aliasing -fstack-protector -Wno-invalid-offsetof ") +elseif(${ANDROID_ABI} STREQUAL "arm64-v8a") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-rtti -fno-exceptions -ffunction-sections -fdata-sections -Wno-invalid-offsetof ") +elseif(${ANDROID_ABI} STREQUAL "x86") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-rtti -fno-exceptions -ffunction-sections -fdata-sections -Wno-invalid-offsetof -fpack-struct=8 -malign-double ") +elseif(${ANDROID_ABI} STREQUAL "x86_64") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-rtti -fno-exceptions -ffunction-sections -fdata-sections -Wno-invalid-offsetof -mstackrealign -msse3 ") +endif() + +SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g") +SET(CMAKE_CXX_FLAGS_CHECKED "-O3") +SET(CMAKE_CXX_FLAGS_PROFILE "-O3") +SET(CMAKE_CXX_FLAGS_RELEASE "-O3") + +# a version from pxshared +#SET(NVCLOTH_ANDROID_COMPILE_DEFS _LIB;__STDC_LIMIT_MACROS;) +# TODO: __ARM_NEON__;__arm64__ only on supporting archs +SET(NVCLOTH_ANDROID_COMPILE_DEFS _LIB;__STDC_LIMIT_MACROS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;PX_NVCLOTH_STATIC_LIB;__ARM_NEON__;__arm64__) +SET(NVCLOTH_ANDROID_DEBUG_COMPILE_DEFS _DEBUG;PX_DEBUG=1;PX_CHECKED=1) +SET(NVCLOTH_ANDROID_CHECKED_COMPILE_DEFS NDEBUG;PX_CHECKED=1) +SET(NVCLOTH_ANDROID_PROFILE_COMPILE_DEFS NDEBUG;PX_PROFILE=1) +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 new file mode 100644 index 0000000..544a3b5 --- /dev/null +++ b/NvCloth/compiler/cmake/android/NvCloth.cmake @@ -0,0 +1,39 @@ +# +# Build NvCloth +# + +SET(GW_DEPS_ROOT $ENV{GW_DEPS_ROOT}) + +SET(NVCLOTH_SOURCE_DIR ${PROJECT_SOURCE_DIR}/../../../) + +SET(NVCLOTH_PLATFORM_SOURCE_FILES + ${PROJECT_ROOT_DIR}/src/neon/NeonCollision.cpp + ${PROJECT_ROOT_DIR}/src/neon/NeonSelfCollision.cpp + ${PROJECT_ROOT_DIR}/src/neon/NeonSolverKernel.cpp + ${PROJECT_ROOT_DIR}/src/neon/SwCollisionHelpers.h +) + +SET(NVCLOTH_PLATFORM_INCLUDES + ${LL_SOURCE_DIR}/include/linux + ${ANDROID_NDK}/sources/android/cpufeatures +) + +# Use generator expressions to set config specific preprocessor definitions +SET(NVCLOTH_COMPILE_DEFS + ${NVCLOTH_ANDROID_COMPILE_DEFS}; + NvCloth_STATIC_LIB; # TODO: needed? + + NV_ANDROID + NV_SIMD_SCALAR=1 # always compile scalar paths on android, so we may use them as fallback + NV_CLOTH_IMPORT=PX_DLL_EXPORT + NV_CLOTH_ENABLE_DX11=0 + NV_CLOTH_ENABLE_CUDA=0 + + $<$<CONFIG:debug>:${NVCLOTH_ANDROID_DEBUG_COMPILE_DEFS};> + $<$<CONFIG:checked>:${NVCLOTH_ANDROID_CHECKED_COMPILE_DEFS};> + $<$<CONFIG:profile>:${NVCLOTH_ANDROID_PROFILE_COMPILE_DEFS};> + $<$<CONFIG:release>:${NVCLOTH_ANDROID_RELEASE_COMPILE_DEFS};> +) + +# include common low level settings +INCLUDE(../common/NvCloth.cmake) diff --git a/NvCloth/compiler/cmake/windows/NvCloth.cmake b/NvCloth/compiler/cmake/windows/NvCloth.cmake index a867a75..2a757f5 100644 --- a/NvCloth/compiler/cmake/windows/NvCloth.cmake +++ b/NvCloth/compiler/cmake/windows/NvCloth.cmake @@ -6,9 +6,11 @@ MESSAGE("[NvCloth]cmake/windows/NvCloth.cmake") IF(NOT DEFINED NV_CLOTH_ENABLE_CUDA) SET(NV_CLOTH_ENABLE_CUDA 1) +MESSAGE("Setting NV_CLOTH_ENABLE_CUDA 1") ENDIF() IF(NOT DEFINED NV_CLOTH_ENABLE_DX11) SET(NV_CLOTH_ENABLE_DX11 1) +MESSAGE("Setting NV_CLOTH_ENABLE_DX11 1") ENDIF() SET(GW_DEPS_ROOT $ENV{GW_DEPS_ROOT}) |