17117f1b4Smrg 27117f1b4Smrg/* 37117f1b4Smrg * Mesa 3-D graphics library 47117f1b4Smrg * 57117f1b4Smrg * Copyright (C) 1999-2003 Brian Paul All Rights Reserved. 67117f1b4Smrg * 77117f1b4Smrg * Permission is hereby granted, free of charge, to any person obtaining a 87117f1b4Smrg * copy of this software and associated documentation files (the "Software"), 97117f1b4Smrg * to deal in the Software without restriction, including without limitation 107117f1b4Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 117117f1b4Smrg * and/or sell copies of the Software, and to permit persons to whom the 127117f1b4Smrg * Software is furnished to do so, subject to the following conditions: 137117f1b4Smrg * 147117f1b4Smrg * The above copyright notice and this permission notice shall be included 157117f1b4Smrg * in all copies or substantial portions of the Software. 167117f1b4Smrg * 177117f1b4Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 187117f1b4Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 197117f1b4Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20af69d88dSmrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21af69d88dSmrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22af69d88dSmrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23af69d88dSmrg * OTHER DEALINGS IN THE SOFTWARE. 247117f1b4Smrg */ 257117f1b4Smrg 267117f1b4Smrg/* 277117f1b4Smrg * x86-64 optimizations shamelessy converted from x86/sse/3dnow assembly by 287117f1b4Smrg * Mikko Tiihonen 297117f1b4Smrg */ 307117f1b4Smrg 317117f1b4Smrg#ifdef USE_X86_64_ASM 327117f1b4Smrg 33c1f859d4Smrg#include "main/glheader.h" 34c1f859d4Smrg#include "main/context.h" 357117f1b4Smrg#include "math/m_xform.h" 367117f1b4Smrg#include "tnl/t_context.h" 377117f1b4Smrg#include "x86-64.h" 384a49301eSmrg#include "../x86/x86_xform.h" 397117f1b4Smrg 407117f1b4Smrg#ifdef DEBUG 417117f1b4Smrg#include "math/m_debug.h" 427117f1b4Smrg#endif 437117f1b4Smrg 44c1f859d4Smrgextern void _mesa_x86_64_cpuid(unsigned int *regs); 45c1f859d4Smrg 467117f1b4SmrgDECLARE_XFORM_GROUP( x86_64, 4 ) 47c1f859d4SmrgDECLARE_XFORM_GROUP( 3dnow, 4 ) 487117f1b4Smrg 497117f1b4Smrg#else 507117f1b4Smrg/* just to silence warning below */ 517117f1b4Smrg#include "x86-64.h" 527117f1b4Smrg#endif 537117f1b4Smrg 547117f1b4Smrg/* 557117f1b4Smrgextern void _mesa_x86_64_transform_points4_general( XFORM_ARGS ); 567117f1b4Smrgextern void _mesa_x86_64_transform_points4_identity( XFORM_ARGS ); 577117f1b4Smrgextern void _mesa_x86_64_transform_points4_perspective( XFORM_ARGS ); 587117f1b4Smrgextern void _mesa_x86_64_transform_points4_3d( XFORM_ARGS ); 597117f1b4Smrgextern void _mesa_x86_64_transform_points4_3d_no_rot( XFORM_ARGS ); 607117f1b4Smrgextern void _mesa_x86_64_transform_points4_2d_no_rot( XFORM_ARGS ); 617117f1b4Smrgextern void _mesa_x86_64_transform_points4_2d( XFORM_ARGS ); 627117f1b4Smrg*/ 637117f1b4Smrg 647117f1b4Smrg#ifdef USE_X86_64_ASM 657117f1b4Smrgstatic void message( const char *msg ) 667117f1b4Smrg{ 6701e04c3fSmrg if (getenv("MESA_DEBUG")) { 687117f1b4Smrg _mesa_debug( NULL, "%s", msg ); 697117f1b4Smrg } 707117f1b4Smrg} 717117f1b4Smrg#endif 727117f1b4Smrg 737117f1b4Smrg 747117f1b4Smrgvoid _mesa_init_all_x86_64_transform_asm(void) 757117f1b4Smrg{ 767117f1b4Smrg#ifdef USE_X86_64_ASM 77c1f859d4Smrg unsigned int regs[4]; 787117f1b4Smrg 7901e04c3fSmrg if ( getenv( "MESA_NO_ASM" ) ) { 807117f1b4Smrg return; 817117f1b4Smrg } 827117f1b4Smrg 837117f1b4Smrg message("Initializing x86-64 optimizations\n"); 847117f1b4Smrg 857117f1b4Smrg 867117f1b4Smrg _mesa_transform_tab[4][MATRIX_GENERAL] = 877117f1b4Smrg _mesa_x86_64_transform_points4_general; 887117f1b4Smrg _mesa_transform_tab[4][MATRIX_IDENTITY] = 897117f1b4Smrg _mesa_x86_64_transform_points4_identity; 907117f1b4Smrg _mesa_transform_tab[4][MATRIX_3D] = 917117f1b4Smrg _mesa_x86_64_transform_points4_3d; 92c1f859d4Smrg 93c1f859d4Smrg regs[0] = 0x80000001; 94c1f859d4Smrg regs[1] = 0x00000000; 95c1f859d4Smrg regs[2] = 0x00000000; 96c1f859d4Smrg regs[3] = 0x00000000; 97c1f859d4Smrg _mesa_x86_64_cpuid(regs); 98c1f859d4Smrg if (regs[3] & (1U << 31)) { 99c1f859d4Smrg message("3Dnow! detected\n"); 100c1f859d4Smrg _mesa_transform_tab[4][MATRIX_3D_NO_ROT] = 101c1f859d4Smrg _mesa_3dnow_transform_points4_3d_no_rot; 102c1f859d4Smrg _mesa_transform_tab[4][MATRIX_PERSPECTIVE] = 103c1f859d4Smrg _mesa_3dnow_transform_points4_perspective; 104c1f859d4Smrg _mesa_transform_tab[4][MATRIX_2D_NO_ROT] = 105c1f859d4Smrg _mesa_3dnow_transform_points4_2d_no_rot; 106c1f859d4Smrg _mesa_transform_tab[4][MATRIX_2D] = 107c1f859d4Smrg _mesa_3dnow_transform_points4_2d; 108c1f859d4Smrg 109c1f859d4Smrg } 110c1f859d4Smrg 1117117f1b4Smrg 1127117f1b4Smrg#ifdef DEBUG_MATH 1137117f1b4Smrg _math_test_all_transform_functions("x86_64"); 1147117f1b4Smrg _math_test_all_cliptest_functions("x86_64"); 1157117f1b4Smrg _math_test_all_normal_transform_functions("x86_64"); 1167117f1b4Smrg#endif 1177117f1b4Smrg 1187117f1b4Smrg#endif 1197117f1b4Smrg} 120