1 /* $Id: sse_xform2.S,v 1.3 2005/01/04 14:33:47 brianp Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2001 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 * - insert PREFETCH instructions to avoid cache-misses !
29 * - some more optimizations are possible...
30 * - for 40-50% more performance in the SSE-functions, the
31 * data (trans-matrix, src_vert, dst_vert) needs to be 16byte aligned !
36 #include "xform_args.h"
40 #define S(i) REGOFF(i * 4, ESI)
41 #define D(i) REGOFF(i * 4, EDI)
42 #define M(i) REGOFF(i * 4, EDX)
46 GLOBL GLNAME(_mesa_sse_transform_points2_general)
47 HIDDEN (_mesa_sse_transform_points2_general)
48 GLNAME( _mesa_sse_transform_points2_general ):
50 #define FRAME_OFFSET 8
54 MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */
55 MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */
57 MOV_L( ARG_MATRIX, EDX ) /* ptr to matrix */
58 MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */
61 JZ( LLBL(K_GTP2GR_finish) ) /* count was zero; go to finish */
63 MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */
64 OR_L( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */
66 MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */
67 MOV_L( CONST(4), REGOFF(V4F_SIZE, EDI) ) /* set dest size */
69 SHL_L( CONST(4), ECX ) /* count *= 16 */
70 MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */
72 MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */
73 ADD_L( EDI, ECX ) /* count += dest ptr */
76 MOVAPS( M(0), XMM0 ) /* m3 | m2 | m1 | m0 */
77 MOVAPS( M(4), XMM1 ) /* m7 | m6 | m5 | m4 */
78 MOVAPS( M(12), XMM2 ) /* m15 | m14 | m13 | m12 */
82 MOVSS( S(0), XMM3 ) /* ox */
83 SHUFPS( CONST(0x0), XMM3, XMM3 ) /* ox | ox | ox | ox */
84 MULPS( XMM0, XMM3 ) /* ox*m3 | ox*m2 | ox*m1 | ox*m0 */
85 MOVSS( S(1), XMM4 ) /* oy */
86 SHUFPS( CONST(0x0), XMM4, XMM4 ) /* oy | oy | oy | oy */
87 MULPS( XMM1, XMM4 ) /* oy*m7 | oy*m6 | oy*m5 | oy*m4 */
94 ADD_L ( CONST(16), EDI )
97 JNE ( LLBL(K_GTP2GR_top) )
99 LLBL(K_GTP2GR_finish):
107 GLOBL GLNAME(_mesa_sse_transform_points2_identity)
108 HIDDEN(_mesa_sse_transform_points2_identity)
109 GLNAME( _mesa_sse_transform_points2_identity ):
111 #define FRAME_OFFSET 8
115 MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */
116 MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */
118 MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */
121 JZ( LLBL(K_GTP2IR_finish) ) /* count was zero; go to finish */
123 MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */
124 OR_L( CONST(VEC_SIZE_2), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */
126 MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */
127 MOV_L( CONST(2), REGOFF(V4F_SIZE, EDI) ) /* set dest size */
129 SHL_L( CONST(4), ECX ) /* count *= 16 */
130 MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */
132 MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */
133 ADD_L( EDI, ECX ) /* count += dest ptr */
136 JE( LLBL(K_GTP2IR_finish) )
147 ADD_L ( CONST(16), EDI )
150 JNE ( LLBL(K_GTP2IR_top) )
152 LLBL(K_GTP2IR_finish):
160 GLOBL GLNAME(_mesa_sse_transform_points2_3d_no_rot)
161 HIDDEN(_mesa_sse_transform_points2_3d_no_rot)
162 GLNAME(_mesa_sse_transform_points2_3d_no_rot):
164 #define FRAME_OFFSET 8
168 MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */
169 MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */
171 MOV_L( ARG_MATRIX, EDX ) /* ptr to matrix */
172 MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */
175 JZ( LLBL(K_GTP23DNRR_finish) ) /* count was zero; go to finish */
177 MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */
178 OR_L( CONST(VEC_SIZE_3), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */
180 MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */
181 MOV_L( CONST(3), REGOFF(V4F_SIZE, EDI) ) /* set dest size */
183 SHL_L( CONST(4), ECX ) /* count *= 16 */
184 MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */
186 MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */
187 ADD_L( EDI, ECX ) /* count += dest ptr */
191 MOVSS ( M(0), XMM1 ) /* - | - | - | m0 */
192 MOVSS ( M(5), XMM2 ) /* - | - | - | m5 */
193 UNPCKLPS ( XMM2, XMM1 ) /* - | - | m5 | m0 */
194 MOVLPS ( M(12), XMM2 ) /* - | - | m13 | m12 */
195 MOVSS ( M(14), XMM3 ) /* - | - | - | m14 */
198 LLBL(K_GTP23DNRR_top):
199 MOVLPS ( S(0), XMM0 ) /* - | - | oy | ox */
200 MULPS ( XMM1, XMM0 ) /* - | - | oy*m5 | ox*m0 */
201 ADDPS ( XMM2, XMM0 ) /* - | - | +m13 | +m12 */
202 MOVLPS ( XMM0, D(0) ) /* -> D(1) | -> D(0) */
204 MOVSS ( XMM3, D(2) ) /* -> D(2) */
206 LLBL(K_GTP23DNRR_skip):
207 ADD_L ( CONST(16), EDI )
210 JNE ( LLBL(K_GTP23DNRR_top) )
212 LLBL(K_GTP23DNRR_finish):
220 GLOBL GLNAME(_mesa_sse_transform_points2_perspective)
221 HIDDEN(_mesa_sse_transform_points2_perspective)
222 GLNAME(_mesa_sse_transform_points2_perspective):
224 #define FRAME_OFFSET 8
228 MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */
229 MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */
231 MOV_L( ARG_MATRIX, EDX ) /* ptr to matrix */
232 MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */
235 JZ( LLBL(K_GTP23PR_finish) ) /* count was zero; go to finish */
237 MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */
238 OR_L( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */
240 MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */
241 MOV_L( CONST(4), REGOFF(V4F_SIZE, EDI) ) /* set dest size */
243 SHL_L( CONST(4), ECX ) /* count *= 16 */
244 MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */
246 MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */
247 ADD_L( EDI, ECX ) /* count += dest ptr */
250 MOVSS ( M(0), XMM1 ) /* - | - | - | m0 */
251 MOVSS ( M(5), XMM2 ) /* - | - | - | m5 */
252 UNPCKLPS ( XMM2, XMM1 ) /* - | - | m5 | m0 */
253 MOVSS ( M(14), XMM3 ) /* m14 */
254 XORPS ( XMM0, XMM0 ) /* 0 | 0 | 0 | 0 */
258 MOVLPS( S(0), XMM4 ) /* oy | ox */
259 MULPS( XMM1, XMM4 ) /* oy*m5 | ox*m0 */
260 MOVLPS( XMM4, D(0) ) /* ->D(1) | ->D(0) */
261 MOVSS( XMM3, D(2) ) /* ->D(2) */
262 MOVSS( XMM0, D(3) ) /* ->D(3) */
264 LLBL(K_GTP23PR_skip):
265 ADD_L( CONST(16), EDI )
268 JNE( LLBL(K_GTP23PR_top) )
270 LLBL(K_GTP23PR_finish):
279 GLOBL GLNAME(_mesa_sse_transform_points2_2d)
280 HIDDEN(_mesa_sse_transform_points2_2d)
281 GLNAME(_mesa_sse_transform_points2_2d):
283 #define FRAME_OFFSET 8
287 MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */
288 MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */
290 MOV_L( ARG_MATRIX, EDX ) /* ptr to matrix */
291 MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */
294 JZ( LLBL(K_GTP23P2DR_finish) ) /* count was zero; go to finish */
296 MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */
297 OR_L( CONST(VEC_SIZE_2), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */
299 MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */
300 MOV_L( CONST(2), REGOFF(V4F_SIZE, EDI) ) /* set dest size */
302 SHL_L( CONST(4), ECX ) /* count *= 16 */
303 MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */
305 MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */
306 ADD_L( EDI, ECX ) /* count += dest ptr */
309 MOVLPS( M(0), XMM0 ) /* m1 | m0 */
310 MOVLPS( M(4), XMM1 ) /* m5 | m4 */
311 MOVLPS( M(12), XMM2 ) /* m13 | m12 */
314 LLBL(K_GTP23P2DR_top):
315 MOVSS( S(0), XMM3 ) /* ox */
316 SHUFPS( CONST(0x0), XMM3, XMM3 ) /* ox | ox */
317 MULPS( XMM0, XMM3 ) /* ox*m1 | ox*m0 */
319 MOVSS( S(1), XMM4 ) /* oy */
320 SHUFPS( CONST(0x0), XMM4, XMM4 ) /* oy | oy */
321 MULPS( XMM1, XMM4 ) /* oy*m5 | oy*m4 */
325 MOVLPS( XMM3, D(0) ) /* ->D(1) | ->D(0) */
327 LLBL(K_GTP23P2DR_skip):
328 ADD_L ( CONST(16), EDI )
331 JNE ( LLBL(K_GTP23P2DR_top) )
333 LLBL(K_GTP23P2DR_finish):
342 GLOBL GLNAME(_mesa_sse_transform_points2_2d_no_rot)
343 HIDDEN(_mesa_sse_transform_points2_2d_no_rot)
344 GLNAME(_mesa_sse_transform_points2_2d_no_rot):
346 #define FRAME_OFFSET 8
350 MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */
351 MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */
353 MOV_L( ARG_MATRIX, EDX ) /* ptr to matrix */
354 MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */
357 JZ( LLBL(K_GTP23P2DNRR_finish) ) /* count was zero; go to finish */
359 MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */
360 OR_L( CONST(VEC_SIZE_2), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */
362 MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */
363 MOV_L( CONST(2), REGOFF(V4F_SIZE, EDI) ) /* set dest size */
365 SHL_L( CONST(4), ECX ) /* count *= 16 */
366 MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */
368 MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */
369 ADD_L( EDI, ECX ) /* count += dest ptr */
372 MOVSS ( M(0), XMM1 ) /* m0 */
373 MOVSS ( M(5), XMM2 ) /* m5 */
374 UNPCKLPS ( XMM2, XMM1 ) /* m5 | m0 */
375 MOVLPS ( M(12), XMM2 ) /* m13 | m12 */
378 LLBL(K_GTP23P2DNRR_top):
379 MOVLPS( S(0), XMM0 ) /* oy | ox */
380 MULPS( XMM1, XMM0 ) /* oy*m5 | ox*m0 */
381 ADDPS( XMM2, XMM0 ) /* +m13 | +m12 */
382 MOVLPS( XMM0, D(0) ) /* ->D(1) | ->D(0) */
384 LLBL(K_GTP23P2DNRR_skip):
385 ADD_L( CONST(16), EDI )
388 JNE( LLBL(K_GTP23P2DNRR_top) )
390 LLBL(K_GTP23P2DNRR_finish):
399 GLOBL GLNAME(_mesa_sse_transform_points2_3d)
400 HIDDEN(_mesa_sse_transform_points2_3d)
401 GLNAME(_mesa_sse_transform_points2_3d):
403 #define FRAME_OFFSET 8
407 MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */
408 MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */
410 MOV_L( ARG_MATRIX, EDX ) /* ptr to matrix */
411 MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */
414 JZ( LLBL(K_GTP23P3DR_finish) ) /* count was zero; go to finish */
416 MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */
417 OR_L( CONST(VEC_SIZE_3), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */
419 MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */
420 MOV_L( CONST(3), REGOFF(V4F_SIZE, EDI) ) /* set dest size */
422 SHL_L( CONST(4), ECX ) /* count *= 16 */
423 MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */
425 MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */
426 ADD_L( EDI, ECX ) /* count += dest ptr */
429 MOVAPS( M(0), XMM0 ) /* m2 | m1 | m0 */
430 MOVAPS( M(4), XMM1 ) /* m6 | m5 | m4 */
431 MOVAPS( M(12), XMM2 ) /* m14 | m13 | m12 */
434 LLBL(K_GTP23P3DR_top):
435 MOVSS( S(0), XMM3 ) /* ox */
436 SHUFPS( CONST(0x0), XMM3, XMM3 ) /* ox | ox | ox */
437 MULPS( XMM0, XMM3 ) /* ox*m2 | ox*m1 | ox*m0 */
439 MOVSS( S(1), XMM4 ) /* oy */
440 SHUFPS( CONST(0x0), XMM4, XMM4 ) /* oy | oy | oy */
441 MULPS( XMM1, XMM4 ) /* oy*m6 | oy*m5 | oy*m4 */
446 MOVLPS( XMM3, D(0) ) /* ->D(1) | ->D(0) */
447 UNPCKHPS( XMM3, XMM3 )
448 MOVSS( XMM3, D(2) ) /* ->D(2) */
450 LLBL(K_GTP23P3DR_skip):
451 ADD_L( CONST(16), EDI )
454 JNE( LLBL(K_GTP23P3DR_top) )
456 LLBL(K_GTP23P3DR_finish):