-
Notifications
You must be signed in to change notification settings - Fork 15.1k
Closed
Labels
HLSLHLSL Language SupportHLSL Language Supportbackend:DirectXbackend:SPIR-Vbot:HLSLmetaissueIssue to collect references to a group of similar or related issues.Issue to collect references to a group of similar or related issues.
Description
- Implement
lengthclang builtin, - Link
lengthclang builtin withhlsl_intrinsics.h - Add sema checks for
lengthtoCheckHLSLBuiltinFunctionCallinSemaChecking.cpp#101096 - Add codegen for
lengthtoEmitHLSLBuiltinExprinCGBuiltin.cpp - Add codegen tests to
clang/test/CodeGenHLSL/builtins/length.hlsl - Add sema tests to
clang/test/SemaHLSL/BuiltIns/length-errors.hlsl - Create the
int_dx_lengthintrinsic inIntrinsicsDirectX.td - Create an intrinsic expansion of
int_dx_lengthinllvm/lib/Target/DirectX/DXILIntrinsicExpansion.cpp - Create the
length.llandlength_errors.lltests inllvm/test/CodeGen/DirectX/ - Create the
int_spv_lengthintrinsic inIntrinsicsSPIRV.td - In SPIRVInstructionSelector.cpp create the
lengthlowering and map it toint_spv_lengthinSPIRVInstructionSelector::selectIntrinsic. - Create SPIR-V backend test case in
llvm/test/CodeGen/SPIRV/hlsl-intrinsics/length.ll
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> |
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.
| ret length(x) |
|---|
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
| Name | Template Type | Component Type | Size |
|---|---|---|---|
| x | vector | float | any |
| ret | scalar | float | 1 |
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 only) |
See also
Metadata
Metadata
Assignees
Labels
HLSLHLSL Language SupportHLSL Language Supportbackend:DirectXbackend:SPIR-Vbot:HLSLmetaissueIssue to collect references to a group of similar or related issues.Issue to collect references to a group of similar or related issues.
Type
Projects
Status
No status