-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Implement the smoothstep
HLSL Function
#99156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Expanded in DXIL, opcode in SPIRV |
I will be taking on this task. |
@llvm/issue-subscribers-clang-codegen Author: Farzon Lotfi (farzonl)
- [ ] Implement `smoothstep` using HLSL source in `hlsl_intrinsics.h`
- [ ] Implement the `smoothstep` SPIR-V target built-in in clang/include/clang/Basic/BuiltinsSPIRV.td
- [ ] Add sema checks for `smoothstep` to `CheckSPIRVBuiltinFunctionCall ` in `clang/lib/Sema/SemaSPIRV.cpp`
- [ ] Add codegen for spv `smoothstep` to `EmitSPIRVBuiltinExpr ` in `CGBuiltin.cpp`
- [ ] Add codegen tests to `clang/test/CodeGenHLSL/builtins/smoothstep.hlsl`
- [ ] Add spv codegen test to `clang/test/CodeGenSPIRV/Builtins/smoothstep.c`
- [ ] Add sema tests to `clang/test/SemaHLSL/BuiltIns/smoothstep-errors.hlsl`
- [ ] Add spv sema tests to `clang/test/SemaSPIRV/BuiltIns/smoothstep-errors.c`
- [ ] Create the `int_spv_smoothstep` intrinsic in `IntrinsicsSPIRV.td`
- [ ] In SPIRVInstructionSelector.cpp create the `smoothstep` lowering and map it to `int_spv_smoothstep` in `SPIRVInstructionSelector::selectIntrinsic`.
- [ ] Create SPIR-V backend test case in `llvm/test/CodeGen/SPIRV/hlsl-intrinsics/smoothstep.ll`
- [ ] Check for what OpenCL support is needed.
DirectX
SPIR-VSmoothStep:Description:SmoothStep Result is 0.0 if x ≤ edge0 and 1.0 if x ≥ edge1 and performs t * t * (3 - 2 * t), where t = clamp ((x - edge0) / Result is undefined if edge0 ≥ edge1. The operands must all be a scalar or vector whose component type is Result Type and the type of all operands must be the same type. <table> Test Case(s)Example 1//dxc smoothstep_test.hlsl -T lib_6_8 -enable-16bit-types -O0
export float4 fn(float4 p1, float4 p2, float4 p3) {
return smoothstep(p1, p2, p3);
} HLSL:Returns a smooth Hermite interpolation between 0 and 1, if x is in the range [min, max].
Parameters
Return ValueReturns 0 if x is less than min; 1 if x is greater than max; otherwise, a value between 0 and 1 if x is in the range [min, max]. RemarksUse the smoothstep HLSL intrinsic function to create a smooth transition between two values. For example, you can use this function to blend two colors smoothly. Type Description
Minimum Shader ModelThis function is supported in the following shader models.
See also<dl> <dt> Intrinsic Functions (DirectX HLSL) |
smoothstep
using HLSL source inhlsl_intrinsics.h
smoothstep
SPIR-V target built-in in clang/include/clang/Basic/BuiltinsSPIRV.tdsmoothstep
toCheckSPIRVBuiltinFunctionCall
inclang/lib/Sema/SemaSPIRV.cpp
smoothstep
toEmitSPIRVBuiltinExpr
inCGBuiltin.cpp
clang/test/CodeGenHLSL/builtins/smoothstep.hlsl
clang/test/CodeGenSPIRV/Builtins/smoothstep.c
clang/test/SemaHLSL/BuiltIns/smoothstep-errors.hlsl
clang/test/SemaSPIRV/BuiltIns/smoothstep-errors.c
int_spv_smoothstep
intrinsic inIntrinsicsSPIRV.td
smoothstep
lowering and map it toint_spv_smoothstep
inSPIRVInstructionSelector::selectIntrinsic
.llvm/test/CodeGen/SPIRV/hlsl-intrinsics/smoothstep.ll
DirectX
SPIR-V
SmoothStep:
Description:
SmoothStep
Result is 0.0 if x ≤ edge0 and 1.0 if x ≥ edge1 and performs
smooth Hermite interpolation between 0 and 1 when edge0 < x <
edge1. This is equivalent to:
t * t * (3 - 2 * t), where t = clamp ((x - edge0) /
(edge1 - edge0), 0, 1)
Result is undefined if edge0 ≥ edge1.
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.
49
<id>
edge0
<id>
edge1
<id>
x
Test Case(s)
Example 1
HLSL:
Returns a smooth Hermite interpolation between 0 and 1, if x is in the range [min, max].
Parameters
Return Value
Returns 0 if x is less than min; 1 if x is greater than max; otherwise, a value between 0 and 1 if x is in the range [min, max].
Remarks
Use the smoothstep HLSL intrinsic function to create a smooth transition between two values. For example, you can use this function to blend two colors smoothly.
Type Description
Minimum Shader Model
This function is supported in the following shader models.
See also
Intrinsic Functions (DirectX HLSL)
The text was updated successfully, but these errors were encountered: