Commit 4b5229c8 authored by Geoffroy Couprie's avatar Geoffroy Couprie

Win32: use IsProcessorFeaturePresent() to detect available instructions

parent 583e3215
...@@ -40,6 +40,9 @@ ...@@ -40,6 +40,9 @@
#include <signal.h> #include <signal.h>
#else #else
#include <errno.h> #include <errno.h>
#include <windows.h>
#include <winbase.h>
#define PF_SSE3_INSTRUCTIONS_AVAILABLE 13
#endif #endif
#include "libvlc.h" #include "libvlc.h"
...@@ -169,12 +172,12 @@ uint32_t CPUCapabilities( void ) ...@@ -169,12 +172,12 @@ uint32_t CPUCapabilities( void )
/* test for the MMX flag */ /* test for the MMX flag */
cpuid( 0x00000001 ); cpuid( 0x00000001 );
# if !defined (__MMX__) # if !defined (__MMX__)
if( ! (i_edx & 0x00800000) ) if( ! (i_edx & 0x00800000) )
goto out; goto out;
# endif # endif
i_capabilities |= CPU_CAPABILITY_MMX; i_capabilities |= CPU_CAPABILITY_MMX;
# if defined (__SSE__) # if defined (__SSE__)
i_capabilities |= CPU_CAPABILITY_MMXEXT | CPU_CAPABILITY_SSE; i_capabilities |= CPU_CAPABILITY_MMXEXT | CPU_CAPABILITY_SSE;
# else # else
...@@ -183,8 +186,13 @@ uint32_t CPUCapabilities( void ) ...@@ -183,8 +186,13 @@ uint32_t CPUCapabilities( void )
i_capabilities |= CPU_CAPABILITY_MMXEXT; i_capabilities |= CPU_CAPABILITY_MMXEXT;
# ifdef CAN_COMPILE_SSE # ifdef CAN_COMPILE_SSE
# ifdef WIN32
if( IsProcessorFeaturePresent( PF_XMMI_INSTRUCTIONS_AVAILABLE ) )
i_capabilities |= CPU_CAPABILITY_SSE;
# else
check_capability( "SSE", CPU_CAPABILITY_SSE, check_capability( "SSE", CPU_CAPABILITY_SSE,
"xorps %%xmm0,%%xmm0\n" ); "xorps %%xmm0,%%xmm0\n" );
# endif
# endif # endif
} }
# endif # endif
...@@ -193,40 +201,66 @@ uint32_t CPUCapabilities( void ) ...@@ -193,40 +201,66 @@ uint32_t CPUCapabilities( void )
i_capabilities |= CPU_CAPABILITY_SSE2; i_capabilities |= CPU_CAPABILITY_SSE2;
# elif defined (CAN_COMPILE_SSE2) # elif defined (CAN_COMPILE_SSE2)
if( i_edx & 0x04000000 ) if( i_edx & 0x04000000 )
{
# ifdef WIN32
if( IsProcessorFeaturePresent( PF_XMMI64_INSTRUCTIONS_AVAILABLE ) )
i_capabilities |= CPU_CAPABILITY_SSE2;
# else
check_capability( "SSE2", CPU_CAPABILITY_SSE2, check_capability( "SSE2", CPU_CAPABILITY_SSE2,
"movupd %%xmm0, %%xmm0\n" ); "movupd %%xmm0, %%xmm0\n" );
# endif # endif
}
# endif
# if defined (__SSE3__) # if defined (__SSE3__)
i_capabilities |= CPU_CAPABILITY_SSE3; i_capabilities |= CPU_CAPABILITY_SSE3;
# elif defined (CAN_COMPILE_SSE3) # elif defined (CAN_COMPILE_SSE3)
if( i_ecx & 0x00000001 ) if( i_ecx & 0x00000001 )
{
# ifdef WIN32
if( IsProcessorFeaturePresent( PF_SSE3_INSTRUCTIONS_AVAILABLE ) )
i_capabilities |= CPU_CAPABILITY_SSE3;
# else
check_capability( "SSE3", CPU_CAPABILITY_SSE3, check_capability( "SSE3", CPU_CAPABILITY_SSE3,
"movsldup %%xmm1, %%xmm0\n" ); "movsldup %%xmm1, %%xmm0\n" );
# endif # endif
}
# endif
# if defined (__SSSE3__) # if defined (__SSSE3__)
i_capabilities |= CPU_CAPABILITY_SSSE3; i_capabilities |= CPU_CAPABILITY_SSSE3;
# elif defined (CAN_COMPILE_SSSE3) # elif defined (CAN_COMPILE_SSSE3)
# ifdef WIN32
/* FIXME: IsProcessorFeaturePresent can't check for SSSE3 */
# else
if( i_ecx & 0x00000200 ) if( i_ecx & 0x00000200 )
check_capability( "SSSE3", CPU_CAPABILITY_SSSE3, check_capability( "SSSE3", CPU_CAPABILITY_SSSE3,
"pabsw %%xmm1, %%xmm0\n" ); "pabsw %%xmm1, %%xmm0\n" );
# endif # endif
# endif
# if defined (__SSE4_1__) # if defined (__SSE4_1__)
i_capabilities |= CPU_CAPABILITY_SSE4_1; i_capabilities |= CPU_CAPABILITY_SSE4_1;
# elif defined (CAN_COMPILE_SSE4_1) # elif defined (CAN_COMPILE_SSE4_1)
# ifdef WIN32
/* FIXME: IsProcessorFeaturePresent can't check for SSE4.1 */
# else
if( i_ecx & 0x00080000 ) if( i_ecx & 0x00080000 )
check_capability( "SSE4.1", CPU_CAPABILITY_SSE4_1, check_capability( "SSE4.1", CPU_CAPABILITY_SSE4_1,
"pmaxsb %%xmm1, %%xmm0\n" ); "pmaxsb %%xmm1, %%xmm0\n" );
# endif # endif
# endif
# if defined (__SSE4_2__) # if defined (__SSE4_2__)
i_capabilities |= CPU_CAPABILITY_SSE4_2; i_capabilities |= CPU_CAPABILITY_SSE4_2;
# elif defined (CAN_COMPILE_SSE4_2) # elif defined (CAN_COMPILE_SSE4_2)
# ifdef WIN32
/* FIXME: IsProcessorFeaturePresent can't check for SSE4.2 */
# else
if( i_ecx & 0x00100000 ) if( i_ecx & 0x00100000 )
check_capability( "SSE4.2", CPU_CAPABILITY_SSE4_2, check_capability( "SSE4.2", CPU_CAPABILITY_SSE4_2,
"pcmpgtq %%xmm1, %%xmm0\n" ); "pcmpgtq %%xmm1, %%xmm0\n" );
# endif
# endif # endif
/* test for additional capabilities */ /* test for additional capabilities */
...@@ -241,10 +275,18 @@ uint32_t CPUCapabilities( void ) ...@@ -241,10 +275,18 @@ uint32_t CPUCapabilities( void )
# if defined (__3dNOW__) # if defined (__3dNOW__)
i_capabilities |= CPU_CAPABILITY_3DNOW; i_capabilities |= CPU_CAPABILITY_3DNOW;
# elif defined (CAN_COMPILE_3DNOW) # elif defined (CAN_COMPILE_3DNOW)
if( i_edx & 0x80000000 ) if( i_edx & 0x80000000 )
{
# ifdef WIN32
if( IsProcessorFeaturePresent( PF_3DNOW_INSTRUCTIONS_AVAILABLE ) )
i_capabilities |= CPU_CAPABILITY_3DNOW;
# else
check_capability( "3D Now!", CPU_CAPABILITY_3DNOW, check_capability( "3D Now!", CPU_CAPABILITY_3DNOW,
"pfadd %%mm0,%%mm0\n" "femms\n" ); "pfadd %%mm0,%%mm0\n" "femms\n" );
# endif # endif
}
# endif
if( b_amd && ( i_edx & 0x00400000 ) ) if( b_amd && ( i_edx & 0x00400000 ) )
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment