Changes to reduce the memory footprint of display lists
[mesa.git] / src / mesa / x86 / x86.c
1 /* $Id: x86.c,v 1.2 1999/10/19 18:37:07 keithw 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 "vertices.h"
40 #include "xform.h"
41 #include "x86.h"
42
43 extern void gl_v16_x86_cliptest_points4(GLfloat *first_vert,
44 GLfloat *last_vert,
45 GLubyte *or_mask,
46 GLubyte *and_mask,
47 GLubyte *clip_mask );
48
49
50 extern void gl_v16_x86_general_xform(GLfloat *dest,
51 const GLfloat *m,
52 const GLfloat *src,
53 GLuint src_stride,
54 GLuint count);
55
56
57
58 #define XFORM_ARGS GLvector4f *to_vec, \
59 const GLmatrix *mat, \
60 const GLvector4f *from_vec, \
61 const GLubyte *mask, \
62 const GLubyte flag
63
64 #define DECLARE_XFORM_GROUP(pfx, vsize, masked) \
65 extern void gl_##pfx##_transform_points##vsize##_general_##masked(XFORM_ARGS); \
66 extern void gl_##pfx##_transform_points##vsize##_identity_##masked(XFORM_ARGS); \
67 extern void gl_##pfx##_transform_points##vsize##_3d_no_rot_##masked(XFORM_ARGS); \
68 extern void gl_##pfx##_transform_points##vsize##_perspective_##masked(XFORM_ARGS); \
69 extern void gl_##pfx##_transform_points##vsize##_2d_##masked(XFORM_ARGS); \
70 extern void gl_##pfx##_transform_points##vsize##_2d_no_rot_##masked(XFORM_ARGS); \
71 extern void gl_##pfx##_transform_points##vsize##_3d_##masked(XFORM_ARGS);
72
73 #define ASSIGN_XFORM_GROUP( pfx, cma, vsize, masked ) \
74 gl_transform_tab[cma][vsize][MATRIX_GENERAL] \
75 = gl_##pfx##_transform_points##vsize##_general_##masked; \
76 gl_transform_tab[cma][vsize][MATRIX_IDENTITY] \
77 = gl_##pfx##_transform_points##vsize##_identity_##masked; \
78 gl_transform_tab[cma][vsize][MATRIX_3D_NO_ROT] \
79 = gl_##pfx##_transform_points##vsize##_3d_no_rot_##masked; \
80 gl_transform_tab[cma][vsize][MATRIX_PERSPECTIVE] \
81 = gl_##pfx##_transform_points##vsize##_perspective_##masked; \
82 gl_transform_tab[cma][vsize][MATRIX_2D] \
83 = gl_##pfx##_transform_points##vsize##_2d_##masked; \
84 gl_transform_tab[cma][vsize][MATRIX_2D_NO_ROT] \
85 = gl_##pfx##_transform_points##vsize##_2d_no_rot_##masked; \
86 gl_transform_tab[cma][vsize][MATRIX_3D] \
87 = gl_##pfx##_transform_points##vsize##_3d_##masked;
88
89 void gl_init_x86_asm_transforms( void )
90 {
91 #ifdef USE_X86_ASM
92 DECLARE_XFORM_GROUP( x86, 2, raw )
93 DECLARE_XFORM_GROUP( x86, 3, raw )
94 DECLARE_XFORM_GROUP( x86, 4, raw )
95 DECLARE_XFORM_GROUP( x86, 2, masked )
96 DECLARE_XFORM_GROUP( x86, 3, masked )
97 DECLARE_XFORM_GROUP( x86, 4, masked )
98
99 extern GLvector4f *gl_x86_cliptest_points4( GLvector4f *clip_vec,
100 GLvector4f *proj_vec,
101 GLubyte clipMask[],
102 GLubyte *orMask,
103 GLubyte *andMask );
104
105
106 ASSIGN_XFORM_GROUP( x86, 0, 2, raw )
107 ASSIGN_XFORM_GROUP( x86, 0, 3, raw )
108 ASSIGN_XFORM_GROUP( x86, 0, 4, raw )
109
110 ASSIGN_XFORM_GROUP( x86, CULL_MASK_ACTIVE, 2, masked )
111 ASSIGN_XFORM_GROUP( x86, CULL_MASK_ACTIVE, 3, masked )
112 ASSIGN_XFORM_GROUP( x86, CULL_MASK_ACTIVE, 4, masked )
113
114 gl_clip_tab[4] = gl_x86_cliptest_points4;
115
116 #ifdef DEBUG
117 gl_test_all_transform_functions("x86");
118 #endif
119
120
121 gl_cliptest_points4_v16 = gl_v16_x86_cliptest_points4;
122 gl_xform_points3_v16_general = gl_v16_x86_general_xform;
123 #endif
124 }