1 /* $Id: sparc.c,v 1.8 2002/07/12 16:00:57 brianp Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
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:
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
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.
28 * Sparc assembly code by David S. Miller
33 #include "math/m_xform.h"
34 #include "tnl/t_context.h"
38 #include "math/m_debug.h"
41 #define XFORM_ARGS GLvector4f *to_vec, \
42 const GLfloat m[16], \
43 const GLvector4f *from_vec
45 #define DECLARE_XFORM_GROUP(pfx, sz) \
46 extern void _mesa_##pfx##_transform_points##sz##_general(XFORM_ARGS); \
47 extern void _mesa_##pfx##_transform_points##sz##_identity(XFORM_ARGS); \
48 extern void _mesa_##pfx##_transform_points##sz##_3d_no_rot(XFORM_ARGS); \
49 extern void _mesa_##pfx##_transform_points##sz##_perspective(XFORM_ARGS); \
50 extern void _mesa_##pfx##_transform_points##sz##_2d(XFORM_ARGS); \
51 extern void _mesa_##pfx##_transform_points##sz##_2d_no_rot(XFORM_ARGS); \
52 extern void _mesa_##pfx##_transform_points##sz##_3d(XFORM_ARGS);
54 #define ASSIGN_XFORM_GROUP(pfx, sz) \
55 _mesa_transform_tab[sz][MATRIX_GENERAL] = \
56 _mesa_##pfx##_transform_points##sz##_general; \
57 _mesa_transform_tab[sz][MATRIX_IDENTITY] = \
58 _mesa_##pfx##_transform_points##sz##_identity; \
59 _mesa_transform_tab[sz][MATRIX_3D_NO_ROT] = \
60 _mesa_##pfx##_transform_points##sz##_3d_no_rot; \
61 _mesa_transform_tab[sz][MATRIX_PERSPECTIVE] = \
62 _mesa_##pfx##_transform_points##sz##_perspective; \
63 _mesa_transform_tab[sz][MATRIX_2D] = \
64 _mesa_##pfx##_transform_points##sz##_2d; \
65 _mesa_transform_tab[sz][MATRIX_2D_NO_ROT] = \
66 _mesa_##pfx##_transform_points##sz##_2d_no_rot; \
67 _mesa_transform_tab[sz][MATRIX_3D] = \
68 _mesa_##pfx##_transform_points##sz##_3d;
72 DECLARE_XFORM_GROUP(sparc
, 1)
73 DECLARE_XFORM_GROUP(sparc
, 2)
74 DECLARE_XFORM_GROUP(sparc
, 3)
75 DECLARE_XFORM_GROUP(sparc
, 4)
77 extern GLvector4f
*_mesa_sparc_cliptest_points4(GLvector4f
*clip_vec
,
83 extern GLvector4f
*_mesa_sparc_cliptest_points4_np(GLvector4f
*clip_vec
,
89 #define NORM_ARGS const GLmatrix *mat, \
91 const GLvector3f *in, \
92 const GLfloat *lengths, \
95 extern void _mesa_sparc_transform_normalize_normals(NORM_ARGS
);
96 extern void _mesa_sparc_transform_normalize_normals_no_rot(NORM_ARGS
);
97 extern void _mesa_sparc_transform_rescale_normals_no_rot(NORM_ARGS
);
98 extern void _mesa_sparc_transform_rescale_normals(NORM_ARGS
);
99 extern void _mesa_sparc_transform_normals_no_rot(NORM_ARGS
);
100 extern void _mesa_sparc_transform_normals(NORM_ARGS
);
101 extern void _mesa_sparc_normalize_normals(NORM_ARGS
);
102 extern void _mesa_sparc_rescale_normals(NORM_ARGS
);
106 void _mesa_init_all_sparc_transform_asm(void)
109 ASSIGN_XFORM_GROUP(sparc
, 1)
110 ASSIGN_XFORM_GROUP(sparc
, 2)
111 ASSIGN_XFORM_GROUP(sparc
, 3)
112 ASSIGN_XFORM_GROUP(sparc
, 4)
115 /* Disabled for now. See Mesa bug report # 544665. Evidently these
116 * functions are using SPARC registers that shouldn't be touched.
118 _mesa_clip_tab
[4] = _mesa_sparc_cliptest_points4
;
119 _mesa_clip_np_tab
[4] = _mesa_sparc_cliptest_points4_np
;
121 _mesa_normal_tab
[NORM_TRANSFORM
| NORM_NORMALIZE
] =
122 _mesa_sparc_transform_normalize_normals
;
123 _mesa_normal_tab
[NORM_TRANSFORM_NO_ROT
| NORM_NORMALIZE
] =
124 _mesa_sparc_transform_normalize_normals_no_rot
;
125 _mesa_normal_tab
[NORM_TRANSFORM_NO_ROT
| NORM_RESCALE
] =
126 _mesa_sparc_transform_rescale_normals_no_rot
;
127 _mesa_normal_tab
[NORM_TRANSFORM
| NORM_RESCALE
] =
128 _mesa_sparc_transform_rescale_normals
;
129 _mesa_normal_tab
[NORM_TRANSFORM_NO_ROT
] =
130 _mesa_sparc_transform_normals_no_rot
;
131 _mesa_normal_tab
[NORM_TRANSFORM
] =
132 _mesa_sparc_transform_normals
;
133 _mesa_normal_tab
[NORM_NORMALIZE
] =
134 _mesa_sparc_normalize_normals
;
135 _mesa_normal_tab
[NORM_RESCALE
] =
136 _mesa_sparc_rescale_normals
;
139 _math_test_all_transform_functions("sparc");
140 _math_test_all_cliptest_functions("sparc");
141 _math_test_all_normal_transform_functions("sparc");
147 extern unsigned int _mesa_sparc_glapi_begin
;
148 extern unsigned int _mesa_sparc_glapi_end
;
149 extern void __glapi_sparc_icache_flush(unsigned int *);
151 void _mesa_init_sparc_glapi_relocs(void)
153 unsigned int *insn_ptr
, *end_ptr
;
154 unsigned long disp_addr
;
156 insn_ptr
= &_mesa_sparc_glapi_begin
;
157 end_ptr
= &_mesa_sparc_glapi_end
;
158 disp_addr
= (unsigned long) &_glapi_Dispatch
;
160 while (insn_ptr
< end_ptr
) {
162 insn_ptr
[0] |= (disp_addr
>> (32 + 10));
163 insn_ptr
[1] |= ((disp_addr
& 0xffffffff) >> 10);
164 __glapi_sparc_icache_flush(&insn_ptr
[0]);
165 insn_ptr
[2] |= ((disp_addr
>> 32) & ((1 << 10) - 1));
166 insn_ptr
[3] |= (disp_addr
& ((1 << 10) - 1));
167 __glapi_sparc_icache_flush(&insn_ptr
[2]);
170 insn_ptr
[0] |= (disp_addr
>> 10);
171 insn_ptr
[1] |= (disp_addr
& ((1 << 10) - 1));
172 __glapi_sparc_icache_flush(&insn_ptr
[0]);