-
Couldn't load subscription status.
- Fork 15k
Closed
Labels
HLSLHLSL Language SupportHLSL Language Supportbackend:DirectXbackend:SPIR-Vbot:HLSLclang:codegenIR generation bugs: mangling, exceptions, etc.IR generation bugs: mangling, exceptions, etc.metaissueIssue 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
normalizeclang builtin, - Link
normalizeclang builtin withhlsl_intrinsics.h - Add sema checks for
normalizetoCheckHLSLBuiltinFunctionCallinSemaChecking.cpp - Add codegen for
normalizetoEmitHLSLBuiltinExprinCGBuiltin.cpp - Add codegen tests to
clang/test/CodeGenHLSL/builtins/normalize.hlsl - Add sema tests to
clang/test/SemaHLSL/BuiltIns/normalize-errors.hlsl - Create the
int_dx_normalizeintrinsic inIntrinsicsDirectX.td - Create an intrinsic expansion
int_dx_normalizeinllvm/lib/Target/DirectX/DXILIntrinsicExpansion.cpp - Create the
normalize.llandnormalize_errors.lltests inllvm/test/CodeGen/DirectX/ - Create the
int_spv_normalizeintrinsic inIntrinsicsSPIRV.td - In SPIRVInstructionSelector.cpp create the
normalizelowering and map it toint_spv_normalizeinSPIRVInstructionSelector::selectIntrinsic. - Create SPIR-V backend test case in
llvm/test/CodeGen/SPIRV/hlsl-intrinsics/normalize.ll
DirectX
| DXIL Opcode | DXIL OpName | Shader Model | Shader Stages |
|---|---|---|---|
| 56 | Dot4 | 6.0 | () |
SPIR-V
Normalize:
Description:
Normalize
Result is the vector in the same direction as x but with a length of
1.
The operand x must be a scalar or vector whose component type is
floating-point.
Result Type and the type of x must be the same type.
| Number | Operand 1 | Operand 2 | Operand 3 | Operand 4 |
|---|---|---|---|---|
69 |
<id> |
Test Case(s)
Example 1
//dxc normalize_test.hlsl -T lib_6_8 -enable-16bit-types -O0
export float4 fn(float4 p1) {
return normalize(p1);
}HLSL:
Normalizes the specified floating-point vector according to x / length(x).
| ret normalize(x) |
|---|
Parameters
| Item | Description |
|---|---|
| x |
[in] The specified floating-point vector. |
Return Value
The normalized x parameter. If the length of the x parameter is 0, the result is indefinite.
Remarks
The normalize HLSL intrinsic function uses the following formula: x / length(x).
Type Description
| Name | Template Type | Component Type | Size |
|---|---|---|---|
| x | vector | float | any |
| ret | same as input x | float | 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 only) |
See also
Metadata
Metadata
Assignees
Labels
HLSLHLSL Language SupportHLSL Language Supportbackend:DirectXbackend:SPIR-Vbot:HLSLclang:codegenIR generation bugs: mangling, exceptions, etc.IR generation bugs: mangling, exceptions, etc.metaissueIssue 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