Intel i86W Manual page 190

Table of Contents

Advertisement

PROGRAMMING EXAMPLES
9.13.3.1 Z-8UFFER MASKING
When either the first or last pixel of the line segment is not at an 8-byte boundary, the
rendering procedure must mask the first or last set of new Z-buffer values (newz) so that
the Z-buffer and the frame buffer are not erroneously updated. Sometimes both the first
and last pixels are in the same 4-pixel set, in which case either one may not be on an
8-byte boundary. A function that looks up and calculates masks is outlined in
Example 9-19.
Because the value OxFFFF is used for masking, the Z-buffer is initialized with OxFFFE,
so that the
fzchks
instruction always finds the mask to be greater than any Z-buffer
contents.
II.
CONSTRUCT INTERPOLANTS iR, iG, iB GIVEN mR, mG, mB
shl
18,
mR,
Ra
II
Multiply each color slope by four,
shl
18,
mG,
Rb
II
shift by 16 to put the significant
shl
18,
mB,
Rc
II
bits into the high-order half
shr
16,
Ra,
mR
II
Return significant 16 bits
shr
16,
Rb,
mG
II
to low-order half. Any sign bits
shr
16,
Rc,
mB
II
in high-order half are gone.
or
mR,
Ra,
Ra
II
Join 16-bit quarters
or
mG,
Rb,
Rb
II
in 32-bit register
or
mB,
Rc,
Rc
II
ixfr
Ra,
iR
II
Join 32-bit halves
ixfr
Rb,
iG
II
in-64-bit register
ixfr
Rc,
iB
II
fmov·ss
iR,
iRh
II
fmov.ss
iG,
iGh
II
fmov.ss
iB,
iBh
II
Example 9-18. Construction of Color Interpolants
·macro zmask I_align, r_align, Rx, Ry
II
I_align -- left-end alignment in two-byte units
II
r_align -- right-end alignment in two-byte units
II
Rx, Ry
-- scratch registers
II
Left-end OR masks
Right-end OR masks
II
Input
Output
Input
II
I_align
IZmask
r_align
II
~
~~~~ ~~~~ ~~~~ ~~~~
~
FFFF
II
1
~~~~
~~~~ ~~~~
FFFF
1
FFFF
II
2
~~~~
~~~~
FFFF FFFF
2
FFFF
II
3
~~~~
FFFF FFFF FFFF
3
~~~~
II
If the first and last pixels are contained in
II
aligned set, then IZmask
=
IZmask DR rZmask •
. endm
Output
rZmask
FFFF FFFF
~~~~
FFFF
~~~~
~~~~
~~~~
~~~~
~~~~
~~~~
~~~~
~~~~
the same 64-bit
Example 9-19. Z Mask Procedure
9-28
then

Advertisement

Table of Contents
loading

Table of Contents