aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri/tdfx/X86/fx_3dnow_fasttmp.h
blob: 9ec4935d781c7d9faf4e7019cf62a966255cd323 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/X86/fx_3dnow_fasttmp.h,v 1.2 2000/09/26 15:56:51 tsi Exp $ */

#if !defined(NASM_ASSEMBLER) && !defined(MASM_ASSEMBLER)
#define TAGLLBL(a) TAG(.L##a)
#else
#define TAGLLBL(a) TAG(a)
#endif

#if !GLIDE3

#define GR_VERTEX_X_OFFSET              0
#define GR_VERTEX_Y_OFFSET              4
#define GR_VERTEX_Z_OFFSET              8
#define GR_VERTEX_R_OFFSET              12
#define GR_VERTEX_G_OFFSET              16
#define GR_VERTEX_B_OFFSET              20
#define GR_VERTEX_OOZ_OFFSET            24
#define GR_VERTEX_A_OFFSET              28
#define GR_VERTEX_OOW_OFFSET            32

#else /* GLIDE3 */

#define GR_VERTEX_X_OFFSET              0
#define GR_VERTEX_Y_OFFSET              4
#define GR_VERTEX_OOZ_OFFSET            8
#define GR_VERTEX_OOW_OFFSET            12
#define GR_VERTEX_R_OFFSET              16
#define GR_VERTEX_G_OFFSET              20
#define GR_VERTEX_B_OFFSET              24
#define GR_VERTEX_A_OFFSET              28
#define GR_VERTEX_Z_OFFSET              32

#endif /* GLIDE3 */

#define GR_VERTEX_SOW_TMU0_OFFSET       36
#define GR_VERTEX_TOW_TMU0_OFFSET       40
#define GR_VERTEX_OOW_TMU0_OFFSET       44
#define GR_VERTEX_SOW_TMU1_OFFSET       48
#define GR_VERTEX_TOW_TMU1_OFFSET       52
#define GR_VERTEX_OOW_TMU1_OFFSET       56




/*#define MAT_SX 0        /*  accessed by REGIND !! */
#define MAT_SY 20
#define MAT_SZ 40
#define MAT_TX 48
#define MAT_TY 52
#define MAT_TZ 56




/* Do viewport map, device scale and perspective projection.
 *
 * void project_verts( GLfloat *first,
 *		       GLfloat *last,
 *		       const GLfloat *m,
 *		       GLuint stride )
 *
 *
 * Rearrange fxVertices to look like grVertices.
 */

GLOBL GLNAME( TAG(fx_3dnow_project_vertices) )
GLNAME( TAG(fx_3dnow_project_vertices) ):

    PUSH_L    ( EBP )

    MOV_L     ( REGOFF(8, ESP), ECX )    /* first_vert */
    MOV_L     ( REGOFF(12, ESP), EDX )     /* last_vert */

    CMP_L     ( ECX, EDX )
    JE        ( TAGLLBL(FXPV_end) )

    FEMMS

    PREFETCH  ( REGIND(ECX) )         /* fetch the first vertex */

    MOV_L     ( REGOFF(16, ESP), EBP )     /* matrix */
    MOV_L     ( REGOFF(20, ESP), EAX )     /* stride */

    MOVD      ( REGOFF(MAT_TX, EBP), MM6 )      /*             | tx           */
    PUNPCKLDQ ( REGOFF(MAT_TY, EBP), MM6 )      /*  ty         | tx           */

#if !defined(FX_V2)
    MOV_L     ( CONST(0x49400000), REGOFF(-8, ESP) )    /*  snapper           */
    MOV_L     ( CONST(0x49400000), REGOFF(-4, ESP) )    /*  snapper           */
#endif

    MOVQ      ( REGOFF(-8, ESP), MM4 )          /*  snapper    | snapper      */
    PFADD     ( MM4, MM6 )                      /*  ty+snapper | tx+snapper   */

    MOVD      ( REGIND(EBP), MM5 )
    PUNPCKLDQ ( REGOFF(MAT_SY, EBP), MM5 )      /*  vsy        | vsx          */

    MOVD      ( REGOFF(MAT_SZ, EBP), MM1 )      /*             | vsz          */


ALIGNTEXT32
TAGLLBL(FXPV_loop_start):

    PREFETCH  ( REGOFF(64, ECX) )               /* fetch the next-ish vertex */


    MOVD      ( REGOFF(12, ECX), MM0 )          /*              | f[3]        */
    PFRCP     ( MM0, MM0 )                      /*  oow = 1/f[3]              */

    MOVD      ( REGOFF(12, ECX), MM7 )          /*              | f[3]        */
    PFRCPIT1  ( MM0, MM7 )
    PFRCPIT2  ( MM0, MM7 )                      /*  oow         | oow         */

    PUNPCKLDQ ( MM7, MM7 )


#if (TYPE & SETUP_RGBA)
    MOVD      ( REGOFF(CLIP_R, ECX ), MM0 )     /*  f[RCOORD] = f[CLIP_R];    */
    MOVD      ( MM0, REGOFF(GR_VERTEX_R_OFFSET, ECX) )
#endif

#if (TYPE & SETUP_TMU1)
    MOVQ      ( REGOFF(CLIP_S1, ECX), MM0 ) /* f[S1COORD] = f[CLIP_S1] * oow  */
    PFMUL     ( MM7, MM0 )                  /* f[T1COORD] = f[CLIP_T1] * oow  */
    MOVQ      ( MM0, REGOFF(GR_VERTEX_SOW_TMU1_OFFSET, ECX) )
#endif


#if (TYPE & SETUP_TMU0)
    MOVQ      ( REGOFF(CLIP_S0, ECX), MM0 ) /* f[S0COORD] = f[CLIP_S0] * oow  */
    PFMUL     ( MM7, MM0 )                  /* f[T0COORD] = f[CLIP_T0] * oow  */
    MOVQ      ( MM0, REGOFF(GR_VERTEX_SOW_TMU0_OFFSET, ECX) )
#endif





/*  DO_SETUP_XYZ */

    MOVQ      ( REGIND(ECX), MM2 )              /*  f[1]        | f[0]        */
    PFMUL     ( MM7, MM2 )                      /*  f[1] * oow  | f[0] * oow  */

    MOVD      ( REGOFF(8, ECX), MM3 )           /*              | f[2]        */
    PFMUL     ( MM7, MM3 )                      /*              | f[2] * oow  */

    MOVD      ( REGOFF(MAT_TZ, EBP), MM0 )      /*              | vtz         */
    PFMUL     ( MM1, MM3 )                      /*              | f[2] *= vsz */

    PFADD     ( MM0, MM3 )                      /*              | f[2] += vtz */
    PFMUL     ( MM5, MM2 )                      /*  f[1] *= vsy | f[0] *= vsx */

    PFADD     ( MM6, MM2 )                      /*  f[1] += vty | f[0] += vtx */

#if !defined(FX_V2)
    PFSUB     ( MM4, MM2 )                      /*  f[0,1] -= snapper         */
#endif

    MOVQ      ( MM2, REGOFF(GR_VERTEX_X_OFFSET, ECX) )
    MOVD      ( MM3, REGOFF(GR_VERTEX_OOZ_OFFSET, ECX) )


/* end of DO_SETUP_XYZ   */

    MOVD      ( MM7, REGOFF(GR_VERTEX_OOW_OFFSET, ECX) ) /* f[OOWCOORD] = oow */
    ADD_L     ( EAX, ECX )        /* f += stride */

    CMP_L     ( ECX, EDX )	/* stall??? */
    JA        ( TAGLLBL(FXPV_loop_start) )

TAGLLBL(FXPV_end):
    FEMMS
    POP_L     ( EBP )
    RET







/* void project_verts( GLfloat *first,
 *		       GLfloat *last,
 *		       const GLfloat *m,
 *		       GLuint stride,
 *                     const GLubyte *mask )
 *
 */

GLOBL GLNAME( TAG(fx_3dnow_project_clipped_vertices) )
GLNAME( TAG(fx_3dnow_project_clipped_vertices) ):

    PUSH_L    ( EBP )

    MOV_L     ( REGOFF(8, ESP), ECX ) /* first FXDRIVER(VB)->verts*/
    MOV_L     ( REGOFF(12, ESP), EDX ) /* last FXDRIVER(VB)->last_vert  */

    FEMMS

    PUSH_L    ( EDI )
    PUSH_L    ( ESI )

    PREFETCH  ( REGIND(ECX) )         /* fetch the first vertex */

    MOV_L     ( REGOFF(24, ESP), EBP ) /* mat ctx->Viewport.WindowMap.M */
    MOV_L     ( REGOFF(28, ESP), EAX )     /* stride */
    MOV_L     ( REGOFF(32, ESP), ESI ) /* VB->ClipMask       */

    MOVD      ( REGOFF(MAT_TX, EBP), MM6 )      /*             | tx           */
    PUNPCKLDQ ( REGOFF(MAT_TY, EBP), MM6 )      /*  ty         | tx           */

#if !defined(FX_V2)
    MOV_L     ( CONST(0x49400000), REGOFF(-8, ESP) )    /*  snapper           */
    MOV_L     ( CONST(0x49400000), REGOFF(-4, ESP) )    /*  snapper           */
#endif

    MOVQ      ( REGOFF(-8, ESP), MM4 )          /*  snapper    | snapper      */
    PFADD     ( MM4, MM6 )                      /*  ty+snapper | tx+snapper   */

    MOVD      ( REGIND(EBP), MM5 )
    PUNPCKLDQ ( REGOFF(MAT_SY, EBP), MM5 )      /*  vsy        | vsx          */

    MOVD      ( REGOFF(MAT_SZ, EBP), MM1 )      /*             | vsz          */



ALIGNTEXT32
TAGLLBL(FXPCV_loop_start):

    PREFETCH  ( REGOFF(64, ECX) )         /* fetch the next-ish vertex */

    CMP_B     ( CONST(0), REGIND(ESI) )
    JNE       ( TAGLLBL(FXPCV_skip) )

    MOVD      ( REGOFF(12, ECX), MM0)           /*              | f[3]        */
    PFRCP     ( MM0, MM0 )                      /*  oow = 1/f[3]              */

    MOVD      ( REGOFF(12, ECX), MM7)           /*              | f[3]        */
    PFRCPIT1  ( MM0, MM7 )
    PFRCPIT2  ( MM0, MM7 )                      /*  oow         | oow         */

    PUNPCKLDQ ( MM7, MM7 )


#if (TYPE & SETUP_RGBA)
    MOVD      ( REGOFF(CLIP_R, ECX ), MM0 )     /*  f[RCOORD] = f[CLIP_R];    */
    MOVD      ( MM0, REGOFF(GR_VERTEX_R_OFFSET, ECX) )
#endif

#if (TYPE & SETUP_TMU1)
    MOVQ      ( REGOFF(CLIP_S1, ECX), MM0 ) /* f[S1COORD] = f[CLIP_S1] * oow  */
    PFMUL     ( MM7, MM0 )                  /* f[T1COORD] = f[CLIP_T1] * oow  */
    MOVQ      ( MM0, REGOFF(GR_VERTEX_SOW_TMU1_OFFSET, ECX) )
#endif


#if (TYPE & SETUP_TMU0)
    MOVQ      ( REGOFF(CLIP_S0, ECX), MM0 ) /* f[S0COORD] = f[CLIP_S0] * oow  */
    PFMUL     ( MM7, MM0 )                  /* f[T0COORD] = f[CLIP_T0] * oow  */
    MOVQ      ( MM0, REGOFF(GR_VERTEX_SOW_TMU0_OFFSET, ECX) )
#endif




/*  DO_SETUP_XYZ */

    MOVQ      ( REGIND(ECX), MM2 )              /*  f[1]        | f[0]        */
    PFMUL     ( MM7, MM2 )                      /*  f[1] * oow  | f[0] * oow  */

    MOVD      ( REGOFF(8, ECX), MM3 )           /*              | f[2]        */
    PFMUL     ( MM7, MM3 )                      /*              | f[2] * oow  */

    MOVD      ( REGOFF(MAT_TZ, EBP), MM0 )      /*              | vtz         */
    PFMUL     ( MM1, MM3 )                      /*              | f[2] *= vsz */

    PFADD     ( MM0, MM3 )                      /*              | f[2] += vtz */
    PFMUL     ( MM5, MM2 )                      /*  f[1] *= vsy | f[0] *= vsx */

    PFADD     ( MM6, MM2 )                      /*  f[1] += vty | f[0] += vtx */

#if !defined(FX_V2)
    PFSUB     ( MM4, MM2 )                      /*  f[0,1] -= snapper         */
#endif

    MOVQ      ( MM2, REGOFF(GR_VERTEX_X_OFFSET, ECX) )
    MOVD      ( MM3, REGOFF(GR_VERTEX_OOZ_OFFSET, ECX) )


/* end of DO_SETUP_XYZ   */

    MOVD      ( MM7, REGOFF(GR_VERTEX_OOW_OFFSET, ECX) ) /* f[OOWCOORD] = oow */

TAGLLBL(FXPCV_skip):
    ADD_L     ( EAX, ECX )    /* f += stride     */

    INC_L     ( ESI )                           /*  next ClipMask             */
    CMP_L     ( ECX, EDX )
    JA        ( TAGLLBL(FXPCV_loop_start) )

    POP_L     ( ESI )
    POP_L     ( EDI )

TAGLLBL(FXPCV_end):
    FEMMS
    POP_L     ( EBP )
    RET



#undef TYPE
#undef TAG
#undef SIZE