SPARC assembly optimizations from David Miller.
[mesa.git] / src / mesa / sparc / sparc.c
1 /* $Id: sparc.c,v 1.1 2001/05/23 14:27:03 brianp 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 * Sparc assembly code by David S. Miller
29 */
30
31
32 #include "glheader.h"
33 #include "context.h"
34 #include "math/m_vertices.h"
35 #include "math/m_xform.h"
36 #include "tnl/t_context.h"
37 #include "sparc.h"
38
39 #ifdef DEBUG
40 #include "math/m_debug.h"
41 #endif
42
43 #define XFORM_ARGS GLvector4f *to_vec, \
44 const GLfloat m[16], \
45 const GLvector4f *from_vec
46
47 #define DECLARE_XFORM_GROUP(pfx, sz) \
48 extern void _mesa_##pfx##_transform_points##sz##_general(XFORM_ARGS); \
49 extern void _mesa_##pfx##_transform_points##sz##_identity(XFORM_ARGS); \
50 extern void _mesa_##pfx##_transform_points##sz##_3d_no_rot(XFORM_ARGS); \
51 extern void _mesa_##pfx##_transform_points##sz##_perspective(XFORM_ARGS); \
52 extern void _mesa_##pfx##_transform_points##sz##_2d(XFORM_ARGS); \
53 extern void _mesa_##pfx##_transform_points##sz##_2d_no_rot(XFORM_ARGS); \
54 extern void _mesa_##pfx##_transform_points##sz##_3d(XFORM_ARGS);
55
56 #define ASSIGN_XFORM_GROUP(pfx, sz) \
57 _mesa_transform_tab[sz][MATRIX_GENERAL] = \
58 _mesa_##pfx##_transform_points##sz##_general; \
59 _mesa_transform_tab[sz][MATRIX_IDENTITY] = \
60 _mesa_##pfx##_transform_points##sz##_identity; \
61 _mesa_transform_tab[sz][MATRIX_3D_NO_ROT] = \
62 _mesa_##pfx##_transform_points##sz##_3d_no_rot; \
63 _mesa_transform_tab[sz][MATRIX_PERSPECTIVE] = \
64 _mesa_##pfx##_transform_points##sz##_perspective; \
65 _mesa_transform_tab[sz][MATRIX_2D] = \
66 _mesa_##pfx##_transform_points##sz##_2d; \
67 _mesa_transform_tab[sz][MATRIX_2D_NO_ROT] = \
68 _mesa_##pfx##_transform_points##sz##_2d_no_rot; \
69 _mesa_transform_tab[sz][MATRIX_3D] = \
70 _mesa_##pfx##_transform_points##sz##_3d;
71
72
73 #ifdef USE_SPARC_ASM
74 DECLARE_XFORM_GROUP(sparc, 1)
75 DECLARE_XFORM_GROUP(sparc, 2)
76 DECLARE_XFORM_GROUP(sparc, 3)
77 DECLARE_XFORM_GROUP(sparc, 4)
78
79 extern GLvector4f *_mesa_sparc_cliptest_points4(GLvector4f *clip_vec,
80 GLvector4f *proj_vec,
81 GLubyte clipMask[],
82 GLubyte *orMask,
83 GLubyte *andMask);
84
85 extern GLvector4f *_mesa_sparc_cliptest_points4_np(GLvector4f *clip_vec,
86 GLvector4f *proj_vec,
87 GLubyte clipMask[],
88 GLubyte *orMask,
89 GLubyte *andMask);
90 #endif
91
92 void _mesa_init_all_sparc_transform_asm(void)
93 {
94 #ifdef USE_SPARC_ASM
95 ASSIGN_XFORM_GROUP(sparc, 1)
96 ASSIGN_XFORM_GROUP(sparc, 2)
97 ASSIGN_XFORM_GROUP(sparc, 3)
98 ASSIGN_XFORM_GROUP(sparc, 4)
99
100 _mesa_clip_tab[4] = _mesa_sparc_cliptest_points4;
101 _mesa_clip_np_tab[4] = _mesa_sparc_cliptest_points4_np;
102
103 #ifdef DEBUG
104 _math_test_all_transform_functions("sparc");
105 _math_test_all_cliptest_functions("sparc");
106 #endif
107
108 #endif
109 }