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

Denormals are handled as follows:

src0 src1-> -inf F +inf NAN
-inf -inf src1 +inf -inf
F src0 src0 or src1 +inf src0
+inf +inf +inf +inf +inf
NaN -inf src1 +inf NaN

F means finite-real number.

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)

DirectX Functional Specification