diff options
Diffstat (limited to 'xc/extras/Mesa/src/X86')
-rw-r--r-- | xc/extras/Mesa/src/X86/.cvsignore | 7 | ||||
-rw-r--r-- | xc/extras/Mesa/src/X86/3dnow.c | 13 | ||||
-rw-r--r-- | xc/extras/Mesa/src/X86/3dnow.h | 3 | ||||
-rw-r--r-- | xc/extras/Mesa/src/X86/Makefile.am | 2 | ||||
-rw-r--r-- | xc/extras/Mesa/src/X86/common_x86.c | 123 | ||||
-rw-r--r-- | xc/extras/Mesa/src/X86/common_x86_asm.h | 1 | ||||
-rw-r--r-- | xc/extras/Mesa/src/X86/katmai.c | 1 | ||||
-rw-r--r-- | xc/extras/Mesa/src/X86/katmai.h | 2 | ||||
-rw-r--r-- | xc/extras/Mesa/src/X86/x86_cliptest.S | 1 |
9 files changed, 146 insertions, 7 deletions
diff --git a/xc/extras/Mesa/src/X86/.cvsignore b/xc/extras/Mesa/src/X86/.cvsignore new file mode 100644 index 000000000..dcae4aa9c --- /dev/null +++ b/xc/extras/Mesa/src/X86/.cvsignore @@ -0,0 +1,7 @@ +.deps +.libs +Makefile +Makefile.in +*.lo +*.o +*.la diff --git a/xc/extras/Mesa/src/X86/3dnow.c b/xc/extras/Mesa/src/X86/3dnow.c index 7b642dc04..e52809493 100644 --- a/xc/extras/Mesa/src/X86/3dnow.c +++ b/xc/extras/Mesa/src/X86/3dnow.c @@ -30,6 +30,7 @@ #include "glheader.h" #include "context.h" +#include "shade.h" #include "types.h" #include "vertices.h" #include "xform.h" @@ -170,6 +171,18 @@ void gl_init_3dnow_transform_asm( void ) #endif } +void gl_init_3dnow_shade_asm( void ) +{ +#ifdef USE_3DNOW_ASM + /* When the time comes, initialize optimized lighting here. + */ + +#if 0 + gl_test_all_shade_functions( "3DNow!" ); +#endif +#endif +} + void gl_init_3dnow_vertex_asm( void ) { #ifdef USE_3DNOW_ASM diff --git a/xc/extras/Mesa/src/X86/3dnow.h b/xc/extras/Mesa/src/X86/3dnow.h index 6e34b6ce4..a65c51060 100644 --- a/xc/extras/Mesa/src/X86/3dnow.h +++ b/xc/extras/Mesa/src/X86/3dnow.h @@ -31,9 +31,8 @@ #ifndef __3DNOW_H__ #define __3DNOW_H__ -#include "xform.h" - void gl_init_3dnow_transform_asm( void ); +void gl_init_3dnow_shade_asm( void ); void gl_init_3dnow_vertex_asm( void ); #endif diff --git a/xc/extras/Mesa/src/X86/Makefile.am b/xc/extras/Mesa/src/X86/Makefile.am index d4d4f2ebd..96c377198 100644 --- a/xc/extras/Mesa/src/X86/Makefile.am +++ b/xc/extras/Mesa/src/X86/Makefile.am @@ -1,6 +1,6 @@ ## Process this file with automake to produce Makefile.in -AUTOMAKE_OPTIONS = no-dependencies +#AUTOMAKE_OPTIONS = no-dependencies x3dnow_files = \ 3dnow.c \ diff --git a/xc/extras/Mesa/src/X86/common_x86.c b/xc/extras/Mesa/src/X86/common_x86.c index 68b7403c2..d64484d52 100644 --- a/xc/extras/Mesa/src/X86/common_x86.c +++ b/xc/extras/Mesa/src/X86/common_x86.c @@ -53,6 +53,108 @@ static void message( const char *msg ) } } +#if defined(USE_KATMAI_ASM) && defined(__linux__) +/* + * GH: This is a hack. Try to determine at runtime what version of the + * Linux kernel we're running on, and disable the SSE assembly if the + * kernel is too old and doesn't correctly support the code. + * + * Magic versions tested for are: + * + * - 2.2.18-pre19 and newer + * - 2.4.0-test11 and newer + * + * If we find a version older than this, or can't correctly determine + * the version, disable the code to be safe. + */ +static void verify_linux_kernel_version( void ) +{ + FILE *fd; + int major, minor, teeny, extra; + int use_sse = 0; + int ret; + + fd = fopen( "/proc/sys/kernel/osrelease", "r" ); + if ( fd == NULL ) { + /* If we can't test the kernel version, disable the code. + */ + message( "couldn't open /proc/sys/kernel/osrelease, disabling SSE." ); + gl_x86_cpu_features &= ~(X86_FEATURE_XMM); + return; + } + + fscanf( fd, "%d.%d.%d", &major, &minor, &teeny ); + + if ( major == 2 ) { + if ( minor == 2 ) { + /* Test 2.2 kernel versions. 2.2.18-pre19 and newer are okay. + */ + if ( teeny == 18 ) { + ret = fscanf( fd, "-pre%d", &extra ); + switch ( ret ) { + case 1: + if ( extra >= 19 ) { + message( "kernel 2.2.18-pre19 or newer, enabling SSE." ); + use_sse = 1; + } else { + message( "kernel older than 2.2.18-pre19, disabling SSE." ); + } + break; + case 0: + message( "kernel 2.2.18 or newer, enabling SSE." ); + use_sse = 1; + break; + } + } else if ( teeny > 18 ) { + message( "kernel 2.2.19 or newer, enabling SSE." ); + use_sse = 1; + } else { + message( "kernel older than 2.2.18, disabling SSE." ); + } + + } else if ( minor == 3 ) { + message( "kernel older than 2.4.0-test11, disabling SSE." ); + } else if ( minor == 4 ) { + /* Test 2.4 kernel versions. 2.4.0-test11 and newer are okay. + */ + if ( teeny == 0 ) { + ret = fscanf( fd, "-test%d", &extra ); + switch ( ret ) { + case 1: + if ( extra >= 11 ) { + message( "kernel 2.4.0-test11 or newer, enabling SSE." ); + use_sse = 1; + } else { + message( "kernel older than 2.4.0-test11, disabling SSE." ); + } + break; + case 0: + message( "kernel 2.4.0 or newer, enabling SSE." ); + use_sse = 1; + break; + } + } else if ( teeny > 0 ) { + message( "kernel 2.4.1 or newer, enabling SSE." ); + use_sse = 1; + } + } else if ( minor >= 5 ) { + /* This test should be removed eventually, but cover ourselves + * just in case. + */ + message( "kernel 2.5.0 or newer, enabling SSE." ); + use_sse = 1; + } else { + message( "kernel older than 2.2.18-pre19, disabling SSE." ); + } + } + + fclose( fd ); + + if ( !use_sse ) { + gl_x86_cpu_features &= ~(X86_FEATURE_XMM); + } +} +#endif void gl_init_all_x86_transform_asm( void ) { @@ -89,6 +191,12 @@ void gl_init_all_x86_transform_asm( void ) #endif #ifdef USE_KATMAI_ASM +#ifdef __linux__ + /* HACK: Check the version of the Linux kernel we're being run on, + * and disable 'cpu_has_xmm' if user-space SSE is not supported. + */ + verify_linux_kernel_version(); +#endif if ( cpu_has_xmm ) { if ( getenv( "MESA_NO_KATMAI" ) == 0 ) { message( "Katmai cpu detected." ); @@ -104,6 +212,21 @@ void gl_init_all_x86_transform_asm( void ) /* Note: the above function must be called before this one, so that * gl_x86_cpu_features gets correctly initialized. */ +void gl_init_all_x86_shade_asm( void ) +{ +#ifdef USE_X86_ASM + if ( gl_x86_cpu_features ) { + /* Nothing here yet... */ + } + +#ifdef USE_3DNOW_ASM + if ( cpu_has_3dnow && getenv( "MESA_NO_3DNOW" ) == 0 ) { + gl_init_3dnow_shade_asm(); + } +#endif +#endif +} + void gl_init_all_x86_vertex_asm( void ) { #ifdef USE_X86_ASM diff --git a/xc/extras/Mesa/src/X86/common_x86_asm.h b/xc/extras/Mesa/src/X86/common_x86_asm.h index f781d503e..cf1116f8d 100644 --- a/xc/extras/Mesa/src/X86/common_x86_asm.h +++ b/xc/extras/Mesa/src/X86/common_x86_asm.h @@ -57,6 +57,7 @@ extern int gl_x86_cpu_features; extern void gl_init_all_x86_transform_asm( void ); +extern void gl_init_all_x86_shade_asm( void ); extern void gl_init_all_x86_vertex_asm( void ); #endif diff --git a/xc/extras/Mesa/src/X86/katmai.c b/xc/extras/Mesa/src/X86/katmai.c index ec40bd6db..d0aa79e27 100644 --- a/xc/extras/Mesa/src/X86/katmai.c +++ b/xc/extras/Mesa/src/X86/katmai.c @@ -22,7 +22,6 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/* $XFree86: xc/extras/Mesa/src/X86/katmai.c,v 1.6 2000/11/13 23:31:11 dawes Exp $ */ /* * PentiumIII-SIMD (SSE) optimizations contributed by diff --git a/xc/extras/Mesa/src/X86/katmai.h b/xc/extras/Mesa/src/X86/katmai.h index 0deeb629b..e1149e8a0 100644 --- a/xc/extras/Mesa/src/X86/katmai.h +++ b/xc/extras/Mesa/src/X86/katmai.h @@ -31,8 +31,6 @@ #ifndef __KATMAI_H__ #define __KATMAI_H__ -#include "xform.h" - void gl_init_katmai_transform_asm( void ); void gl_init_katmai_vertex_asm( void ); diff --git a/xc/extras/Mesa/src/X86/x86_cliptest.S b/xc/extras/Mesa/src/X86/x86_cliptest.S index a98026c31..992fec3d7 100644 --- a/xc/extras/Mesa/src/X86/x86_cliptest.S +++ b/xc/extras/Mesa/src/X86/x86_cliptest.S @@ -1,4 +1,3 @@ -/* $Id: x86_cliptest.S,v 1.1.1.1 2000/11/30 17:31:35 dawes Exp $ */ /* * Mesa 3-D graphics library |