Datatype color conversions are a common requirement in 3-D application pipelines. In a simple lighting scheme, these conversions happen at least once per color channel, red, green, blue (R, G, B) per vertex, and in a more realistic lighting scheme, such values are often calculated multiple times for different light components. Color conversion from single-precision floating point values to integer values is typically done by using simple casts, for example intvalR = (int)fpvalR; where intval is an integer and fpval a singleprecision floating point number.
This approach can be less than optimal on an out-of-order execution CPU architecture with a large execution pipeline such as the Pentium® 4 processor. The technique described in this paper makes possible an alternative, more architectural friendly approach to using simple high-level-language casts to solve this problem on data sets of specific configurations. The result is a faster method for doing such conversions using the Streaming SIMD Extension (SSE) instructions and their associated registers, in conjunction with the MMX™ technology registers and instructions.