diff --git a/externals/cmakemodules/GetCompilerAndPlatform.cmake b/externals/cmakemodules/GetCompilerAndPlatform.cmake index 3ab5cfbfa..ace464b01 100644 --- a/externals/cmakemodules/GetCompilerAndPlatform.cmake +++ b/externals/cmakemodules/GetCompilerAndPlatform.cmake @@ -103,7 +103,13 @@ FUNCTION (GetPlatformBinName PLATFORM_BIN_NAME LIBPATH_SUFFIX) ELSEIF(TARGET_BUILD_PLATFORM STREQUAL "uwp") SET(RETVAL "uwp.${PX_OUTPUT_ARCH}_${LIBPATH_SUFFIX}.${COMPILER}") ELSEIF(TARGET_BUILD_PLATFORM STREQUAL "mac") - SET(RETVAL "mac.x86_${LIBPATH_SUFFIX}") + IF(PX_OUTPUT_ARCH STREQUAL "x86") + SET(RETVAL "mac.x86_${LIBPATH_SUFFIX}") + ELSEIF(PX_OUTPUT_ARCH STREQUAL "arm") + SET(RETVAL "mac.arm_${LIBPATH_SUFFIX}") + ELSE() + SET(RETVAL "mac.universal") + ENDIF() ELSEIF(TARGET_BUILD_PLATFORM STREQUAL "ios") SET(RETVAL "ios.arm_${LIBPATH_SUFFIX}") ELSEIF(TARGET_BUILD_PLATFORM STREQUAL "ps4") diff --git a/externals/cmakemodules/NvidiaBuildOptions.cmake b/externals/cmakemodules/NvidiaBuildOptions.cmake index 46cb7d637..8ca7cbe97 100644 --- a/externals/cmakemodules/NvidiaBuildOptions.cmake +++ b/externals/cmakemodules/NvidiaBuildOptions.cmake @@ -102,7 +102,8 @@ IF(NV_USE_GAMEWORKS_OUTPUT_DIRS) SET(PX_ROOT_LIB_DIR "bin/${PLATFORM_BIN_NAME}" CACHE INTERNAL "Relative root of the lib output directory") SET(PX_ROOT_EXE_DIR "bin/${PLATFORM_BIN_NAME}" CACHE INTERNAL "Relative root dir of the exe output directory") - IF (NOT DEFINED PX_OUTPUT_ARCH) # platforms with fixed arch like ps4 dont need to have arch defined + # platforms with fixed arch like ps4 dont need to have arch defined + IF (NOT DEFINED PX_OUTPUT_ARCH AND NOT (NV_FORCE_64BIT_SUFFIX OR NV_FORCE_32BIT_SUFFIX)) SET(EXE_SUFFIX "") ENDIF() @@ -201,7 +202,8 @@ IF(NV_APPEND_CONFIG_NAME) 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 + # platforms with fixed arch like ps4 dont need to have arch defined, then dont add bitness + IF (DEFINED PX_OUTPUT_ARCH OR NV_FORCE_64BIT_SUFFIX OR NV_FORCE_32BIT_SUFFIX) SET(CMAKE_DEBUG_POSTFIX "_${LIBPATH_SUFFIX}") SET(CMAKE_PROFILE_POSTFIX "_${LIBPATH_SUFFIX}") SET(CMAKE_CHECKED_POSTFIX "_${LIBPATH_SUFFIX}") diff --git a/physx/source/compiler/cmake/mac/CMakeLists.txt b/physx/source/compiler/cmake/mac/CMakeLists.txt index 36799700b..bfd135769 100644 --- a/physx/source/compiler/cmake/mac/CMakeLists.txt +++ b/physx/source/compiler/cmake/mac/CMakeLists.txt @@ -25,10 +25,18 @@ ## ## Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved. -SET(OSX_BITNESS "-arch x86_64") -SET(CMAKE_OSX_ARCHITECTURES "x86_64") +IF(PX_OUTPUT_ARCH STREQUAL "x86") + SET(OSX_BITNESS "-arch x86_64 -msse2") + SET(CMAKE_OSX_ARCHITECTURES "x86_64") +ELSEIF(PX_OUTPUT_ARCH STREQUAL "arm") + SET(OSX_BITNESS "-arch arm64") + SET(CMAKE_OSX_ARCHITECTURES "arm64") +ELSE() + SET(OSX_BITNESS "-arch x86_64 -arch arm64 -msse2") + SET(CMAKE_OSX_ARCHITECTURES "x86_64;arm64") +ENDIF() -SET(PHYSX_CXX_FLAGS "${OSX_BITNESS} -msse2 -std=c++11 -fno-rtti -fno-exceptions -ffunction-sections -fdata-sections -Werror -ferror-limit=0 -Wall -Wextra -fstrict-aliasing -Wstrict-aliasing=2 -Weverything -Wno-unknown-warning-option -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 -Wno-zero-as-null-pointer-constant -Wno-atomic-implicit-seq-cst -gdwarf-2" CACHE INTERNAL "PhysX CXX") +SET(PHYSX_CXX_FLAGS "${OSX_BITNESS} -std=c++11 -fno-rtti -fno-exceptions -ffunction-sections -fdata-sections -Werror -ferror-limit=0 -Wall -Wextra -fstrict-aliasing -Wstrict-aliasing=2 -Weverything -Wno-unknown-warning-option -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 -Wno-zero-as-null-pointer-constant -Wno-atomic-implicit-seq-cst -gdwarf-2" CACHE INTERNAL "PhysX CXX") SET(CMAKE_SHARED_LINKER_FLAGS_CHECKED "") SET(CMAKE_SHARED_LINKER_FLAGS_PROFILE "") diff --git a/physx/source/foundation/include/PsVecMath.h b/physx/source/foundation/include/PsVecMath.h index 2718de2a8..03949acb1 100644 --- a/physx/source/foundation/include/PsVecMath.h +++ b/physx/source/foundation/include/PsVecMath.h @@ -56,6 +56,8 @@ #define COMPILE_VECTOR_INTRINSICS 1 #elif PX_IOS && PX_NEON #define COMPILE_VECTOR_INTRINSICS 1 +#elif PX_OSX && PX_NEON +#define COMPILE_VECTOR_INTRINSICS 1 #elif PX_SWITCH #define COMPILE_VECTOR_INTRINSICS 1 #else diff --git a/physx/source/foundation/include/unix/neon/PsUnixNeonInlineAoS.h b/physx/source/foundation/include/unix/neon/PsUnixNeonInlineAoS.h index 81b7a99d0..d3b1e2aed 100644 --- a/physx/source/foundation/include/unix/neon/PsUnixNeonInlineAoS.h +++ b/physx/source/foundation/include/unix/neon/PsUnixNeonInlineAoS.h @@ -3567,28 +3567,23 @@ PX_FORCE_INLINE VecU32V V4U32SplatElement(VecU32V a) template PX_FORCE_INLINE Vec4V V4SplatElement(Vec4V a) { -#if PX_UWP - if(index == 0) - { - return vdupq_lane_f32(vget_low_f32(a), 0); - } - else if (index == 1) - { - return vdupq_lane_f32(vget_low_f32(a), 1); - } -#else - if(index < 2) - { - return vdupq_lane_f32(vget_low_f32(a), index); - } -#endif - else if(index == 2) - { - return vdupq_lane_f32(vget_high_f32(a), 0); - } - else if(index == 3) - { - return vdupq_lane_f32(vget_high_f32(a), 1); + switch(index){ + case 0: + { + return vdupq_lane_f32(vget_low_f32(a), 0); + } + case 1: + { + return vdupq_lane_f32(vget_low_f32(a), 1); + } + case 2: + { + return vdupq_lane_f32(vget_high_f32(a), 0); + } + case 3: + { + return vdupq_lane_f32(vget_high_f32(a), 1); + } } } diff --git a/physx/source/foundation/src/unix/PsUnixFPU.cpp b/physx/source/foundation/src/unix/PsUnixFPU.cpp index eb2cd0506..5a223a107 100644 --- a/physx/source/foundation/src/unix/PsUnixFPU.cpp +++ b/physx/source/foundation/src/unix/PsUnixFPU.cpp @@ -33,7 +33,7 @@ PX_COMPILE_TIME_ASSERT(8 * sizeof(uint32_t) >= sizeof(fenv_t)); #endif -#if PX_OSX +#if PX_OSX && (PX_X86 || PX_X64) // osx defines SIMD as standard for floating point operations. #include #endif @@ -47,7 +47,7 @@ physx::shdfnd::FPUGuard::FPUGuard() #elif PX_PS4 // not supported PX_UNUSED(mControlWords); -#elif PX_OSX +#elif PX_OSX && (PX_X86 || PX_X64) mControlWords[0] = _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)); @@ -76,7 +76,7 @@ physx::shdfnd::FPUGuard::~FPUGuard() // not supported unless ARM_HARD_FLOAT is enabled. #elif PX_PS4 // not supported -#elif PX_OSX +#elif PX_OSX && (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(mControlWords[0] & ~_MM_EXCEPT_MASK); @@ -92,7 +92,7 @@ PX_FOUNDATION_API void physx::shdfnd::enableFPExceptions() #if PX_LINUX && !defined(__EMSCRIPTEN__) feclearexcept(FE_ALL_EXCEPT); feenableexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW); -#elif PX_OSX +#elif PX_OSX && (PX_X86 || PX_X64) // clear any pending exceptions // (setting exception state flags cause exceptions on the first following fp operation) uint32_t control = _mm_getcsr() & ~_MM_EXCEPT_MASK; @@ -108,7 +108,7 @@ PX_FOUNDATION_API void physx::shdfnd::disableFPExceptions() { #if PX_LINUX && !defined(__EMSCRIPTEN__) fedisableexcept(FE_ALL_EXCEPT); -#elif PX_OSX +#elif PX_OSX && (PX_X86 || PX_X64) // clear any pending exceptions // (setting exception state flags cause exceptions on the first following fp operation) uint32_t control = _mm_getcsr() & ~_MM_EXCEPT_MASK; diff --git a/physx/source/geomutils/include/GuSIMDHelpers.h b/physx/source/geomutils/include/GuSIMDHelpers.h index caa8e5a6d..733eca34c 100644 --- a/physx/source/geomutils/include/GuSIMDHelpers.h +++ b/physx/source/geomutils/include/GuSIMDHelpers.h @@ -72,7 +72,7 @@ namespace Gu const QuatV qV = V4LoadU(&q.x); Vec3V column0V, column1V, column2V; QuatGetMat33V(qV, column0V, column1V, column2V); -#if defined(PX_SIMD_DISABLED) || PX_ANDROID || (PX_LINUX && (PX_ARM || PX_A64)) || (PX_UWP && (PX_ARM || PX_A64)) +#if defined(PX_SIMD_DISABLED) || PX_ANDROID || (PX_LINUX && (PX_ARM || PX_A64)) || (PX_UWP && (PX_ARM || PX_A64)) || (PX_OSX && PX_A64) V3StoreU(column0V, column0); V3StoreU(column1V, column1); V3StoreU(column2V, column2); diff --git a/physx/source/physxextensions/src/serialization/SnSerialUtils.cpp b/physx/source/physxextensions/src/serialization/SnSerialUtils.cpp index 282b9810b..6fdfd8f66 100644 --- a/physx/source/physxextensions/src/serialization/SnSerialUtils.cpp +++ b/physx/source/physxextensions/src/serialization/SnSerialUtils.cpp @@ -39,7 +39,7 @@ using namespace physx; namespace { -#define SN_NUM_BINARY_PLATFORMS 16 +#define SN_NUM_BINARY_PLATFORMS 17 const PxU32 sBinaryPlatformTags[SN_NUM_BINARY_PLATFORMS] = { PX_MAKE_FOURCC('W','_','3','2'), @@ -58,6 +58,7 @@ const PxU32 sBinaryPlatformTags[SN_NUM_BINARY_PLATFORMS] = PX_MAKE_FOURCC('L','A','6','4'), PX_MAKE_FOURCC('W','A','3','2'), PX_MAKE_FOURCC('W','A','6','4'), + PX_MAKE_FOURCC('M','A','6','4'), }; const char* sBinaryPlatformNames[SN_NUM_BINARY_PLATFORMS] = @@ -78,6 +79,7 @@ const char* sBinaryPlatformNames[SN_NUM_BINARY_PLATFORMS] = "linuxaarch64", "uwparm", "uwparm64", + "macaarch64" }; } @@ -118,6 +120,8 @@ PxU32 getBinaryPlatformTag() return sBinaryPlatformTags[14]; #elif PX_UWP && PX_A64 return sBinaryPlatformTags[15]; +#elif PX_OSX && PX_A64 + return sBinaryPlatformTags[16]; #else #error Unknown binary platform #endif diff --git a/pxshared/include/foundation/PxPreprocessor.h b/pxshared/include/foundation/PxPreprocessor.h index 12d6147f1..4a7d0e93c 100644 --- a/pxshared/include/foundation/PxPreprocessor.h +++ b/pxshared/include/foundation/PxPreprocessor.h @@ -100,10 +100,15 @@ Operating system defines, see http://sourceforge.net/p/predef/wiki/OperatingSyst #define PX_ANDROID 1 #elif defined(__linux__) || defined (__EMSCRIPTEN__) // note: __ANDROID__ implies __linux__ #define PX_LINUX 1 -#elif defined(__APPLE__) && (defined(__arm__) || defined(__arm64__)) -#define PX_IOS 1 #elif defined(__APPLE__) -#define PX_OSX 1 + #include + #if TARGET_OS_IPHONE && TARGET_OS_MACCATALYST + #define PX_OSX 1 + #elif TARGET_OS_IPHONE + #define PX_IOS 1 + #else + #define PX_OSX 1 + #endif #elif defined(__ORBIS__) #define PX_PS4 1 #elif defined(__NX__)