• 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/** TODO:
27  * - insert PREFETCH instructions to avoid cache-misses !
28  * - some more optimizations are possible...
29  * - for 40-50% more performance in the SSE-functions, the
30  *   data (trans-matrix, src_vert, dst_vert) needs to be 16byte aligned !
31  */
32
33#ifdef USE_SSE_ASM
34#include "assyntax.h"
35#define MATH_ASM_PTR_SIZE 4
36#include "math/m_vector_asm.h"
37#include "norm_args.h"
38
39   SEG_TEXT
40
41#define M(i)    REGOFF(i * 4, EDX)
42#define S(i)	REGOFF(i * 4, ESI)
43#define D(i)	REGOFF(i * 4, EDI)
44#define STRIDE  REGOFF(12, ESI)
45
46
47ALIGNTEXT16
48GLOBL GLNAME(_mesa_sse_transform_rescale_normals_no_rot)
49HIDDEN(_mesa_sse_transform_rescale_normals_no_rot)
50GLNAME(_mesa_sse_transform_rescale_normals_no_rot):
51	_CET_ENDBR
52#define FRAME_OFFSET 8
53	PUSH_L  ( ESI )
54	PUSH_L  ( EDI )
55
56	MOV_L	( ARG_IN, ESI )				/* ptr to source GLvector3f */
57	MOV_L	( ARG_DEST, EDI )			/* ptr to dest GLvector3f */
58
59	MOV_L	( ARG_MAT, EDX )			/* ptr to matrix */
60	ADD_L	( CONST(MATRIX_INV), EDX )		/* matrix->inv */
61
62	MOV_L	( REGOFF(V4F_COUNT, ESI), ECX ) 	/* source count */
63
64	TEST_L	( ECX, ECX )
65	JZ( LLBL(K_G3TRNNRR_finish) )			/* count was zero; go to finish */
66
67	MOV_L	( STRIDE, EAX )				/* stride */
68	MOV_L	( ECX, REGOFF(V4F_COUNT, EDI) )		/* set dest-count */
69
70	IMUL_L( CONST(16), ECX )			/* count *= 16 */
71	MOV_L( REGOFF(V4F_START, ESI), ESI )		/* ptr to first source vertex */
72
73	MOV_L( REGOFF(V4F_START, EDI), EDI )		/* ptr to first dest vertex */
74	ADD_L( EDI, ECX ) 				/* count += dest ptr */
75
76ALIGNTEXT32
77	MOVSS	( M(0), XMM1 )				/* m0 */
78	MOVSS	( M(5), XMM2 )				/* m5 */
79	UNPCKLPS( XMM2, XMM1 )				/* m5 | m0 */
80	MOVSS	( ARG_SCALE, XMM0 )			/* scale */
81	SHUFPS	( CONST(0x0), XMM0, XMM0 )		/* scale | scale */
82	MULPS	( XMM0, XMM1 )				/* m5*scale | m0*scale */
83	MULSS	( M(10), XMM0 )				/* m10*scale */
84
85ALIGNTEXT32
86LLBL(K_G3TRNNRR_top):
87	MOVLPS	( S(0), XMM2 )				/* uy | ux */
88	MULPS	( XMM1, XMM2 )				/* uy*m5*scale | ux*m0*scale */
89	MOVLPS	( XMM2, D(0) )				/* ->D(1) | D(0) */
90
91	MOVSS	( S(2), XMM2 )				/* uz */
92	MULSS	( XMM0, XMM2 )				/* uz*m10*scale */
93	MOVSS	( XMM2, D(2) )				/* ->D(2) */
94
95LLBL(K_G3TRNNRR_skip):
96	ADD_L	( CONST(16), EDI )
97	ADD_L	( EAX, ESI )
98	CMP_L	( ECX, EDI )
99	JNE	( LLBL(K_G3TRNNRR_top) )
100
101LLBL(K_G3TRNNRR_finish):
102	POP_L	( EDI )
103	POP_L	( ESI )
104	RET
105#undef FRAME_OFFSET
106
107
108
109ALIGNTEXT16
110GLOBL GLNAME(_mesa_sse_transform_rescale_normals)
111HIDDEN(_mesa_sse_transform_rescale_normals)
112GLNAME(_mesa_sse_transform_rescale_normals):
113	_CET_ENDBR
114#define FRAME_OFFSET 8
115	PUSH_L  ( ESI )
116	PUSH_L  ( EDI )
117
118	MOV_L	( ARG_IN, ESI )				/* ptr to source GLvector3f */
119	MOV_L	( ARG_DEST, EDI )			/* ptr to dest GLvector3f */
120
121	MOV_L	( ARG_MAT, EDX )			/* ptr to matrix */
122	ADD_L	( CONST(MATRIX_INV), EDX )		/* matrix->inv */
123
124	MOV_L	( REGOFF(V4F_COUNT, ESI), ECX ) 	/* source count */
125
126	TEST_L	( ECX, ECX )
127	JZ( LLBL(K_G3TRNR_finish) )			/* count was zero; go to finish */
128
129	MOV_L	( STRIDE, EAX )				/* stride */
130	MOV_L	( ECX, REGOFF(V4F_COUNT, EDI) )		/* set dest-count */
131
132	IMUL_L( CONST(16), ECX )			/* count *= 16 */
133	MOV_L( REGOFF(V4F_START, ESI), ESI )		/* ptr to first source vertex */
134
135	MOV_L( REGOFF(V4F_START, EDI), EDI )		/* ptr to first dest vertex */
136	ADD_L( EDI, ECX ) 				/* count += dest ptr */
137
138ALIGNTEXT32
139	MOVSS	( M(0), XMM0 )				/* m0 */
140	MOVSS	( M(4), XMM1 )				/* m4 */
141	UNPCKLPS( XMM1, XMM0 )				/* m4 | m0 */
142
143	MOVSS	( ARG_SCALE, XMM4 )			/* scale */
144	SHUFPS	( CONST(0x0), XMM4, XMM4 )		/* scale | scale */
145
146	MULPS	( XMM4, XMM0 )				/* m4*scale | m0*scale */
147	MOVSS	( M(1), XMM1 )				/* m1 */
148	MOVSS	( M(5), XMM2 )				/* m5 */
149	UNPCKLPS( XMM2, XMM1 )				/* m5 | m1 */
150	MULPS	( XMM4, XMM1 )				/* m5*scale | m1*scale */
151	MOVSS	( M(2), XMM2 )				/* m2 */
152	MOVSS	( M(6), XMM3 )				/* m6 */
153	UNPCKLPS( XMM3, XMM2 )				/* m6 | m2 */
154	MULPS	( XMM4, XMM2 )				/* m6*scale | m2*scale */
155
156	MOVSS	( M(8), XMM6 )				/* m8 */
157	MULSS	( ARG_SCALE, XMM6 )			/* m8*scale */
158	MOVSS	( M(9), XMM7 )				/* m9 */
159	MULSS	( ARG_SCALE, XMM7 )			/* m9*scale */
160
161ALIGNTEXT32
162LLBL(K_G3TRNR_top):
163	MOVSS	( S(0), XMM3 )				/* ux */
164	SHUFPS	( CONST(0x0), XMM3, XMM3 )		/* ux | ux */
165	MULPS	( XMM0, XMM3 )				/* ux*m4 | ux*m0 */
166	MOVSS	( S(1), XMM4 )				/* uy */
167	SHUFPS	( CONST(0x0), XMM4, XMM4 )		/* uy | uy */
168	MULPS	( XMM1, XMM4 )				/* uy*m5 | uy*m1 */
169	MOVSS	( S(2), XMM5 )				/* uz */
170	SHUFPS	( CONST(0x0), XMM5, XMM5 )		/* uz | uz */
171	MULPS	( XMM2, XMM5 )				/* uz*m6 | uz*m2 */
172
173	ADDPS	( XMM4, XMM3 )
174	ADDPS	( XMM5, XMM3 )
175	MOVLPS	( XMM3, D(0) )
176
177	MOVSS	( M(10), XMM3 )				/* m10 */
178	MULSS	( ARG_SCALE, XMM3 )			/* m10*scale */
179	MULSS	( S(2), XMM3 )				/* m10*scale*uz */
180	MOVSS	( S(1), XMM4 )				/* uy */
181	MULSS	( XMM7, XMM4 )				/* uy*m9*scale */
182	MOVSS	( S(0), XMM5 )				/* ux */
183	MULSS	( XMM6, XMM5 )				/* ux*m8*scale */
184
185	ADDSS	( XMM4, XMM3 )
186	ADDSS	( XMM5, XMM3 )
187	MOVSS	( XMM3, D(2) )
188
189LLBL(K_G3TRNR_skip):
190	ADD_L	( CONST(16), EDI )
191	ADD_L	( EAX, ESI )
192	CMP_L	( ECX, EDI )
193	JNE	( LLBL(K_G3TRNR_top) )
194
195LLBL(K_G3TRNR_finish):
196	POP_L	( EDI )
197	POP_L	( ESI )
198	RET
199#undef FRAME_OFFSET
200
201
202ALIGNTEXT16
203GLOBL GLNAME(_mesa_sse_transform_normals_no_rot)
204HIDDEN(_mesa_sse_transform_normals_no_rot)
205GLNAME(_mesa_sse_transform_normals_no_rot):
206	_CET_ENDBR
207#define FRAME_OFFSET 8
208	PUSH_L  ( ESI )
209	PUSH_L  ( EDI )
210
211	MOV_L	( ARG_IN, ESI )				/* ptr to source GLvector3f */
212	MOV_L	( ARG_DEST, EDI )			/* ptr to dest GLvector3f */
213
214	MOV_L	( ARG_MAT, EDX )			/* ptr to matrix */
215	ADD_L	( CONST(MATRIX_INV), EDX )		/* matrix->inv */
216
217	MOV_L	( REGOFF(V4F_COUNT, ESI), ECX ) 	/* source count */
218
219	TEST_L	( ECX, ECX )
220	JZ( LLBL(K_G3TNNRR_finish) )			/* count was zero; go to finish */
221
222	MOV_L	( STRIDE, EAX )				/* stride */
223	MOV_L	( ECX, REGOFF(V4F_COUNT, EDI) )		/* set dest-count */
224
225	IMUL_L( CONST(16), ECX )			/* count *= 16 */
226	MOV_L( REGOFF(V4F_START, ESI), ESI )		/* ptr to first source vertex */
227
228	MOV_L( REGOFF(V4F_START, EDI), EDI )		/* ptr to first dest vertex */
229	ADD_L( EDI, ECX ) 				/* count += dest ptr */
230
231ALIGNTEXT32
232	MOVSS( M(0), XMM0 )				/* m0 */
233	MOVSS( M(5), XMM1 )				/* m5 */
234	UNPCKLPS( XMM1, XMM0 )				/* m5 | m0 */
235	MOVSS( M(10), XMM1 )				/* m10 */
236
237ALIGNTEXT32
238LLBL(K_G3TNNRR_top):
239	MOVLPS( S(0), XMM2 )				/* uy | ux */
240	MULPS( XMM0, XMM2 )				/* uy*m5 | ux*m0 */
241	MOVLPS( XMM2, D(0) )
242
243	MOVSS( S(2), XMM2 )				/* uz */
244	MULSS( XMM1, XMM2 )				/* uz*m10 */
245	MOVSS( XMM2, D(2) )
246
247LLBL(K_G3TNNRR_skip):
248	ADD_L	( CONST(16), EDI )
249	ADD_L	( EAX, ESI )
250	CMP_L	( ECX, EDI )
251	JNE	( LLBL(K_G3TNNRR_top) )
252
253LLBL(K_G3TNNRR_finish):
254	POP_L	( EDI )
255	POP_L	( ESI )
256	RET
257#undef FRAME_OFFSET
258#endif
259
260#if defined (__ELF__) && defined (__linux__)
261	.section .note.GNU-stack,"",%progbits
262#endif
263