3 * Mesa 3-D graphics library
6 * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
15 * The above copyright notice and this permission notice shall be included
16 * in all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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 !
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 */
192 MOVSS ( M(0), XMM1 ) /* - | - | - | m0 */
193 MOVSS ( M(5), XMM2 ) /* - | - | - | m5 */
194 UNPCKLPS ( XMM2, XMM1 ) /* - | - | m5 | m0 */
195 MOVLPS ( M(12), XMM2 ) /* - | - | m13 | m12 */
196 MOVSS ( M(14), XMM3 ) /* - | - | - | m14 */
199 LLBL(K_GTP23DNRR_top):
200 MOVLPS ( S(0), XMM0 ) /* - | - | oy | ox */
201 MULPS ( XMM1, XMM0 ) /* - | - | oy*m5 | ox*m0 */
202 ADDPS ( XMM2, XMM0 ) /* - | - | +m13 | +m12 */
203 MOVLPS ( XMM0, D(0) ) /* -> D(1) | -> D(0) */
205 MOVSS ( XMM3, D(2) ) /* -> D(2) */
207 LLBL(K_GTP23DNRR_skip):
208 ADD_L ( CONST(16), EDI )
211 JNE ( LLBL(K_GTP23DNRR_top) )
213 LLBL(K_GTP23DNRR_finish):
221 GLOBL GLNAME(_mesa_sse_transform_points2_perspective)
222 HIDDEN(_mesa_sse_transform_points2_perspective)
223 GLNAME(_mesa_sse_transform_points2_perspective):
225 #define FRAME_OFFSET 8
229 MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */
230 MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */
232 MOV_L( ARG_MATRIX, EDX ) /* ptr to matrix */
233 MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */
236 JZ( LLBL(K_GTP23PR_finish) ) /* count was zero; go to finish */
238 MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */
239 OR_L( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */
241 MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */
242 MOV_L( CONST(4), REGOFF(V4F_SIZE, EDI) ) /* set dest size */
244 SHL_L( CONST(4), ECX ) /* count *= 16 */
245 MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */
247 MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */
248 ADD_L( EDI, ECX ) /* count += dest ptr */
251 MOVSS ( M(0), XMM1 ) /* - | - | - | m0 */
252 MOVSS ( M(5), XMM2 ) /* - | - | - | m5 */
253 UNPCKLPS ( XMM2, XMM1 ) /* - | - | m5 | m0 */
254 MOVSS ( M(14), XMM3 ) /* m14 */
255 XORPS ( XMM0, XMM0 ) /* 0 | 0 | 0 | 0 */
259 MOVLPS( S(0), XMM4 ) /* oy | ox */
260 MULPS( XMM1, XMM4 ) /* oy*m5 | ox*m0 */
261 MOVLPS( XMM4, D(0) ) /* ->D(1) | ->D(0) */
262 MOVSS( XMM3, D(2) ) /* ->D(2) */
263 MOVSS( XMM0, D(3) ) /* ->D(3) */
265 LLBL(K_GTP23PR_skip):
266 ADD_L( CONST(16), EDI )
269 JNE( LLBL(K_GTP23PR_top) )
271 LLBL(K_GTP23PR_finish):
280 GLOBL GLNAME(_mesa_sse_transform_points2_2d)
281 HIDDEN(_mesa_sse_transform_points2_2d)
282 GLNAME(_mesa_sse_transform_points2_2d):
284 #define FRAME_OFFSET 8
288 MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */
289 MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */
291 MOV_L( ARG_MATRIX, EDX ) /* ptr to matrix */
292 MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */
295 JZ( LLBL(K_GTP23P2DR_finish) ) /* count was zero; go to finish */
297 MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */
298 OR_L( CONST(VEC_SIZE_2), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */
300 MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */
301 MOV_L( CONST(2), REGOFF(V4F_SIZE, EDI) ) /* set dest size */
303 SHL_L( CONST(4), ECX ) /* count *= 16 */
304 MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */
306 MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */
307 ADD_L( EDI, ECX ) /* count += dest ptr */
310 MOVLPS( M(0), XMM0 ) /* m1 | m0 */
311 MOVLPS( M(4), XMM1 ) /* m5 | m4 */
312 MOVLPS( M(12), XMM2 ) /* m13 | m12 */
315 LLBL(K_GTP23P2DR_top):
316 MOVSS( S(0), XMM3 ) /* ox */
317 SHUFPS( CONST(0x0), XMM3, XMM3 ) /* ox | ox */
318 MULPS( XMM0, XMM3 ) /* ox*m1 | ox*m0 */
320 MOVSS( S(1), XMM4 ) /* oy */
321 SHUFPS( CONST(0x0), XMM4, XMM4 ) /* oy | oy */
322 MULPS( XMM1, XMM4 ) /* oy*m5 | oy*m4 */
326 MOVLPS( XMM3, D(0) ) /* ->D(1) | ->D(0) */
328 LLBL(K_GTP23P2DR_skip):
329 ADD_L ( CONST(16), EDI )
332 JNE ( LLBL(K_GTP23P2DR_top) )
334 LLBL(K_GTP23P2DR_finish):
343 GLOBL GLNAME(_mesa_sse_transform_points2_2d_no_rot)
344 HIDDEN(_mesa_sse_transform_points2_2d_no_rot)
345 GLNAME(_mesa_sse_transform_points2_2d_no_rot):
347 #define FRAME_OFFSET 8
351 MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */
352 MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */
354 MOV_L( ARG_MATRIX, EDX ) /* ptr to matrix */
355 MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */
358 JZ( LLBL(K_GTP23P2DNRR_finish) ) /* count was zero; go to finish */
360 MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */
361 OR_L( CONST(VEC_SIZE_2), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */
363 MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */
364 MOV_L( CONST(2), REGOFF(V4F_SIZE, EDI) ) /* set dest size */
366 SHL_L( CONST(4), ECX ) /* count *= 16 */
367 MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */
369 MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */
370 ADD_L( EDI, ECX ) /* count += dest ptr */
373 MOVSS ( M(0), XMM1 ) /* m0 */
374 MOVSS ( M(5), XMM2 ) /* m5 */
375 UNPCKLPS ( XMM2, XMM1 ) /* m5 | m0 */
376 MOVLPS ( M(12), XMM2 ) /* m13 | m12 */
379 LLBL(K_GTP23P2DNRR_top):
380 MOVLPS( S(0), XMM0 ) /* oy | ox */
381 MULPS( XMM1, XMM0 ) /* oy*m5 | ox*m0 */
382 ADDPS( XMM2, XMM0 ) /* +m13 | +m12 */
383 MOVLPS( XMM0, D(0) ) /* ->D(1) | ->D(0) */
385 LLBL(K_GTP23P2DNRR_skip):
386 ADD_L( CONST(16), EDI )
389 JNE( LLBL(K_GTP23P2DNRR_top) )
391 LLBL(K_GTP23P2DNRR_finish):
400 GLOBL GLNAME(_mesa_sse_transform_points2_3d)
401 HIDDEN(_mesa_sse_transform_points2_3d)
402 GLNAME(_mesa_sse_transform_points2_3d):
404 #define FRAME_OFFSET 8
408 MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */
409 MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */
411 MOV_L( ARG_MATRIX, EDX ) /* ptr to matrix */
412 MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */
415 JZ( LLBL(K_GTP23P3DR_finish) ) /* count was zero; go to finish */
417 MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */
418 OR_L( CONST(VEC_SIZE_3), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */
420 MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */
421 MOV_L( CONST(3), REGOFF(V4F_SIZE, EDI) ) /* set dest size */
423 SHL_L( CONST(4), ECX ) /* count *= 16 */
424 MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */
426 MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */
427 ADD_L( EDI, ECX ) /* count += dest ptr */
430 MOVAPS( M(0), XMM0 ) /* m2 | m1 | m0 */
431 MOVAPS( M(4), XMM1 ) /* m6 | m5 | m4 */
432 MOVAPS( M(12), XMM2 ) /* m14 | m13 | m12 */
435 LLBL(K_GTP23P3DR_top):
436 MOVSS( S(0), XMM3 ) /* ox */
437 SHUFPS( CONST(0x0), XMM3, XMM3 ) /* ox | ox | ox */
438 MULPS( XMM0, XMM3 ) /* ox*m2 | ox*m1 | ox*m0 */
440 MOVSS( S(1), XMM4 ) /* oy */
441 SHUFPS( CONST(0x0), XMM4, XMM4 ) /* oy | oy | oy */
442 MULPS( XMM1, XMM4 ) /* oy*m6 | oy*m5 | oy*m4 */
447 MOVLPS( XMM3, D(0) ) /* ->D(1) | ->D(0) */
448 UNPCKHPS( XMM3, XMM3 )
449 MOVSS( XMM3, D(2) ) /* ->D(2) */
451 LLBL(K_GTP23P3DR_skip):
452 ADD_L( CONST(16), EDI )
455 JNE( LLBL(K_GTP23P3DR_top) )
457 LLBL(K_GTP23P3DR_finish):
464 #if defined (__ELF__) && defined (__linux__)
465 .section .note.GNU-stack,"",%progbits