Skip to content

Implement the asdouble HLSL Function #99081

Closed
@farzonl

Description

@farzonl

NOTE: asdouble is special: there are questions around what the right design is for this. If 64-bit integers are supported then we don't need a specific DXIL operation to do this. We also need to consider what the right thing is for the SPIR-V backend.

  • Implement asdouble clang builtin,
  • Link asdouble clang builtin with hlsl_intrinsics.h
  • Add sema checks for asdouble to CheckHLSLBuiltinFunctionCall in SemaChecking.cpp
  • Add codegen for asdouble to EmitHLSLBuiltinExpr in CGBuiltin.cpp
  • Add codegen tests to clang/test/CodeGenHLSL/builtins/asdouble.hlsl
  • Add sema tests to clang/test/SemaHLSL/BuiltIns/asdouble-errors.hlsl
  • Create the int_dx_asdouble intrinsic in IntrinsicsDirectX.td
  • Create the DXILOpMapping of int_dx_asdouble to 101 in DXIL.td
  • Create the asdouble.ll and asdouble_errors.ll tests in llvm/test/CodeGen/DirectX/

DirectX

DXIL Opcode DXIL OpName Shader Model Shader Stages
101 MakeDouble 6.0 ()

SPIR-V

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

Test Case(s)

Example 1

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

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

HLSL:

Reinterprets a cast value (two 32-bit values) into a double.

Syntax

double asdouble(
  in uint lowbits,
  in uint highbits
);

Parameters

lowbits [in]

Type: uint

The low 32-bit pattern of the input value.

highbits [in]

Type: uint

The high 32-bit pattern of the input value.

Return value

Type: double

The input (two 32-bit values) recast as a double.

Remarks

The following overloaded version is also available:

double2 asdouble(uint2 lowbits, uint2 highbits);

If the input value is two 32-bit components, the return type will contain one double. If the input value is four 32-bit components, the return type will contain two doubles. If the input value is a 64-bit type, the returned value will have the same number of components as the input value.

Minimum Shader Model

This function is supported in the following shader models.

Shader Model Supported
Shader Model 5 and higher shader models yes

 

This function is supported in the following types of shaders:

Vertex Hull Domain Geometry Pixel Compute
x x x x x x

 

See also

Intrinsic Functions

Shader Model 5

Metadata

Metadata

Assignees

Labels

HLSLHLSL Language Supportbackend:DirectXbot:HLSLclang:codegenIR generation bugs: mangling, exceptions, etc.clang:frontendLanguage frontend issues, e.g. anything involving "Sema"metaissueIssue to collect references to a group of similar or related issues.

Type

No type

Projects

Status

Closed

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions