DirectX
| DXIL Opcode |
DXIL OpName |
Shader Model |
Shader Stages |
| 24 |
Sqrt |
6.0 |
() |
SPIR-V
Length:
Description:
Length
Result is the length of vector x, i.e., sqrt(x [0] 2 +
x [1] 2 + …).
The operand x must be a scalar or vector whose component type is
floating-point.
Result Type must be a scalar of the same type as the component type of
x.
| Number |
Operand 1 |
Operand 2 |
Operand 3 |
Operand 4 |
66 |
<id>
x |
|
|
|
Test Case(s)
Example 1
//dxc length_test.hlsl -T lib_6_8 -enable-16bit-types -O0
export float fn(float4 p1) {
return length(p1);
}
HLSL:
Returns the length of the specified floating-point vector.
Parameters
| Item |
Description |
x
|
The specified floating-point vector.
|
Return Value
A floating-point scalar that represents the length of the x parameter.
Type Description
Minimum Shader Model
This function is supported in the following shader models.
See also
-
Intrinsic Functions (DirectX HLSL)
lengthclang builtin,lengthclang builtin withhlsl_intrinsics.hlengthtoCheckHLSLBuiltinFunctionCallinSemaChecking.cpp#101096lengthtoEmitHLSLBuiltinExprinCGBuiltin.cppclang/test/CodeGenHLSL/builtins/length.hlslclang/test/SemaHLSL/BuiltIns/length-errors.hlslint_dx_lengthintrinsic inIntrinsicsDirectX.tdint_dx_lengthinllvm/lib/Target/DirectX/DXILIntrinsicExpansion.cpplength.llandlength_errors.lltests inllvm/test/CodeGen/DirectX/int_spv_lengthintrinsic inIntrinsicsSPIRV.tdlengthlowering and map it toint_spv_lengthinSPIRVInstructionSelector::selectIntrinsic.llvm/test/CodeGen/SPIRV/hlsl-intrinsics/length.llDirectX
SPIR-V
Length:
Description:
Length
Result is the length of vector x, i.e., sqrt(x [0] 2 +
x [1] 2 + …).
The operand x must be a scalar or vector whose component type is
floating-point.
Result Type must be a scalar of the same type as the component type of
x.
66
<id>
x
Test Case(s)
Example 1
HLSL:
Returns the length of the specified floating-point vector.
Parameters
Return Value
A floating-point scalar that represents the length of the x parameter.
Type Description
Minimum Shader Model
This function is supported in the following shader models.
See also
Intrinsic Functions (DirectX HLSL)