misc -> glmisc
[mesa.git] / src / mesa / x86 / x86.c
1 /* $Id: x86.c,v 1.1 1999/08/19 00:55:42 jtg Exp $ */
2
3 /*
4 * Mesa 3-D graphics library
5 * Version: 3.1
6 *
7 * Copyright (C) 1999 Brian Paul All Rights Reserved.
8 *
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 */
26
27 /*
28 * Intel x86 assembly code by Josh Vanderhoof
29 */
30
31
32 #include <limits.h>
33 #include <stdio.h>
34 #include <stdlib.h>
35 #include <math.h>
36
37 #include "context.h"
38 #include "types.h"
39 #include "xform.h"
40 #include "x86.h"
41
42
43
44 #define XFORM_ARGS GLvector4f *to_vec, \
45 const GLmatrix *mat, \
46 const GLvector4f *from_vec, \
47 const GLubyte *mask, \
48 const GLubyte flag
49
50 #define DECLARE_XFORM_GROUP(pfx, vsize, masked) \
51 extern void gl_##pfx##_transform_points##vsize##_general_##masked(XFORM_ARGS); \
52 extern void gl_##pfx##_transform_points##vsize##_identity_##masked(XFORM_ARGS); \
53 extern void gl_##pfx##_transform_points##vsize##_3d_no_rot_##masked(XFORM_ARGS); \
54 extern void gl_##pfx##_transform_points##vsize##_perspective_##masked(XFORM_ARGS); \
55 extern void gl_##pfx##_transform_points##vsize##_2d_##masked(XFORM_ARGS); \
56 extern void gl_##pfx##_transform_points##vsize##_2d_no_rot_##masked(XFORM_ARGS); \
57 extern void gl_##pfx##_transform_points##vsize##_3d_##masked(XFORM_ARGS);
58
59 #define ASSIGN_XFORM_GROUP( pfx, cma, vsize, masked ) \
60 gl_transform_tab[cma][vsize][MATRIX_GENERAL] \
61 = gl_##pfx##_transform_points##vsize##_general_##masked; \
62 gl_transform_tab[cma][vsize][MATRIX_IDENTITY] \
63 = gl_##pfx##_transform_points##vsize##_identity_##masked; \
64 gl_transform_tab[cma][vsize][MATRIX_3D_NO_ROT] \
65 = gl_##pfx##_transform_points##vsize##_3d_no_rot_##masked; \
66 gl_transform_tab[cma][vsize][MATRIX_PERSPECTIVE] \
67 = gl_##pfx##_transform_points##vsize##_perspective_##masked; \
68 gl_transform_tab[cma][vsize][MATRIX_2D] \
69 = gl_##pfx##_transform_points##vsize##_2d_##masked; \
70 gl_transform_tab[cma][vsize][MATRIX_2D_NO_ROT] \
71 = gl_##pfx##_transform_points##vsize##_2d_no_rot_##masked; \
72 gl_transform_tab[cma][vsize][MATRIX_3D] \
73 = gl_##pfx##_transform_points##vsize##_3d_##masked;
74
75 void gl_init_x86_asm_transforms( void )
76 {
77 #ifdef USE_X86_ASM
78 DECLARE_XFORM_GROUP( x86, 2, raw )
79 DECLARE_XFORM_GROUP( x86, 3, raw )
80 DECLARE_XFORM_GROUP( x86, 4, raw )
81 DECLARE_XFORM_GROUP( x86, 2, masked )
82 DECLARE_XFORM_GROUP( x86, 3, masked )
83 DECLARE_XFORM_GROUP( x86, 4, masked )
84
85 extern GLvector4f *gl_x86_cliptest_points4( GLvector4f *clip_vec,
86 GLvector4f *proj_vec,
87 GLubyte clipMask[],
88 GLubyte *orMask,
89 GLubyte *andMask );
90
91
92 ASSIGN_XFORM_GROUP( x86, 0, 2, raw )
93 ASSIGN_XFORM_GROUP( x86, 0, 3, raw )
94 ASSIGN_XFORM_GROUP( x86, 0, 4, raw )
95
96 ASSIGN_XFORM_GROUP( x86, CULL_MASK_ACTIVE, 2, masked )
97 ASSIGN_XFORM_GROUP( x86, CULL_MASK_ACTIVE, 3, masked )
98 ASSIGN_XFORM_GROUP( x86, CULL_MASK_ACTIVE, 4, masked )
99
100 gl_clip_tab[4] = gl_x86_cliptest_points4;
101
102 #ifdef DEBUG
103 gl_test_all_transform_functions("x86");
104 #endif
105
106 #endif
107 }