Skip to content
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

Implement the radians HLSL Function #99151

Closed
9 tasks
Tracked by #99235
farzonl opened this issue Jul 16, 2024 · 1 comment · Fixed by #110800 or #110802
Closed
9 tasks
Tracked by #99235

Implement the radians HLSL Function #99151

farzonl opened this issue Jul 16, 2024 · 1 comment · Fixed by #110800 or #110802
Assignees
Labels
backend:SPIR-V bot:HLSL HLSL HLSL Language Support metabug Issue to collect references to a group of similar or related issues.

Comments

@farzonl
Copy link
Member

farzonl commented Jul 16, 2024

  • Implement radians clang builtin,
  • Link radians clang builtin with hlsl_intrinsics.h
  • Add sema checks for radians to CheckHLSLBuiltinFunctionCall in SemaChecking.cpp
  • Add codegen for radians to EmitHLSLBuiltinExpr in CGBuiltin.cpp
  • Add codegen tests to clang/test/CodeGenHLSL/builtins/radians.hlsl
  • Add sema tests to clang/test/SemaHLSL/BuiltIns/radians-errors.hlsl
  • Create the int_spv_radians intrinsic in IntrinsicsSPIRV.td
  • In SPIRVInstructionSelector.cpp create the radians lowering and map it to int_spv_radians in SPIRVInstructionSelector::selectIntrinsic.
  • Create SPIR-V backend test case in llvm/test/CodeGen/SPIRV/hlsl-intrinsics/radians.ll

DirectX

There were no DXIL opcodes found for radians.

SPIR-V

Radians:

Description:

Radians

Converts degrees to radians, i.e., degrees * π / 180.

The operand degrees must be a scalar or vector whose component type is
16-bit or 32-bit floating-point.

Result Type and the type of degrees must be the same type. Results
are computed per component.

Number Operand 1 Operand 2 Operand 3 Operand 4

11

<id>
degrees

Test Case(s)

Example 1

//dxc radians_test.hlsl -T lib_6_8 -enable-16bit-types -O0

export float4 fn(float4 p1) {
    return radians(p1);
}

HLSL:

Converts the specified value from degrees to radians.

ret radians(x)

Parameters

Item Description
x
[in] The specified value.

Return Value

The x parameter converted from degrees to radians.

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

Intrinsic Functions (DirectX HLSL)

@farzonl farzonl added backend:SPIR-V bot:HLSL HLSL HLSL Language Support metabug Issue to collect references to a group of similar or related issues. labels Jul 16, 2024
@adam-yang
Copy link
Contributor

I'll be working on this task.

@farzonl farzonl closed this as completed in c0f8889 Oct 4, 2024
farzonl pushed a commit that referenced this issue Oct 4, 2024
makes progress on #99151

### Changes
- Added int_dx_radians intrinsic in IntrinsicsDirectX.td
- Added expansion for int_dx_radians in DXILIntrinsicExpansion.cpp`
- Added DXIL backend test case

### Related PRs
* [[clang][HLSL] Add radians intrinsic
#110802](#110802)
* [[SPIRV] Add radians intrinsic
#110800](#110800)
farzonl pushed a commit that referenced this issue Oct 4, 2024
partially fixes #99151

### Changes
* Implemented `radians` clang builtin
* Linked `radians` clang builtin with `hlsl_intrinsics.h`
* Added sema checks for `radians` to `CheckHLSLBuiltinFunctionCall` in
`SemaChecking.cpp`
* Add codegen for `radians` to `EmitHLSLBuiltinExpr` in `CGBuiltin.cpp`
* Add codegen tests to `clang/test/CodeGenHLSL/builtins/radians.hlsl`
* Add sema tests to `clang/test/SemaHLSL/BuiltIns/radians-errors.hlsl`

### Related PRs
* [[DXIL] Add radians intrinsic
#110616](#110616)
* [[SPIRV] Add radians intrinsic
#110800](#110800)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:SPIR-V bot:HLSL HLSL HLSL Language Support metabug Issue to collect references to a group of similar or related issues.
Projects
Archived in project
2 participants