stb_image: use SDL_HasSSE2 and <SDL3/SDL_intrin.h> macro's for SSE2 detection

This commit is contained in:
Anonymous Maarten
2026-01-23 18:34:53 +01:00
committed by Anonymous Maarten
parent a929eb71b3
commit 0457891d50
+6 -3
View File
@@ -791,11 +791,13 @@ typedef unsigned char validate_uint32[sizeof(stbi__uint32)==4 ? 1 : -1];
#endif #endif
#if !defined(STBI_NO_SIMD) && (defined(STBI__X86_TARGET) || defined(STBI__X64_TARGET)) #if !defined(STBI_NO_SIMD) && (defined(STBI__X86_TARGET) || defined(STBI__X64_TARGET))
#ifdef SDL_SSE2_INTRINSICS /* SDL change */
#define STBI_SSE2 #define STBI_SSE2
#include <emmintrin.h> #include <emmintrin.h>
#ifdef _MSC_VER #ifdef _MSC_VER
#if 0 /* SDL change (unused due to using SDL_HasSSE2) */
#if _MSC_VER >= 1400 // not VC6 #if _MSC_VER >= 1400 // not VC6
#include <intrin.h> // __cpuid #include <intrin.h> // __cpuid
static int stbi__cpuid3(void) static int stbi__cpuid3(void)
@@ -816,14 +818,14 @@ static int stbi__cpuid3(void)
return res; return res;
} }
#endif #endif
#endif /* SDL change */
#define STBI_SIMD_ALIGN(type, name) __declspec(align(16)) type name #define STBI_SIMD_ALIGN(type, name) __declspec(align(16)) type name
#if !defined(STBI_NO_JPEG) && defined(STBI_SSE2) #if !defined(STBI_NO_JPEG) && defined(STBI_SSE2)
static int stbi__sse2_available(void) static int stbi__sse2_available(void)
{ {
int info3 = stbi__cpuid3(); return SDL_HasSSE2(); /* SDL change */
return ((info3 >> 26) & 1) != 0;
} }
#endif #endif
@@ -836,11 +838,12 @@ static int stbi__sse2_available(void)
// If we're even attempting to compile this on GCC/Clang, that means // If we're even attempting to compile this on GCC/Clang, that means
// -msse2 is on, which means the compiler is allowed to use SSE2 // -msse2 is on, which means the compiler is allowed to use SSE2
// instructions at will, and so are we. // instructions at will, and so are we.
return 1; return SDL_HasSSE2(); /* SDL change */
} }
#endif #endif
#endif #endif
#endif /* SDL change (SDL_SSE2_INTRINSICS) */
#endif #endif
// ARM NEON // ARM NEON