Skip to content

Implement the RayFlags HLSL Function #99196

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

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

Implement the RayFlags HLSL Function #99196

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

DirectX

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

SPIR-V

IncomingRayFlagsKHR

Short Description

IncomingRayFlagsKHR - Flags used to trace a ray

Description

IncomingRayFlagsKHR
A variable with the IncomingRayFlagsKHR decoration will contain the
ray flags passed in to the trace call that invoked this particular
shader. Setting pipeline flags on the ray tracing pipeline must not
cause any corresponding flags to be set in variables with this
decoration.

Valid Usage


  • VUID-IncomingRayFlagsKHR-IncomingRayFlagsKHR-04248

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


  • VUID-IncomingRayFlagsKHR-IncomingRayFlagsKHR-04249

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


  • VUID-IncomingRayFlagsKHR-IncomingRayFlagsKHR-04250

    The variable decorated with IncomingRayFlagsKHR must be
    declared as a scalar 32-bit integer value

Test Case(s)

Example 1

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

export uint fn() {
    return RayFlags();
}

SPIRV Example(s):

Example 2

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

[shader("intersection")]
void fn() {
uint 	ret = RayFlags();
}

HLSL:

An unsigned integer containing the current ray_flag flags.

Syntax

uint RayFlags();

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
@damyanp damyanp removed the status in HLSL Support Apr 25, 2025
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