A method and apparatus for executing loop and branch program instructions
in a programmable graphics shader. The programmable graphics shader
converts a sequence of instructions comprising a portion of a shader
program and selects a first set of fragments to be processed. Subsequent
sequences of instructions are converted until all of the instructions
comprising the shader program have been executed on the first set of
fragments. Each remaining set of fragments is processed by the shader
program until all of the fragments are processed in the same manner.
Furthermore, the instructions can contain one or more loop or branch
program instructions that are conditionally executed. Additionally, when
instructions within a loop as defined by a loop instruction are being
executed a current loop count is pipelined through the programmable
graphics shader and used as an index to access graphics memory.