-
Notifications
You must be signed in to change notification settings - Fork 15.1k
Closed
Labels
Description
- Implement
signclang builtin, - Link
signclang builtin withhlsl_intrinsics.h - Add sema checks for
signtoCheckHLSLBuiltinFunctionCallinSemaChecking.cpp - Add codegen for
signtoEmitHLSLBuiltinExprinCGBuiltin.cpp - Add codegen tests to
clang/test/CodeGenHLSL/builtins/sign.hlsl - Add sema tests to
clang/test/SemaHLSL/BuiltIns/sign-errors.hlsl - Create the
int_spv_signintrinsic inIntrinsicsSPIRV.td - In SPIRVInstructionSelector.cpp create the
signlowering and map it toint_spv_signinSPIRVInstructionSelector::selectIntrinsic. - Create SPIR-V backend test case in
llvm/test/CodeGen/SPIRV/hlsl-intrinsics/sign.ll
DirectX
There were no DXIL opcodes found for sign.
SPIR-V
FSign:
Description:
FSign
Result is 1.0 if x > 0, 0.0 if x = 0, or -1.0 if x < 0.
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. Results are
computed per component.
| Number | Operand 1 | Operand 2 | Operand 3 | Operand 4 |
|---|---|---|---|---|
6 |
<id> |
Test Case(s)
Example 1
//dxc sign_test.hlsl -T lib_6_8 -enable-16bit-types -spirv -fspv-target-env=universal1.5 -fcgl -O0
export int4 fn(float4 p1) {
return sign(p1);
}Example 2
//dxc sign_1_test.hlsl -T lib_6_8 -enable-16bit-types -O0
export int4 fn(uint4 p1) {
return sign(p1);
}Example 3
//dxc sign_2_test.hlsl -T lib_6_8 -enable-16bit-types -O0
export int4 fn(int4 p1) {
return sign(p1);
}HLSL:
Returns the sign of x.
| ret sign(x) |
|---|
Parameters
| Item | Description |
|---|---|
| x |
[in] The input value. |
Return Value
Returns -1 if x is less than zero; 0 if x equals zero; and 1 if x is greater than zero.
Type Description
| Name | Template Type | Component Type | Size |
|---|---|---|---|
| x | scalar, vector, or matrix | float, int | any |
| ret | same as input x | int | 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 and ps_1_4) |
See also
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Closed