Performs an arithmetic multiply/add operation on three values.
numeric mad( in numeric mvalue, in numeric avalue, in numeric bvalue );
- mvalue [in]
The multiplication value.
- avalue [in]
The first addition value.
- bvalue [in]
The second addition value.
The result of mvalue * avalue + bvalue.
This function is supported in the following shader models.
|Shader Model 5 and higher shader models||yes|
This function is supported in the following types of shaders:
Shader authors can use the mad instrinsic to explicitly target the mad hardware instruction in the compiled shader output, which is particularly useful with shaders that mark results with the precise keyword. The mad instruction can be implemented in hardware as either "fused," which offers higher precision than implementing a mul instruction followed by an add instruction, or as a mul + add.
If shader authors use the mad instrinsic to calculate a result that the shader marked as precise, they indicate to the hardware to use any valid implementation of the mad instruction (fused or not) as long as the implementation is consistent for all uses of that mad intrinsic in any shader on that hardware. Shaders can then take advantage of potential performance improvements by using a native mad instruction (versus mul + add) on some hardware. The result of performing a native mad hardware instruction might or might not be different than performing a mul followed by an add. However, whatever the result is, the result must be consistent for the same operation to occur in multiple shaders or different parts of a shader.