Shader Code Format
A command to create a pixel or vertex shader is composed of a group of shader codes. These codes instruct the driver on how to create the shader. The format of tokens within each shader code determines its uniqueness. A shader code token is a DWORD with a specific format.
The DirectX3D runtime validates shader code before passing the code to a driver. When shader code arrives at the driver, the driver can interpret the code because the code's format is valid. The driver reads the shader code's tokens to interpret the code.
Each individual shader code is formatted with a general token layout. The first token must be a version token. The version token provides the version number of the code and also determines whether the code is for a pixel or vertex shader. Shader content follows the version token and is composed of various instruction tokens, perhaps intermingled with comment tokens and white space. Depending on the precise operation that an instruction token specifies, label, destination parameter, and source parameter tokens can also be part of the shader content and follow an instruction token. For example, if the instruction token specifies an ADD instruction, the driver determines that one destination and two source parameter tokens follow the instruction token. An end token completes the shader code.
Setup instructions (for example, D3DSIO_DCL and D3DSIO_DEF) contain uniquely formatted tokens.
Each shader instruction contains a specific token format. The Shader Operation Codes section describes the token format of each shader instruction.
Shader instructions start with the primary instruction and end with a D3DSIO_RET or D3DSIO_END instruction. Subroutines follow the D3DSIO_RET instruction.
See the Pixel Shader Reference and Vertex Shader Reference in the latest DirectX SDK documentation for more information about operations that can be specified in instruction tokens.
Available in Windows Vista and later versions of the Windows operating systems.