max

Selects the greater of x and y.

ret max(x, y)

Parameters

Item Description
x
[in] The x input value.
y
[in] The y input value.

Return Value

The x or y parameter, whichever is the largest value.

Remarks

For values of -INF or INF, max will behave as expected. However for values of NaN, the results are undefined.

Type Description

Name In/Out Template Type Component Type Size
x in scalar, vector, or matrix float, int any
y in same as input x float, int same dimension(s) as input x
ret return type same as input x float, int same dimension(s) as input x

Minimum Shader Model

This function is supported in the following shader models.

Shader Model Supported
Shader Model 2 (DirectX HLSL) and higher shader models yes
Shader Model 1 (DirectX HLSL) yes (vs_1_1 and ps_1_4)

See also

Intrinsic Functions (DirectX HLSL)