Flow Control

Most hardware is designed to run shader code line by line, executing each HLSL statement once. A flow-control statement determines at run time which block of HLSL statements to execute next. Using a flow-control statement, a shader can loop through a set of statements, or jump (branch) to an instruction other than the one on the next line. Some flow-control statements support static control that is specified at compile time; others offer predicated control which is a per-component decision made at runtime, and still others support dynamic control which is a decision made at run time based on the contents of a variable.

HLSL supports the following flow-control statements.

Language Syntax (DirectX HLSL)