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_points1_general)
47 HIDDEN( _mesa_sse_transform_points1_general )
48 GLNAME( _mesa_sse_transform_points1_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 */
60 CMP_L( CONST(0), ECX ) /* count == 0 ? */
61 JE( LLBL(K_GTP1GR_finish) ) /* yes -> nothing to do. */
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 */
77 MOVAPS( M(0), XMM0 ) /* m3 | m2 | m1 | m0 */
78 MOVAPS( M(12), XMM1 ) /* m15 | m14 | m13 | m12 */
82 MOVSS( S(0), XMM2 ) /* ox */
83 SHUFPS( CONST(0x0), XMM2, XMM2 ) /* ox | ox | ox | ox */
84 MULPS( XMM0, XMM2 ) /* ox*m3 | ox*m2 | ox*m1 | ox*m0 */
85 ADDPS( XMM1, XMM2 ) /* + | + | + | + */
89 ADD_L ( CONST(16), EDI )
92 JNE ( LLBL(K_GTP1GR_top) )
94 LLBL(K_GTP1GR_finish):
103 GLOBL GLNAME(_mesa_sse_transform_points1_identity)
104 HIDDEN(_mesa_sse_transform_points1_identity)
105 GLNAME( _mesa_sse_transform_points1_identity ):
107 #define FRAME_OFFSET 8
111 MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */
112 MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */
114 MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */
117 JZ( LLBL(K_GTP1IR_finish) ) /* count was zero; go to finish */
119 MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */
120 OR_L( CONST(VEC_SIZE_1), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */
122 MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */
123 MOV_L( CONST(1), REGOFF(V4F_SIZE, EDI) ) /* set dest size */
125 SHL_L( CONST(4), ECX ) /* count *= 16 */
126 MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */
128 MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */
129 ADD_L( EDI, ECX ) /* count += dest ptr */
132 JE( LLBL(K_GTP1IR_finish) )
141 ADD_L ( CONST(16), EDI )
144 JNE ( LLBL(K_GTP1IR_top) )
146 LLBL(K_GTP1IR_finish):
155 GLOBL GLNAME(_mesa_sse_transform_points1_3d_no_rot)
156 HIDDEN(_mesa_sse_transform_points1_3d_no_rot)
157 GLNAME(_mesa_sse_transform_points1_3d_no_rot):
159 #define FRAME_OFFSET 8
163 MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */
164 MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */
166 MOV_L( ARG_MATRIX, EDX ) /* ptr to matrix */
167 MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */
170 JZ( LLBL(K_GTP13DNRR_finish) ) /* count was zero; go to finish */
172 MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */
173 OR_L( CONST(VEC_SIZE_3), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */
175 MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */
176 MOV_L( CONST(3), REGOFF(V4F_SIZE, EDI) ) /* set dest size */
178 SHL_L( CONST(4), ECX ) /* count *= 16 */
179 MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */
181 MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */
182 ADD_L( EDI, ECX ) /* count += dest ptr */
186 MOVSS( M(0), XMM0 ) /* m0 */
187 MOVSS( M(12), XMM1 ) /* m12 */
188 MOVSS( M(13), XMM2 ) /* m13 */
189 MOVSS( M(14), XMM3 ) /* m14 */
192 LLBL(K_GTP13DNRR_top):
193 MOVSS( S(0), XMM4 ) /* ox */
194 MULSS( XMM0, XMM4 ) /* ox*m0 */
195 ADDSS( XMM1, XMM4 ) /* ox*m0+m12 */
201 LLBL(K_GTP13DNRR_skip):
202 ADD_L ( CONST(16), EDI )
205 JNE ( LLBL(K_GTP13DNRR_top) )
207 LLBL(K_GTP13DNRR_finish):
216 GLOBL GLNAME(_mesa_sse_transform_points1_perspective)
217 HIDDEN(_mesa_sse_transform_points1_perspective)
218 GLNAME(_mesa_sse_transform_points1_perspective):
220 #define FRAME_OFFSET 8
224 MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */
225 MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */
227 MOV_L( ARG_MATRIX, EDX ) /* ptr to matrix */
228 MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */
231 JZ( LLBL(K_GTP13PR_finish) ) /* count was zero; go to finish */
233 MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */
234 OR_L( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */
236 MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */
237 MOV_L( CONST(4), REGOFF(V4F_SIZE, EDI) ) /* set dest size */
239 SHL_L( CONST(4), ECX ) /* count *= 16 */
240 MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */
242 MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */
243 ADD_L( EDI, ECX ) /* count += dest ptr */
247 XORPS( XMM0, XMM0 ) /* 0 | 0 | 0 | 0 */
248 MOVSS( M(0), XMM1 ) /* m0 */
249 MOVSS( M(14), XMM2 ) /* m14 */
253 MOVSS( S(0), XMM3 ) /* ox */
254 MULSS( XMM1, XMM3 ) /* ox*m0 */
255 MOVSS( XMM3, D(0) ) /* ox*m0->D(0) */
256 MOVSS( XMM2, D(2) ) /* m14->D(2) */
261 LLBL(K_GTP13PR_skip):
262 ADD_L( CONST(16), EDI )
265 JNE( LLBL(K_GTP13PR_top) )
267 LLBL(K_GTP13PR_finish):
275 GLOBL GLNAME(_mesa_sse_transform_points1_2d)
276 HIDDEN(_mesa_sse_transform_points1_2d)
277 GLNAME(_mesa_sse_transform_points1_2d):
279 #define FRAME_OFFSET 8
283 MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */
284 MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */
286 MOV_L( ARG_MATRIX, EDX ) /* ptr to matrix */
287 MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */
290 JZ( LLBL(K_GTP13P2DR_finish) ) /* count was zero; go to finish */
292 MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */
293 OR_L( CONST(VEC_SIZE_2), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */
295 MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */
296 MOV_L( CONST(2), REGOFF(V4F_SIZE, EDI) ) /* set dest size */
298 SHL_L( CONST(4), ECX ) /* count *= 16 */
299 MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */
301 MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */
302 ADD_L( EDI, ECX ) /* count += dest ptr */
305 MOVLPS( M(0), XMM0 ) /* m1 | m0 */
306 MOVLPS( M(12), XMM1 ) /* m13 | m12 */
309 LLBL(K_GTP13P2DR_top):
310 MOVSS( S(0), XMM2 ) /* ox */
311 SHUFPS( CONST(0x0), XMM2, XMM2 ) /* ox | ox | ox | ox */
312 MULPS( XMM0, XMM2 ) /* - | - | ox*m1 | ox*m0 */
313 ADDPS( XMM1, XMM2 ) /* - | - | ox*m1+m13 | ox*m0+m12 */
316 LLBL(K_GTP13P2DR_skip):
317 ADD_L ( CONST(16), EDI )
320 JNE ( LLBL(K_GTP13P2DR_top) )
322 LLBL(K_GTP13P2DR_finish):
330 GLOBL GLNAME(_mesa_sse_transform_points1_2d_no_rot)
331 HIDDEN(_mesa_sse_transform_points1_2d_no_rot)
332 GLNAME(_mesa_sse_transform_points1_2d_no_rot):
334 #define FRAME_OFFSET 8
338 MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */
339 MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */
341 MOV_L( ARG_MATRIX, EDX ) /* ptr to matrix */
342 MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */
345 JZ( LLBL(K_GTP13P2DNRR_finish) ) /* count was zero; go to finish */
347 MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */
348 OR_L( CONST(VEC_SIZE_2), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */
350 MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */
351 MOV_L( CONST(2), REGOFF(V4F_SIZE, EDI) ) /* set dest size */
353 SHL_L( CONST(4), ECX ) /* count *= 16 */
354 MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */
356 MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */
357 ADD_L( EDI, ECX ) /* count += dest ptr */
360 MOVSS( M(0), XMM0 ) /* m0 */
361 MOVSS( M(12), XMM1 ) /* m12 */
362 MOVSS( M(13), XMM2 ) /* m13 */
365 LLBL(K_GTP13P2DNRR_top):
366 MOVSS( S(0), XMM3 ) /* ox */
367 MULSS( XMM0, XMM3 ) /* ox*m0 */
368 ADDSS( XMM1, XMM3 ) /* ox*m0+m12 */
372 LLBL(K_GTP13P2DNRR_skip):
373 ADD_L( CONST(16), EDI )
376 JNE( LLBL(K_GTP13P2DNRR_top) )
378 LLBL(K_GTP13P2DNRR_finish):
387 GLOBL GLNAME(_mesa_sse_transform_points1_3d)
388 HIDDEN(_mesa_sse_transform_points1_3d)
389 GLNAME(_mesa_sse_transform_points1_3d):
391 #define FRAME_OFFSET 8
395 MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */
396 MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */
398 MOV_L( ARG_MATRIX, EDX ) /* ptr to matrix */
399 MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */
402 JZ( LLBL(K_GTP13P3DR_finish) ) /* count was zero; go to finish */
404 MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */
405 OR_L( CONST(VEC_SIZE_3), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */
407 MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */
408 MOV_L( CONST(3), REGOFF(V4F_SIZE, EDI) ) /* set dest size */
410 SHL_L( CONST(4), ECX ) /* count *= 16 */
411 MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */
413 MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */
414 ADD_L( EDI, ECX ) /* count += dest ptr */
418 MOVAPS( M(0), XMM0 ) /* m3 | m2 | m1 | m0 */
419 MOVAPS( M(12), XMM1 ) /* m15 | m14 | m13 | m12 */
422 LLBL(K_GTP13P3DR_top):
423 MOVSS( S(0), XMM2 ) /* ox */
424 SHUFPS( CONST(0x0), XMM2, XMM2 ) /* ox | ox | ox | ox */
425 MULPS( XMM0, XMM2 ) /* ox*m3 | ox*m2 | ox*m1 | ox*m0 */
426 ADDPS( XMM1, XMM2 ) /* +m15 | +m14 | +m13 | +m12 */
427 MOVLPS( XMM2, D(0) ) /* - | - | ->D(1)| ->D(0)*/
428 UNPCKHPS( XMM2, XMM2 ) /* ox*m3+m15 | ox*m3+m15 | ox*m2+m14 | ox*m2+m14 */
431 LLBL(K_GTP13P3DR_skip):
432 ADD_L( CONST(16), EDI )
435 JNE( LLBL(K_GTP13P3DR_top) )
437 LLBL(K_GTP13P3DR_finish):
444 #if defined (__ELF__) && defined (__linux__)
445 .section .note.GNU-stack,"",%progbits