Skip to content

Implement the ReportHit HLSL Function #99179

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 ReportHit HLSL Function #99179

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

DirectX

DXIL Opcode DXIL OpName Shader Model Shader Stages
158 ReportHit 6.3 ('library', 'intersection')

SPIR-V

OpReportIntersectionKHR:

Description:

(OpReportIntersectionNV)**

Reserved.

Capability:
RayTracingNV, RayTracingKHR

Reserved.

Word Count Opcode Results Operands

5

5334

<id>
Result Type

Result <id>

<id>
Hit

<id>
HitKind

Test Case(s)

Example 1

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

struct RayPayload
{
	float4 color;
	float distance;
};
export bool fn(float p1, uint p2, RayPayload p3) {
    return ReportHit(p1, p2, p3);
}

HLSL:

Called by an intersection shader to report a ray intersection.

Syntax

This intrinsic function definition is equivalent to the following function template:

template<attr_t>
bool ReportHit(float THit, uint HitKind, attr_t Attributes);

Parameters

THit

A float value specifying the parametric distance of the intersection..

HitKind

An unsigned integer that identifies the type of hit that occurred. This is a user-specified value in the range of 0-127. The value can be read by any hit or closest hit shaders with the HitKind intrinsic.

Attributes

The user-defined Intersection Attribute Structure structure specifying the intersection attributes.

Return Value

bool True if the hit was accepted. A hit is rejected if THit is outside the current ray interval, or the any hit shader calls IgnoreHit. The current ray interval is defined by RayTMin and RayTCurrent.

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