Skip to content

Implement the AcceptHitAndEndSearch HLSL Function #99182

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 AcceptHitAndEndSearch HLSL Function #99182

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

DirectX

DXIL Opcode DXIL OpName Shader Model Shader Stages
156 AcceptHitAndEndSearch 6.3 ('anyhit',)

SPIR-V

OpTerminateRayKHR:

Description:

Reserved.

Capability:
RayTracingKHR

Reserved.

Word Count Opcode Results Operands
1 4449

Test Case(s)

Example 1

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

struct [raypayload] RayPayload
{
	float4 color : write(caller) : read(anyhit);
	float distance : write(caller) : read(anyhit);
};

struct Attributes {
	float3 barycentrics;
	uint primitiveIndex;
};

[shader("anyhit")]
export void fn(inout RayPayload payload, in Attributes attributes) {
	return AcceptHitAndEndSearch();
}

SPIRV Example(s):

Example 2

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

struct [raypayload] RayPayload
{
	float4 color : write(caller) : read(anyhit);
	float distance : write(caller) : read(anyhit);
};

struct Attributes {
	float3 barycentrics;
	uint primitiveIndex;
};

[shader("anyhit")]
void fn(inout RayPayload payload, in Attributes attributes) {
	return AcceptHitAndEndSearch();
}

HLSL:

Used in an any hit shader to commit the current hit and then stop searching for more hits for the ray. If there is an intersection shader running, it's execution stops. Execution passes to the closest hit shader, if enabled, with the closest hit recorded so far.

Syntax

void AcceptHitAndEndSearch();

Return Value

void

Remarks

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

See also

@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