#include "math/m_debug.h"
#endif
+extern void _mesa_x86_64_cpuid(unsigned int *regs);
+
DECLARE_XFORM_GROUP( x86_64, 4 )
+DECLARE_XFORM_GROUP( 3dnow, 4 )
#else
/* just to silence warning below */
void _mesa_init_all_x86_64_transform_asm(void)
{
#ifdef USE_X86_64_ASM
+ unsigned int regs[4];
if ( _mesa_getenv( "MESA_NO_ASM" ) ) {
return;
message("Initializing x86-64 optimizations\n");
- ASSIGN_XFORM_GROUP( x86_64, 4 );
- /*
_mesa_transform_tab[4][MATRIX_GENERAL] =
_mesa_x86_64_transform_points4_general;
_mesa_transform_tab[4][MATRIX_IDENTITY] =
_mesa_x86_64_transform_points4_identity;
_mesa_transform_tab[4][MATRIX_3D] =
_mesa_x86_64_transform_points4_3d;
- _mesa_transform_tab[4][MATRIX_3D_NO_ROT] =
- _mesa_x86_64_transform_points4_3d_no_rot;
- _mesa_transform_tab[4][MATRIX_PERSPECTIVE] =
- _mesa_x86_64_transform_points4_perspective;
- _mesa_transform_tab[4][MATRIX_2D_NO_ROT] =
- _mesa_x86_64_transform_points4_2d_no_rot;
- _mesa_transform_tab[4][MATRIX_2D] =
- _mesa_x86_64_transform_points4_2d;
- */
+
+ regs[0] = 0x80000001;
+ regs[1] = 0x00000000;
+ regs[2] = 0x00000000;
+ regs[3] = 0x00000000;
+ _mesa_x86_64_cpuid(regs);
+ if (regs[3] & (1U << 31)) {
+ message("3Dnow! detected\n");
+ _mesa_transform_tab[4][MATRIX_3D_NO_ROT] =
+ _mesa_3dnow_transform_points4_3d_no_rot;
+ _mesa_transform_tab[4][MATRIX_PERSPECTIVE] =
+ _mesa_3dnow_transform_points4_perspective;
+ _mesa_transform_tab[4][MATRIX_2D_NO_ROT] =
+ _mesa_3dnow_transform_points4_2d_no_rot;
+ _mesa_transform_tab[4][MATRIX_2D] =
+ _mesa_3dnow_transform_points4_2d;
+
+ }
+
#ifdef DEBUG_MATH
_math_test_all_transform_functions("x86_64");
.text
.align 16
+.globl _mesa_x86_64_cpuid
+_mesa_x86_64_cpuid:
+ pushq %rbx
+ movl (%rdi), %eax
+ movl 8(%rdi), %ecx
+
+ cpuid
+
+ movl %ebx, 4(%rdi)
+ movl %eax, (%rdi)
+ movl %ecx, 8(%rdi)
+ movl %edx, 12(%rdi)
+ popq %rbx
+ ret
+.align 16
.globl _mesa_x86_64_transform_points4_general
_mesa_x86_64_transform_points4_general:
/*
.align 16
-.globl _mesa_x86_64_transform_points4_3d_no_rot
-_mesa_x86_64_transform_points4_3d_no_rot:
+.globl _mesa_3dnow_transform_points4_3d_no_rot
+_mesa_3dnow_transform_points4_3d_no_rot:
movl V4F_COUNT(%rdx), %ecx /* count */
movzx V4F_STRIDE(%rdx), %eax /* stride */
.align 16
-.globl _mesa_x86_64_transform_points4_perspective
-_mesa_x86_64_transform_points4_perspective:
+.globl _mesa_3dnow_transform_points4_perspective
+_mesa_3dnow_transform_points4_perspective:
movl V4F_COUNT(%rdx), %ecx /* count */
movzx V4F_STRIDE(%rdx), %eax /* stride */
ret
.align 16
-.globl _mesa_x86_64_transform_points4_2d_no_rot
-_mesa_x86_64_transform_points4_2d_no_rot:
+.globl _mesa_3dnow_transform_points4_2d_no_rot
+_mesa_3dnow_transform_points4_2d_no_rot:
movl V4F_COUNT(%rdx), %ecx /* count */
movzx V4F_STRIDE(%rdx), %eax /* stride */
.align 16
-.globl _mesa_x86_64_transform_points4_2d
-_mesa_x86_64_transform_points4_2d:
+.globl _mesa_3dnow_transform_points4_2d
+_mesa_3dnow_transform_points4_2d:
movl V4F_COUNT(%rdx), %ecx /* count */
movzx V4F_STRIDE(%rdx), %eax /* stride */