@@ -65,49 +65,57 @@ else ifeq ($(BLITTER_SIMD),neon)
6565else ifeq ($(BLITTER_SIMD),scalar)
6666 BLITTER_SIMD_SRC := $(CORE_DIR)/src/blitter_simd_scalar.c
6767else
68- # ARM targets: prefer NEON when the target configuration says it is available .
68+ # ARM targets: prefer NEON when guaranteed or explicitly enabled .
6969ifeq ($(HAVE_NEON), 1)
7070 BLITTER_SIMD_SRC := $(CORE_DIR)/src/blitter_simd_neon.c
7171endif
7272ifneq (,$(filter ios-arm64 tvos-arm64,$(platform)))
7373 BLITTER_SIMD_SRC := $(CORE_DIR)/src/blitter_simd_neon.c
7474endif
75- # Only aarch64/arm64 guaranteed to have NEON; plain 'arm' may lack it
75+ # aarch64/arm64 always have NEON; plain 'arm' may lack it.
7676ifneq (,$(filter aarch64 arm64,$(ARCH)))
7777 BLITTER_SIMD_SRC := $(CORE_DIR)/src/blitter_simd_neon.c
7878endif
79- ifneq (,$(filter arm64 armv8% armv7% armhf,$(platform)))
79+ # armv8+ implies NEON; armv7/armhf only use NEON if HAVE_NEON was set above.
80+ ifneq (,$(filter arm64 armv8%,$(platform)))
8081 BLITTER_SIMD_SRC := $(CORE_DIR)/src/blitter_simd_neon.c
8182endif
8283
8384# x86/x64 targets: use SSE2.
8485ifneq (,$(filter x86_64 x86 i686 i386,$(ARCH)))
8586 BLITTER_SIMD_SRC := $(CORE_DIR)/src/blitter_simd_sse2.c
86- # 32-bit x86 may need explicit SSE2 enable
87- ifneq (,$(filter i686 i386 x86,$(ARCH)))
88- CFLAGS += -msse2
89- endif
9087endif
9188ifneq (,$(filter x86_64 x86 i686 i386 win-x64 win32,$(platform)))
9289 BLITTER_SIMD_SRC := $(CORE_DIR)/src/blitter_simd_sse2.c
9390endif
94- # MSYS2/MinGW on x86_64
95- ifneq (,$(filter MINGW64%,$(MSYSTEM)))
91+ # MSYS2/MinGW
92+ ifneq (,$(filter MINGW64% MINGW32% ,$(MSYSTEM)))
9693 BLITTER_SIMD_SRC := $(CORE_DIR)/src/blitter_simd_sse2.c
9794endif
95+ # 32-bit x86 needs explicit -msse2 (x86_64 has it baseline).
96+ ifeq ($(BLITTER_SIMD_SRC),$(CORE_DIR)/src/blitter_simd_sse2.c)
97+ ifneq (,$(filter i686 i386 x86 win32,$(ARCH) $(platform)))
98+ CFLAGS += -msse2
99+ endif
100+ ifneq (,$(filter MINGW32%,$(MSYSTEM)))
101+ CFLAGS += -msse2
102+ endif
103+ endif
98104
99- # Native build fallback: auto-detect from host when no SIMD was selected above.
105+ # Native build fallback: auto-detect from host architecture, but only for
106+ # native-build platforms (unix/osx/win). Cross-compile targets (vita, ps3,
107+ # libnx, etc.) set platform explicitly and should not use host detection.
100108ifeq ($(BLITTER_SIMD_SRC),)
101- ifneq (,$(filter x86_64 x86 i686 i386,$(shell uname -m 2>/dev/null)))
109+ ifneq (,$(filter unix osx win,$(platform)))
110+ ifneq (,$(filter x86_64 i686 i386,$(shell uname -m 2>/dev/null)))
102111 BLITTER_SIMD_SRC := $(CORE_DIR)/src/blitter_simd_sse2.c
103112endif
104- endif
105- ifeq ($(BLITTER_SIMD_SRC),)
106113ifneq (,$(filter aarch64 arm64,$(shell uname -m 2>/dev/null)))
107114 BLITTER_SIMD_SRC := $(CORE_DIR)/src/blitter_simd_neon.c
108115endif
109116endif
110117endif
118+ endif
111119
112120# Fall back to scalar if no SIMD was selected (e.g., exotic platforms)
113121ifeq ($(BLITTER_SIMD_SRC),)
0 commit comments