• Slang Standard Library Reference
    • Interfaces
    • Types
    • Attributes
    • Global Declarations
      • Atomic functions
      • Memory and control barriers
      • Bit operation functions
      • Conversion functions
      • Derivative functions
      • Math functions
        • abs
        • acos
        • acosh
        • asin
        • asinh
        • atan
        • atan2
        • atanh
        • ceil
        • clamp
        • copysign
        • copysign_double
        • copysign_float
        • copysign_half
        • cos
        • cosh
        • cospi
        • cross
        • degrees
        • determinant
        • distance
        • divide
        • dot
        • dot2add
        • dot4add_i8packed
        • dot4add_u8packed
        • dst
        • exp
        • exp10
        • exp2
        • fabs
        • faceforward
        • fdim
        • floor
        • fma
        • fmax
        • fmax3
        • fmedian3
        • fmin
        • fmin3
        • fmod
        • frac
        • fract
        • frexp
        • isfinite
        • isinf
        • isnan
        • ldexp
        • length
        • lerp
        • lit
        • log
        • log10
        • log2
        • mad
        • max
        • max3
        • median3
        • min
        • min3
        • modf
        • msad4
        • mul
        • noise
        • normalize
        • pow
        • powr
        • radians
        • rcp
        • reflect
        • refract
        • rint
        • round
        • rsqrt
        • saturate
        • sign
        • sin
        • sincos
        • sinh
        • sinpi
        • smoothstep
        • sqrt
        • step
        • tan
        • tanh
        • tanpi
        • transpose
        • trunc
      • Mesh shading
      • Ray-tracing
      • Tessellation functions
      • Wave and quad functions
      • CheckAccessFullyMapped
      • D3DCOLORtoUBYTE4
      • EvaluateAttributeAtCentroid
      • EvaluateAttributeAtSample
      • EvaluateAttributeSnapped
      • GetAttributeAtVertex
      • GetRenderTargetSampleCount
      • GetRenderTargetSamplePosition
      • IsHelperLane
      • NonUniformResourceIndex
      • ReorderThread
      • WorkgroupSize
      • abort
      • all
      • any
      • clip
      • concat
      • createDynamicObject
      • cudaBlockDim
      • cudaBlockIdx
      • cudaThreadIdx
      • debugBreak
      • getRealtimeClock
      • getRealtimeClockLow
      • getStringHash
      • makeTuple
      • nextafter
      • printf
      • select
      • static_assert
      • unmodified
      • unused

mad

Description

Computes multiply-add.

Signature

/// Requires Capability Set 1:
T mad<T>(
    T mvalue,
    T avalue,
    T bvalue)
    where T : __BuiltinFloatingPointType;

/// Requires Capability Set 1:
vector<T, N> mad<T, N:int>(
    vector<T, N> mvalue,
    vector<T, N> avalue,
    vector<T, N> bvalue)
    where T : __BuiltinFloatingPointType;

/// Requires Capability Set 1:
matrix<T, N, M> mad<T, N:int, M:int>(
    matrix<T, N, M> mvalue,
    matrix<T, N, M> avalue,
    matrix<T, N, M> bvalue)
    where T : __BuiltinFloatingPointType;

/// Requires Capability Set 2:
T mad<T>(
    T mvalue,
    T avalue,
    T bvalue)
    where T : __BuiltinIntegerType;

/// Requires Capability Set 2:
vector<T, N> mad<T, N:int>(
    vector<T, N> mvalue,
    vector<T, N> avalue,
    vector<T, N> bvalue)
    where T : __BuiltinIntegerType;

/// Requires Capability Set 2:
matrix<T, N, M> mad<T, N:int, M:int>(
    matrix<T, N, M> mvalue,
    matrix<T, N, M> avalue,
    matrix<T, N, M> bvalue)
    where T : __BuiltinIntegerType;

Generic Parameters

T: __BuiltinFloatingPointType

N : int

M : int

T: __BuiltinIntegerType

Parameters

mvalue : T

avalue : T

bvalue : T

mvalue : vector<T, N>

avalue : vector<T, N>

bvalue : vector<T, N>

mvalue : matrix<T, N, M>

avalue : matrix<T, N, M>

bvalue : matrix<T, N, M>

Availability and Requirements

Capability Set 1

Defined for the following targets:

hlsl

Available in all stages.

glsl

Available in all stages.

cpp

Available in all stages.

cuda

Available in all stages.

metal

Available in all stages.

spirv

Available in all stages.

Capability Set 2

Defined for the following targets:

hlsl

Available in all stages.

glsl

Available in all stages.

cpp

Available in all stages.

cuda

Available in all stages.

spirv

Available in all stages.