diff --git a/physx/buildtools/cmake_generate_projects.py b/physx/buildtools/cmake_generate_projects.py
index 4ac527868..54756d47f 100644
--- a/physx/buildtools/cmake_generate_projects.py
+++ b/physx/buildtools/cmake_generate_projects.py
@@ -119,6 +119,8 @@ def isMultiConfigPlatform(self):
return False
elif self.targetPlatform == 'linuxAarch64':
return False
+ elif self.targetPlatform == 'linuxLoongarch64':
+ return False
return True
def getCMakeSwitches(self):
@@ -215,13 +217,25 @@ def getPlatformCMakeParams(self):
outString = outString + ' -DCMAKE_TOOLCHAIN_FILE=\"' + \
cmake_modules_root + '/linux/LinuxAarch64.cmake\"'
return outString
+ elif self.targetPlatform == 'linuxLoongarch64':
+ outString = outString + ' -DTARGET_BUILD_PLATFORM=linux'
+ outString = outString + ' -DPX_OUTPUT_ARCH=loongarch64'
+ if self.compiler == 'clang':
+ if os.environ.get('PM_clang_PATH') is not None:
+ outString = outString + ' -DCMAKE_C_COMPILER=' + \
+ os.environ['PM_clang_PATH'] + '/bin/clang'
+ outString = outString + ' -DCMAKE_CXX_COMPILER=' + \
+ os.environ['PM_clang_PATH'] + '/bin/clang++'
+ else:
+ outString = outString + ' -DCMAKE_C_COMPILER=clang'
+ outString = outString + ' -DCMAKE_CXX_COMPILER=clang++'
+ return outString
elif self.targetPlatform == 'mac64':
outString = outString + ' -DTARGET_BUILD_PLATFORM=mac'
outString = outString + ' -DPX_OUTPUT_ARCH=x86'
return outString
return ''
-
def getCommonParams():
outString = '--no-warn-unused-cli'
outString = outString + ' -DCMAKE_PREFIX_PATH=\"' + os.environ['PM_PATHS'] + '\"'
diff --git a/physx/buildtools/presets/public/linux-loongarch64.xml b/physx/buildtools/presets/public/linux-loongarch64.xml
new file mode 100644
index 000000000..3c5c084c7
--- /dev/null
+++ b/physx/buildtools/presets/public/linux-loongarch64.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/physx/generate_projects.sh b/physx/generate_projects.sh
index d037378cc..0559f7cfe 100755
--- a/physx/generate_projects.sh
+++ b/physx/generate_projects.sh
@@ -1,5 +1,10 @@
#!/bin/bash +x
+machine=`uname -m`
+if [ "$machine"x = "loongarch64"x ]; then
+ export PM_PYTHON_EXT="python3"
+fi
+
if [ -n "${BASH_SOURCE[0]}" ]; then
SCRIPT_DIR=$(dirname "${BASH_SOURCE[0]}")
else
@@ -33,4 +38,4 @@ status=$?
if [ "$status" -ne "0" ]; then
echo "Error $status"
exit 1
-fi
\ No newline at end of file
+fi
diff --git a/physx/include/foundation/PxAlloca.h b/physx/include/foundation/PxAlloca.h
index 37516b371..46d3487f9 100644
--- a/physx/include/foundation/PxAlloca.h
+++ b/physx/include/foundation/PxAlloca.h
@@ -62,7 +62,7 @@ class PxScopedPointer : private Alloc
#if PX_WINDOWS_FAMILY
#include
#define PxAlloca(x) _alloca(x)
-#elif PX_LINUX
+#elif PX_LINUX || PX_LOONGARCH64
#include
#define PxAlloca(x) alloca(x)
#elif PX_APPLE_FAMILY
diff --git a/physx/include/foundation/PxIntrinsics.h b/physx/include/foundation/PxIntrinsics.h
index d61c209da..ffea20584 100644
--- a/physx/include/foundation/PxIntrinsics.h
+++ b/physx/include/foundation/PxIntrinsics.h
@@ -33,7 +33,7 @@
#if PX_WINDOWS_FAMILY
#include "windows/PxWindowsIntrinsics.h"
-#elif(PX_LINUX || PX_APPLE_FAMILY)
+#elif(PX_LINUX || PX_APPLE_FAMILY || PX_LOONGARCH64)
#include "unix/PxUnixIntrinsics.h"
#elif PX_SWITCH
#include "switch/PxSwitchIntrinsics.h"
diff --git a/physx/include/foundation/PxMath.h b/physx/include/foundation/PxMath.h
index 974c340ca..e9ded0c96 100644
--- a/physx/include/foundation/PxMath.h
+++ b/physx/include/foundation/PxMath.h
@@ -42,7 +42,7 @@
#pragma warning(pop)
#endif
-#if (PX_LINUX_FAMILY && !PX_ARM_FAMILY)
+#if (PX_LINUX_FAMILY && !PX_ARM_FAMILY && !PX_LOONGARCH64)
// Force linking against nothing newer than glibc v2.17 to remain compatible with platforms with older glibc versions
__asm__(".symver expf,expf@GLIBC_2.2.5");
__asm__(".symver powf,powf@GLIBC_2.2.5");
diff --git a/physx/include/foundation/PxMathIntrinsics.h b/physx/include/foundation/PxMathIntrinsics.h
index 6bc42587e..c2f104126 100644
--- a/physx/include/foundation/PxMathIntrinsics.h
+++ b/physx/include/foundation/PxMathIntrinsics.h
@@ -33,7 +33,7 @@
#if PX_WINDOWS_FAMILY
#include "foundation/windows/PxWindowsMathIntrinsics.h"
-#elif(PX_LINUX || PX_APPLE_FAMILY)
+#elif(PX_LINUX || PX_APPLE_FAMILY || PX_LOONGARCH64)
#include "foundation/unix/PxUnixMathIntrinsics.h"
#elif PX_SWITCH
#include "foundation/switch/PxSwitchMathIntrinsics.h"
diff --git a/physx/include/foundation/PxPreprocessor.h b/physx/include/foundation/PxPreprocessor.h
index b47ff7bff..89a9de943 100644
--- a/physx/include/foundation/PxPreprocessor.h
+++ b/physx/include/foundation/PxPreprocessor.h
@@ -111,6 +111,8 @@ Architecture defines, see http://sourceforge.net/p/predef/wiki/Architectures/
#define PX_A64 1
#elif defined(__arm__) || defined(_M_ARM)
#define PX_ARM 1
+#elif defined(__loongarch64__) || defined(__loongarch64)
+ #define PX_LOONGARCH64 1
#elif defined(__ppc__) || defined(_M_PPC) || defined(__CELLOS_LV2__)
#define PX_PPC 1
#else
@@ -171,6 +173,9 @@ define anything not defined on this platform to 0
#ifndef PX_ARM
#define PX_ARM 0
#endif
+#ifndef PX_LOONGARCH64
+ #define PX_LOONGARCH64 0
+#endif
#ifndef PX_PPC
#define PX_PPC 0
#endif
@@ -224,7 +229,7 @@ family shortcuts
// architecture
#define PX_INTEL_FAMILY (PX_X64 || PX_X86)
#define PX_ARM_FAMILY (PX_ARM || PX_A64)
-#define PX_P64_FAMILY (PX_X64 || PX_A64) // shortcut for 64-bit architectures
+#define PX_P64_FAMILY (PX_X64 || PX_A64 || PX_LOONGARCH64) // shortcut for 64-bit architectures
/**
C++ standard library defines
@@ -522,7 +527,7 @@ protected: \
//#define DISABLE_CUDA_PHYSX
#ifndef DISABLE_CUDA_PHYSX
//CUDA is currently supported on x86_64 windows and linux, and ARM_64 linux
- #define PX_SUPPORT_GPU_PHYSX ((PX_X64 && (PX_WINDOWS_FAMILY || PX_LINUX)) || (PX_A64 && PX_LINUX))
+ #define PX_SUPPORT_GPU_PHYSX ((PX_X64 && (PX_WINDOWS_FAMILY || PX_LINUX)) || (PX_A64 && PX_LINUX) || PX_LOONGARCH64)
#else
#define PX_SUPPORT_GPU_PHYSX 0
#endif
diff --git a/physx/include/foundation/PxSIMDHelpers.h b/physx/include/foundation/PxSIMDHelpers.h
index 7c9e17067..dfc0da4a1 100644
--- a/physx/include/foundation/PxSIMDHelpers.h
+++ b/physx/include/foundation/PxSIMDHelpers.h
@@ -48,7 +48,7 @@ namespace physx
const QuatV qV = V4LoadU(&q.x);
Vec3V column0V, column1V, column2V;
QuatGetMat33V(qV, column0V, column1V, column2V);
-#if defined(PX_SIMD_DISABLED) || (PX_LINUX && (PX_ARM || PX_A64))
+#if defined(PX_SIMD_DISABLED) || (PX_LINUX && (PX_ARM || PX_A64 || PX_LOONGARCH64))
V3StoreU(column0V, column0);
V3StoreU(column1V, column1);
V3StoreU(column2V, column2);
diff --git a/physx/snippets/compiler/cmake/linux/SnippetRender.cmake b/physx/snippets/compiler/cmake/linux/SnippetRender.cmake
index 100f28030..8eb84479a 100644
--- a/physx/snippets/compiler/cmake/linux/SnippetRender.cmake
+++ b/physx/snippets/compiler/cmake/linux/SnippetRender.cmake
@@ -28,7 +28,7 @@
# Build SnippetRender
#
-IF(NOT ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64")
+IF(NOT (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64" OR ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "loongarch64"))
FIND_PACKAGE(OpenGL $ENV{PM_OpenGL_VERSION} CONFIG REQUIRED) # Pull in OpenGL and GLUT
ENDIF()
@@ -46,7 +46,7 @@ SET(SNIPPETRENDER_COMPILE_DEFS
SET(SNIPPETRENDER_PLATFORM_INCLUDES)
# gwoolery: aarch64 requires glut library to be lower case, for whatever reason
-IF(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
+IF(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "loongarch64")
SET(GLUT_LIB "glut")
ELSE()
SET(GLUT_LIB "GLUT")
diff --git a/physx/snippets/compiler/cmake/linux/SnippetTemplate.cmake b/physx/snippets/compiler/cmake/linux/SnippetTemplate.cmake
index 8e5f7c299..580a64881 100644
--- a/physx/snippets/compiler/cmake/linux/SnippetTemplate.cmake
+++ b/physx/snippets/compiler/cmake/linux/SnippetTemplate.cmake
@@ -57,7 +57,7 @@ IF(${SNIPPET_NAME} STREQUAL "ArticulationLoader")
ENDIF()
# gwoolery: aarch64 requires glut library to be lower case, for whatever reason
-IF(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
+IF(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "loongarch64")
SET(GLUT_LIB "glut")
ELSE()
SET(GLUT_LIB "GLUT")
diff --git a/physx/snippets/compiler/cmake/linux/SnippetVehicle2Template.cmake b/physx/snippets/compiler/cmake/linux/SnippetVehicle2Template.cmake
index f407521d4..765039b26 100644
--- a/physx/snippets/compiler/cmake/linux/SnippetVehicle2Template.cmake
+++ b/physx/snippets/compiler/cmake/linux/SnippetVehicle2Template.cmake
@@ -47,7 +47,7 @@ SET(SNIPPET_PLATFORM_SOURCES
)
# gwoolery: aarch64 requires glut library to be lower case, for whatever reason
-IF(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
+IF(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "loongarch64")
SET(GLUT_LIB "glut")
ELSE()
SET(GLUT_LIB "GLUT")
diff --git a/physx/source/compiler/cmake/linux/CMakeLists.txt b/physx/source/compiler/cmake/linux/CMakeLists.txt
index 13148bf9a..efc091aa8 100644
--- a/physx/source/compiler/cmake/linux/CMakeLists.txt
+++ b/physx/source/compiler/cmake/linux/CMakeLists.txt
@@ -138,6 +138,11 @@ IF(${CMAKE_CROSSCOMPILING} AND CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
ELSE()
SET(PX_SUPPORT_OMNI_PVD_FLAG "PX_SUPPORT_OMNI_PVD=1")
ENDIF()
+
+IF(CMAKE_SYSTEM_PROCESSOR STREQUAL "loongarch64")
+ SET(GPU_LIB_COPIED 1 CACHE INTERNAL "PhysX GPU so files not copied")
+ENDIF()
+
SET(PHYSX_LINUX_COMPILE_DEFS "${PHYSX_AUTOBUILD};${PUBLIC_RELEASE_FLAG};${FEATURES_UNDER_CONSTRUCTION_FLAG}" CACHE INTERNAL "Base PhysX preprocessor definitions")
SET(PHYSX_LINUX_DEBUG_COMPILE_DEFS "PX_DEBUG=1;PX_CHECKED=1;${NVTX_FLAG};PX_SUPPORT_PVD=1;${PX_SUPPORT_OMNI_PVD_FLAG}" CACHE INTERNAL "Debug PhysX preprocessor definitions")
SET(PHYSX_LINUX_CHECKED_COMPILE_DEFS "NDEBUG;PX_CHECKED=1;${NVTX_FLAG};PX_SUPPORT_PVD=1;${PX_SUPPORT_OMNI_PVD_FLAG}" CACHE INTERNAL "Checked PhysX preprocessor definitions")
diff --git a/physx/source/compiler/cmake/modules/GetCompilerAndPlatform.cmake b/physx/source/compiler/cmake/modules/GetCompilerAndPlatform.cmake
index 5632b82af..ed1f3e2ab 100644
--- a/physx/source/compiler/cmake/modules/GetCompilerAndPlatform.cmake
+++ b/physx/source/compiler/cmake/modules/GetCompilerAndPlatform.cmake
@@ -135,6 +135,8 @@ FUNCTION (GetPlatformBinName PLATFORM_BIN_NAME LIBPATH_SUFFIX)
SET(RETVAL "linux.clang")
ELSEIF(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64")
SET(RETVAL "linux.aarch64")
+ ELSEIF(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "loongarch64")
+ SET(RETVAL "linux.loongarch64")
ENDIF()
ENDIF()
diff --git a/physx/source/foundation/unix/FdUnixThread.cpp b/physx/source/foundation/unix/FdUnixThread.cpp
index 7b72e4a3d..dbc8e6e61 100644
--- a/physx/source/foundation/unix/FdUnixThread.cpp
+++ b/physx/source/foundation/unix/FdUnixThread.cpp
@@ -269,6 +269,7 @@ void PxThreadImpl::yieldProcessor()
{
#if (PX_ARM || PX_A64)
__asm__ __volatile__("yield");
+#elif PX_LOONGARCH64
#else
__asm__ __volatile__("pause");
#endif
diff --git a/physx/source/physxextensions/src/serialization/SnSerialUtils.cpp b/physx/source/physxextensions/src/serialization/SnSerialUtils.cpp
index 3749ad885..6abc5ec99 100644
--- a/physx/source/physxextensions/src/serialization/SnSerialUtils.cpp
+++ b/physx/source/physxextensions/src/serialization/SnSerialUtils.cpp
@@ -38,7 +38,7 @@ using namespace physx;
namespace
{
-#define SN_NUM_BINARY_PLATFORMS 9
+#define SN_NUM_BINARY_PLATFORMS 10
const PxU32 sBinaryPlatformTags[SN_NUM_BINARY_PLATFORMS] =
{
PX_MAKE_FOURCC('W','_','3','2'),
@@ -49,7 +49,8 @@ const PxU32 sBinaryPlatformTags[SN_NUM_BINARY_PLATFORMS] =
PX_MAKE_FOURCC('M','_','6','4'),
PX_MAKE_FOURCC('N','X','3','2'),
PX_MAKE_FOURCC('N','X','6','4'),
- PX_MAKE_FOURCC('L','A','6','4')
+ PX_MAKE_FOURCC('L','A','6','4'),
+ PX_MAKE_FOURCC('L','O','6','4')
};
const char* sBinaryPlatformNames[SN_NUM_BINARY_PLATFORMS] =
@@ -62,7 +63,8 @@ const char* sBinaryPlatformNames[SN_NUM_BINARY_PLATFORMS] =
"mac64",
"switch32",
"switch64",
- "linuxaarch64"
+ "linuxaarch64",
+ "loongarch64"
};
}
@@ -89,6 +91,8 @@ PxU32 getBinaryPlatformTag()
return sBinaryPlatformTags[7];
#elif PX_LINUX && PX_A64
return sBinaryPlatformTags[8];
+#elif PX_LINUX && PX_LOONGARCH64
+ return sBinaryPlatformTags[9];
#else
#error Unknown binary platform
#endif