From b27a92c881022cb375697475cdccf3302b658334 Mon Sep 17 00:00:00 2001 From: Pavel Zenov <9086704+linuxoidmc@users.noreply.github.com> Date: Sun, 4 Apr 2021 22:33:39 +0300 Subject: [PATCH] Initial support for Apple ARM64 --- Sources/CMakeLists.txt | 4 ++-- Sources/Engine/Models/RenderModel_View.cpp | 2 +- Sources/Engine/World/WorldRayCasting.cpp | 2 +- Sources/build-macarm.sh | 14 ++++++++++++++ 4 files changed, 18 insertions(+), 4 deletions(-) create mode 100755 Sources/build-macarm.sh diff --git a/Sources/CMakeLists.txt b/Sources/CMakeLists.txt index 50a60db..5315602 100755 --- a/Sources/CMakeLists.txt +++ b/Sources/CMakeLists.txt @@ -101,13 +101,13 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang") add_compile_options(-Wall) add_compile_options(-pipe) add_compile_options(-fPIC) - if(NOT PANDORA AND NOT PYRA) + if(NOT PANDORA AND NOT PYRA AND NOT (MACOSX AND CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64")) add_compile_options(-march=native) endif() if(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm.*") if(PYRA) add_compile_options(-mfpu=neon-vfpv4) - else() + elseif(NOT (MACOSX AND CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64")) add_compile_options(-mfpu=neon) endif() endif() diff --git a/Sources/Engine/Models/RenderModel_View.cpp b/Sources/Engine/Models/RenderModel_View.cpp index 1038ca8..35fba13 100755 --- a/Sources/Engine/Models/RenderModel_View.cpp +++ b/Sources/Engine/Models/RenderModel_View.cpp @@ -2106,7 +2106,7 @@ vtxRest: vtxEnd: pop ebx } -#elif defined(__ARM_NEON__) +#elif defined(__ARM_NEON__) && !defined (PLATFORM_MACOSX) register float tc_u __asm__("s0") = fTexCorrU; register float tc_v __asm__("s1") = fTexCorrV; const void *tc_src = pvTexCoord->vector; diff --git a/Sources/Engine/World/WorldRayCasting.cpp b/Sources/Engine/World/WorldRayCasting.cpp index e100d4b..3c158e9 100644 --- a/Sources/Engine/World/WorldRayCasting.cpp +++ b/Sources/Engine/World/WorldRayCasting.cpp @@ -512,7 +512,7 @@ void CCastRay::TestBrushSector(CBrushSector *pbscSector) continue; } } -#ifdef __ARM_NEON__ +#if defined __ARM_NEON__ && !defined PLATFORM_MACOSX // get distances of ray points from the polygon plane register FLOAT fDistance0 __asm__("s0") = bpoPolygon.bpo_pbplPlane->bpl_plAbsolute.PointDistance(cr_vOrigin); register FLOAT fDistance1 __asm__("s2") = bpoPolygon.bpo_pbplPlane->bpl_plAbsolute.PointDistance(cr_vTarget); diff --git a/Sources/build-macarm.sh b/Sources/build-macarm.sh new file mode 100755 index 0000000..8c4ebee --- /dev/null +++ b/Sources/build-macarm.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +NCPU=`sysctl -n hw.ncpu` +echo "Will build with 'make -j$NCPU' ... please edit this script if incorrect." + +set -e +set -x + +rm -rf cmake-build +mkdir $_ +cd $_ +cmake -DCMAKE_BUILD_TYPE=RelWithDbgInfo -DCMAKE_OSX_ARCHITECTURES=arm64 .. $1 +make -j$NCPU +