cpu: Removed 3DNow! support and SDL_Has3DNow().

Reference Issue #6636.
main
Ryan C. Gordon 2022-12-22 01:24:59 -05:00 committed by Sam Lantinga
parent 0187209f46
commit 1cf2b566af
13 changed files with 20 additions and 206 deletions

View File

@ -384,7 +384,6 @@ dep_option(SDL_SSE "Use SSE assembly routines" ON "SDL_ASSEMBLY;
dep_option(SDL_SSE2 "Use SSE2 assembly routines" ON "SDL_ASSEMBLY;SDL_CPU_X86 OR SDL_CPU_X64" OFF)
dep_option(SDL_SSE3 "Use SSE3 assembly routines" ON "SDL_ASSEMBLY;SDL_CPU_X86 OR SDL_CPU_X64" OFF)
dep_option(SDL_MMX "Use MMX assembly routines" ON "SDL_ASSEMBLY;SDL_CPU_X86 OR SDL_CPU_X64" OFF)
dep_option(SDL_3DNOW "Use 3Dnow! MMX assembly routines" ON "SDL_ASSEMBLY;SDL_CPU_X86 OR SDL_CPU_X64" OFF)
dep_option(SDL_ALTIVEC "Use Altivec assembly routines" ON "SDL_ASSEMBLY" OFF)
dep_option(SDL_ARMSIMD "Use SIMD assembly blitters on ARM" OFF "SDL_ASSEMBLY;SDL_CPU_ARM32" OFF)
dep_option(SDL_ARMNEON "Use NEON assembly blitters on ARM" OFF "SDL_ASSEMBLY;SDL_CPU_ARM32" OFF)
@ -719,26 +718,6 @@ if(SDL_ASSEMBLY)
endif()
endif()
if(SDL_3DNOW)
cmake_push_check_state()
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -m3dnow")
check_c_source_compiles("
#include <mm3dnow.h>
#ifndef __3dNOW__
#error Assembler CPP flag not enabled
#endif
int main(int argc, char **argv) {
void *p = 0;
_m_prefetch(p);
return 0;
}" CPU_SUPPORTS_3DNOW)
cmake_pop_check_state()
if(CPU_SUPPORTS_3DNOW)
set(HAVE_3DNOW TRUE)
list(APPEND EXTRA_CFLAGS "-m3dnow")
endif()
endif()
if(SDL_SSE)
cmake_push_check_state()
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -msse")
@ -948,9 +927,6 @@ if(SDL_ASSEMBLY)
if(SDL_MMX)
set(HAVE_MMX TRUE)
endif()
if(SDL_3DNOW)
set(HAVE_3DNOW TRUE)
endif()
endif()
if(SDL_SSE)
set(HAVE_SSE TRUE)

View File

@ -34,6 +34,8 @@ begin_code.h and close_code.h in the public headers have been renamed to SDL_beg
## SDL_cpuinfo.h
- SDL_Has3DNow() has been removed; there is no replacement.
The following headers are no longer automatically included, and will need to be included manually:
- immintrin.h
- mm3dnow.h

View File

@ -75,7 +75,6 @@ extern DECLSPEC int SDLCALL SDL_GetCPUCacheLineSize(void);
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_Has3DNow
* \sa SDL_HasAltiVec
* \sa SDL_HasAVX
* \sa SDL_HasAVX2
@ -98,7 +97,6 @@ extern DECLSPEC SDL_bool SDLCALL SDL_HasRDTSC(void);
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_Has3DNow
* \sa SDL_HasAVX
* \sa SDL_HasAVX2
* \sa SDL_HasMMX
@ -120,7 +118,6 @@ extern DECLSPEC SDL_bool SDLCALL SDL_HasAltiVec(void);
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_Has3DNow
* \sa SDL_HasAltiVec
* \sa SDL_HasAVX
* \sa SDL_HasAVX2
@ -133,28 +130,6 @@ extern DECLSPEC SDL_bool SDLCALL SDL_HasAltiVec(void);
*/
extern DECLSPEC SDL_bool SDLCALL SDL_HasMMX(void);
/**
* Determine whether the CPU has 3DNow! features.
*
* This always returns false on CPUs that aren't using AMD instruction sets.
*
* \returns SDL_TRUE if the CPU has 3DNow! features or SDL_FALSE if not.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_HasAltiVec
* \sa SDL_HasAVX
* \sa SDL_HasAVX2
* \sa SDL_HasMMX
* \sa SDL_HasRDTSC
* \sa SDL_HasSSE
* \sa SDL_HasSSE2
* \sa SDL_HasSSE3
* \sa SDL_HasSSE41
* \sa SDL_HasSSE42
*/
extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNow(void);
/**
* Determine whether the CPU has SSE features.
*
@ -164,7 +139,6 @@ extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNow(void);
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_Has3DNow
* \sa SDL_HasAltiVec
* \sa SDL_HasAVX
* \sa SDL_HasAVX2
@ -186,7 +160,6 @@ extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE(void);
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_Has3DNow
* \sa SDL_HasAltiVec
* \sa SDL_HasAVX
* \sa SDL_HasAVX2
@ -208,7 +181,6 @@ extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE2(void);
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_Has3DNow
* \sa SDL_HasAltiVec
* \sa SDL_HasAVX
* \sa SDL_HasAVX2
@ -230,7 +202,6 @@ extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE3(void);
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_Has3DNow
* \sa SDL_HasAltiVec
* \sa SDL_HasAVX
* \sa SDL_HasAVX2
@ -252,7 +223,6 @@ extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE41(void);
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_Has3DNow
* \sa SDL_HasAltiVec
* \sa SDL_HasAVX
* \sa SDL_HasAVX2
@ -274,7 +244,6 @@ extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE42(void);
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_Has3DNow
* \sa SDL_HasAltiVec
* \sa SDL_HasAVX2
* \sa SDL_HasMMX
@ -296,7 +265,6 @@ extern DECLSPEC SDL_bool SDLCALL SDL_HasAVX(void);
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_Has3DNow
* \sa SDL_HasAltiVec
* \sa SDL_HasAVX
* \sa SDL_HasMMX

View File

@ -47,9 +47,6 @@ _m_prefetch(void *__P)
#ifndef __MMX__
#define __MMX__
#endif
#ifndef __3dNOW__
#define __3dNOW__
#endif
#endif
#ifndef __SSE__
#define __SSE__
@ -90,9 +87,6 @@ _m_prefetch(void *__P)
#endif
#endif /* compiler version */
#if defined(__3dNOW__) && !defined(SDL_DISABLE_MM3DNOW_H)
#include <mm3dnow.h>
#endif
#if defined(__loongarch_sx) && !defined(SDL_DISABLE_LSX_H)
#include <lsxintrin.h>
#define __LSX__

View File

@ -86,19 +86,18 @@
#define CPU_HAS_RDTSC (1 << 0)
#define CPU_HAS_ALTIVEC (1 << 1)
#define CPU_HAS_MMX (1 << 2)
#define CPU_HAS_3DNOW (1 << 3)
#define CPU_HAS_SSE (1 << 4)
#define CPU_HAS_SSE2 (1 << 5)
#define CPU_HAS_SSE3 (1 << 6)
#define CPU_HAS_SSE41 (1 << 7)
#define CPU_HAS_SSE42 (1 << 8)
#define CPU_HAS_AVX (1 << 9)
#define CPU_HAS_AVX2 (1 << 10)
#define CPU_HAS_NEON (1 << 11)
#define CPU_HAS_AVX512F (1 << 12)
#define CPU_HAS_ARM_SIMD (1 << 13)
#define CPU_HAS_LSX (1 << 14)
#define CPU_HAS_LASX (1 << 15)
#define CPU_HAS_SSE (1 << 3)
#define CPU_HAS_SSE2 (1 << 4)
#define CPU_HAS_SSE3 (1 << 5)
#define CPU_HAS_SSE41 (1 << 6)
#define CPU_HAS_SSE42 (1 << 7)
#define CPU_HAS_AVX (1 << 8)
#define CPU_HAS_AVX2 (1 << 9)
#define CPU_HAS_NEON (1 << 10)
#define CPU_HAS_AVX512F (1 << 11)
#define CPU_HAS_ARM_SIMD (1 << 12)
#define CPU_HAS_LSX (1 << 13)
#define CPU_HAS_LASX (1 << 14)
#define CPU_CFG2 0x2
#define CPU_CFG2_LSX (1 << 6)
@ -516,31 +515,6 @@ static int CPU_readCPUCFG(void)
#define CPU_haveLSX() (CPU_readCPUCFG() & CPU_CFG2_LSX)
#define CPU_haveLASX() (CPU_readCPUCFG() & CPU_CFG2_LASX)
#if defined(__e2k__)
inline int
CPU_have3DNow(void)
{
#if defined(__3dNOW__)
return 1;
#else
return 0;
#endif
}
#else
static int CPU_have3DNow(void)
{
if (CPU_CPUIDMaxFunction > 0) { /* that is, do we have CPUID at all? */
int a, b, c, d;
cpuid(0x80000000, a, b, c, d);
if (a >= 0x80000001) {
cpuid(0x80000001, a, b, c, d);
return d & 0x80000000;
}
}
return 0;
}
#endif
#if defined(__e2k__)
#define CPU_haveRDTSC() (0)
#if defined(__MMX__)
@ -900,10 +874,6 @@ static Uint32 SDL_GetCPUFeatures(void)
SDL_CPUFeatures |= CPU_HAS_MMX;
SDL_SIMDAlignment = SDL_max(SDL_SIMDAlignment, 8);
}
if (CPU_have3DNow()) {
SDL_CPUFeatures |= CPU_HAS_3DNOW;
SDL_SIMDAlignment = SDL_max(SDL_SIMDAlignment, 8);
}
if (CPU_haveSSE()) {
SDL_CPUFeatures |= CPU_HAS_SSE;
SDL_SIMDAlignment = SDL_max(SDL_SIMDAlignment, 16);
@ -975,12 +945,6 @@ SDL_HasMMX(void)
return CPU_FEATURE_AVAILABLE(CPU_HAS_MMX);
}
SDL_bool
SDL_Has3DNow(void)
{
return CPU_FEATURE_AVAILABLE(CPU_HAS_3DNOW);
}
SDL_bool
SDL_HasSSE(void)
{
@ -1228,7 +1192,6 @@ int main()
printf("RDTSC: %d\n", SDL_HasRDTSC());
printf("Altivec: %d\n", SDL_HasAltiVec());
printf("MMX: %d\n", SDL_HasMMX());
printf("3DNow: %d\n", SDL_Has3DNow());
printf("SSE: %d\n", SDL_HasSSE());
printf("SSE2: %d\n", SDL_HasSSE2());
printf("SSE3: %d\n", SDL_HasSSE3());

View File

@ -632,7 +632,6 @@ SDL3_0.0.0 {
SDL_HasRDTSC;
SDL_HasAltiVec;
SDL_HasMMX;
SDL_Has3DNow;
SDL_HasSSE;
SDL_HasSSE2;
SDL_HasSSE3;

View File

@ -102,7 +102,6 @@
#define SDL_HasRDTSC SDL_HasRDTSC_REAL
#define SDL_HasAltiVec SDL_HasAltiVec_REAL
#define SDL_HasMMX SDL_HasMMX_REAL
#define SDL_Has3DNow SDL_Has3DNow_REAL
#define SDL_HasSSE SDL_HasSSE_REAL
#define SDL_HasSSE2 SDL_HasSSE2_REAL
#define SDL_HasSSE3 SDL_HasSSE3_REAL

View File

@ -129,7 +129,6 @@ SDL_DYNAPI_PROC(int,SDL_GetCPUCacheLineSize,(void),(),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_HasRDTSC,(void),(),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_HasAltiVec,(void),(),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_HasMMX,(void),(),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_Has3DNow,(void),(),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_HasSSE,(void),(),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_HasSSE2,(void),(),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_HasSSE3,(void),(),return)

View File

@ -141,9 +141,6 @@ static SDL_BlitFunc SDL_ChooseBlitFunc(Uint32 src_format, Uint32 dst_format, int
if (SDL_HasMMX()) {
features |= SDL_CPU_MMX;
}
if (SDL_Has3DNow()) {
features |= SDL_CPU_3DNOW;
}
if (SDL_HasSSE()) {
features |= SDL_CPU_SSE;
}

View File

@ -49,11 +49,10 @@ extern Uint8 *SDL_expand_byte[9];
/* SDL blit CPU flags */
#define SDL_CPU_ANY 0x00000000
#define SDL_CPU_MMX 0x00000001
#define SDL_CPU_3DNOW 0x00000002
#define SDL_CPU_SSE 0x00000004
#define SDL_CPU_SSE2 0x00000008
#define SDL_CPU_ALTIVEC_PREFETCH 0x00000010
#define SDL_CPU_ALTIVEC_NOPREFETCH 0x00000020
#define SDL_CPU_SSE 0x00000002
#define SDL_CPU_SSE2 0x00000004
#define SDL_CPU_ALTIVEC_PREFETCH 0x00000008
#define SDL_CPU_ALTIVEC_NOPREFETCH 0x00000010
typedef struct
{

View File

@ -614,78 +614,6 @@ static void BlitRGBtoBGRPixelAlpha(SDL_BlitInfo *info)
}
}
#ifdef __3dNOW__
/* fast (as in MMX with prefetch) ARGB888->(A)RGB888 blending with pixel alpha */
static void BlitRGBtoRGBPixelAlphaMMX3DNOW(SDL_BlitInfo *info)
{
int width = info->dst_w;
int height = info->dst_h;
Uint32 *srcp = (Uint32 *)info->src;
int srcskip = info->src_skip >> 2;
Uint32 *dstp = (Uint32 *)info->dst;
int dstskip = info->dst_skip >> 2;
SDL_PixelFormat *sf = info->src_fmt;
Uint32 amask = sf->Amask;
Uint32 ashift = sf->Ashift;
Uint64 multmask, multmask2;
__m64 src1, dst1, mm_alpha, mm_zero, mm_alpha2;
mm_zero = _mm_setzero_si64(); /* 0 -> mm_zero */
multmask = 0x00FF;
multmask <<= (ashift * 2);
multmask2 = 0x00FF00FF00FF00FFULL;
while (height--) {
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP4({
Uint32 alpha;
_m_prefetch(srcp + 16);
_m_prefetch(dstp + 16);
alpha = *srcp & amask;
if (alpha == 0) {
/* do nothing */
} else if (alpha == amask) {
*dstp = *srcp;
} else {
src1 = _mm_cvtsi32_si64(*srcp); /* src(ARGB) -> src1 (0000ARGB) */
src1 = _mm_unpacklo_pi8(src1, mm_zero); /* 0A0R0G0B -> src1 */
dst1 = _mm_cvtsi32_si64(*dstp); /* dst(ARGB) -> dst1 (0000ARGB) */
dst1 = _mm_unpacklo_pi8(dst1, mm_zero); /* 0A0R0G0B -> dst1 */
mm_alpha = _mm_cvtsi32_si64(alpha); /* alpha -> mm_alpha (0000000A) */
mm_alpha = _mm_srli_si64(mm_alpha, ashift); /* mm_alpha >> ashift -> mm_alpha(0000000A) */
mm_alpha = _mm_unpacklo_pi16(mm_alpha, mm_alpha); /* 00000A0A -> mm_alpha */
mm_alpha2 = _mm_unpacklo_pi32(mm_alpha, mm_alpha); /* 0A0A0A0A -> mm_alpha2 */
mm_alpha = _mm_or_si64(mm_alpha2, *(__m64 *) & multmask); /* 0F0A0A0A -> mm_alpha */
mm_alpha2 = _mm_xor_si64(mm_alpha2, *(__m64 *) & multmask2); /* 255 - mm_alpha -> mm_alpha */
/* blend */
src1 = _mm_mullo_pi16(src1, mm_alpha);
src1 = _mm_srli_pi16(src1, 8);
dst1 = _mm_mullo_pi16(dst1, mm_alpha2);
dst1 = _mm_srli_pi16(dst1, 8);
dst1 = _mm_add_pi16(src1, dst1);
dst1 = _mm_packs_pu16(dst1, mm_zero);
*dstp = _mm_cvtsi64_si32(dst1); /* dst1 -> pixel */
}
++srcp;
++dstp;
}, width);
/* *INDENT-ON* */ /* clang-format on */
srcp += srcskip;
dstp += dstskip;
}
_mm_empty();
}
#endif /* __3dNOW__ */
/* 16bpp special case for per-surface alpha=50%: blend 2 pixels in parallel */
/* blend a single 16 bit pixel at 50% */
@ -1401,20 +1329,15 @@ SDL_CalculateBlitA(SDL_Surface *surface)
case 4:
if (sf->Rmask == df->Rmask && sf->Gmask == df->Gmask && sf->Bmask == df->Bmask && sf->BytesPerPixel == 4) {
#if defined(__MMX__) || defined(__3dNOW__)
#if defined(__MMX__)
if (sf->Rshift % 8 == 0 && sf->Gshift % 8 == 0 && sf->Bshift % 8 == 0 && sf->Ashift % 8 == 0 && sf->Aloss == 0) {
#ifdef __3dNOW__
if (SDL_Has3DNow()) {
return BlitRGBtoRGBPixelAlphaMMX3DNOW;
}
#endif
#ifdef __MMX__
if (SDL_HasMMX()) {
return BlitRGBtoRGBPixelAlphaMMX;
}
#endif
}
#endif /* __MMX__ || __3dNOW__ */
#endif /* __MMX__ */
if (sf->Amask == 0xff000000) {
#if SDL_ARM_NEON_BLITTERS
if (SDL_HasNEON()) {

View File

@ -164,7 +164,6 @@ int platform_testGetFunctions(void *arg)
/* !
* \brief Tests SDL_HasXYZ() functions
* \sa
* http://wiki.libsdl.org/SDL_Has3DNow
* http://wiki.libsdl.org/SDL_HasAltiVec
* http://wiki.libsdl.org/SDL_HasMMX
* http://wiki.libsdl.org/SDL_HasRDTSC
@ -188,9 +187,6 @@ int platform_testHasFunctions(void *arg)
SDL_HasMMX();
SDLTest_AssertPass("SDL_HasMMX()");
SDL_Has3DNow();
SDLTest_AssertPass("SDL_Has3DNow()");
SDL_HasSSE();
SDLTest_AssertPass("SDL_HasSSE()");

View File

@ -393,7 +393,6 @@ int TestCPUInfo(SDL_bool verbose)
SDL_Log("RDTSC %s\n", SDL_HasRDTSC() ? "detected" : "not detected");
SDL_Log("AltiVec %s\n", SDL_HasAltiVec() ? "detected" : "not detected");
SDL_Log("MMX %s\n", SDL_HasMMX() ? "detected" : "not detected");
SDL_Log("3DNow! %s\n", SDL_Has3DNow() ? "detected" : "not detected");
SDL_Log("SSE %s\n", SDL_HasSSE() ? "detected" : "not detected");
SDL_Log("SSE2 %s\n", SDL_HasSSE2() ? "detected" : "not detected");
SDL_Log("SSE3 %s\n", SDL_HasSSE3() ? "detected" : "not detected");