[MSHTML_WINETEST]
[reactos.git] / reactos / dll / opengl / mesa / x86-64 / x86-64.c
1
2 /*
3 * Mesa 3-D graphics library
4 * Version: 6.3
5 *
6 * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included
16 * in all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 */
25
26 /*
27 * x86-64 optimizations shamelessy converted from x86/sse/3dnow assembly by
28 * Mikko Tiihonen
29 */
30
31 #ifdef USE_X86_64_ASM
32
33 #include "main/glheader.h"
34 #include "main/context.h"
35 #include "math/m_xform.h"
36 #include "tnl/t_context.h"
37 #include "x86-64.h"
38 #include "../x86/x86_xform.h"
39
40 #ifdef DEBUG
41 #include "math/m_debug.h"
42 #endif
43
44 extern void _mesa_x86_64_cpuid(unsigned int *regs);
45
46 DECLARE_XFORM_GROUP( x86_64, 4 )
47 DECLARE_XFORM_GROUP( 3dnow, 4 )
48
49 #else
50 /* just to silence warning below */
51 #include "x86-64.h"
52 #endif
53
54 /*
55 extern void _mesa_x86_64_transform_points4_general( XFORM_ARGS );
56 extern void _mesa_x86_64_transform_points4_identity( XFORM_ARGS );
57 extern void _mesa_x86_64_transform_points4_perspective( XFORM_ARGS );
58 extern void _mesa_x86_64_transform_points4_3d( XFORM_ARGS );
59 extern void _mesa_x86_64_transform_points4_3d_no_rot( XFORM_ARGS );
60 extern void _mesa_x86_64_transform_points4_2d_no_rot( XFORM_ARGS );
61 extern void _mesa_x86_64_transform_points4_2d( XFORM_ARGS );
62 */
63
64 #ifdef USE_X86_64_ASM
65 static void message( const char *msg )
66 {
67 GLboolean debug;
68 #ifdef DEBUG
69 debug = GL_TRUE;
70 #else
71 if ( _mesa_getenv( "MESA_DEBUG" ) ) {
72 debug = GL_TRUE;
73 } else {
74 debug = GL_FALSE;
75 }
76 #endif
77 if ( debug ) {
78 _mesa_debug( NULL, "%s", msg );
79 }
80 }
81 #endif
82
83
84 void _mesa_init_all_x86_64_transform_asm(void)
85 {
86 #ifdef USE_X86_64_ASM
87 unsigned int regs[4];
88
89 if ( _mesa_getenv( "MESA_NO_ASM" ) ) {
90 return;
91 }
92
93 message("Initializing x86-64 optimizations\n");
94
95
96 _mesa_transform_tab[4][MATRIX_GENERAL] =
97 _mesa_x86_64_transform_points4_general;
98 _mesa_transform_tab[4][MATRIX_IDENTITY] =
99 _mesa_x86_64_transform_points4_identity;
100 _mesa_transform_tab[4][MATRIX_3D] =
101 _mesa_x86_64_transform_points4_3d;
102
103 regs[0] = 0x80000001;
104 regs[1] = 0x00000000;
105 regs[2] = 0x00000000;
106 regs[3] = 0x00000000;
107 _mesa_x86_64_cpuid(regs);
108 if (regs[3] & (1U << 31)) {
109 message("3Dnow! detected\n");
110 _mesa_transform_tab[4][MATRIX_3D_NO_ROT] =
111 _mesa_3dnow_transform_points4_3d_no_rot;
112 _mesa_transform_tab[4][MATRIX_PERSPECTIVE] =
113 _mesa_3dnow_transform_points4_perspective;
114 _mesa_transform_tab[4][MATRIX_2D_NO_ROT] =
115 _mesa_3dnow_transform_points4_2d_no_rot;
116 _mesa_transform_tab[4][MATRIX_2D] =
117 _mesa_3dnow_transform_points4_2d;
118
119 }
120
121
122 #ifdef DEBUG_MATH
123 _math_test_all_transform_functions("x86_64");
124 _math_test_all_cliptest_functions("x86_64");
125 _math_test_all_normal_transform_functions("x86_64");
126 #endif
127
128 #endif
129 }