AMD x86 manual Data

Models: x86

1 256
Download 256 pages 58.62 Kb
Page 138
Image 138

AMD Athlon™ Processor x86 Code Optimization

22007E/0 — November 1999

Efficient 3D-Clipping Code Computation Using 3DNow!™ Instructions

Clipping is one of the major activities occurring in a 3D graphics pipeline. In many instances, this activity is split into two parts which do not necessarily have to occur consecutively:

Computation of the clip code for each vertex, where each bit of the clip code indicates whether the vertex is outside the frustum with regard to a specific clip plane.

Examination of the clip code for a vertex and clipping if the clip code is non-zero.

The following example shows how to use 3DNow! instructions to efficiently implement a clip code computation for a frustum that is defined by:

-w <= x <= w

-w <= y <= w

-w <= z <= w

.DATA

RIGHT EQU 01h

LEFT EQU 02h

ABOVE EQU 04h

BELOW EQU 08h

BEHIND EQU 10h

BEFORE EQU 20h

 

ALIGN 8

ABOVE_RIGHT

DD

RIGHT

 

DD

ABOVE

BELOW_LEFT

DD

LEFT

DDBELOW

BEHIND_BEFORE DD BEFORE

DD BEHIND

.CODE

;;Generalized computation of 3D clip code (out code)

;; Register usage: IN

MM5

y

x

;;

 

MM6

w

z

;;

 

 

 

 

 

;;

OUT

MM2

clip code (out code)

122

Efficient 3D-Clipping Code Computation Using

Page 138
Image 138
AMD x86 manual Data