Description
- Implement
saturate
clang builtin,Linksaturate
clang builtin withhlsl_intrinsics.h
Add sema checks forsaturate
toCheckHLSLBuiltinFunctionCall
inSemaChecking.cpp
Add codegen forsaturate
toEmitHLSLBuiltinExpr
inCGBuiltin.cpp
Add codegen tests toclang/test/CodeGenHLSL/builtins/saturate.hlsl
Add sema tests toclang/test/SemaHLSL/BuiltIns/saturate-errors.hlsl
Create theint_dx_saturate
intrinsic inIntrinsicsDirectX.td
Create theDXILOpMapping
ofint_dx_saturate
to7
inDXIL.td
Create thesaturate.ll
andsaturate_errors.ll
tests inllvm/test/CodeGen/DirectX/
Create theint_spv_saturate
intrinsic inIntrinsicsSPIRV.td
In SPIRVInstructionSelector.cpp create thesaturate
lowering and map it toint_spv_saturate
inSPIRVInstructionSelector::selectIntrinsic
.Create SPIR-V backend test case inllvm/test/CodeGen/SPIRV/hlsl-intrinsics/saturate.ll
DirectX
DXIL Opcode | DXIL OpName | Shader Model | Shader Stages |
---|---|---|---|
7 | Saturate | 6.0 | () |
SPIR-V
FClamp:
Description:
FClamp
Result is min(max(x, minVal), maxVal). Result is undefined if
minVal > maxVal.The semantics used by min() and max() are those of
FMin and FMax.
The operands must all be a scalar or vector whose component type is
floating-point.
Result Type and the type of all operands must be the same type.
Results are computed per component.
Number | Operand 1 | Operand 2 | Operand 3 | Operand 4 |
---|---|---|---|---|
43 |
<id> |
<id> |
<id> |
Test Case(s)
Example 1
//dxc saturate_test.hlsl -T lib_6_8 -enable-16bit-types -O0
export float4 fn(float4 p1) {
return saturate(p1);
}
HLSL:
Clamps the specified value within the range of 0 to 1.
ret saturate(x) |
---|
Parameters
Item | Description |
---|---|
x |
[in] The specified value. |
Return Value
The x parameter, clamped within the range of 0 to 1.
Type Description
Name | Template Type | Component Type | Size |
---|---|---|---|
x | scalar, vector, or matrix | 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 1 (DirectX HLSL) and higher shader models | yes |
See also
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
No status
Activity
5 remaining items