-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathengine.s
More file actions
277 lines (216 loc) · 5.56 KB
/
Copy pathengine.s
File metadata and controls
277 lines (216 loc) · 5.56 KB
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
.section .data
.global ENGINE_TIME
ENGINE_TIME: .quad 0
.align 32
plane_mask: .long 0, 4, 1, 5, 2, 6, 0, 0
.section .text
.global compute_point
compute_point:
pushq %rbp
movq %rsp, %rbp
subq $64, %rsp
movq CCURRENT(%rip), %r14
movq %rdx, -8(%rbp)
movq %rcx, %rdx
movq 8(%r14), %rcx
leaq -24(%rbp), %r8
call mulmv
movq 16(%r14), %rcx
leaq -24(%rbp), %rdx
leaq -40(%rbp), %r8
call mulmv
movss -28(%rbp), %xmm0
ucomiss 36(%r14), %xmm0
jbe compute_point_Cquit
movss -28(%rbp), %xmm0
ucomiss 40(%r14), %xmm0
jae compute_point_Cquit
leaq -40(%rbp), %rcx
leaq -40(%rbp), %rdx
call vndc
fld1
fadds -40(%rbp)
fstps -40(%rbp)
fld1
fsubs -36(%rbp)
fstps -36(%rbp)
movq $2, %rax
cvtsi2ss %rax, %xmm2
movss Width(%rip), %xmm0
divss %xmm2, %xmm0
mulss -40(%rbp), %xmm0
movss %xmm0, -40(%rbp)
movss Height(%rip), %xmm0
divss %xmm2, %xmm0
mulss -36(%rbp), %xmm0
movss %xmm0, -36(%rbp)
vpxor %xmm1, %xmm1, %xmm1
movss -40(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jb compute_point_Cquit
movss -40(%rbp), %xmm0
ucomiss Width(%rip), %xmm0
ja compute_point_Cquit
movss -36(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jb compute_point_Cquit
movss -36(%rbp), %xmm0
ucomiss Height(%rip), %xmm0
ja compute_point_Cquit
jmp compute_point_quit
compute_point_Cquit:
movq $0, %rax
jmp compute_point_end
compute_point_quit:
movq -8(%rbp), %rax
vmovups -40(%rbp), %xmm0
vmovups %xmm0, (%rax)
movq $1, %rax
compute_point_end:
addq $64, %rsp
popq %rbp
ret
.global compute_line
compute_line:
pushq %rbp
movq %rsp, %rbp
subq $256, %rsp
movq CCURRENT(%rip), %r14
movq %r8, -8(%rbp)
movq %r9, -16(%rbp)
movq %rdx, -24(%rbp)
movq %rcx, %rdx
movq 8(%r14), %rcx
leaq -48(%rbp), %r8
call mulmv
leaq -48(%rbp), %rdx
movq 16(%r14), %rcx
leaq -64(%rbp), %r8
call mulmv
vmovups -64(%rbp), %xmm0
vmovups %xmm0, -48(%rbp)
movq -24(%rbp), %rdx
movq 8(%r14), %rcx
leaq -64(%rbp), %r8
call mulmv
leaq -64(%rbp), %rdx
movq 16(%r14), %rcx
leaq -80(%rbp), %r8
call mulmv
vmovups -80(%rbp), %xmm0
vmovups %xmm0, -64(%rbp)
movq $0, -168(%rbp)
vpxor %xmm15, %xmm15, %xmm15
vmovdqa plane_mask(%rip), %ymm14
compute_line_loop:
vbroadcastss -36(%rbp), %xmm0
vaddps -48(%rbp), %xmm0, %xmm1
vsubps -48(%rbp), %xmm0, %xmm2
vmovups %xmm1, -128(%rbp)
vmovups %xmm2, -112(%rbp)
vmovups -128(%rbp), %ymm0
vpermps %ymm0, %ymm14, %ymm0
vmovups %ymm0, -128(%rbp)
vbroadcastss -52(%rbp), %xmm0
vaddps -64(%rbp), %xmm0, %xmm1
vsubps -64(%rbp), %xmm0, %xmm2
vmovups %xmm1, -160(%rbp)
vmovups %xmm2, -144(%rbp)
vmovups -160(%rbp), %ymm0
vpermps %ymm0, %ymm14, %ymm0
vmovups %ymm0, -160(%rbp)
leaq -128(%rbp), %rdx
addq -168(%rbp), %rdx
movss (%rdx), %xmm0
leaq -160(%rbp), %rcx
addq -168(%rbp), %rcx
movss (%rcx), %xmm1
ucomiss %xmm15, %xmm1
ja compute_line_loop0
ucomiss %xmm15, %xmm0
jb compute_line_Cquit
jmp compute_line_loop1
compute_line_loop0:
ucomiss %xmm15, %xmm0
ja compute_line_loop_cont
jmp compute_line_loop2
compute_line_loop1:
movss %xmm0, %xmm2
subss %xmm1, %xmm0
divss %xmm0, %xmm2
vbroadcastss %xmm2, %xmm2
vmovups -64(%rbp), %xmm0
vsubps -48(%rbp), %xmm0, %xmm0
vmulps %xmm0, %xmm2, %xmm0
vmovups -48(%rbp), %xmm1
vaddps %xmm1, %xmm0, %xmm0
vmovups %xmm0, -64(%rbp)
jmp compute_line_loop_cont
compute_line_loop2:
movss %xmm0, %xmm2
subss %xmm1, %xmm0
divss %xmm0, %xmm2
vbroadcastss %xmm2, %xmm2
vmovups -64(%rbp), %xmm0
vsubps -48(%rbp), %xmm0, %xmm0
vmulps %xmm0, %xmm2, %xmm0
vmovups -48(%rbp), %xmm1
vaddps %xmm1, %xmm0, %xmm0
vmovups %xmm0, -48(%rbp)
compute_line_loop_cont:
addq $4, -168(%rbp)
cmpq $24, -168(%rbp)
jb compute_line_loop
leaq -48(%rbp), %rcx
leaq -48(%rbp), %rdx
call vndc
leaq -64(%rbp), %rcx
leaq -64(%rbp), %rdx
call vndc
fld1
fadds -48(%rbp)
fstps -48(%rbp)
fld1
fsubs -44(%rbp)
fstps -44(%rbp)
fld1
fadds -64(%rbp)
fstps -64(%rbp)
fld1
fsubs -60(%rbp)
fstps -60(%rbp)
movq $2, %rax
cvtsi2ss %rax, %xmm2
movss Width(%rip), %xmm0
divss %xmm2, %xmm0
mulss -48(%rbp), %xmm0
movss %xmm0, -48(%rbp)
movss Height(%rip), %xmm0
divss %xmm2, %xmm0
mulss -44(%rbp), %xmm0
movss %xmm0, -44(%rbp)
movss Width(%rip), %xmm0
divss %xmm2, %xmm0
mulss -64(%rbp), %xmm0
movss %xmm0, -64(%rbp)
movss Height(%rip), %xmm0
divss %xmm2, %xmm0
mulss -60(%rbp), %xmm0
movss %xmm0, -60(%rbp)
vpxor %xmm1, %xmm1, %xmm1
jmp compute_line_quit
compute_line_Cquit:
movq $0, %rax
jmp compute_line_end
compute_line_quit:
movq -8(%rbp), %rax
vmovups -48(%rbp), %xmm0
vmovups %xmm0, (%rax)
movq -16(%rbp), %rax
vmovups -64(%rbp), %xmm0
vmovups %xmm0, (%rax)
movq $1, %rax
compute_line_end:
addq $256, %rsp
popq %rbp
ret