From ac4f852a6a2ab2ba1cd164fc730ec4e0ade0f51b Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Sat, 24 Jan 2026 00:33:53 +0100 Subject: [PATCH] stb_image: use SDL_TARGETING("sse2") macro for supporting intrinsics on 386 --- src/video/stb_image.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/video/stb_image.h b/src/video/stb_image.h index 5c05a293cf..87b9970e57 100644 --- a/src/video/stb_image.h +++ b/src/video/stb_image.h @@ -772,7 +772,7 @@ typedef unsigned char validate_uint32[sizeof(stbi__uint32)==4 ? 1 : -1]; // exposed in GCC/Clang is, sadly, not really suited for one-file libs. // New behavior: if compiled with -msse2, we use SSE2 without any // detection; if not, we don't use it at all. -#define STBI_NO_SIMD +// #define STBI_NO_SIMD /* Changed by SDL: use SDL_TARGETING("sse2") */ #endif #if defined(__MINGW32__) && defined(STBI__X86_TARGET) && !defined(STBI_MINGW_ENABLE_SSE2) && !defined(STBI_NO_SIMD) @@ -2690,7 +2690,7 @@ static void stbi__idct_block(stbi_uc *out, int out_stride, short data[64]) // sse2 integer IDCT. not the fastest possible implementation but it // produces bit-identical results to the generic C version so it's // fully "transparent". -static void stbi__idct_simd(stbi_uc *out, int out_stride, short data[64]) +static void SDL_TARGETING("sse2") stbi__idct_simd(stbi_uc *out, int out_stride, short data[64]) /* Changed by SDL: SDL_TARGETING("sse2") */ { // This is constructed to match our regular (generic) integer IDCT exactly. __m128i row0, row1, row2, row3, row4, row5, row6, row7; @@ -3690,7 +3690,12 @@ static stbi_uc *stbi__resample_row_hv_2(stbi_uc *out, stbi_uc *in_near, stbi_uc } #if defined(STBI_SSE2) || defined(STBI_NEON) -static stbi_uc *stbi__resample_row_hv_2_simd(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) +#ifdef STBI_SSE2 /* Added by SDL */ +#define TARGETING_SSE2 SDL_TARGETING("sse2") /* Added by SDL */ +#else +#define TARGETING_SSE2 +#endif /* Added by SDL */ +static stbi_uc *TARGETING_SSE2 stbi__resample_row_hv_2_simd(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) /* Changed by SDL: TARGETING_SSE2 */ { // need to generate 2x2 samples for every one in input int i=0,t0,t1; @@ -3846,7 +3851,7 @@ static void stbi__YCbCr_to_RGB_row(stbi_uc *out, const stbi_uc *y, const stbi_uc } #if defined(STBI_SSE2) || defined(STBI_NEON) -static void stbi__YCbCr_to_RGB_simd(stbi_uc *out, stbi_uc const *y, stbi_uc const *pcb, stbi_uc const *pcr, int count, int step) +static void TARGETING_SSE2 stbi__YCbCr_to_RGB_simd(stbi_uc *out, stbi_uc const *y, stbi_uc const *pcb, stbi_uc const *pcr, int count, int step) /* Changed by SDL: TARGETING_SSE2 */ { int i = 0;