-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Closed
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
ldexpentirely inhlsl_intrinsics.hand other hlsl headers. - Implement
ldexpcodgen tests in clang/test/CodeGenHLSL/builtins/ldexp.hlsl - Implement
ldexpsema tests in clang/test/SemaHLSL/BuiltIns/ldexp-errors.hlsl
https://hlsl.godbolt.org/z/97c4GxGrP
Implementation should look something like this:
template <typename T, int N>
constexpr T ldexp(T p0, T p1) {
return exp2(p1) * p0;
}DirectX
| DXIL Opcode | DXIL OpName | Shader Model | Shader Stages |
|---|---|---|---|
| 21 | Exp2 | 6.0 | () |
SPIR-V
Exp2:
Description:
Exp2
Result is 2 raised to the x power; 2x.
The operand x must be a scalar or vector whose component type is
16-bit or 32-bit 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 |
|---|---|---|---|---|
29 |
<id> |
Test Case(s)
Example 1
//dxc ldexp_test.hlsl -T lib_6_8 -enable-16bit-types -O0
export float4 fn(float4 p1, float4 p2) {
return ldexp(p1, p2);
}HLSL:
Returns the result of multiplying the specified value by two, raised to the power of the specified exponent.
| ret ldexp(x, exp) |
|---|
This function uses the following formula: x * 2exp
Parameters
| Item | Description |
|---|---|
| x |
[in] The specified value. |
| exp |
[in] The specified exponent. |
Return Value
The result of multiplying the x parameter by two, raised to the power of the exp parameter.
Type Description
| Name | Template Type | Component Type | Size |
|---|---|---|---|
| x | scalar, vector, or matrix | float | any |
| exp | same as input x | float | same dimension(s) as input x |
| 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) |
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
Closed