~ubuntu-branches/ubuntu/gutsy/vnc4/gutsy

« back to all changes in this revision

Viewing changes to unix/xc/extras/Mesa/src/X86/3dnow_vertex.S

  • Committer: Bazaar Package Importer
  • Author(s): Ola Lundqvist
  • Date: 2006-05-15 20:35:17 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060515203517-l4lre1ku942mn26k
Tags: 4.1.1+X4.3.0-10
* Correction of critical security issue. Thanks to Martin Kogler
  <e9925248@student.tuwien.ac.at> that informed me about the issue,
  and provided the patch.
  This flaw was originally found by Steve Wiseman of intelliadmin.com.
* Applied patch from Javier Kohen <jkohen@users.sourceforge.net> that
  inform the user that only 8 first characters of the password will
  actually be used when typing more than 8 characters, closes:
  #355619.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "matypes.h"
 
2
 
 
3
   SEG_TEXT
 
4
 
 
5
#define MAT_SY 20
 
6
#define MAT_SZ 40
 
7
#define MAT_TX 48
 
8
#define MAT_TY 52
 
9
#define MAT_TZ 56
 
10
 
 
11
 
 
12
/*
 
13
 * void _mesa_v16_3dnow_general_xform( GLfloat *dest,
 
14
 *                                  const GLfloat *m,
 
15
 *                                  const GLfloat *src,
 
16
 *                                  GLuint src_stride,
 
17
 *                                  GLuint count )
 
18
 *
 
19
 * These tranformation functions could disappear if the standard ones
 
20
 * took an output stride.
 
21
 */
 
22
GLOBL GLNAME( _mesa_v16_3dnow_general_xform )
 
23
GLNAME( _mesa_v16_3dnow_general_xform ):
 
24
 
 
25
    PUSH_L    ( EDI )
 
26
    PUSH_L    ( ESI )
 
27
 
 
28
    MOV_L     ( REGOFF(12, ESP), EAX )          /* dest                      */
 
29
    MOV_L     ( REGOFF(16, ESP), ESI )          /* mat                       */
 
30
    MOV_L     ( REGOFF(20, ESP), EDX )          /* src                       */
 
31
    MOV_L     ( REGOFF(24, ESP), EDI )          /* src_stride                */
 
32
    MOV_L     ( REGOFF(28, ESP), ECX )          /* count                     */
 
33
 
 
34
    FEMMS
 
35
 
 
36
    MOVQ      ( REGOFF(MAT_TX, ESI), MM7 )      /* ty          | tx          */
 
37
    MOVQ      ( REGOFF(MAT_TZ, ESI), MM3 )      /* tw          | tz          */
 
38
 
 
39
ALIGNTEXT32
 
40
LLBL( v16_3dnow_general_loop ):
 
41
 
 
42
    PREFETCHW ( REGOFF(128, EAX) )              /* write alloc 2 verts ahead */
 
43
    PREFETCH  ( REGOFF(32, EDX) )               /* prefetch next cache line  */
 
44
 
 
45
    MOVQ      ( REGIND(EDX),  MM0 )             /* x1          | x0          */
 
46
    MOVD      ( REGOFF(8, EDX), MM1 )           /*             | x2          */
 
47
    MOVQ      ( REGIND(ESI),  MM4 )             /* m1          | m0          */
 
48
    PUNPCKHDQ ( MM0, MM2 )                      /* x1          |             */
 
49
    MOVQ      ( REGOFF(16, ESI), MM5 )          /* m5          | m4          */
 
50
    PUNPCKLDQ ( MM0, MM0 )                      /* x0          | x0          */
 
51
    MOVQ      ( REGOFF(32, ESI), MM6 )          /* m9          | m8          */
 
52
    PFMUL     ( MM0, MM4 )                      /* x0*m1       | x0*m0       */
 
53
    PUNPCKHDQ ( MM2, MM2 )                      /* x1          | x1          */
 
54
    PFMUL     ( MM2, MM5 )                      /* x1*m5       | x1*m4       */
 
55
    PUNPCKLDQ ( MM1, MM1 )                      /* x2          | x2          */
 
56
    PFMUL     ( REGOFF(8, ESI), MM0 )           /* x0*m3       | x0*m2       */
 
57
    PFMUL     ( REGOFF(24, ESI), MM2 )          /* x1*m7       | x1*m6       */
 
58
    PFMUL     ( MM1, MM6 )                      /* x2*m9       | x2*m8       */
 
59
    PFADD     ( MM4, MM5 )                      /* x0*m1+x1*m5 | x0*m0+x1*m4 */
 
60
    PFMUL     ( REGOFF(40, ESI), MM1 )          /* x2*m11      | x2*m10      */
 
61
    PFADD     ( MM0, MM2 )                      /* x0*m3+x1*m7 | x0*m2+x1*m6 */
 
62
    PFADD     ( MM5, MM6 )
 
63
    PFADD     ( MM1, MM2 )
 
64
    PFADD     ( MM7, MM6 )                      /* r1          | r0          */
 
65
    PFADD     ( MM3, MM2 )                      /* r3          | r2          */
 
66
    ADD_L     ( EDI, EDX )                      /* next input vertex         */
 
67
    MOVQ      ( MM6, REGIND(EAX) )
 
68
    MOVQ      ( MM2, REGOFF(8, EAX) )
 
69
    ADD_L     ( CONST(64), EAX )                /* next output vertex        */
 
70
    DEC_L     ( ECX )
 
71
    JNE       ( LLBL(v16_3dnow_general_loop) )
 
72
 
 
73
    FEMMS
 
74
 
 
75
    POP_L     ( ESI )
 
76
    POP_L     ( EDI )
 
77
    RET
 
78
 
 
79
 
 
80
 
 
81
/* Do viewport map and perspective projection.  Args should look like:
 
82
 *
 
83
 * _mesa_3dnow_project_vertices( float *first_vertex,
 
84
 *                            const float *last_vertex,
 
85
 *                            float *matrix,
 
86
 *                            GLuint stride )
 
87
 *
 
88
 * This routine assumes a sane vertex layout with x,y,z,w as
 
89
 * the first four elements, to be projected in clip-space, to
 
90
 * x/w,y/w,z/w,1/w, and then transformed according to the matrix to
 
91
 * device space.  The device coordinates will overwrite the clip
 
92
 * coordinates as the first four elements of the vertex.
 
93
 *
 
94
 * If projection is required for other elements, such as texcoords,
 
95
 * you will have to code a specialized version of this routine.  See
 
96
 * FX/X86 for examples.
 
97
 *
 
98
 * These routines are simplified versions of the FX code written by
 
99
 * Holger.
 
100
 */
 
101
 
 
102
GLOBL GLNAME( _mesa_3dnow_project_vertices )
 
103
GLNAME( _mesa_3dnow_project_vertices ):
 
104
 
 
105
    PUSH_L    ( EBP )
 
106
    FEMMS
 
107
    PREFETCH  ( REGOFF(8, ESP) )                /* fetch the first vertex    */
 
108
 
 
109
    MOV_L     ( REGOFF(8, ESP), ECX )           /* first_vert                */
 
110
    MOV_L     ( REGOFF(12, ESP), EDX )          /* last_vert                 */
 
111
    MOV_L     ( REGOFF(16, ESP), EBP )          /* matrix                    */
 
112
    MOV_L     ( REGOFF(20, ESP), EAX )          /* stride                    */
 
113
 
 
114
    MOVD      ( REGOFF(MAT_TX, EBP), MM6 )      /*             | tx          */
 
115
    PUNPCKLDQ ( REGOFF(MAT_TY, EBP), MM6 )      /* ty          | tx          */
 
116
    MOVD      ( REGIND(EBP), MM5 )
 
117
    PUNPCKLDQ ( REGOFF(MAT_SY, EBP), MM5 )      /* vsy         | vsx         */
 
118
    MOVD      ( REGOFF(MAT_SZ, EBP), MM1 )      /*             | vsz         */
 
119
    SUB_L     ( ECX, EDX )                      /* last -= first             */
 
120
 
 
121
ALIGNTEXT32
 
122
LLBL( v16_3dnow_pv_loop_start ):
 
123
 
 
124
    PREFETCH  ( REGOFF(64, ECX) )               /* fetch one/two verts ahead */
 
125
    MOVD      ( REGOFF(12, ECX), MM0 )          /*             | f[3]        */
 
126
    PFRCP     ( MM0, MM0 )                      /* oow = 1/f[3]              */
 
127
    MOVD      ( REGOFF(12, ECX), MM7 )          /*             | f[3]        */
 
128
    PFRCPIT1  ( MM0, MM7 )
 
129
    PFRCPIT2  ( MM0, MM7 )                      /* oow         | oow         */
 
130
    PUNPCKLDQ ( MM7, MM7 )
 
131
    MOVQ      ( REGIND(ECX), MM2 )              /* f[1]        | f[0]        */
 
132
    PFMUL     ( MM7, MM2 )                      /* f[1] * oow  | f[0] * oow  */
 
133
    MOVD      ( REGOFF(8, ECX), MM3 )           /*             | f[2]        */
 
134
    PFMUL     ( MM7, MM3 )                      /*             | f[2] * oow  */
 
135
    MOVD      ( REGOFF(MAT_TZ, EBP), MM0 )      /*             | vtz         */
 
136
    PFMUL     ( MM1, MM3 )                      /*             | f[2] *= vsz */
 
137
    PFADD     ( MM0, MM3 )                      /*             | f[2] += vtz */
 
138
    PFMUL     ( MM5, MM2 )                      /* f[1] *= vsy | f[0] *= vsx */
 
139
    PFADD     ( MM6, MM2 )                      /* f[1] += vty | f[0] += vtx */
 
140
    PUNPCKLDQ ( MM7, MM3 )                      /* f[3] = oow  | f[2]        */
 
141
    MOVQ      ( MM2, REGOFF(0, ECX) )
 
142
    MOVQ      ( MM3, REGOFF(8, ECX) )
 
143
    ADD_L     ( EAX, ECX )                      /* f += stride               */
 
144
    SUB_L     ( EAX, EDX )
 
145
    JA        ( LLBL(v16_3dnow_pv_loop_start) )
 
146
 
 
147
    FEMMS
 
148
    POP_L     ( EBP )
 
149
    RET
 
150
 
 
151
 
 
152
 
 
153
/*
 
154
 * _mesa_3dnow_project_clipped_vertices( float *first_vertex,
 
155
 *                                    const float *last_vertex,
 
156
 *                                    float *matrix,
 
157
 *                                    GLuint stride,
 
158
 *                                    const GLubyte *clip_mask )
 
159
 */
 
160
GLOBL GLNAME( _mesa_3dnow_project_clipped_vertices )
 
161
GLNAME( _mesa_3dnow_project_clipped_vertices ):
 
162
 
 
163
    PUSH_L    ( EBP )
 
164
    PUSH_L    ( ESI )
 
165
 
 
166
    FEMMS
 
167
 
 
168
    PREFETCH  ( REGOFF(12, ESP) )               /* fetch the first vertex    */
 
169
 
 
170
    MOV_L     ( REGOFF(12, ESP), ECX )          /* first_vert                */
 
171
    MOV_L     ( REGOFF(16, ESP), EDX )          /* last_vert                 */
 
172
    MOV_L     ( REGOFF(20, ESP), EBP )          /* matrix                    */
 
173
    MOV_L     ( REGOFF(24, ESP), EAX )          /* stride                    */
 
174
    MOV_L     ( REGOFF(28, ESP), ESI )          /* clip_mask                 */
 
175
 
 
176
 
 
177
    MOVD      ( REGOFF(MAT_TX, EBP), MM6 )      /*             | tx          */
 
178
    PUNPCKLDQ ( REGOFF(MAT_TY, EBP), MM6 )      /* ty          | tx          */
 
179
    MOVD      ( REGIND(EBP), MM5 )
 
180
    PUNPCKLDQ ( REGOFF(MAT_SY, EBP), MM5 )      /* vsy         | vsx         */
 
181
    MOVD      ( REGOFF(MAT_SZ, EBP), MM1 )      /*             | vsz         */
 
182
 
 
183
ALIGNTEXT32
 
184
LLBL( v16_3dnow_pcv_loop_start ):
 
185
 
 
186
    CMP_B     ( CONST(0), REGIND(ESI) )
 
187
    JNE       ( LLBL(v16_3dnow_pcv_skip) )
 
188
 
 
189
    MOVD      ( REGOFF(12, ECX), MM0)           /*             | f[3]        */
 
190
    PFRCP     ( MM0, MM0 )                      /* oow = 1/f[3]              */
 
191
    MOVD      ( REGOFF(12, ECX), MM7)           /*             | f[3]        */
 
192
    PFRCPIT1  ( MM0, MM7 )
 
193
    PFRCPIT2  ( MM0, MM7 )                      /* oow         | oow         */
 
194
    PUNPCKLDQ ( MM7, MM7 )
 
195
    MOVQ      ( REGIND(ECX), MM2 )              /* f[1]        | f[0]        */
 
196
    PFMUL     ( MM7, MM2 )                      /* f[1] * oow  | f[0] * oow  */
 
197
    MOVD      ( REGOFF(8, ECX), MM3 )           /*             | f[2]        */
 
198
    PFMUL     ( MM7, MM3 )                      /*             | f[2] * oow  */
 
199
    MOVD      ( REGOFF(MAT_TZ, EBP), MM0 )      /*             | vtz         */
 
200
    PFMUL     ( MM1, MM3 )                      /*             | f[2] *= vsz */
 
201
    PFADD     ( MM0, MM3 )                      /*             | f[2] += vtz */
 
202
    PFMUL     ( MM5, MM2 )                      /* f[1] *= vsy | f[0] *= vsx */
 
203
    PFADD     ( MM6, MM2 )                      /* f[1] += vty | f[0] += vtx */
 
204
    PUNPCKLDQ ( MM7, MM3 )                      /* f[3] = oow  | f[2]        */
 
205
    MOVQ      ( MM2, REGOFF(0, ECX) )
 
206
    MOVQ      ( MM3, REGOFF(8, ECX) )
 
207
 
 
208
LLBL( v16_3dnow_pcv_skip ):
 
209
 
 
210
    ADD_L     ( EAX, ECX )                      /* f += stride               */
 
211
    INC_L     ( ESI )                           /* next clip_mask            */
 
212
 
 
213
    CMP_L     ( ECX, EDX )
 
214
    JNE       ( LLBL(v16_3dnow_pcv_loop_start) )
 
215
 
 
216
    FEMMS
 
217
 
 
218
    POP_L     ( ESI )
 
219
    POP_L     ( EBP )
 
220
    RET