Skip to content

Implement the asuint HLSL Function #70097

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
6 tasks
Tracked by #99235 ...
llvm-beanz opened this issue Oct 24, 2023 · 1 comment · Fixed by #107292
Closed
6 tasks
Tracked by #99235 ...

Implement the asuint HLSL Function #70097

llvm-beanz opened this issue Oct 24, 2023 · 1 comment · Fixed by #107292
Assignees
Labels
HLSL HLSL Language Support

Comments

@llvm-beanz
Copy link
Collaborator

llvm-beanz commented Oct 24, 2023

  • Implement asuint clang builtin,
  • Link asuint clang builtin with hlsl_intrinsics.h
  • Add sema checks for asuint to CheckHLSLBuiltinFunctionCall in SemaChecking.cpp
  • Add codegen for asuint to EmitHLSLBuiltinExpr in CGBuiltin.cpp
  • Add codegen tests to clang/test/CodeGenHLSL/builtins/asuint.hlsl
  • Add sema tests to clang/test/SemaHLSL/BuiltIns/asuint-errors.hlsl

DirectX

There were no DXIL opcodes found for most asuint cases. There is an opcode for the three arg case:

DXIL Opcode DXIL OpName Shader Model Shader Stages Description
102 SplitDouble 6.0 () splits a double into low and high parts

SPIR-V

There is no support for asuint when targeting SPIR-V.

Test Case(s)

Example 1

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

export uint4 fn(double4 p1, uint4 p2, uint4 p3) {
    asuint(p1, p2, p3);
    return p3;
}

Example 2

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

export uint4 fn(float p1) {
    return asuint(p1);
}

Example 3

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

export uint4 fn(uint p1) {
    return asuint(p1);
}

Example 4

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

export uint4 fn(int p1) {
    return asuint(p1);
}

HLSL:

Interprets the bit pattern of x as an unsigned integer.

ret asuint(x)

Parameters

Item Description
x
[in] The input value.

Return Value

The input interpreted as an unsigned integer.

Type Description

Name Template Type Component Type Size
x scalar, vector, or matrix float, int any
ret same as input x uint same dimension(s) as input x

Minimum Shader Model

This function is supported in the following shader models.

Shader Model Supported
Shader Model 4 and higher shader models yes
Shader Model 3 (DirectX HLSL) no
Shader Model 2 (DirectX HLSL) no
Shader Model 1 (DirectX HLSL) no

See also

Intrinsic Functions (DirectX HLSL)

@llvm-beanz llvm-beanz converted this from a draft issue Oct 24, 2023
@llvm-beanz llvm-beanz added the HLSL HLSL Language Support label Oct 24, 2023
@farzonl farzonl changed the title [HLSL] implement asuint intrinsic Implement the asuint HLSL Function Jul 16, 2024
@joaosaffran
Copy link
Contributor

I can work on it

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
HLSL HLSL Language Support
Projects
Status: Closed
Development

Successfully merging a pull request may close this issue.

2 participants