aboutsummaryrefslogtreecommitdiff
path: root/PxShared/src
diff options
context:
space:
mode:
authorsschirm <[email protected]>2017-02-27 16:40:12 +0100
committersschirm <[email protected]>2017-03-01 18:04:26 +0100
commit7840347c32755e94a807f978f1cbb558717ac8cf (patch)
tree295cd3ca93a45f8fcc43cf3cbf3887c0e0c5526b /PxShared/src
parentPre-release comments marking end of beta. (diff)
downloadphysx-3.4-7840347c32755e94a807f978f1cbb558717ac8cf.tar.xz
physx-3.4-7840347c32755e94a807f978f1cbb558717ac8cf.zip
PhysX 3.4, APEX 1.4 final release @21757769v3.4.0-rc-2
Diffstat (limited to 'PxShared/src')
-rw-r--r--PxShared/src/NvSimd/include/NvSimdTypes.h8
-rw-r--r--PxShared/src/foundation/include/PsAllocator.h3
-rw-r--r--PxShared/src/foundation/include/PsAoS.h2
-rw-r--r--PxShared/src/foundation/include/PsFPU.h2
-rw-r--r--PxShared/src/foundation/include/PsInlineAoS.h2
-rw-r--r--PxShared/src/foundation/include/PsIntrinsics.h2
-rw-r--r--PxShared/src/foundation/include/PsMathUtils.h5
-rw-r--r--PxShared/src/foundation/include/PsThread.h4
-rw-r--r--PxShared/src/foundation/include/PsVecMath.h13
-rw-r--r--PxShared/src/foundation/include/PsVecMathAoSScalarInline.h8
-rw-r--r--PxShared/src/foundation/include/unix/PsUnixFPU.h3
-rw-r--r--PxShared/src/foundation/include/unix/neon/PsUnixNeonInlineAoS.h5
-rw-r--r--PxShared/src/foundation/include/unix/sse2/PsUnixSse2AoS.h2
-rw-r--r--PxShared/src/foundation/include/unix/sse2/PsUnixSse2InlineAoS.h18
-rw-r--r--PxShared/src/foundation/src/PsAssert.cpp4
-rw-r--r--PxShared/src/foundation/src/unix/PsUnixAtomic.cpp4
-rw-r--r--PxShared/src/foundation/src/unix/PsUnixSList.cpp2
-rw-r--r--PxShared/src/foundation/src/unix/PsUnixThread.cpp4
-rw-r--r--PxShared/src/pvd/include/PxProfileAllocatorWrapper.h2
19 files changed, 74 insertions, 19 deletions
diff --git a/PxShared/src/NvSimd/include/NvSimdTypes.h b/PxShared/src/NvSimd/include/NvSimdTypes.h
index e12afb85..d7b92647 100644
--- a/PxShared/src/NvSimd/include/NvSimdTypes.h
+++ b/PxShared/src/NvSimd/include/NvSimdTypes.h
@@ -78,7 +78,7 @@ void foo(const float* ptr)
#else
#define NV_SIMD_SSE2 0
#endif
-#if defined (_M_ARM) || defined (__ARM_NEON__)
+#if defined (_M_ARM) || defined (__ARM_NEON__) || defined (__ARM_NEON)
#define NV_SIMD_NEON 1
#else
#define NV_SIMD_NEON 0
@@ -99,7 +99,11 @@ void foo(const float* ptr)
// support shift by vector operarations
#define NV_SIMD_SHIFT_BY_VECTOR (NV_SIMD_NEON)
// support inline assembler
-#define NV_SIMD_INLINE_ASSEMBLER !(defined _M_ARM || defined SN_TARGET_PSP2 || defined __arm64__)
+#if defined _M_ARM || defined SN_TARGET_PSP2 || defined __arm64__ || defined __aarch64__
+#define NV_SIMD_INLINE_ASSEMBLER 0
+#else
+#define NV_SIMD_INLINE_ASSEMBLER 1
+#endif
/*! \def NV_SIMD_USE_NAMESPACE
* \brief Set to 1 to define the SIMD library types and functions inside the nvidia::simd namespace.
diff --git a/PxShared/src/foundation/include/PsAllocator.h b/PxShared/src/foundation/include/PsAllocator.h
index 3510ae88..cbf32d38 100644
--- a/PxShared/src/foundation/include/PsAllocator.h
+++ b/PxShared/src/foundation/include/PsAllocator.h
@@ -108,6 +108,9 @@
#elif PX_XBOXONE
#include <malloc.h>
#define PxAlloca(x) alloca(x)
+#elif PX_NX
+#include <malloc.h>
+#define PxAlloca(x) alloca(x)
#endif
#define PxAllocaAligned(x, alignment) ((size_t(PxAlloca(x + alignment)) + (alignment - 1)) & ~size_t(alignment - 1))
diff --git a/PxShared/src/foundation/include/PsAoS.h b/PxShared/src/foundation/include/PsAoS.h
index eed03518..641a40a3 100644
--- a/PxShared/src/foundation/include/PsAoS.h
+++ b/PxShared/src/foundation/include/PsAoS.h
@@ -34,7 +34,7 @@
#if PX_WINDOWS && !PX_NEON
#include "windows/PsWindowsAoS.h"
-#elif(PX_UNIX_FAMILY || PX_PS4)
+#elif(PX_UNIX_FAMILY || PX_PS4 || PX_NX)
#include "unix/PsUnixAoS.h"
#elif PX_XBOXONE
#include "XboxOne/PsXboxOneAoS.h"
diff --git a/PxShared/src/foundation/include/PsFPU.h b/PxShared/src/foundation/include/PsFPU.h
index 4687fe60..fd990a82 100644
--- a/PxShared/src/foundation/include/PsFPU.h
+++ b/PxShared/src/foundation/include/PsFPU.h
@@ -89,7 +89,7 @@ PX_FOUNDATION_API void disableFPExceptions();
#if PX_WINDOWS_FAMILY || PX_XBOXONE
#include "windows/PsWindowsFPU.h"
-#elif PX_LINUX || PX_PS4 || PX_OSX
+#elif (PX_LINUX && PX_SSE2) || PX_PS4 || PX_OSX
#include "unix/PsUnixFPU.h"
#else
PX_INLINE physx::shdfnd::SIMDGuard::SIMDGuard()
diff --git a/PxShared/src/foundation/include/PsInlineAoS.h b/PxShared/src/foundation/include/PsInlineAoS.h
index 27b4470d..6d43607f 100644
--- a/PxShared/src/foundation/include/PsInlineAoS.h
+++ b/PxShared/src/foundation/include/PsInlineAoS.h
@@ -35,7 +35,7 @@
#if PX_WINDOWS
#include "windows/PsWindowsTrigConstants.h"
#include "windows/PsWindowsInlineAoS.h"
-#elif(PX_UNIX_FAMILY || PX_PS4)
+#elif(PX_UNIX_FAMILY || PX_PS4 || PX_NX)
#include "unix/PsUnixTrigConstants.h"
#include "unix/PsUnixInlineAoS.h"
#elif PX_XBOXONE
diff --git a/PxShared/src/foundation/include/PsIntrinsics.h b/PxShared/src/foundation/include/PsIntrinsics.h
index 8cd64dee..1e1b9d1a 100644
--- a/PxShared/src/foundation/include/PsIntrinsics.h
+++ b/PxShared/src/foundation/include/PsIntrinsics.h
@@ -38,6 +38,8 @@
#include "unix/PsUnixIntrinsics.h"
#elif PX_XBOXONE
#include "XboxOne/PsXboxOneIntrinsics.h"
+#elif PX_NX
+#include "nx/PsNXIntrinsics.h"
#else
#error "Platform not supported!"
#endif
diff --git a/PxShared/src/foundation/include/PsMathUtils.h b/PxShared/src/foundation/include/PsMathUtils.h
index 94313f1c..794419be 100644
--- a/PxShared/src/foundation/include/PsMathUtils.h
+++ b/PxShared/src/foundation/include/PsMathUtils.h
@@ -329,6 +329,7 @@ PX_CUDA_CALLABLE PX_FORCE_INLINE bool sameDirection(const PxVec3& d, const PxVec
//! Checks 2 values have different signs
PX_CUDA_CALLABLE PX_FORCE_INLINE IntBool differentSign(PxReal f0, PxReal f1)
{
+#if !PX_EMSCRIPTEN
union
{
PxU32 u;
@@ -337,6 +338,10 @@ PX_CUDA_CALLABLE PX_FORCE_INLINE IntBool differentSign(PxReal f0, PxReal f1)
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)
diff --git a/PxShared/src/foundation/include/PsThread.h b/PxShared/src/foundation/include/PsThread.h
index b6158f17..8ba553af 100644
--- a/PxShared/src/foundation/include/PsThread.h
+++ b/PxShared/src/foundation/include/PsThread.h
@@ -41,7 +41,7 @@
#if PX_WINDOWS_FAMILY || PX_XBOXONE
#define PxSpinLockPause() __asm pause
-#elif PX_LINUX || PX_ANDROID || PX_PS4 || PX_APPLE_FAMILY
+#elif PX_LINUX || PX_ANDROID || PX_PS4 || PX_APPLE_FAMILY || PX_NX
#define PxSpinLockPause() asm("nop")
#else
#error "Platform not supported!"
@@ -173,7 +173,7 @@ class PX_FOUNDATION_API ThreadImpl
Change the affinity mask for this thread. The mask is a platform
specific value.
- On Windows, Linux, PS4 and XboxOne platforms, each set mask bit represents
+ On Windows, Linux, PS4, XboxOne and NX platforms, each set mask bit represents
the index of a logical processor that the OS may schedule thread execution on.
Bits outside the range of valid logical processors may be ignored or cause
the function to return an error.
diff --git a/PxShared/src/foundation/include/PsVecMath.h b/PxShared/src/foundation/include/PsVecMath.h
index 499af335..4e891d8f 100644
--- a/PxShared/src/foundation/include/PsVecMath.h
+++ b/PxShared/src/foundation/include/PsVecMath.h
@@ -47,23 +47,28 @@
// all unknown/experimental cases should better default to NO SIMD.
// enable/disable SIMD
-#if PX_INTEL_FAMILY
+#if !defined(PX_SIMD_DISABLED)
+#if PX_INTEL_FAMILY && (!defined(__EMSCRIPTEN__) || defined(__SSE2__))
#define COMPILE_VECTOR_INTRINSICS 1
#elif PX_ANDROID&& PX_NEON
#define COMPILE_VECTOR_INTRINSICS 1
#elif PX_IOS&& PX_NEON
#define COMPILE_VECTOR_INTRINSICS 1
+#elif PX_NX
+#define COMPILE_VECTOR_INTRINSICS 1
+#else
+#define COMPILE_VECTOR_INTRINSICS 0
+#endif
#else
#define COMPILE_VECTOR_INTRINSICS 0
#endif
-#if defined(COMPILE_VECTOR_INTRINSICS) && PX_INTEL_FAMILY&&(PX_UNIX_FAMILY || PX_PS4)
+#if COMPILE_VECTOR_INTRINSICS && PX_INTEL_FAMILY&&(PX_UNIX_FAMILY || PX_PS4)
// only SSE2 compatible platforms should reach this
#if PX_EMSCRIPTEN
#include <emmintrin.h>
-#else
-#include <xmmintrin.h>
#endif
+#include <xmmintrin.h>
#endif
namespace physx
diff --git a/PxShared/src/foundation/include/PsVecMathAoSScalarInline.h b/PxShared/src/foundation/include/PsVecMathAoSScalarInline.h
index 854190e7..00e179ab 100644
--- a/PxShared/src/foundation/include/PsVecMathAoSScalarInline.h
+++ b/PxShared/src/foundation/include/PsVecMathAoSScalarInline.h
@@ -479,7 +479,7 @@ PX_FORCE_INLINE PxU32 FAllEq(const FloatV a, const FloatV b)
PX_FORCE_INLINE FloatV FRound(const FloatV a)
{
- return floor(a.x + 0.5f);
+ return floorf(a.x + 0.5f);
}
PX_FORCE_INLINE FloatV FSin(const FloatV a)
@@ -816,7 +816,7 @@ PX_FORCE_INLINE PxU32 V3AllEq(const Vec3V a, const Vec3V b)
PX_FORCE_INLINE Vec3V V3Round(const Vec3V a)
{
- return Vec3V(floor(a.x + 0.5f), floor(a.y + 0.5f), floor(a.z + 0.5f));
+ return Vec3V(floorf(a.x + 0.5f), floorf(a.y + 0.5f), floorf(a.z + 0.5f));
}
PX_FORCE_INLINE Vec3V V3Sin(const Vec3V a)
@@ -1271,7 +1271,7 @@ PX_FORCE_INLINE Vec4V V4Clamp(const Vec4V a, const Vec4V minV, const Vec4V maxV)
PX_FORCE_INLINE Vec4V V4Round(const Vec4V a)
{
- return Vec4V(floor(a.x + 0.5f), floor(a.y + 0.5f), floor(a.z + 0.5f), floor(a.w + 0.5f));
+ return Vec4V(floorf(a.x + 0.5f), floorf(a.y + 0.5f), floorf(a.z + 0.5f), floorf(a.w + 0.5f));
}
PX_FORCE_INLINE Vec4V V4Sin(const Vec4V a)
@@ -1479,7 +1479,7 @@ PX_FORCE_INLINE BoolV BOr(const BoolV a, const BoolV b)
PX_FORCE_INLINE PxU32 BAllEq(const BoolV a, const BoolV b)
{
- return (a.ux == b.ux && a.uy == b.uy && a.uz == b.uz && a.uw == b.uw ? TRUE_TO_U32 : FALSE_TO_U32);
+ return (a.ux == b.ux && a.uy == b.uy && a.uz == b.uz && a.uw == b.uw ? 1 : 0);
}
PX_FORCE_INLINE PxU32 BAllEqTTTT(const BoolV a)
diff --git a/PxShared/src/foundation/include/unix/PsUnixFPU.h b/PxShared/src/foundation/include/unix/PsUnixFPU.h
index 2aaabd77..edd55226 100644
--- a/PxShared/src/foundation/include/unix/PsUnixFPU.h
+++ b/PxShared/src/foundation/include/unix/PsUnixFPU.h
@@ -35,6 +35,9 @@
#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>
diff --git a/PxShared/src/foundation/include/unix/neon/PsUnixNeonInlineAoS.h b/PxShared/src/foundation/include/unix/neon/PsUnixNeonInlineAoS.h
index 00683082..2a0578d1 100644
--- a/PxShared/src/foundation/include/unix/neon/PsUnixNeonInlineAoS.h
+++ b/PxShared/src/foundation/include/unix/neon/PsUnixNeonInlineAoS.h
@@ -42,7 +42,12 @@
// "exact"
#define VRECIPQ recipq_newton<4>
+#if PX_NX
+// StabilizationTests.AveragePoint needs more precision to succeed.
+#define VRECIP recip_newton<5>
+#else
#define VRECIP recip_newton<4>
+#endif
#define VRECIPSQRTQ rsqrtq_newton<4>
#define VRECIPSQRT rsqrt_newton<4>
diff --git a/PxShared/src/foundation/include/unix/sse2/PsUnixSse2AoS.h b/PxShared/src/foundation/include/unix/sse2/PsUnixSse2AoS.h
index 1e118c37..9c76438d 100644
--- a/PxShared/src/foundation/include/unix/sse2/PsUnixSse2AoS.h
+++ b/PxShared/src/foundation/include/unix/sse2/PsUnixSse2AoS.h
@@ -35,7 +35,7 @@
#if !COMPILE_VECTOR_INTRINSICS
#error Vector intrinsics should not be included when using scalar implementation.
#endif
-#ifdef __EMSCRIPTEN__
+#if PX_EMSCRIPTEN
typedef int8_t __int8_t;
typedef int16_t __int16_t;
typedef int32_t __int32_t;
diff --git a/PxShared/src/foundation/include/unix/sse2/PsUnixSse2InlineAoS.h b/PxShared/src/foundation/include/unix/sse2/PsUnixSse2InlineAoS.h
index 6986b4ca..03555381 100644
--- a/PxShared/src/foundation/include/unix/sse2/PsUnixSse2InlineAoS.h
+++ b/PxShared/src/foundation/include/unix/sse2/PsUnixSse2InlineAoS.h
@@ -165,9 +165,15 @@ PX_FORCE_INLINE PxU32 FiniteTestEq(const Vec4V a, const Vec4V b)
_mm_comieq_ss(_mm_shuffle_ps(a1, a1, _MM_SHUFFLE(3, 3, 3, 3)), _mm_shuffle_ps(b1, b1, _MM_SHUFFLE(3, 3, 3, 3))));
}
+#if !PX_EMSCRIPTEN
const PX_ALIGN(16, PxF32 gMaskXYZ[4]) = { physx::PxUnionCast<PxF32>(0xffffffff), physx::PxUnionCast<PxF32>(0xffffffff),
physx::PxUnionCast<PxF32>(0xffffffff), 0 };
}
+#else
+// emscripten doesn't like the PxUnionCast data structure
+// the following is what windows and xbox does -- using these for emscripten
+const PX_ALIGN(16, PxU32 gMaskXYZ[4]) = { 0xffffffff, 0xffffffff, 0xffffffff, 0 }; }
+#endif
namespace _VecMathTests
{
@@ -341,7 +347,11 @@ PX_FORCE_INLINE BoolV BLoad(const bool f)
PX_FORCE_INLINE Vec3V V3LoadA(const PxVec3& f)
{
ASSERT_ISALIGNED16(const_cast<PxVec3*>(&f));
+#if !PX_EMSCRIPTEN
return _mm_and_ps(reinterpret_cast<const Vec3V&>(f), V4LoadA(internalUnitSSE2Simd::gMaskXYZ));
+#else
+ return _mm_and_ps((Vec3V&)f, (VecI32V&)internalUnitSSE2Simd::gMaskXYZ);
+#endif
}
PX_FORCE_INLINE Vec3V V3LoadU(const PxVec3& f)
@@ -358,7 +368,11 @@ PX_FORCE_INLINE Vec3V V3LoadUnsafeA(const PxVec3& f)
PX_FORCE_INLINE Vec3V V3LoadA(const PxF32* const f)
{
ASSERT_ISALIGNED16(const_cast<PxF32*>(f));
+#if !PX_EMSCRIPTEN
return _mm_and_ps(V4LoadA(f), V4LoadA(internalUnitSSE2Simd::gMaskXYZ));
+#else
+ return _mm_and_ps((Vec3V&)*f, (VecI32V&)internalUnitSSE2Simd::gMaskXYZ);
+#endif
}
PX_FORCE_INLINE Vec3V V3LoadU(const PxF32* const i)
@@ -1767,7 +1781,11 @@ PX_FORCE_INLINE Vec4V V4SetZ(const Vec4V v, const FloatV f)
PX_FORCE_INLINE Vec4V V4ClearW(const Vec4V v)
{
+#if !PX_EMSCRIPTEN
return _mm_and_ps(v, V4LoadA(internalUnitSSE2Simd::gMaskXYZ));
+#else
+ return _mm_and_ps(v, (VecI32V&)internalUnitSSE2Simd::gMaskXYZ);
+#endif
}
PX_FORCE_INLINE Vec4V V4PermYXWZ(const Vec4V a)
diff --git a/PxShared/src/foundation/src/PsAssert.cpp b/PxShared/src/foundation/src/PsAssert.cpp
index 41e0c359..30703830 100644
--- a/PxShared/src/foundation/src/PsAssert.cpp
+++ b/PxShared/src/foundation/src/PsAssert.cpp
@@ -34,6 +34,8 @@
#if PX_WINDOWS_FAMILY
#include <crtdbg.h>
+#elif PX_NX
+#include "nx/PsNXAbort.h"
#endif
namespace
@@ -61,6 +63,8 @@ class DefaultAssertHandler : public physx::PxAssertHandler
__debugbreak();
#elif PX_WINDOWS_FAMILY&& PX_CHECKED
__debugbreak();
+#elif PX_NX
+ abort(buffer);
#else
abort();
#endif
diff --git a/PxShared/src/foundation/src/unix/PsUnixAtomic.cpp b/PxShared/src/foundation/src/unix/PsUnixAtomic.cpp
index 55ec8840..d4e933b7 100644
--- a/PxShared/src/foundation/src/unix/PsUnixAtomic.cpp
+++ b/PxShared/src/foundation/src/unix/PsUnixAtomic.cpp
@@ -29,7 +29,11 @@
#include "Ps.h"
#include "PsAtomic.h"
+#if ! PX_EMSCRIPTEN
#define PAUSE() asm("nop")
+#else
+#define PAUSE()
+#endif
namespace physx
{
diff --git a/PxShared/src/foundation/src/unix/PsUnixSList.cpp b/PxShared/src/foundation/src/unix/PsUnixSList.cpp
index 79fc809b..5dd8ac37 100644
--- a/PxShared/src/foundation/src/unix/PsUnixSList.cpp
+++ b/PxShared/src/foundation/src/unix/PsUnixSList.cpp
@@ -33,7 +33,7 @@
#include "PsThread.h"
#include <pthread.h>
-#if PX_IOS
+#if PX_IOS || PX_EMSCRIPTEN
#define USE_MUTEX
#endif
diff --git a/PxShared/src/foundation/src/unix/PsUnixThread.cpp b/PxShared/src/foundation/src/unix/PsUnixThread.cpp
index 8c0afa3b..cb369e0f 100644
--- a/PxShared/src/foundation/src/unix/PsUnixThread.cpp
+++ b/PxShared/src/foundation/src/unix/PsUnixThread.cpp
@@ -53,6 +53,8 @@
#if PX_APPLE_FAMILY
#include <sys/types.h>
#include <sys/sysctl.h>
+#include <TargetConditionals.h>
+#include <pthread.h>
#endif
// fwd
@@ -102,7 +104,7 @@ _ThreadImpl* getThread(ThreadImpl* impl)
static void setTid(_ThreadImpl& threadImpl)
{
// query TID
-#if PX_PS4
+#if PX_PS4 || (defined (TARGET_OS_TV) && TARGET_OS_TV)
// AM: TODO: neither of the below are implemented
#elif PX_APPLE_FAMILY
threadImpl.tid = syscall(SYS_gettid);
diff --git a/PxShared/src/pvd/include/PxProfileAllocatorWrapper.h b/PxShared/src/pvd/include/PxProfileAllocatorWrapper.h
index 5b962dfd..22903ec3 100644
--- a/PxShared/src/pvd/include/PxProfileAllocatorWrapper.h
+++ b/PxShared/src/pvd/include/PxProfileAllocatorWrapper.h
@@ -74,7 +74,7 @@ namespace physx { namespace profile {
{
static const char* getName()
{
-#if PX_LINUX || PX_ANDROID || PX_PS4 || PX_IOS || PX_OSX || PX_EMSCRIPTEN
+#if PX_LINUX || PX_ANDROID || PX_PS4 || PX_IOS || PX_OSX || PX_EMSCRIPTEN || PX_NX
return __PRETTY_FUNCTION__;
#else
return typeid(T).name();