Efficient 3D-Clipping Code Computation Using 3Dnow! Instructions - AMD Athlon Processor x86 Optimization Manual

X86 code optimization
Table of Contents

Advertisement

AMD Athlon™ Processor x86 Code Optimization
Efficient 3D-Clipping Code Computation Using 3DNow!™
Instructions
.DATA
RIGHT
EQU 01h
LEFT
EQU 02h
ABOVE
EQU 04h
BELOW
EQU 08h
BEHIND
EQU 10h
BEFORE
EQU 20h
ALIGN 8
ABOVE_RIGHT
DD
DD
BELOW_LEFT
DD
DD
BEHIND_BEFORE
DD
DD
.CODE
;; Generalized computation of 3D clip code (out code)
;;
;; Register usage: IN
;;
;;
;;
122
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
RIGHT
ABOVE
LEFT
BELOW
BEFORE
BEHIND
MM5
y | x
MM6
w | z
OUT
MM2
clip code (out code)
Efficient 3D-Clipping Code Computation Using
22007E/0—November 1999

Advertisement

Table of Contents
loading

Table of Contents