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 RayTMin HLSL Function #99191

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

Implement the RayTMin HLSL Function #99191

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 RayTMin clang builtin,
  • Link RayTMin clang builtin with hlsl_intrinsics.h
  • Add sema checks for RayTMin to CheckHLSLBuiltinFunctionCall in SemaChecking.cpp
  • Add codegen for RayTMin to EmitHLSLBuiltinExpr in CGBuiltin.cpp
  • Add codegen tests to clang/test/CodeGenHLSL/builtins/RayTMin.hlsl
  • Add sema tests to clang/test/SemaHLSL/BuiltIns/RayTMin-errors.hlsl
  • Create the int_dx_RayTMin intrinsic in IntrinsicsDirectX.td
  • Create the DXILOpMapping of int_dx_RayTMin to 153 in DXIL.td
  • Create the RayTMin.ll and RayTMin_errors.ll tests in llvm/test/CodeGen/DirectX/
  • Create the int_spv_RayTMin intrinsic in IntrinsicsSPIRV.td
  • In SPIRVInstructionSelector.cpp create the RayTMin lowering and map it to int_spv_RayTMin in SPIRVInstructionSelector::selectIntrinsic.
  • Create SPIR-V backend test case in llvm/test/CodeGen/SPIRV/hlsl-intrinsics/RayTMin.ll

DirectX

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

SPIR-V

RayTminKHR

Short Description

RayTminKHR - Minimum T value of a ray

Description

RayTminKHR
A variable decorated with the RayTminKHR decoration will contain the
parametric t min value of the ray
being processed. The value is independent of the space in which the ray
origin and direction exist. The value is the parameter passed into the
pipeline trace ray instruction.

The t min value remains constant
for the duration of the ray query.

Valid Usage


  • VUID-RayTminKHR-RayTminKHR-04351

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


  • VUID-RayTminKHR-RayTminKHR-04352

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


  • VUID-RayTminKHR-RayTminKHR-04353

    The variable decorated with RayTminKHR must be declared as a
    scalar 32-bit floating-point value

Test Case(s)

Example 1

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

export float fn() {
    return RayTMin();
}

SPIRV Example(s):

Example 2

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

[shader("intersection")]
void fn() {
float 	ret = RayTMin();
}

HLSL:

A float representing the current parametric starting point for the ray.

Syntax

float RayTMin();

Remarks

RayTMin defines the starting point of the ray according to the following formula: Origin + (Direction * RayTMin). Origin and Direction may be in either world or object space, which results in either a world or an object space starting point.

RayTMin is specified in the call to TraceRay, and is constant for the duration of that call.

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
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: No status
Development

No branches or pull requests

1 participant