diff --git a/.github/workflows/public.continuous.yml b/.github/workflows/public.continuous.yml index 3e87839644..57def63cb7 100644 --- a/.github/workflows/public.continuous.yml +++ b/.github/workflows/public.continuous.yml @@ -113,4 +113,42 @@ jobs: cmake -D BUILD_TBB_FROM_SOURCE=ON -D EMBREE_EXTRA_OPTIONS="-DBUILD_TESTING=ON -DEMBREE_TUTORIALS=ON -DEMBREE_ISPC_SUPPORT=ON -DEMBREE_TESTING_INTENSITY=3" ../superbuild cmake --build . cd embree/build - ctest \ No newline at end of file + ctest + + windows-11-arm: + runs-on: windows-11-arm + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Build and Run + shell: pwsh + run: | + $opts = "-DBUILD_TESTING=ON" + $opts += " -DEMBREE_TUTORIALS=ON" + $opts += " -DEMBREE_ISPC_SUPPORT=OFF" + $opts += " -DEMBREE_TASKING_SYSTEM=INTERNAL" + $opts += " -DEMBREE_TESTING_INTENSITY=2" + + cmake -B build -G "Visual Studio 17 2022" -A ARM64 $opts.Split(" ") . + cmake --build build --config Release + ctest --test-dir build -C Release --output-on-failure + + windows-11: + runs-on: windows-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Build and Run + shell: pwsh + run: | + $opts = "-DBUILD_TESTING=ON" + $opts += " -DEMBREE_TUTORIALS=ON" + $opts += " -DEMBREE_ISPC_SUPPORT=OFF" + $opts += " -DEMBREE_TASKING_SYSTEM=INTERNAL" + $opts += " -DEMBREE_TESTING_INTENSITY=2" + + cmake -B build -G "Visual Studio 17 2022" $opts.Split(" ") . + cmake --build build --config Release + ctest --test-dir build -C Release --output-on-failure diff --git a/common/simd/arm/simd_wrapper_types.h b/common/simd/arm/simd_wrapper_types.h new file mode 100644 index 0000000000..8d638b4767 --- /dev/null +++ b/common/simd/arm/simd_wrapper_types.h @@ -0,0 +1,53 @@ +// Copyright 2009-2024 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include +#include "../../sys/platform.h" + +namespace embree +{ +#if defined(_MSC_VER) && defined(_ARM64_) + // On ARM64 MSVC, __m128 and __m128i are both aliased to __n128 in arm_neon.h, + // causing C++ overload ambiguity. We wrap them in unique types to disambiguate. + + struct __m128_wrapper { + __m128 data; + __forceinline __m128_wrapper() {} + __forceinline __m128_wrapper(__m128 v) : data(v) {} + __forceinline operator __m128() const { return data; } + __forceinline operator __m128&() { return data; } + }; + + struct __m128i_wrapper { + __m128i data; + __forceinline __m128i_wrapper() {} + __forceinline __m128i_wrapper(__m128i v) : data(v) {} + __forceinline operator __m128i() const { return data; } + __forceinline operator __m128i&() { return data; } + }; + + struct __m128d_wrapper { + __m128d data; + __forceinline __m128d_wrapper() {} + __forceinline __m128d_wrapper(__m128d v) : data(v) {} + __forceinline operator __m128d() const { return data; } + __forceinline operator __m128d&() { return data; } + }; + +#else + // On other platforms, use identity "wrappers" that compile away to nothing + template struct identity_wrapper { + T data; + __forceinline identity_wrapper() {} + __forceinline identity_wrapper(T v) : data(v) {} + __forceinline operator T() const { return data; } + __forceinline operator T&() { return data; } + }; + + using __m128_wrapper = identity_wrapper<__m128>; + using __m128i_wrapper = identity_wrapper<__m128i>; + using __m128d_wrapper = identity_wrapper<__m128d>; +#endif +} diff --git a/common/simd/arm/sse2neon.h b/common/simd/arm/sse2neon.h index 35e50a6e3e..f56efe1d6b 100644 --- a/common/simd/arm/sse2neon.h +++ b/common/simd/arm/sse2neon.h @@ -81,7 +81,11 @@ #define _sse2neon_likely(x) __builtin_expect(!!(x), 1) #define _sse2neon_unlikely(x) __builtin_expect(!!(x), 0) #else /* non-GNU / non-clang compilers */ +#if defined(_MSC_VER) +#pragma message("Macro name collisions may happen with unsupported compiler.") +#else #warning "Macro name collisions may happen with unsupported compiler." +#endif #ifndef FORCE_INLINE #define FORCE_INLINE static inline #endif diff --git a/common/simd/vboolf4_sse2.h b/common/simd/vboolf4_sse2.h index e96525c9a7..cb178c44ca 100644 --- a/common/simd/vboolf4_sse2.h +++ b/common/simd/vboolf4_sse2.h @@ -3,6 +3,8 @@ #pragma once +#include "arm/simd_wrapper_types.h" + #define vboolf vboolf_impl #define vboold vboold_impl #define vint vint_impl @@ -23,8 +25,8 @@ namespace embree typedef vint4 Int; typedef vfloat4 Float; - enum { size = 4 }; // number of SIMD elements - union { __m128 v; int i[4]; }; // data + enum { size = 4 }; // number of SIMD elements + union { __m128_wrapper v; int i[4]; }; // data //////////////////////////////////////////////////////////////////////////////// /// Constructors, Assignment & Cast Operators @@ -35,10 +37,10 @@ namespace embree __forceinline vboolf4& operator =(const vboolf4& other) { v = other.v; return *this; } __forceinline vboolf(__m128 input) : v(input) {} - __forceinline operator const __m128&() const { return v; } + __forceinline operator const __m128&() const { return v.data; } #if !defined(__EMSCRIPTEN__) - __forceinline operator const __m128i() const { return _mm_castps_si128(v); } - __forceinline operator const __m128d() const { return _mm_castps_pd(v); } + __forceinline operator const __m128i() const { return _mm_castps_si128(v.data); } + __forceinline operator const __m128d() const { return _mm_castps_pd(v.data); } #endif __forceinline vboolf(bool a) @@ -52,7 +54,7 @@ namespace embree /* return int32 mask */ __forceinline __m128i mask32() const { - return _mm_castps_si128(v); + return _mm_castps_si128(v.data); } //////////////////////////////////////////////////////////////////////////////// @@ -66,7 +68,7 @@ namespace embree /// Array Access //////////////////////////////////////////////////////////////////////////////// - __forceinline bool operator [](size_t index) const { assert(index < 4); return (_mm_movemask_ps(v) >> index) & 1; } + __forceinline bool operator [](size_t index) const { assert(index < 4); return (_mm_movemask_ps(v.data) >> index) & 1; } __forceinline int& operator [](size_t index) { assert(index < 4); return i[index]; } }; diff --git a/common/simd/vfloat4_sse2.h b/common/simd/vfloat4_sse2.h index fccf11fe0c..8d43009bfa 100644 --- a/common/simd/vfloat4_sse2.h +++ b/common/simd/vfloat4_sse2.h @@ -3,6 +3,8 @@ #pragma once +#include "arm/simd_wrapper_types.h" + #define vboolf vboolf_impl #define vboold vboold_impl #define vint vint_impl @@ -23,8 +25,8 @@ namespace embree typedef vint4 Int; typedef vfloat4 Float; - enum { size = 4 }; // number of SIMD elements - union { __m128 v; float f[4]; int i[4]; }; // data + enum { size = 4 }; // number of SIMD elements + union { __m128_wrapper v; float f[4]; int i[4]; }; // data //////////////////////////////////////////////////////////////////////////////// /// Constructors, Assignment & Cast Operators @@ -37,8 +39,8 @@ namespace embree __forceinline vfloat4& operator =(const vfloat4& other) { v = other.v; return *this; } __forceinline vfloat(__m128 a) : v(a) {} - __forceinline operator const __m128&() const { return v; } - __forceinline operator __m128&() { return v; } + __forceinline operator const __m128&() const { return v.data; } + __forceinline operator __m128&() { return v.data; } __forceinline vfloat(float a) : v(_mm_set1_ps(a)) {} __forceinline vfloat(float a, float b, float c, float d) : v(_mm_set_ps(d, c, b, a)) {} diff --git a/common/simd/vint4_sse2.h b/common/simd/vint4_sse2.h index e9e4a5a2c2..a85dd868ed 100644 --- a/common/simd/vint4_sse2.h +++ b/common/simd/vint4_sse2.h @@ -3,6 +3,7 @@ #pragma once +#include "arm/simd_wrapper_types.h" #include "../math/emath.h" #define vboolf vboolf_impl @@ -25,8 +26,8 @@ namespace embree typedef vint4 Int; typedef vfloat4 Float; - enum { size = 4 }; // number of SIMD elements - union { __m128i v; int i[4]; }; // data + enum { size = 4 }; // number of SIMD elements + union { __m128i_wrapper v; int i[4]; }; // data //////////////////////////////////////////////////////////////////////////////// /// Constructors, Assignment & Cast Operators @@ -37,8 +38,8 @@ namespace embree __forceinline vint4& operator =(const vint4& a) { v = a.v; return *this; } __forceinline vint(__m128i a) : v(a) {} - __forceinline operator const __m128i&() const { return v; } - __forceinline operator __m128i&() { return v; } + __forceinline operator const __m128i&() const { return v.data; } + __forceinline operator __m128i&() { return v.data; } __forceinline vint(int a) : v(_mm_set1_epi32(a)) {} __forceinline vint(int a, int b, int c, int d) : v(_mm_set_epi32(d, c, b, a)) {} diff --git a/common/simd/vuint4_sse2.h b/common/simd/vuint4_sse2.h index c2e86c6633..8b38b12c69 100644 --- a/common/simd/vuint4_sse2.h +++ b/common/simd/vuint4_sse2.h @@ -3,6 +3,7 @@ #pragma once +#include "arm/simd_wrapper_types.h" #include "../math/emath.h" #define vboolf vboolf_impl @@ -26,7 +27,7 @@ namespace embree typedef vfloat4 Float; enum { size = 4 }; // number of SIMD elements - union { __m128i v; unsigned int i[4]; }; // data + union { __m128i_wrapper v; unsigned int i[4]; }; // data //////////////////////////////////////////////////////////////////////////////// /// Constructors, Assignment & Cast Operators @@ -37,8 +38,8 @@ namespace embree __forceinline vuint4& operator =(const vuint4& a) { v = a.v; return *this; } __forceinline vuint(const __m128i a) : v(a) {} - __forceinline operator const __m128i&() const { return v; } - __forceinline operator __m128i&() { return v; } + __forceinline operator const __m128i&() const { return v.data; } + __forceinline operator __m128i&() { return v.data; } __forceinline vuint(unsigned int a) : v(_mm_set1_epi32(a)) {} diff --git a/common/sys/intrinsics.h b/common/sys/intrinsics.h index f5074bb29d..c0d0fbe5c9 100644 --- a/common/sys/intrinsics.h +++ b/common/sys/intrinsics.h @@ -9,7 +9,7 @@ #include #endif -#if defined(__ARM_NEON) +#if defined(__ARM_NEON) || defined(__aarch64__) #include "../simd/arm/emulation.h" #else #include diff --git a/common/sys/platform.h b/common/sys/platform.h index 6dc0cf3318..1a840938bb 100644 --- a/common/sys/platform.h +++ b/common/sys/platform.h @@ -57,6 +57,11 @@ #define __X86_ASM__ #endif +/* normalize ARM64 platform macro */ +#if defined(_M_ARM64) || defined(_M_ARM64EC) +#define __aarch64__ +#endif + /* detect 64 bit platform */ #if defined(__X86_64__) || defined(__aarch64__) #define __64BIT__ diff --git a/superbuild/CMakeLists.txt b/superbuild/CMakeLists.txt index 70e1a02774..e315ec9366 100644 --- a/superbuild/CMakeLists.txt +++ b/superbuild/CMakeLists.txt @@ -3,7 +3,7 @@ ## Global settings ## -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.5) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}