Rev 8719 | Rev 9512 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8719 | Rev 9237 | ||
---|---|---|---|
Line 2... | Line 2... | ||
2 | y3d equ 2 |
2 | y3d equ 2 |
3 | z3d equ 4 |
3 | z3d equ 4 |
4 | vec_x equ 0 |
4 | vec_x equ 0 |
5 | vec_y equ 4 |
5 | vec_y equ 4 |
6 | vec_z equ 8 |
6 | vec_z equ 8 |
- | 7 | ||
- | 8 | if 0 ; Ext >= SSE3 |
|
- | 9 | calc_bounding_box: |
|
- | 10 | ; in: |
|
- | 11 | ; xmm0 - normal vector of ray |
|
- | 12 | ; xmm1 - light origin |
|
- | 13 | ; out: |
|
7 | ; 3d point - triple integer word coordinate |
14 | ; eax - axis aligned bounding boxes bit mask |
- | 15 | ||
- | 16 | .rmx equ [ebp-36] |
|
- | 17 | .nray equ [ebp-64] |
|
- | 18 | .origin equ [ebp-80] |
|
- | 19 | .dirfrac equ [ebp-96] |
|
- | 20 | .nrayr equ [ebp-112] |
|
- | 21 | .originr equ [ebp-128] |
|
- | 22 | .tmin equ [ebp-132] |
|
- | 23 | .tmax equ [ebp-136] |
|
- | 24 | ||
- | 25 | ||
- | 26 | push ebp |
|
- | 27 | mov ebp,esp |
|
- | 28 | and ebp,-16 |
|
- | 29 | sub esp,160 |
|
- | 30 | ||
- | 31 | movss xmm5,[rsscale] |
|
- | 32 | shufps xmm5,xmm1,0 |
|
- | 33 | movd xmm2,[vect_x] |
|
- | 34 | punpcklwd xmm2,[the_zero] |
|
- | 35 | cvtdq2ps xmm2,xmm2 |
|
- | 36 | subps xmm1,xmm2 |
|
- | 37 | movaps .origin,xmm1 |
|
- | 38 | mulps xmm0,xmm5 |
|
- | 39 | movaps .nray,xmm0 |
|
- | 40 | ||
- | 41 | mov esi,matrix |
|
- | 42 | lea edi,.rmx |
|
- | 43 | call reverse_mx_3x3 |
|
- | 44 | ||
- | 45 | ; in: esi - ptr to points(normals], each point(normal) coeficient as dword |
|
8 | ; vector - triple float dword coordinate |
46 | ; edi - ptr to rotated points(normals) |
9 | ;----------------------in: -------------------------------- |
47 | ; ebx - ptr to 3x3 (9 dwords, 36 bytes) rotation matrix |
10 | ;------------------------ esi - pointer to 1st 3d point --- |
48 | ; ecx - number of points(normals) |
- | 49 | ||
- | 50 | ; reverse transform |
|
- | 51 | lea esi,.nray |
|
- | 52 | lea edi,.nrayr |
|
- | 53 | lea ebx,.rmx |
|
- | 54 | mov ecx,1 |
|
- | 55 | call rotary |
|
- | 56 | ||
- | 57 | lea esi,.origin |
|
- | 58 | lea edi,.originr |
|
- | 59 | lea ebx,.rmx |
|
- | 60 | mov ecx,1 |
|
- | 61 | call rotary |
|
- | 62 | ||
- | 63 | xor ecx,ecx |
|
- | 64 | mov ebx,aabb1 |
|
- | 65 | xor eax,eax |
|
- | 66 | rcpps xmm7,.nrayr |
|
- | 67 | movaps .dirfrac,xmm7 |
|
- | 68 | ||
- | 69 | .nx_aabb: |
|
- | 70 | movaps xmm5,[ebx] |
|
- | 71 | movaps xmm6,[ebx] |
|
- | 72 | minps xmm5,[the_zero] |
|
- | 73 | maxps xmm6,[the_zero] |
|
11 | ;------------------------ edi - pointer to 2nd 3d point --- |
74 | ; xmm5 - lb corner of AABB with minimal coordinates |
12 | ;------------------------ ebx - pointer to result vector -- |
75 | ; xmm6 - rt cor. of AABB wit maximum coords |
- | 76 | subps xmm5,.originr |
|
- | 77 | subps xmm6,.originr |
|
- | 78 | mulps xmm5,.dirfrac ; xmm5 - tx1, ty1 |
|
13 | ;---------------------- out : none ------------------------ |
79 | mulps xmm6,.dirfrac ; xmm6 - tx2, ty2 |
- | 80 | movaps xmm1,xmm6 |
|
- | 81 | movaps xmm2,xmm6 |
|
- | 82 | ||
- | 83 | ||
- | 84 | minps xmm1,xmm5 |
|
- | 85 | maxps xmm2,xmm5 |
|
- | 86 | ||
- | 87 | movaps xmm5,xmm1 |
|
- | 88 | movaps xmm6,xmm2 |
|
- | 89 | shufps xmm5,xmm5,11100001b |
|
- | 90 | shufps xmm6,xmm6,11100001b |
|
- | 91 | maxss xmm1,xmm5 ;t min |
|
- | 92 | minss xmm2,xmm6 ;t max |
|
- | 93 | comiss xmm2,xmm1 |
|
- | 94 | jb .no_inter |
|
- | 95 | .yes: |
|
- | 96 | bts eax,ecx |
|
- | 97 | .no_inter: |
|
- | 98 | add ebx,16 |
|
- | 99 | inc ecx |
|
- | 100 | cmp ecx,8 |
|
- | 101 | jne .nx_aabb |
|
- | 102 | ||
- | 103 | ; out: eax - bit mask |
|
- | 104 | add esp,160 |
|
- | 105 | pop ebp |
|
- | 106 | ret |
|
- | 107 | end if |
|
- | 108 | ||
14 | reverse_mx_3x3: |
109 | reverse_mx_3x3: |
15 | ; esi - source matrix |
110 | ; esi - source matrix |
16 | ; edi - desired reversed matrix |
111 | ; edi - desired reversed matrix |
Line 17... | Line 112... | ||
17 | 112 | ||
Line 139... | Line 234... | ||
139 | 234 | ||
140 | 235 | ||
141 | mov esp,ebp |
236 | mov esp,ebp |
- | 237 | pop ebp |
|
- | 238 | ret |
|
- | 239 | ; 3d point - triple integer word coordinate |
|
- | 240 | ; vector - triple float dword coordinate |
|
- | 241 | ;----------------------in: -------------------------------- |
|
- | 242 | ;------------------------ esi - pointer to 1st 3d point --- |
|
- | 243 | ;------------------------ edi - pointer to 2nd 3d point --- |
|
Line 142... | Line 244... | ||
142 | pop ebp |
244 | ;------------------------ ebx - pointer to result vector -- |
143 | ret |
245 | ;---------------------- out : none ------------------------ |
144 | 246 | ||
145 | make_vector_r: |
247 | make_vector_r: |
Line 192... | Line 294... | ||
192 | fld dword [esi+vec_y] |
294 | fld dword [esi+vec_y] |
193 | fmul dword [edi+vec_x] |
295 | fmul dword [edi+vec_x] |
194 | fsubp ;st1 ,st |
296 | fsubp ;st1 ,st |
195 | fstp dword [ebx+vec_z] |
297 | fstp dword [ebx+vec_z] |
196 | ret |
298 | ret |
- | 299 | cross_aligned: |
|
- | 300 | movaps xmm0,[esi] |
|
- | 301 | movaps xmm1,[esi] |
|
- | 302 | movaps xmm2,[edi] |
|
- | 303 | movaps xmm3,[edi] |
|
- | 304 | shufps xmm0,xmm0,00001001b |
|
- | 305 | shufps xmm1,xmm1,00010010b |
|
- | 306 | shufps xmm2,xmm2,00010010b |
|
- | 307 | shufps xmm3,xmm3,00001001b |
|
- | 308 | mulps xmm0,xmm2 |
|
- | 309 | mulps xmm1,xmm3 |
|
- | 310 | subps xmm0,xmm1 |
|
- | 311 | movaps [ebx],xmm0 |
|
- | 312 | ret |
|
197 | ;----------------------- in: ------------------------------ |
313 | ;----------------------- in: ------------------------------ |
198 | ;---------------------------- edi - pointer to vector ----- |
314 | ;---------------------------- edi - pointer to vector ----- |
199 | ;----------------------- out : none |
315 | ;----------------------- out : none |
200 | normalize_vector: |
316 | normalize_vector: |
201 | if Ext >= SSE3 |
317 | if Ext >= SSE2 |
202 | movups xmm0,[edi] |
318 | movups xmm0,[edi] |
203 | andps xmm0,[zero_hgst_dd] |
319 | andps xmm0,[zero_hgst_dd] |
204 | movups xmm1,xmm0 |
320 | movups xmm1,xmm0 |
205 | mulps xmm0,xmm0 |
321 | mulps xmm0,xmm0 |
- | 322 | movhlps xmm2,xmm0 |
|
- | 323 | addps xmm0,xmm2 |
|
- | 324 | movaps xmm2,xmm0 |
|
- | 325 | shufps xmm2,xmm2,11100101b |
|
- | 326 | addps xmm0,xmm2 |
|
- | 327 | shufps xmm0,xmm0,0 |
|
206 | haddps xmm0,xmm0 |
328 | ; haddps xmm0,xmm0 |
207 | haddps xmm0,xmm0 |
329 | ; haddps xmm0,xmm0 |
208 | rsqrtps xmm0,xmm0 |
330 | rsqrtps xmm0,xmm0 |
209 | mulps xmm0,xmm1 |
331 | mulps xmm0,xmm1 |
210 | movlps [edi],xmm0 |
332 | movlps [edi],xmm0 |
211 | movhlps xmm0,xmm0 |
333 | movhlps xmm0,xmm0 |
212 | movss [edi+8],xmm0 |
334 | movss [edi+8],xmm0 |
Line 557... | Line 679... | ||
557 | ; movups xmm0,[esi] |
679 | ; movups xmm0,[esi] |
558 | ; cvtps2dq xmm0,xmm0 |
680 | ; cvtps2dq xmm0,xmm0 |
559 | ; packsdw xmm0,xmm0 |
681 | ; packsdw xmm0,xmm0 |
560 | ; movq [edi] |
682 | ; movq [edi] |
561 | fld dword[esi] |
683 | fld dword[esi] |
562 | fiadd [vect_x] |
684 | fiadd word[vect_x] |
563 | fistp word[edi] |
685 | fistp word[edi] |
564 | fld dword[esi+4] |
686 | fld dword[esi+4] |
565 | fiadd [vect_y] |
687 | fiadd [vect_y] |
566 | fistp word[edi+2] |
688 | fistp word[edi+2] |
567 | fld dword[esi+8] |
689 | fld dword[esi+8] |