From: Stephane Marchesin <marchesin@icps.u-strasbg.fr>
[mesa.git] / src / mesa / drivers / dri / radeon / radeon_vtxtmp_x86.S
1 /* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_vtxtmp_x86.S,v 1.1 2002/10/30 12:51:58 alanh Exp $ */
2 /**************************************************************************
3
4 Copyright 2002 Tungsten Graphics Inc., Cedar Park, Texas.
5
6 All Rights Reserved.
7
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 on the rights to use, copy, modify, merge, publish, distribute, sub
12 license, and/or sell copies of the Software, and to permit persons to whom
13 the Software is furnished to do so, subject to the following conditions:
14
15 The above copyright notice and this permission notice (including the next
16 paragraph) shall be included in all copies or substantial portions of the
17 Software.
18
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
22 ATI, TUNGSTEN GRAPHICS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
23 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24 OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
25 USE OR OTHER DEALINGS IN THE SOFTWARE.
26
27 **************************************************************************/
28
29 #define GLOBL( x ) \
30 .globl x; \
31 x:
32
33 .data
34 .align 4
35
36 /*
37 vertex 3f vertex size 4
38 */
39
40 GLOBL ( _x86_Vertex3f_4 )
41 movl (0), %ecx
42 movl 4(%esp), %eax
43 movl 8(%esp), %edx
44 movl %eax, (%ecx)
45 movl %edx, 4(%ecx)
46 movl 12(%esp), %eax
47 movl (0), %edx
48 movl %eax, 8(%ecx)
49 movl %edx, 12(%ecx)
50 movl (0), %eax
51 addl $16, %ecx
52 dec %eax
53 movl %ecx, (0)
54 movl %eax, (0)
55 je .1
56 ret
57 .1: jmp *0
58
59 GLOBL ( _x86_Vertex3f_4_end )
60
61 /*
62 vertex 3f vertex size 6
63 */
64 GLOBL ( _x86_Vertex3f_6 )
65 push %edi
66 movl (0), %edi
67 movl 8(%esp), %eax
68 movl 12(%esp), %edx
69 movl 16(%esp), %ecx
70 movl %eax, (%edi)
71 movl %edx, 4(%edi)
72 movl %ecx, 8(%edi)
73 movl (0), %eax
74 movl (0), %edx
75 movl (0), %ecx
76 movl %eax, 12(%edi)
77 movl %edx, 16(%edi)
78 movl %ecx, 20(%edi)
79 addl $24, %edi
80 movl (0), %eax
81 movl %edi, (0)
82 dec %eax
83 pop %edi
84 movl %eax, (0)
85 je .2
86 ret
87 .2: jmp *0
88 GLOBL ( _x86_Vertex3f_6_end )
89 /*
90 vertex 3f generic size
91 */
92 GLOBL ( _x86_Vertex3f )
93 push %edi
94 push %esi
95 movl $0, %esi
96 movl (0), %edi
97 movl 12(%esp), %eax
98 movl 16(%esp), %edx
99 movl 20(%esp), %ecx
100 movl %eax, (%edi)
101 movl %edx, 4(%edi)
102 movl %ecx, 8(%edi)
103 addl $12, %edi
104 movl $0, %ecx
105 repz
106 movsl %ds:(%esi), %es:(%edi)
107 movl (0), %eax
108 movl %edi, (0)
109 dec %eax
110 movl %eax, (0)
111 pop %esi
112 pop %edi
113 je .3
114 ret
115 .3: jmp *0
116
117 GLOBL ( _x86_Vertex3f_end )
118
119 /*
120 Vertex 3fv vertex size 6
121 */
122 GLOBL ( _x86_Vertex3fv_6 )
123 movl (0), %eax
124 movl 4(%esp), %ecx
125 movl (%ecx), %edx
126 movl %edx, (%eax)
127 movl 4(%ecx), %edx
128 movl 8(%ecx), %ecx
129 movl %edx, 4(%eax)
130 movl %ecx, 8(%eax)
131 movl (28), %edx
132 movl (32), %ecx
133 movl %edx, 12(%eax)
134 movl %ecx, 16(%eax)
135 movl (36), %edx
136 movl %edx, 20(%eax)
137 addl $24, %eax
138 movl %eax, 0
139 movl 4, %eax
140 dec %eax
141 movl %eax, 4
142 je .4
143 ret
144 .4: jmp *8
145
146 GLOBL ( _x86_Vertex3fv_6_end )
147
148 /*
149 Vertex 3fv vertex size 8
150 */
151 GLOBL ( _x86_Vertex3fv_8 )
152 movl (0), %eax
153 movl 4(%esp), %ecx
154 movl (%ecx), %edx
155 movl %edx ,(%eax)
156 movl 4(%ecx) ,%edx
157 movl 8(%ecx) ,%ecx
158 movl %edx, 4(%eax)
159 movl %ecx, 8(%eax)
160 movl (28), %edx
161 movl (32), %ecx
162 movl %edx, 12(%eax)
163 movl %ecx, 16(%eax)
164 movl (28), %edx
165 movl (32), %ecx
166 movl %edx, 20(%eax)
167 movl %ecx, 24(%eax)
168 movl (36), %edx
169 movl %edx, 28(%eax)
170 addl $32, %eax
171 movl %eax, (0)
172 movl 4, %eax
173 dec %eax
174 movl %eax, (4)
175 je .5
176 ret
177 .5: jmp *8
178
179 GLOBL ( _x86_Vertex3fv_8_end )
180
181 /*
182 Vertex 3fv generic vertex size
183 */
184 GLOBL ( _x86_Vertex3fv )
185 movl 4(%esp), %edx
186 push %edi
187 push %esi
188 movl (0x1010101), %edi
189 movl (%edx), %eax
190 movl 4(%edx), %ecx
191 movl 8(%edx), %esi
192 movl %eax, (%edi)
193 movl %ecx, 4(%edi)
194 movl %esi, 8(%edi)
195 addl $12, %edi
196 movl $6, %ecx
197 movl $0x58, %esi
198 repz
199 movsl %ds:(%esi), %es:(%edi)
200 movl %edi, (0x1010101)
201 movl (0x2020202), %eax
202 pop %esi
203 pop %edi
204 dec %eax
205 movl %eax, (0x2020202)
206 je .6
207 ret
208 .6: jmp *0
209 GLOBL ( _x86_Vertex3fv_end )
210
211
212 /**
213 * Generic handler for 2 float format data. This can be used for
214 * TexCoord2f and possibly other functions.
215 */
216
217 GLOBL ( _x86_Attribute2f )
218 movl $0x0, %edx
219 movl 4(%esp), %eax
220 movl 8(%esp), %ecx
221 movl %eax, (%edx)
222 movl %ecx, 4(%edx)
223 ret
224 GLOBL ( _x86_Attribute2f_end )
225
226
227 /**
228 * Generic handler for 2 float vector format data. This can be used for
229 * TexCoord2fv and possibly other functions.
230 */
231
232 GLOBL( _x86_Attribute2fv)
233 movl 4(%esp), %eax /* load 'v' off stack */
234 movl (%eax), %ecx /* load v[0] */
235 movl 4(%eax), %eax /* load v[1] */
236 movl %ecx, 0 /* store v[0] to current vertex */
237 movl %eax, 4 /* store v[1] to current vertex */
238 ret
239 GLOBL ( _x86_Attribute2fv_end )
240
241
242 /**
243 * Generic handler for 3 float format data. This can be used for
244 * Normal3f, Color3f (when the color target is also float), or
245 * TexCoord3f.
246 */
247
248 GLOBL ( _x86_Attribute3f )
249 movl 4(%esp), %ecx
250 movl 8(%esp), %edx
251 movl 12(%esp), %eax
252 movl %ecx, 0
253 movl %edx, 4
254 movl %eax, 8
255 ret
256 GLOBL ( _x86_Attribute3f_end )
257
258 /**
259 * Generic handler for 3 float vector format data. This can be used for
260 * Normal3f, Color3f (when the color target is also float), or
261 * TexCoord3f.
262 */
263
264 GLOBL( _x86_Attribute3fv)
265 movl 4(%esp), %eax /* load 'v' off stack */
266 movl (%eax), %ecx /* load v[0] */
267 movl 4(%eax), %edx /* load v[1] */
268 movl 8(%eax), %eax /* load v[2] */
269 movl %ecx, 0 /* store v[0] to current vertex */
270 movl %edx, 4 /* store v[1] to current vertex */
271 movl %eax, 8 /* store v[2] to current vertex */
272 ret
273 GLOBL ( _x86_Attribute3fv_end )
274
275
276 /*
277 Color 4ubv_ub
278 */
279 GLOBL ( _x86_Color4ubv_ub )
280 movl 4(%esp), %eax
281 movl $0x12345678, %edx
282 movl (%eax), %eax
283 movl %eax, (%edx)
284 ret
285 GLOBL ( _x86_Color4ubv_ub_end )
286
287 /*
288 Color 4ubv 4f
289 */
290 GLOBL ( _x86_Color4ubv_4f )
291 push %ebx
292 movl $0, %edx
293 xor %eax, %eax
294 xor %ecx, %ecx
295 movl 8(%esp), %ebx
296 movl (%ebx), %ebx
297 mov %bl, %al
298 mov %bh, %cl
299 movl (%edx,%eax,4),%eax
300 movl (%edx,%ecx,4),%ecx
301 movl %eax, (0xdeadbeaf)
302 movl %ecx, (0xdeadbeaf)
303 xor %eax, %eax
304 xor %ecx, %ecx
305 shr $16, %ebx
306 mov %bl, %al
307 mov %bh, %cl
308 movl (%edx,%eax,4), %eax
309 movl (%edx,%ecx,4), %ecx
310 movl %eax, (0xdeadbeaf)
311 movl %ecx, (0xdeadbeaf)
312 pop %ebx
313 ret
314 GLOBL ( _x86_Color4ubv_4f_end )
315
316 /*
317
318 Color4ub_ub
319 */
320 GLOBL( _x86_Color4ub_ub )
321 push %ebx
322 movl 8(%esp), %eax
323 movl 12(%esp), %edx
324 movl 16(%esp), %ecx
325 movl 20(%esp), %ebx
326 mov %al, (0)
327 mov %dl, (0)
328 mov %cl, (0)
329 mov %bl, (0)
330 pop %ebx
331 ret
332 GLOBL( _x86_Color4ub_ub_end )
333
334
335 /*
336 MultiTexCoord2fv st0/st1
337 */
338 GLOBL( _x86_MultiTexCoord2fv )
339 movl 4(%esp), %eax
340 movl 8(%esp), %ecx
341 and $1, %eax
342 movl (%ecx), %edx
343 shl $3, %eax
344 movl 4(%ecx), %ecx
345 movl %edx, 0xdeadbeef(%eax)
346 movl %ecx, 0xdeadbeef(%eax)
347 ret
348 GLOBL( _x86_MultiTexCoord2fv_end )
349
350 /*
351 MultiTexCoord2fv
352 */
353
354 GLOBL( _x86_MultiTexCoord2fv_2 )
355 movl 4(%esp,1), %eax
356 movl 8(%esp,1), %ecx
357 and $0x1, %eax
358 movl 0(,%eax,4), %edx
359 movl (%ecx), %eax
360 movl %eax, (%edx)
361 movl 4(%ecx), %eax
362 movl %eax, 4(%edx)
363 ret
364 GLOBL( _x86_MultiTexCoord2fv_2_end )
365
366 /*
367 MultiTexCoord2f st0/st1
368 */
369 GLOBL( _x86_MultiTexCoord2f )
370 movl 4(%esp), %eax
371 movl 8(%esp), %edx
372 movl 12(%esp), %ecx
373 and $1, %eax
374 shl $3, %eax
375 movl %edx, 0xdeadbeef(%eax)
376 movl %ecx, 0xdeadbeef(%eax)
377 ret
378 GLOBL( _x86_MultiTexCoord2f_end )
379
380 /*
381 MultiTexCoord2f
382 */
383 GLOBL( _x86_MultiTexCoord2f_2 )
384 movl 4(%esp), %eax
385 movl 8(%esp), %edx
386 movl 12(%esp,1), %ecx
387 and $1,%eax
388 movl 0(,%eax,4), %eax
389 movl %edx, (%eax)
390 movl %ecx, 4(%eax)
391 ret
392 GLOBL( _x86_MultiTexCoord2f_2_end )
393
394 #if defined(USE_SSE_ASM)
395 /**
396 * This can be used as a template for either Color3fv (when the color
397 * target is also a 3f) or Normal3fv.
398 */
399
400 GLOBL( _sse_Attribute3fv )
401 movl 4(%esp), %eax
402 movlps (%eax), %xmm0
403 movl 8(%eax), %eax
404 movlps %xmm0, 0
405 movl %eax, 8
406 ret
407 GLOBL( _sse_Attribute3fv_end )
408
409 /**
410 * This can be used as a template for either Color3f (when the color
411 * target is also a 3f) or Normal3f.
412 */
413
414 GLOBL( _sse_Attribute3f )
415 movlps 4(%esp), %xmm0
416 movl 12(%esp), %eax
417 movlps %xmm0, 0
418 movl %eax, 8
419 ret
420 GLOBL( _sse_Attribute3f_end )
421
422
423 /**
424 * Generic handler for 2 float vector format data. This can be used for
425 * TexCoord2fv and possibly other functions.
426 */
427
428 GLOBL( _sse_Attribute2fv )
429 movl 4(%esp), %eax
430 movlps (%eax), %xmm0
431 movlps %xmm0, 0
432 ret
433 GLOBL( _sse_Attribute2fv_end )
434
435
436 /**
437 * Generic handler for 2 float format data. This can be used for
438 * TexCoord2f and possibly other functions.
439 */
440
441 GLOBL( _sse_Attribute2f )
442 movlps 4(%esp), %xmm0
443 movlps %xmm0, 0
444 ret
445 GLOBL( _sse_Attribute2f_end )
446
447 /*
448 MultiTexCoord2fv st0/st1
449 */
450 GLOBL( _sse_MultiTexCoord2fv )
451 movl 4(%esp), %eax
452 movl 8(%esp), %ecx
453 and $1, %eax
454 movlps (%ecx), %xmm0
455 movlps %xmm0, 0xdeadbeef(,%eax,8)
456 ret
457 GLOBL( _sse_MultiTexCoord2fv_end )
458
459 /*
460 MultiTexCoord2fv
461 */
462 GLOBL( _sse_MultiTexCoord2fv_2 )
463 movl 4(%esp), %eax
464 movl 8(%esp), %ecx
465 and $0x1, %eax
466 movl 0(,%eax,4), %edx
467 movlps (%ecx), %xmm0
468 movlps %xmm0, (%edx)
469 ret
470 GLOBL( _sse_MultiTexCoord2fv_2_end )
471
472 /*
473 MultiTexCoord2f st0/st1
474 */
475 GLOBL( _sse_MultiTexCoord2f )
476 movl 4(%esp), %eax
477 and $1, %eax
478 movlps 8(%esp), %xmm0
479 movlps %xmm0, 0xdeadbeef(,%eax,8)
480 ret
481 GLOBL( _sse_MultiTexCoord2f_end )
482
483 /*
484 MultiTexCoord2f
485 */
486 GLOBL( _sse_MultiTexCoord2f_2 )
487 movl 4(%esp), %eax
488 movlps 8(%esp), %xmm0
489 and $1,%eax
490 movl 0(,%eax,4), %eax
491 movlps %xmm0, (%eax)
492 ret
493 GLOBL( _sse_MultiTexCoord2f_2_end )
494 #endif