]> git.sesse.net Git - vlc/commitdiff
SSE3 detection (runtime)
authorJean-Baptiste Kempf <jb@videolan.org>
Tue, 22 Sep 2009 17:34:00 +0000 (19:34 +0200)
committerJean-Baptiste Kempf <jb@videolan.org>
Tue, 22 Sep 2009 23:48:27 +0000 (01:48 +0200)
Isn't fork() supposed to be slow on Windows?

src/libvlc-module.c
src/libvlc.c
src/misc/cpu.c

index d92e614529a7a38add4f0b09eb4d5d28f3a285d3..18cefcdef998e0000619b537a7c5d7128d17e8a9 100644 (file)
@@ -1009,6 +1009,12 @@ static const char *const ppsz_clock_descriptions[] =
     "If your processor supports the SSE2 instructions set, VLC can take " \
     "advantage of them.")
 
+#define SSE3_TEXT N_("Enable CPU SSE3 support")
+#define SSE3_LONGTEXT N_( \
+    "If your processor supports the SSE3 instructions set, VLC can take " \
+    "advantage of them.")
+
+
 #define ALTIVEC_TEXT N_("Enable CPU AltiVec support")
 #define ALTIVEC_LONGTEXT N_( \
     "If your processor supports the AltiVec instructions set, VLC can take " \
@@ -1927,6 +1933,8 @@ vlc_module_begin ()
         change_need_restart ()
     add_bool( "sse2", 1, NULL, SSE2_TEXT, SSE2_LONGTEXT, true )
         change_need_restart ()
+    add_bool( "sse3", 1, NULL, SSE3_TEXT, SSE3_LONGTEXT, true )
+        change_need_restart ()
 #endif
 #if defined( __powerpc__ ) || defined( __ppc__ ) || defined( __ppc64__ )
     add_bool( "altivec", 1, NULL, ALTIVEC_TEXT, ALTIVEC_LONGTEXT, true )
index 97755fd7328161e7ef334399e34c4674ecef0e28..a1784b1ccde5a8f14700c62f4e5de2a18942e2d4 100644 (file)
@@ -761,12 +761,15 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
         cpu_flags &= ~CPU_CAPABILITY_SSE;
     if( !config_GetInt( p_libvlc, "sse2" ) )
         cpu_flags &= ~CPU_CAPABILITY_SSE2;
+    if( !config_GetInt( p_libvlc, "sse3" ) )
+        cpu_flags &= ~CPU_CAPABILITY_SSE3;
 
     PRINT_CAPABILITY( CPU_CAPABILITY_MMX, "MMX" );
     PRINT_CAPABILITY( CPU_CAPABILITY_3DNOW, "3DNow!" );
     PRINT_CAPABILITY( CPU_CAPABILITY_MMXEXT, "MMXEXT" );
     PRINT_CAPABILITY( CPU_CAPABILITY_SSE, "SSE" );
     PRINT_CAPABILITY( CPU_CAPABILITY_SSE2, "SSE2" );
+    PRINT_CAPABILITY( CPU_CAPABILITY_SSE3, "SSE3" );
 
 #elif defined( __powerpc__ ) || defined( __ppc__ ) || defined( __ppc64__ )
     if( !config_GetInt( p_libvlc, "altivec" ) )
index 615484cbef4af059d994c1b5fac5849042b67eb9..9ca2ab8bf69cce8d53f93e7ee3451686c50407b3 100644 (file)
@@ -201,6 +201,24 @@ uint32_t CPUCapabilities( void )
     }
 # endif
 
+# if defined (__SSE3__)
+    i_capabilities |= CPU_CAPABILITY_SSE3;
+# elif defined (CAN_COMPILE_SSE3)
+    if( i_ecx & 0x00000001 )
+    {
+        /* We test if OS supports the SSE3 instructions */
+        pid_t pid = fork();
+        if( pid == 0 )
+        {
+            /* Test a SSE3 instruction */
+            __asm__ __volatile__ ( "movsldup %%xmm1, %%xmm0\n" : : );
+            exit(0);
+        }
+        if( check_OS_capability( "SSE3", pid ) )
+            i_capabilities |= CPU_CAPABILITY_SSE3;
+    }
+# endif
+
     /* test for additional capabilities */
     cpuid( 0x80000000 );