Implementers of graphics application programming interfaces (APIs) and
algorithms are often required to support a plethora of options for se
veral stages at the back end of the geometry and rasterization pipelin
e. Implementing these options in high-level programming languages such
as C leads to code with many branches and large object modules due to
indiscriminate duplication of very similar code. This reduces the spe
ed of execution of the program. This paper examines the problems of br
anches and code size in detail and presents techniques for transformin
g typical code sequences in graphics programs to reduce the number of
branches and to reduce to the size of the program. A set of branch-fre
e basis functions is defined first. The application of these functions
to common geometric queries, geometry pipeline computations, rasteriz
ation, and pixel processing algorithms is then discussed.