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 WorldRayDirection HLSL Function #99188

Open
12 tasks
Tracked by #99235
farzonl opened this issue Jul 16, 2024 · 0 comments
Open
12 tasks
Tracked by #99235

Implement the WorldRayDirection HLSL Function #99188

farzonl opened this issue Jul 16, 2024 · 0 comments
Labels
backend:DirectX 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 WorldRayDirection clang builtin,
  • Link WorldRayDirection clang builtin with hlsl_intrinsics.h
  • Add sema checks for WorldRayDirection to CheckHLSLBuiltinFunctionCall in SemaChecking.cpp
  • Add codegen for WorldRayDirection to EmitHLSLBuiltinExpr in CGBuiltin.cpp
  • Add codegen tests to clang/test/CodeGenHLSL/builtins/WorldRayDirection.hlsl
  • Add sema tests to clang/test/SemaHLSL/BuiltIns/WorldRayDirection-errors.hlsl
  • Create the int_dx_WorldRayDirection intrinsic in IntrinsicsDirectX.td
  • Create the DXILOpMapping of int_dx_WorldRayDirection to 148 in DXIL.td
  • Create the WorldRayDirection.ll and WorldRayDirection_errors.ll tests in llvm/test/CodeGen/DirectX/
  • Create the int_spv_WorldRayDirection intrinsic in IntrinsicsSPIRV.td
  • In SPIRVInstructionSelector.cpp create the WorldRayDirection lowering and map it to int_spv_WorldRayDirection in SPIRVInstructionSelector::selectIntrinsic.
  • Create SPIR-V backend test case in llvm/test/CodeGen/SPIRV/hlsl-intrinsics/WorldRayDirection.ll

DirectX

DXIL Opcode DXIL OpName Shader Model Shader Stages
148 WorldRayDirection 6.3 ('library', 'intersection', 'anyhit', 'closesthit', 'miss')

SPIR-V

WorldRayDirectionKHR

Short Description

WorldRayDirectionKHR - Ray direction in world space

Description

WorldRayDirectionKHR
A variable decorated with the WorldRayDirectionKHR decoration will
specify the direction of the ray being processed, in world space. The
value is the parameter passed into the pipeline trace ray instruction.

Valid Usage



  • VUID-WorldRayDirectionKHR-WorldRayDirectionKHR-04428

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



  • VUID-WorldRayDirectionKHR-WorldRayDirectionKHR-04429

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



  • VUID-WorldRayDirectionKHR-WorldRayDirectionKHR-04430

    The variable decorated with WorldRayDirectionKHR must be
    declared as a three-component vector of 32-bit floating-point values

Test Case(s)

Example 1

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

export float3 fn() {
    return WorldRayDirection();
}

SPIRV Example(s):

Example 2

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

[shader("intersection")]
void fn() {
float3 	ret = WorldRayDirection();
}

HLSL:

The world-space direction for the current ray.

Syntax

float3 WorldRayDirection();

Remarks

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

See also

Direct3D 12 Raytracing HLSL Reference

@farzonl farzonl added backend:DirectX 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
@damyanp damyanp moved this to Ready in HLSL Support Oct 30, 2024
@damyanp damyanp moved this from Ready to Planning in HLSL Support Oct 30, 2024
@damyanp damyanp moved this from Planning to Designing in HLSL Support Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:DirectX backend:SPIR-V bot:HLSL HLSL HLSL Language Support metabug Issue to collect references to a group of similar or related issues.
Projects
Status: Designing
Development

No branches or pull requests

1 participant