Counting Instructions
Each shader has a maximum number of instructions allowed. Five types of instructions can be used in a shader: version, constant definition, phase, arithmetic, and texture address. Arithmetic and texture addressing instructions count toward the total number of instructions allowed. Phase, def, and version instructions do not count. These are summarized in the following table.
Instruction type | Version |
1.0 | 1.1 | 1.2 | 1.3 | 1.4 phase 1 | 1.4 phase 2 |
Version | * | * | * | * | * | N/A |
Constant definition | * | * | * | * | * | N/A |
Phase | N/A | N/A | N/A | N/A | * | * |
Arithmetic | 8 | 8 | 8 | 8 | 8 | 8 |
Texture address | 4 | 4 | 4 | 4 | 6 | 6 |
Total | 8 | 12 | 12 | 12 | 14 | 14 |
*Version, constant definition, and phase instructions do not count toward instruction limits.
N/A Not applicable. The phase instruction applies only to pixel shader version 1.4. The version and constant definition instructions can be used only in phase 1.
Instruction count exceptions for pixel shader version 1.0, 1.1, 1.2, 1.3
- For version 1.0 only, the tex instruction does not count toward the total number of instructions, although it does count toward the total number of texture address instructions.
- In version 1.0, texbem counts as two texture address instructions. In versions 1.1, 1.2, and 1.3, texbem counts as one texture address instruction.
- In version 1.0, texbeml counts as two texture address instructions plus one arithmetic instruction. In versions 1.1, 1.2, and 1.3, texbeml counts as one texture address instruction plus one arithmetic instruction.
- For pixel shader version 1.2 and 1.3, both cmp and dp4 count as two instructions. Unfortunately, this was discovered too late in the development cycle and therefore is not validated properly when calling CreatePixelShader. They are incorrectly being counted as only consuming one instruction. Be sure to manually count each of these instructions as two instructions toward the maximum instruction count. For more information about instruction counts, see Counting Instructions.
Instruction count exceptions for pixel shader version 1.4
- In version 1.4, only one phase instruction (also commonly called the phase marker) can be used per shader.
- In version 1.4, bem counts as two arithmetic instructions.
- Version 1.4 allows 14 instructions in both phase 1 and phase 2, for a total of 28 instructions. If no phase marker is specified, the default is phase 2 and the total instruction count is 14.