-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Open
Labels
HLSLHLSL Language SupportHLSL Language Supportbackend:DirectXbackend:SPIR-Vbot:HLSLmetaissueIssue 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
modfclang builtin, - Link
modfclang builtin withhlsl_intrinsics.h - Add sema checks for
modftoCheckHLSLBuiltinFunctionCallinSemaChecking.cpp - Add codegen for
modftoEmitHLSLBuiltinExprinCGBuiltin.cpp - Add codegen tests to
clang/test/CodeGenHLSL/builtins/modf.hlsl - Add sema tests to
clang/test/SemaHLSL/BuiltIns/modf-errors.hlsl - Create the
int_dx_modfintrinsic inIntrinsicsDirectX.td - Create the
DXILOpMappingofint_dx_modfto29inDXIL.td - Create the
modf.llandmodf_errors.lltests inllvm/test/CodeGen/DirectX/ - Create the
int_spv_modfintrinsic inIntrinsicsSPIRV.td - In SPIRVInstructionSelector.cpp create the
modflowering and map it toint_spv_modfinSPIRVInstructionSelector::selectIntrinsic. - Create SPIR-V backend test case in
llvm/test/CodeGen/SPIRV/hlsl-intrinsics/modf.ll
DirectX
| DXIL Opcode | DXIL OpName | Shader Model | Shader Stages |
|---|---|---|---|
| 29 | Round_z | 6.0 | () |
SPIR-V
ModfStruct:
Description:
ModfStruct
Same semantics as in Modf, except that the entire result is in the
instruction’s result; there is not a pointer operand to write through.
Result Type must be an OpTypeStruct with two members. Member 0
holds the fractional part. Member 1 holds the whole number part. These
two members, and the Result Type must all have the same type. This
structure type must be explicitly declared by the module.
| Number | Operand 1 | Operand 2 | Operand 3 | Operand 4 |
|---|---|---|---|---|
36 |
<id> |
Test Case(s)
Example 1
//dxc modf_test.hlsl -T lib_6_8 -enable-16bit-types -O0
export float4 fn(float4 p1, float4 p2) {
return modf(p1, p2);
}HLSL:
Splits the value x into fractional and integer parts, each of which has the same sign as x.
| ret modf(x, out ip) |
|---|
Parameters
| Item | Description |
|---|---|
| x |
[in] The x input value. |
| ip |
[out] The integer portion of x. |
Return Value
The signed-fractional portion of x.
Type Description
| Name | In/Out | Template Type | Component Type | Size |
|---|---|---|---|---|
| x | in | scalar, vector, or matrix | float, int | any |
| ip | out | same as input x | float, int | same dimension(s) as input x |
| ret | out | same as input x | float, 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 only) |
Requirements
| Requirement | Value |
|---|---|
| Header |
|
See also
Metadata
Metadata
Assignees
Labels
HLSLHLSL Language SupportHLSL Language Supportbackend:DirectXbackend:SPIR-Vbot:HLSLmetaissueIssue 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