Closed
Description
- Implement
normalize
clang builtin, - Link
normalize
clang builtin withhlsl_intrinsics.h
- Add sema checks for
normalize
toCheckHLSLBuiltinFunctionCall
inSemaChecking.cpp
- Add codegen for
normalize
toEmitHLSLBuiltinExpr
inCGBuiltin.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_normalize
intrinsic inIntrinsicsDirectX.td
- Create an intrinsic expansion
int_dx_normalize
inllvm/lib/Target/DirectX/DXILIntrinsicExpansion.cpp
- Create the
normalize.ll
andnormalize_errors.ll
tests inllvm/test/CodeGen/DirectX/
- Create the
int_spv_normalize
intrinsic inIntrinsicsSPIRV.td
- In SPIRVInstructionSelector.cpp create the
normalize
lowering and map it toint_spv_normalize
inSPIRVInstructionSelector::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
Type
Projects
Status
No status