![]() |
![]() |
![]() |
Instruction modifiers affect the result of the instruction before it is written into the destination register.
This section contains reference information for the instruction modifiers implemented by pixel shader version 2_0 and above.
Name | Syntax | 2_0 | 2_x | 2_sw | 3_0 | 3_sw |
---|---|---|---|---|---|---|
Saturate | _sat | x | x | x | x | x |
Partial Precision | _pp | x | x | x | x | x |
Centroid | _centroid | x | x |
The saturate instruction modifier (_sat) saturates (or clamps) the instruction result to the range [0, 1] before writing to the destination register.
The _sat instruction modifier can be used with any instruction except frc, sincos, and any tex* instructions.
For ps_2_0, ps_2_x, and ps_2_sw, the _sat instruction modifier cannot be used with instructions writing to any output registers (Output Color Register or Output Depth Register). This restriction does not apply to ps_3_0 and above.
Example:
dp3_sat r0, v0, c1
The partial precision instruction modifier (_pp) indicates areas where partial precision is acceptable, provided that the underlying implementation supports it. Implementations are always free to ignore the modifier and perform the affected operations in full precision.
The _pp modifier can occur in two contexts:
Examples:
dcl_texcoord0_pp t1 cmp_pp r0, r1, r2, r3
Centroid is an optional instruction modifier (ps_3_0 and above) that modifies the way that sampling locations are altered when multisampling. Centroid clamps the attribute interpolation to the range of the attribute across the primitive, when the multisample pixel center is not covered by the primitive. Gradients computed from such data are not guaranteed to be accurate. Take care when an attribute marked with _centroid is used for texture sampling. Normally the evaluation is performed at the pixel center. Any Input Color Register (v#) declared with a _color* usage will automatically have _centroid applied implicitly.
dcl_texcoord0_centroid v0