aboutsummaryrefslogtreecommitdiffstats
path: root/src/3rdparty/PhysX/0001-Add-support-for-building-on-macOS-ARM.patch
blob: b54f27a90108cc0b5d551fc01432218eef9a72a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
From 4ef908d6d777f643f846b8171b27902d218ac6ea Mon Sep 17 00:00:00 2001
From: Andy Nichols <andy.nichols@qt.io>
Date: Thu, 7 Apr 2022 16:09:32 +0200
Subject: [PATCH] Add support for building on macOS ARM

Includes the patch for use with the upstream repository
---
 .../PhysX/pxshared/include/foundation/PxPreprocessor.h |  2 +-
 .../PhysX/source/foundation/src/unix/PsUnixFPU.cpp     | 10 +++++-----
 .../PhysX/source/geomutils/include/GuSIMDHelpers.h     |  2 +-
 .../src/serialization/SnSerialUtils.cpp                |  5 ++++-
 4 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/src/3rdparty/PhysX/pxshared/include/foundation/PxPreprocessor.h b/src/3rdparty/PhysX/pxshared/include/foundation/PxPreprocessor.h
index 12d6147..3aea54e 100644
--- a/src/3rdparty/PhysX/pxshared/include/foundation/PxPreprocessor.h
+++ b/src/3rdparty/PhysX/pxshared/include/foundation/PxPreprocessor.h
@@ -100,7 +100,7 @@ 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__))
+#elif defined(TARGET_OS_IOS) && TARGET_OS_IOS && defined(__APPLE__) && (defined(__arm__) || defined(__arm64__))
 #define PX_IOS 1
 #elif defined(__APPLE__)
 #define PX_OSX 1
diff --git a/src/3rdparty/PhysX/source/foundation/src/unix/PsUnixFPU.cpp b/src/3rdparty/PhysX/source/foundation/src/unix/PsUnixFPU.cpp
index eb2cd05..f245f7a 100644
--- a/src/3rdparty/PhysX/source/foundation/src/unix/PsUnixFPU.cpp
+++ b/src/3rdparty/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 && !defined(PX_ARM_FAMILY)
 // osx defines SIMD as standard for floating point operations.
 #include <xmmintrin.h>
 #endif
@@ -47,7 +47,7 @@ physx::shdfnd::FPUGuard::FPUGuard()
 #elif PX_PS4
 	// not supported
 	PX_UNUSED(mControlWords);
-#elif PX_OSX
+#elif PX_OSX && !defined(PX_ARM_FAMILY)
 	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 && !defined(PX_ARM_FAMILY)
 	// 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 && !defined(PX_ARM_FAMILY)
 	// 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 && !defined(PX_ARM_FAMILY)
 	// 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/src/3rdparty/PhysX/source/geomutils/include/GuSIMDHelpers.h b/src/3rdparty/PhysX/source/geomutils/include/GuSIMDHelpers.h
index caa8e5a..5d22133 100644
--- a/src/3rdparty/PhysX/source/geomutils/include/GuSIMDHelpers.h
+++ b/src/3rdparty/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_ARM || PX_A64))
 			V3StoreU(column0V, column0);
 			V3StoreU(column1V, column1);
 			V3StoreU(column2V, column2);
diff --git a/src/3rdparty/PhysX/source/physxextensions/src/serialization/SnSerialUtils.cpp b/src/3rdparty/PhysX/source/physxextensions/src/serialization/SnSerialUtils.cpp
index 282b981..20b0102 100644
--- a/src/3rdparty/PhysX/source/physxextensions/src/serialization/SnSerialUtils.cpp
+++ b/src/3rdparty/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'),
@@ -78,6 +78,7 @@ const char* sBinaryPlatformNames[SN_NUM_BINARY_PLATFORMS] =
 	"linuxaarch64",
 	"uwparm",
 	"uwparm64",
+	"macarm"
 };
 
 }
@@ -118,6 +119,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
-- 
2.35.1