• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1
2/*
3 * Mesa 3-D graphics library
4 *
5 * Copyright (C) 1999-2001  Brian Paul   All Rights Reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 * OTHER DEALINGS IN THE SOFTWARE.
24 */
25
26#ifdef USE_SSE_ASM
27#include "assyntax.h"
28#include "matypes.h"
29#include "xform_args.h"
30
31	SEG_TEXT
32
33#define FRAME_OFFSET	8
34
35#define SRC(i)		REGOFF(i * 4, ESI)
36#define DST(i)		REGOFF(i * 4, EDI)
37#define MAT(i)		REGOFF(i * 4, EDX)
38
39#define SELECT(r0, r1, r2, r3)	CONST( r0 * 64 + r1 * 16 + r2 * 4 + r3 )
40
41
42ALIGNTEXT16
43GLOBL GLNAME( _mesa_sse_transform_points4_general )
44HIDDEN(_mesa_sse_transform_points4_general)
45GLNAME( _mesa_sse_transform_points4_general ):
46
47	PUSH_L( ESI )
48	PUSH_L( EDI )
49
50	MOV_L( ARG_SOURCE, ESI )
51	MOV_L( ARG_DEST, EDI )
52
53	MOV_L( ARG_MATRIX, EDX )
54	MOV_L( REGOFF(V4F_COUNT, ESI), ECX )
55
56	TEST_L( ECX, ECX )			/* verify non-zero count */
57	JE( LLBL( sse_general_done ) )
58
59	MOV_L( REGOFF(V4F_STRIDE, ESI), EAX )	/* stride */
60	OR_L( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */
61
62	MOV_L( ECX, REGOFF(V4F_COUNT, EDI) )	/* set dest count */
63	MOV_L( CONST(4), REGOFF(V4F_SIZE, EDI) )/* set dest size */
64
65	MOV_L( REGOFF(V4F_START, ESI), ESI )	/* ptr to first source vertex */
66	MOV_L( REGOFF(V4F_START, EDI), EDI )	/* ptr to first dest vertex */
67
68	PREFETCHT0( REGIND(ESI) )
69
70	MOVAPS( MAT(0), XMM4 )			/* m3  | m2  | m1  | m0  */
71	MOVAPS( MAT(4), XMM5 )			/* m7  | m6  | m5  | m4  */
72	MOVAPS( MAT(8), XMM6 )			/* m11 | m10 | m9  | m8  */
73	MOVAPS( MAT(12), XMM7 )			/* m15 | m14 | m13 | m12 */
74
75ALIGNTEXT16
76LLBL( sse_general_loop ):
77
78	MOVSS( SRC(0), XMM0 )			/* ox */
79	SHUFPS( CONST(0x0), XMM0, XMM0 )	/* ox | ox | ox | ox */
80	MULPS( XMM4, XMM0 )			/* ox*m3 | ox*m2 | ox*m1 | ox*m0 */
81
82	MOVSS( SRC(1), XMM1 )			/* oy */
83	SHUFPS( CONST(0x0), XMM1, XMM1 )	/* oy | oy | oy | oy */
84	MULPS( XMM5, XMM1 )			/* oy*m7 | oy*m6 | oy*m5 | oy*m4 */
85
86	MOVSS( SRC(2), XMM2 )			/* oz */
87	SHUFPS( CONST(0x0), XMM2, XMM2 )	/* oz | oz | oz | oz */
88	MULPS( XMM6, XMM2 )			/* oz*m11 | oz*m10 | oz*m9 | oz*m8 */
89
90	MOVSS( SRC(3), XMM3 )			/* ow */
91	SHUFPS( CONST(0x0), XMM3, XMM3 )	/* ow | ow | ow | ow */
92	MULPS( XMM7, XMM3 )			/* ow*m15 | ow*m14 | ow*m13 | ow*m12 */
93
94	ADDPS( XMM1, XMM0 )			/* ox*m3+oy*m7 | ... */
95	ADDPS( XMM2, XMM0 )			/* ox*m3+oy*m7+oz*m11 | ... */
96	ADDPS( XMM3, XMM0 )			/* ox*m3+oy*m7+oz*m11+ow*m15 | ... */
97	MOVAPS( XMM0, DST(0) )			/* ->D(3) | ->D(2) | ->D(1) | ->D(0) */
98
99	ADD_L( CONST(16), EDI )
100	ADD_L( EAX, ESI )
101
102	DEC_L( ECX )
103	JNZ( LLBL( sse_general_loop ) )
104
105LLBL( sse_general_done ):
106
107	POP_L( EDI )
108	POP_L( ESI )
109	RET
110
111
112
113
114ALIGNTEXT4
115GLOBL GLNAME( _mesa_sse_transform_points4_3d )
116HIDDEN(_mesa_sse_transform_points4_3d)
117GLNAME( _mesa_sse_transform_points4_3d ):
118
119	PUSH_L( ESI )
120	PUSH_L( EDI )
121
122	MOV_L( ARG_SOURCE, ESI )		/* ptr to source GLvector4f */
123	MOV_L( ARG_DEST, EDI )			/* ptr to dest GLvector4f */
124
125	MOV_L( ARG_MATRIX, EDX )		/* ptr to matrix */
126	MOV_L( REGOFF(V4F_COUNT, ESI), ECX )	/* source count */
127
128	TEST_L( ECX, ECX)
129	JZ( LLBL(K_GTP43P3DR_finish) )		/* count was zero; go to finish */
130
131	MOV_L( REGOFF(V4F_STRIDE, ESI), EAX )	/* stride */
132	OR_L( CONST(VEC_SIZE_3), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */
133
134	MOV_L( ECX, REGOFF(V4F_COUNT, EDI) )	/* set dest count */
135	MOV_L( CONST(3), REGOFF(V4F_SIZE, EDI) )/* set dest size */
136
137	SHL_L( CONST(4), ECX )			/* count *= 16 */
138	MOV_L( REGOFF(V4F_START, ESI), ESI )	/* ptr to first source vertex */
139
140	MOV_L( REGOFF(V4F_START, EDI), EDI )	/* ptr to first dest vertex */
141	ADD_L( EDI, ECX )			/* count += dest ptr */
142
143	MOVAPS( MAT(0), XMM0 )			/* m3  | m2  | m1  |  m0 */
144	MOVAPS( MAT(4), XMM1 )			/* m7  | m6  | m5  |  m4 */
145	MOVAPS( MAT(8), XMM2 )			/* m11 | m10 | m9  |  m8 */
146	MOVAPS( MAT(12), XMM3 )			/* m15 | m14 | m13 | m12 */
147
148ALIGNTEXT32
149LLBL( K_GTP43P3DR_top ):
150	MOVSS( SRC(0), XMM4 )			/* ox */
151	SHUFPS( CONST(0x0), XMM4, XMM4 )	/* ox | ox | ox | ox */
152	MULPS( XMM0, XMM4 )			/* ox*m3 | ox*m2 | ox*m1 | ox*m0 */
153
154	MOVSS( SRC(1), XMM5 )			/* oy */
155	SHUFPS( CONST(0x0), XMM5, XMM5 )	/* oy | oy | oy | oy */
156	MULPS( XMM1, XMM5 )			/* oy*m7 | oy*m6 | oy*m5 | oy*m4 */
157
158	MOVSS( SRC(2), XMM6 )			/* oz */
159	SHUFPS( CONST(0x0), XMM6, XMM6 )	/* oz | oz | oz | oz */
160	MULPS( XMM2, XMM6 )			/* oz*m11 | oz*m10 | oz*m9 | oz*m8 */
161
162	MOVSS( SRC(3), XMM7 )			/* ow */
163	SHUFPS( CONST(0x0), XMM7, XMM7 )	/* ow | ow | ow | ow */
164	MULPS( XMM3, XMM7 )			/* ow*m15 | ow*m14 | ow*m13 | ow*m12 */
165
166	ADDPS( XMM5, XMM4 )			/* ox*m3+oy*m7 | ... */
167	ADDPS( XMM6, XMM4 )			/* ox*m3+oy*m7+oz*m11 | ... */
168	ADDPS( XMM7, XMM4 )			/* ox*m3+oy*m7+oz*m11+ow*m15 | ... */
169	MOVAPS( XMM4, DST(0) )			/* ->D(3) | ->D(2) | ->D(1) | ->D(0) */
170
171	MOVSS( SRC(3), XMM4 )			/* ow */
172	MOVSS( XMM4, DST(3) )			/* ->D(3) */
173
174LLBL( K_GTP43P3DR_skip ):
175	ADD_L( CONST(16), EDI )
176	ADD_L( EAX, ESI )
177	CMP_L( ECX, EDI )
178	JNE( LLBL(K_GTP43P3DR_top) )
179
180LLBL( K_GTP43P3DR_finish ):
181	POP_L( EDI )
182	POP_L( ESI )
183	RET
184
185
186ALIGNTEXT16
187GLOBL GLNAME( _mesa_sse_transform_points4_identity )
188HIDDEN(_mesa_sse_transform_points4_identity)
189GLNAME( _mesa_sse_transform_points4_identity ):
190
191	PUSH_L( ESI )
192	PUSH_L( EDI )
193
194	MOV_L( ARG_SOURCE, ESI )
195	MOV_L( ARG_DEST, EDI )
196
197	MOV_L( ARG_MATRIX, EDX )
198	MOV_L( REGOFF(V4F_COUNT, ESI), ECX )
199
200	TEST_L( ECX, ECX )			/* verify non-zero count */
201	JE( LLBL( sse_identity_done ) )
202
203	MOV_L( REGOFF(V4F_STRIDE, ESI), EAX )	/* stride */
204	OR_L( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */
205
206	MOV_L( ECX, REGOFF(V4F_COUNT, EDI) )	/* set dest count */
207	MOV_L( CONST(4), REGOFF(V4F_SIZE, EDI) )/* set dest size */
208
209	MOV_L( REGOFF(V4F_START, ESI), ESI )	/* ptr to first source vertex */
210	MOV_L( REGOFF(V4F_START, EDI), EDI )	/* ptr to first dest vertex */
211
212ALIGNTEXT16
213LLBL( sse_identity_loop ):
214
215	PREFETCHNTA( REGOFF(32, ESI) )
216
217	MOVAPS( REGIND(ESI), XMM0 )
218	ADD_L( EAX, ESI )
219
220	MOVAPS( XMM0, REGIND(EDI) )
221	ADD_L( CONST(16), EDI )
222
223	DEC_L( ECX )
224	JNZ( LLBL( sse_identity_loop ) )
225
226LLBL( sse_identity_done ):
227
228	POP_L( EDI )
229	POP_L( ESI )
230	RET
231#endif
232
233#if defined (__ELF__) && defined (__linux__)
234	.section .note.GNU-stack,"",%progbits
235#endif
236