1 | {$IFDEF PARAM_USESSE} {$asmmode intel}
|
---|
2 | minVal := 0;
|
---|
3 | maxVal := 65535;
|
---|
4 | asm
|
---|
5 | movss xmm6, invZ
|
---|
6 | shufps xmm6,xmm6,0 //xmm6 = invZ
|
---|
7 | movss xmm7, invZStep
|
---|
8 | shufps xmm7,xmm7,0 //xmm7 = invZStep
|
---|
9 | movups xmm4, colorPos
|
---|
10 | movups xmm5, colorStep
|
---|
11 |
|
---|
12 | movss xmm2, minVal
|
---|
13 | shufps xmm2,xmm2,0 //xmm2 = minVal
|
---|
14 | movss xmm3, maxVal
|
---|
15 | shufps xmm3,xmm3,0 //xmm3 = maxVal
|
---|
16 | end;
|
---|
17 |
|
---|
18 | for i := ix1 to ix2 do
|
---|
19 | begin
|
---|
20 | {$IFDEF PARAM_USEZBUFFER}
|
---|
21 | if invZ > zbufferpos^ then
|
---|
22 | {$ENDIF}
|
---|
23 | begin
|
---|
24 | {$IFDEF PARAM_USEZBUFFER}
|
---|
25 | zbufferpos^ := invz;
|
---|
26 | {$ENDIF}
|
---|
27 | asm
|
---|
28 | movaps xmm0,xmm6
|
---|
29 | rcpps xmm0,xmm0
|
---|
30 | mulps xmm0, xmm4
|
---|
31 | minps xmm0, xmm3
|
---|
32 | maxps xmm0, xmm2
|
---|
33 | {$IFDEF PARAM_USESSE2}
|
---|
34 | cvtps2dq xmm0,xmm0
|
---|
35 | movups cInt, xmm0
|
---|
36 | {$ELSE}
|
---|
37 | movups colorPosByZ, xmm0
|
---|
38 | {$ENDIF}
|
---|
39 | end;
|
---|
40 | {$IFDEF PARAM_USESSE2}
|
---|
41 | c.red := GammaCompressionTab[cInt.r];
|
---|
42 | c.green := GammaCompressionTab[cInt.g];
|
---|
43 | c.blue := GammaCompressionTab[cInt.b];
|
---|
44 | c.alpha := GammaCompressionTab[cInt.a];
|
---|
45 | DrawPixelInlineWithAlphaCheck(pdest, c);
|
---|
46 | {$ELSE}
|
---|
47 | ec.red := round(colorPosByZ[1]);
|
---|
48 | ec.green := round(colorPosByZ[2]);
|
---|
49 | ec.blue := round(colorPosByZ[3]);
|
---|
50 | ec.alpha := round(colorPosByZ[4]);
|
---|
51 | DrawPixelInlineWithAlphaCheck(pdest, GammaCompression(ec));
|
---|
52 | {$ENDIF}
|
---|
53 | end;
|
---|
54 | asm
|
---|
55 | addps xmm6,xmm7
|
---|
56 | addps xmm4,xmm5
|
---|
57 | {$IFDEF PARAM_USEZBUFFER}
|
---|
58 | movss invZ,xmm6
|
---|
59 | {$ENDIF}
|
---|
60 | end;
|
---|
61 | inc(pdest);
|
---|
62 | {$IFDEF PARAM_USEZBUFFER}
|
---|
63 | inc(zbufferpos);
|
---|
64 | {$ENDIF}
|
---|
65 | end;
|
---|
66 | {$ELSE}
|
---|
67 | for i := ix1 to ix2 do
|
---|
68 | begin
|
---|
69 | {$IFDEF PARAM_USEZBUFFER}
|
---|
70 | if invZ > zbufferpos^ then
|
---|
71 | {$ENDIF}
|
---|
72 | begin
|
---|
73 | {$IFDEF PARAM_USEZBUFFER}
|
---|
74 | zbufferpos^ := invz;
|
---|
75 | {$ENDIF}
|
---|
76 | z := 1/invZ;
|
---|
77 | r := round(z*colorPos[1]);
|
---|
78 | g := round(z*colorPos[2]);
|
---|
79 | b := round(z*colorPos[3]);
|
---|
80 | a := round(z*colorPos[4]);
|
---|
81 | if r < 0 then ec.red := 0 else
|
---|
82 | if r > 65535 then ec.red := 65535
|
---|
83 | else ec.red := r;
|
---|
84 | if g < 0 then ec.green := 0 else
|
---|
85 | if g > 65535 then ec.green := 65535
|
---|
86 | else ec.green := g;
|
---|
87 | if b < 0 then ec.blue := 0 else
|
---|
88 | if b > 65535 then ec.blue := 65535
|
---|
89 | else ec.blue := b;
|
---|
90 | if a < 0 then ec.alpha := 0 else
|
---|
91 | if a > 65535 then ec.alpha := 65535
|
---|
92 | else ec.alpha := a;
|
---|
93 | DrawPixelInlineWithAlphaCheck(pdest, GammaCompression(ec));
|
---|
94 | end;
|
---|
95 | colorPos += colorStep;
|
---|
96 | invZ += invZStep;
|
---|
97 | inc(pdest);
|
---|
98 | {$IFDEF PARAM_USEZBUFFER}
|
---|
99 | inc(zbufferpos);
|
---|
100 | {$ENDIF}
|
---|
101 | end;
|
---|
102 | {$ENDIF}
|
---|
103 |
|
---|