Line | |
---|
1 | {$asmmode intel}
|
---|
2 | asm
|
---|
3 | {$ifdef cpux86_64}
|
---|
4 | mov rax, Context
|
---|
5 | movaps xmm0,[rax+160] //Context^.vL
|
---|
6 | movaps xmm2,[rax+192] //Context^.vH
|
---|
7 | movaps xmm1,[rax+16] //Context^.Normal
|
---|
8 | {$else}
|
---|
9 | mov eax, Context
|
---|
10 | movaps xmm0,[eax+160] //Context^.vL
|
---|
11 | movaps xmm2,[eax+192] //Context^.vH
|
---|
12 | movaps xmm1,[eax+16] //Context^.Normal
|
---|
13 | {$endif}
|
---|
14 |
|
---|
15 | {$IFDEF PARAM_POINTLIGHT}
|
---|
16 | {$ifdef cpux86_64}
|
---|
17 | movaps xmm6,[rax+0] //Context^.Position
|
---|
18 | {$else}
|
---|
19 | movaps xmm6,[eax+0] //Context^.Position
|
---|
20 | {$endif}
|
---|
21 | subps xmm0,xmm6 //xmm0 = vL
|
---|
22 | movaps xmm6, xmm0
|
---|
23 | mulps xmm6, xmm6
|
---|
24 |
|
---|
25 | {$IFDEF PARAM_USESSE3}
|
---|
26 | haddps xmm6,xmm6
|
---|
27 | haddps xmm6,xmm6
|
---|
28 | {$ELSE}
|
---|
29 | //mix1
|
---|
30 | movaps xmm7, xmm6
|
---|
31 | shufps xmm7, xmm7, $4e
|
---|
32 | addps xmm6, xmm7
|
---|
33 | //mix2
|
---|
34 | movaps xmm7, xmm6
|
---|
35 | shufps xmm7, xmm7, $11
|
---|
36 | addps xmm6, xmm7
|
---|
37 | {$ENDIF}
|
---|
38 |
|
---|
39 | movss dist2, xmm6 //dist2 := vL*vL;
|
---|
40 |
|
---|
41 | rsqrtps xmm6, xmm6
|
---|
42 | mulps xmm0, xmm6 //xmm0 = normalized vL
|
---|
43 | {$ENDIF}
|
---|
44 |
|
---|
45 | {$IFDEF PARAM_POINTLIGHT}
|
---|
46 | addps xmm2,xmm0 //vH += normalized vL
|
---|
47 | movaps xmm6, xmm2
|
---|
48 | mulps xmm2, xmm2
|
---|
49 |
|
---|
50 | {$IFDEF PARAM_USESSE3}
|
---|
51 | haddps xmm2,xmm2
|
---|
52 | haddps xmm2,xmm2
|
---|
53 | {$ELSE}
|
---|
54 | //mix1
|
---|
55 | movaps xmm7, xmm2
|
---|
56 | shufps xmm7, xmm7, $4e
|
---|
57 | addps xmm2, xmm7
|
---|
58 | //mix2
|
---|
59 | movaps xmm7, xmm2
|
---|
60 | shufps xmm7, xmm7, $11
|
---|
61 | addps xmm2, xmm7
|
---|
62 | {$ENDIF}
|
---|
63 |
|
---|
64 | rsqrtps xmm2, xmm2
|
---|
65 | mulps xmm2, xmm6 //xmm2 = normalized vH
|
---|
66 | {$ENDIF}
|
---|
67 |
|
---|
68 | //vL*Normal
|
---|
69 | mulps xmm0, xmm1
|
---|
70 | //vH*Normal
|
---|
71 | mulps xmm2, xmm1
|
---|
72 |
|
---|
73 | {$IFDEF PARAM_USESSE3}
|
---|
74 | haddps xmm0,xmm0
|
---|
75 | haddps xmm0,xmm0
|
---|
76 | {$ELSE}
|
---|
77 | //mix1
|
---|
78 | movaps xmm7, xmm0
|
---|
79 | shufps xmm7, xmm7, $4e
|
---|
80 | addps xmm0, xmm7
|
---|
81 | //mix2
|
---|
82 | movaps xmm7, xmm0
|
---|
83 | shufps xmm7, xmm7, $11
|
---|
84 | addps xmm0, xmm7
|
---|
85 | {$ENDIF}
|
---|
86 |
|
---|
87 | {$IFDEF PARAM_USESSE3}
|
---|
88 | haddps xmm2,xmm2
|
---|
89 | haddps xmm2,xmm2
|
---|
90 | {$ELSE}
|
---|
91 | //mix1
|
---|
92 | movaps xmm7, xmm2
|
---|
93 | shufps xmm7, xmm7, $4e
|
---|
94 | addps xmm2, xmm7
|
---|
95 | //mix2
|
---|
96 | movaps xmm7, xmm2
|
---|
97 | shufps xmm7, xmm7, $11
|
---|
98 | addps xmm2, xmm7
|
---|
99 | {$ENDIF}
|
---|
100 |
|
---|
101 | movss LdotN, xmm0
|
---|
102 | movss NdotH, xmm2
|
---|
103 | end;
|
---|
104 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.