source: trunk/Packages/bgrabitmap/phongdrawsse.inc

Last change on this file was 2, checked in by chronos, 5 years ago
File size: 3.3 KB
Line 
1asm
2 //vL := vLS- vP*LightDestFactor;
3 movups xmm4, vP
4 movups xmm6,LightDestFactor4
5 mulps xmm6, xmm4 //keep xmm4 = vP
6 movaps xmm0, xmm1
7 subps xmm0, xmm6
8
9 movups xmm2, vV //preload xmm2 (A)
10
11 //normalize(vL);
12 movaps xmm6, xmm0 //save
13 mulps xmm0, xmm0
14
15 {$IFDEF PARAM_USESSE3}
16 haddps xmm0,xmm0
17 haddps xmm0,xmm0
18 {$ELSE}
19 //mix1
20 movaps xmm7, xmm0
21 shufps xmm7, xmm7, $4e
22 addps xmm0, xmm7
23 //mix2
24 movaps xmm7, xmm0
25 shufps xmm7, xmm7, $11
26 addps xmm0, xmm7
27 {$ENDIF}
28
29 //1/sqrt
30 rsqrtps xmm0, xmm0
31 mulps xmm0, xmm6 //apply
32
33
34 //vH := vL + vV; (A)
35 //xmm2 = vV
36 addps xmm2, xmm0
37
38
39
40 //vectproduct(vS1,vS2,vN);
41 movups xmm6, vS1
42 shufps xmm6, xmm6, Shift231
43
44 movups xmm7, vS2
45 shufps xmm7, xmm7, Shift312
46
47 movaps xmm3,xmm6
48 mulps xmm3,xmm7
49
50 movups xmm6, vS1
51 shufps xmm6, xmm6, Shift312
52
53 movups xmm7, vS2
54 shufps xmm7, xmm7, Shift231
55
56 mulps xmm7,xmm6
57 subps xmm3,xmm7
58 //end of vectproduct
59
60
61 //normalize(vH);
62 movaps xmm6, xmm2 //save
63 mulps xmm2, xmm2
64
65 {$IFDEF PARAM_USESSE3}
66 haddps xmm2,xmm2
67 haddps xmm2,xmm2
68 {$ELSE}
69 //mix1
70 movaps xmm7, xmm2
71 shufps xmm7, xmm7, $4e
72 addps xmm2, xmm7
73 //mix2
74 movaps xmm7, xmm2
75 shufps xmm7, xmm7, $11
76 addps xmm2, xmm7
77 {$ENDIF}
78
79 //1/sqrt
80 rsqrtps xmm2, xmm2
81 mulps xmm2, xmm6 //apply
82
83 //normalize(vN);
84 movaps xmm6, xmm3 //save
85 mulps xmm3, xmm3
86
87 {$IFDEF PARAM_USESSE3}
88 haddps xmm3,xmm3
89 haddps xmm3,xmm3
90 {$ELSE}
91 //mix1
92 movaps xmm7, xmm3
93 shufps xmm7, xmm7, $4e
94 addps xmm3, xmm7
95 //mix2
96 movaps xmm7, xmm3
97 shufps xmm7, xmm7, $11
98 addps xmm3, xmm7
99 {$ENDIF}
100
101 //1/sqrt
102 rsqrtps xmm3, xmm3
103 mulps xmm3, xmm6 //apply
104
105 //LdotN := vN * vL;
106 movups xmm5, xmm3
107 mulps xmm5, xmm0
108 //mix1
109 movaps xmm7, xmm5
110 shufps xmm7, xmm7, $4e
111 addps xmm5, xmm7
112 //mix2
113 movaps xmm7, xmm5
114 shufps xmm7, xmm7, $11
115 addps xmm5, xmm7
116 //:=
117 movss LdotN, xmm5
118
119 //vD := vLS-vP;
120 movaps xmm5, xmm1
121 subps xmm5, xmm4
122
123 //dist := sqrt(vD*vD);
124 mulps xmm5, xmm5
125
126 {$IFDEF PARAM_USESSE3}
127 haddps xmm5,xmm5
128 haddps xmm5,xmm5
129 {$ELSE}
130 //mix1
131 movaps xmm7, xmm5
132 shufps xmm7, xmm7, $4e
133 addps xmm5, xmm7
134 //mix2
135 movaps xmm7, xmm5
136 shufps xmm7, xmm7, $11
137 addps xmm5, xmm7
138 {$ENDIF}
139
140 //:= sqrt
141 sqrtss xmm5,xmm5
142 movss dist, xmm5
143
144 //NH := vH * vN;
145 movups xmm6, xmm2
146 mulps xmm6, xmm3
147
148 {$IFDEF PARAM_USESSE3}
149 haddps xmm6,xmm6
150 haddps xmm6,xmm6
151 {$ELSE}
152 //mix1
153 movaps xmm7, xmm6
154 shufps xmm7, xmm7, $4e
155 addps xmm6, xmm7
156 //mix2
157 movaps xmm7, xmm6
158 shufps xmm7, xmm7, $11
159 addss xmm6, xmm7
160 {$ENDIF}
161 //:=
162 movss NH, xmm6
163 end;
Note: See TracBrowser for help on using the repository browser.