Skip to content

Implement the asint HLSL Function #99091

Closed
@farzonl

Description

@farzonl

Note: see how we did asfloat and asuint.

  • Link bitcast clang builtin for int with asint hlsl_intrinsics.h
  • Add checks for asint
  • Add codegen tests to clang/test/CodeGenHLSL/builtins/asint.hlsl
  • Add sema tests to clang/test/SemaHLSL/BuiltIns/asint-errors.hlsl

DirectX

There were no DXIL opcodes found for asint.

SPIR-V

There were no SPIRV opcodes found for asint.

Test Case(s)

Example 1

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

export int4 fn(float p1) {
    return asint(p1);
}

Example 2

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

export int4 fn(uint p1) {
    return asint(p1);
}

Example 3

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

export int4 fn(int p1) {
    return asint(p1);
}

HLSL:

Interprets the bit pattern of x as an integer.

ret asint(x)

Parameters

Item Description
x
[in] The input value.

Return Value

The input interpreted as an integer.

Type Description

Name Template Type Component Type Size
x scalar, vector, or matrix float, uint 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 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)

Metadata

Metadata

Assignees

Labels

HLSLHLSL Language Supportbot:HLSLclang:headersHeaders provided by Clang, e.g. for intrinsicsmetabugIssue to collect references to a group of similar or related issues.

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions