Pixel Shader Source Register Modifiers
Use source register modifiers to change the value read from a register before an instruction runs. The contents of a source register are left unchanged. Modifiers are useful for adjusting the range of register data in preparation for the instruction. A set of modifiers called selectors copies or replicates the data from a single channel (r,g,b,a) into the other channels.
ps_1_1 - ps_1_4
This table identifies the versions that support each modifier:
| Source register modifiers | Syntax | Version | |||||
|---|---|---|---|---|---|---|---|
| 1_1 | 1_2 | 1_3 | 1_4 | ||||
| bias | register_bias | X | X | X | X | ||
| invert | 1 - register | X | X | X | X | ||
| negate | - register | X | X | X | X | ||
| scale by 2 | register_x2 | X | |||||
| signed scaling | register_bx2 | X | X | X | X | ||
| texld and texcrd modifiers | register_d* | X | X | X | X | ||
| source register swizzling | register.xyzw | X | X | X | X |
Source register modifiers can be used only on arithmetic instructions. They cannot be used on texture address instructions. The exception to this is the scale by 2 modifier. For version 1_1, signed scale can be used on the source argument of any texm* instruction. For version 1_2 or 1_3, signed scale can be used on the source argument of any texture address instruction.
Some modifier specific restrictions:
- Negate can be combined with either the bias, signed scaling, or scalex2 modifier. When combined, negate is run last.
- Invert cannot be combined with any other modifier.
- Invert, negate, bias, signed scaling, and scalex2 can be combined with any of the selectors.
- Source register modifiers should not be used on constant registers because they will cause undefined results. For version 1_4, modifiers on constants are not allowed and will fail validation.
ps_2_0 and Above
For version ps_2_0 and up, the number of modifiers has been simplified.
Negate
Negate the contents of the source register.
| Component modifier | Description |
|---|---|
| - r | Source negation |
The negate modifier cannot be used on second source register of these instructions: m3x2 - ps, m3x3 - ps, m3x4 - ps, m4x3 - ps, and m4x4 - ps.
| Pixel shader versions | 2_0 | 2_x | 2_sw | 3_0 | 3_sw |
|---|---|---|---|---|---|
| - | x | x | x | x | x |
Absolute Value
Take the absolute value of the register.
| Pixel shader versions | 2_0 | 2_x | 2_sw | 3_0 | 3_sw |
|---|---|---|---|---|---|
| abs | x | x |
If any version 3 shader reads from one or more constant float registers (c#), one of the following must be true.
- All of the constant floating-point registers must use the abs modifier.
- None of the constant floating-point registers can use the abs modifier.
Related topics