Skip to content

Implement the DispatchRaysDimensions HLSL Function #99186

@farzonl

Description

@farzonl
  • Implement DispatchRaysDimensions clang builtin,
    Link DispatchRaysDimensions clang builtin with hlsl_intrinsics.h
    Add sema checks for DispatchRaysDimensions to CheckHLSLBuiltinFunctionCall in SemaChecking.cpp
    Add codegen for DispatchRaysDimensions to EmitHLSLBuiltinExpr in CGBuiltin.cpp
    Add codegen tests to clang/test/CodeGenHLSL/builtins/DispatchRaysDimensions.hlsl
    Add sema tests to clang/test/SemaHLSL/BuiltIns/DispatchRaysDimensions-errors.hlsl
    Create the int_dx_DispatchRaysDimensions intrinsic in IntrinsicsDirectX.td
    Create the DXILOpMapping of int_dx_DispatchRaysDimensions to 146 in DXIL.td
    Create the DispatchRaysDimensions.ll and DispatchRaysDimensions_errors.ll tests in llvm/test/CodeGen/DirectX/
    Create the int_spv_DispatchRaysDimensions intrinsic in IntrinsicsSPIRV.td
    In SPIRVInstructionSelector.cpp create the DispatchRaysDimensions lowering and map it to int_spv_DispatchRaysDimensions in SPIRVInstructionSelector::selectIntrinsic.
    Create SPIR-V backend test case in llvm/test/CodeGen/SPIRV/hlsl-intrinsics/DispatchRaysDimensions.ll

DirectX

DXIL Opcode DXIL OpName Shader Model Shader Stages
146 DispatchRaysDimensions 6.3 ('library', 'raygeneration', 'intersection', 'anyhit', 'closesthit', 'miss', 'callable')

SPIR-V

LaunchSizeKHR

Short Description

LaunchSizeKHR - Launch dimensions for ray shaders

Description

LaunchSizeKHR
A variable decorated with the LaunchSizeKHR decoration will contain
the width , height , and depth dimensions passed to the
vkCmdTraceRaysKHR command that initiated this
shader execution. The width is in the first component, the
height is in the second component, and the depth is in the third
component.

Valid Usage


  • VUID-LaunchSizeKHR-LaunchSizeKHR-04269

    The LaunchSizeKHR decoration must be used only within the
    RayGenerationKHR , IntersectionKHR , AnyHitKHR ,
    ClosestHitKHR , MissKHR , or CallableKHR Execution
    Model


  • VUID-LaunchSizeKHR-LaunchSizeKHR-04270

    The variable decorated with LaunchSizeKHR must be declared
    using the Input Storage Class


  • VUID-LaunchSizeKHR-LaunchSizeKHR-04271

    The variable decorated with LaunchSizeKHR must be declared as
    a three-component vector of 32-bit integer values

Test Case(s)

Example 1

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

export uint3 fn() {
    return DispatchRaysDimensions();
}

SPIRV Example(s):

Example 2

//dxc DispatchRaysDimensions_spirv_test.hlsl -T lib_6_8 -E fn -enable-16bit-types -spirv -fspv-target-env=universal1.5 -fcgl -O0

[shader("intersection")]
void fn() {
uint3 	ret = DispatchRaysDimensions();
}

HLSL:

The width, height and depth values from the D3D12_DISPATCH_RAYS_DESC structure specified in the originating DispatchRays call.

Syntax

uint3 DispatchRaysDimensions();

Remarks

This function can be called from the following raytracing shader types:

See also

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Development

    No branches or pull requests

      Participants

      @farzonl

      Issue actions

        Implement the `DispatchRaysDimensions` HLSL Function · Issue #99186 · llvm/llvm-project