From d0f89138424d8a7ae1445463470487cd47dc0539 Mon Sep 17 00:00:00 2001 From: amaldika Date: Mon, 2 Mar 2026 13:28:49 +0530 Subject: [PATCH] Added changes for build for arm64EC. --- src/external/miniaudio.h | 6 +++--- src/external/stb_image.h | 2 +- src/external/stb_image_resize2.h | 20 ++++++++++++-------- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/external/miniaudio.h b/src/external/miniaudio.h index 24e676bb2..974876fde 100644 --- a/src/external/miniaudio.h +++ b/src/external/miniaudio.h @@ -11644,11 +11644,11 @@ IMPLEMENTATION #if defined(__arm__) || defined(_M_ARM) #define MA_ARM32 #endif -#if defined(__arm64) || defined(__arm64__) || defined(__aarch64__) || defined(_M_ARM64) +#if defined(__arm64) || defined(__arm64__) || defined(__aarch64__) || defined(_M_ARM64) || defined(_M_ARM64EC) #define MA_ARM64 #endif -#if defined(__x86_64__) || defined(_M_X64) +#if defined(__x86_64__) || (defined(_M_X64) && !defined(_M_ARM64EC)) #define MA_X64 #elif defined(__i386) || defined(_M_IX86) #define MA_X86 @@ -11703,7 +11703,7 @@ IMPLEMENTATION #endif #if defined(MA_ARM) - #if !defined(MA_NO_NEON) && (defined(__ARM_NEON) || defined(__aarch64__) || defined(_M_ARM64)) + #if !defined(MA_NO_NEON) && (defined(__ARM_NEON) || defined(__aarch64__) || defined(_M_ARM64) || defined(_M_ARM64EC)) #define MA_SUPPORT_NEON #include #endif diff --git a/src/external/stb_image.h b/src/external/stb_image.h index 9eedabedc..05ced18ec 100644 --- a/src/external/stb_image.h +++ b/src/external/stb_image.h @@ -689,7 +689,7 @@ typedef unsigned char validate_uint32[sizeof(stbi__uint32)==4 ? 1 : -1]; #endif // x86/x64 detection -#if defined(__x86_64__) || defined(_M_X64) +#if defined(__x86_64__) || (defined(_M_X64) && !defined(_M_ARM64EC)) #define STBI__X64_TARGET #elif defined(__i386) || defined(_M_IX86) #define STBI__X86_TARGET diff --git a/src/external/stb_image_resize2.h b/src/external/stb_image_resize2.h index 2f2627463..a92512667 100644 --- a/src/external/stb_image_resize2.h +++ b/src/external/stb_image_resize2.h @@ -390,7 +390,7 @@ typedef uint64_t stbir_uint64; #endif #endif -#if defined(_x86_64) || defined( __x86_64__ ) || defined( _M_X64 ) || defined(__x86_64) || defined(_M_AMD64) || defined(__SSE2__) || defined(STBIR_SSE) || defined(STBIR_SSE2) +#if defined(_x86_64) || defined( __x86_64__ ) || ((defined(_M_X64) || defined(_M_AMD64)) && !defined(_M_ARM64EC)) || defined(__x86_64) || defined(__SSE2__) || defined(STBIR_SSE) || defined(STBIR_SSE2) #ifndef STBIR_SSE2 #define STBIR_SSE2 #endif @@ -420,7 +420,7 @@ typedef uint64_t stbir_uint64; #endif #endif -#if defined( _M_ARM64 ) || defined( __aarch64__ ) || defined( __arm64__ ) || ((__ARM_NEON_FP & 4) != 0) || defined(__ARM_NEON__) +#if defined( _M_ARM64 ) || defined( _M_ARM64EC ) || defined( __aarch64__ ) || defined( __arm64__ ) || ((__ARM_NEON_FP & 4) != 0) || defined(__ARM_NEON__) #ifndef STBIR_NEON #define STBIR_NEON #endif @@ -1779,7 +1779,7 @@ static stbir__inline stbir_uint8 stbir__linear_to_srgb_uchar(float in) #define stbir__simdf_a1a1( out, alp, ones ) (out) = vzipq_f32(vuzpq_f32(alp, alp).val[1], ones).val[0] #define stbir__simdf_1a1a( out, alp, ones ) (out) = vzipq_f32(ones, vuzpq_f32(alp, alp).val[0]).val[0] - #if defined( _M_ARM64 ) || defined( __aarch64__ ) || defined( __arm64__ ) + #if defined( _M_ARM64 ) || defined( _M_ARM64EC ) || defined( __aarch64__ ) || defined( __arm64__ ) #define stbir__simdf_aaa1( out, alp, ones ) (out) = vcopyq_laneq_f32(vdupq_n_f32(vgetq_lane_f32(alp, 3)), 3, ones, 3) #define stbir__simdf_1aaa( out, alp, ones ) (out) = vcopyq_laneq_f32(vdupq_n_f32(vgetq_lane_f32(alp, 0)), 0, ones, 0) @@ -1912,7 +1912,7 @@ static stbir__inline stbir_uint8 stbir__linear_to_srgb_uchar(float in) #define STBIR_FLOORF stbir_simd_floorf static stbir__inline float stbir_simd_floorf(float x) { - #if defined( _M_ARM64 ) || defined( __aarch64__ ) || defined( __arm64__ ) + #if defined( _M_ARM64 ) || defined( _M_ARM64EC ) || defined( __aarch64__ ) || defined( __arm64__ ) return vget_lane_f32( vrndm_f32( vdup_n_f32(x) ), 0); #else float32x2_t f = vdup_n_f32(x); @@ -1930,7 +1930,7 @@ static stbir__inline stbir_uint8 stbir__linear_to_srgb_uchar(float in) #define STBIR_CEILF stbir_simd_ceilf static stbir__inline float stbir_simd_ceilf(float x) { - #if defined( _M_ARM64 ) || defined( __aarch64__ ) || defined( __arm64__ ) + #if defined( _M_ARM64 ) || defined( _M_ARM64EC ) || defined( __aarch64__ ) || defined( __arm64__ ) return vget_lane_f32( vrndp_f32( vdup_n_f32(x) ), 0); #else float32x2_t f = vdup_n_f32(x); @@ -2430,7 +2430,7 @@ static stbir__inline stbir_uint8 stbir__linear_to_srgb_uchar(float in) stbir__simdi_store( output,final ); } -#elif defined(STBIR_NEON) && defined(_MSC_VER) && defined(_M_ARM64) && !defined(__clang__) // 64-bit ARM on MSVC (not clang) +#elif defined(STBIR_NEON) && defined(_MSC_VER) && (defined(_M_ARM64) || defined(_M_ARM64EC)) && !defined(__clang__) // 64-bit ARM on MSVC (not clang) static stbir__inline void stbir__half_to_float_SIMD(float * output, stbir__FP16 const * input) { @@ -2458,7 +2458,7 @@ static stbir__inline stbir_uint8 stbir__linear_to_srgb_uchar(float in) return vget_lane_f16(vcvt_f16_f32(vdupq_n_f32(f)), 0).n16_u16[0]; } -#elif defined(STBIR_NEON) && ( defined( _M_ARM64 ) || defined( __aarch64__ ) || defined( __arm64__ ) ) // 64-bit ARM +#elif defined(STBIR_NEON) && ( defined( _M_ARM64 ) || defined( _M_ARM64EC ) || defined( __aarch64__ ) || defined( __arm64__ ) ) // 64-bit ARM static stbir__inline void stbir__half_to_float_SIMD(float * output, stbir__FP16 const * input) { @@ -2705,6 +2705,10 @@ static void stbir_overlapping_memcpy( void * dest, void const * src, size_t byte #ifdef _MSC_VER +#if defined (_M_ARM64EC) +#include +#endif + STBIRDEF stbir_uint64 __rdtsc(); #define STBIR_PROFILE_FUNC() __rdtsc() @@ -2719,7 +2723,7 @@ static void stbir_overlapping_memcpy( void * dest, void const * src, size_t byte #endif // msvc -#elif defined( _M_ARM64 ) || defined( __aarch64__ ) || defined( __arm64__ ) || defined(__ARM_NEON__) +#elif defined( _M_ARM64 ) || defined( _M_ARM64EC ) || defined( __aarch64__ ) || defined( __arm64__ ) || defined(__ARM_NEON__) #if defined( _MSC_VER ) && !defined(__clang__)