Skip to content

Implement the IgnoreHit HLSL Function #99181

Open
Listed in
@farzonl

Description

@farzonl
  • Implement IgnoreHit clang builtin,
    Link IgnoreHit clang builtin with hlsl_intrinsics.h
    Add sema checks for IgnoreHit to CheckHLSLBuiltinFunctionCall in SemaChecking.cpp
    Add codegen for IgnoreHit to EmitHLSLBuiltinExpr in CGBuiltin.cpp
    Add codegen tests to clang/test/CodeGenHLSL/builtins/IgnoreHit.hlsl
    Add sema tests to clang/test/SemaHLSL/BuiltIns/IgnoreHit-errors.hlsl
    Create the int_dx_IgnoreHit intrinsic in IntrinsicsDirectX.td
    Create the DXILOpMapping of int_dx_IgnoreHit to 155 in DXIL.td
    Create the IgnoreHit.ll and IgnoreHit_errors.ll tests in llvm/test/CodeGen/DirectX/
    Create the int_spv_IgnoreHit intrinsic in IntrinsicsSPIRV.td
    In SPIRVInstructionSelector.cpp create the IgnoreHit lowering and map it to int_spv_IgnoreHit in SPIRVInstructionSelector::selectIntrinsic.
    Create SPIR-V backend test case in llvm/test/CodeGen/SPIRV/hlsl-intrinsics/IgnoreHit.ll

DirectX

DXIL Opcode DXIL OpName Shader Model Shader Stages
155 IgnoreHit 6.3 ('anyhit',)

SPIR-V

OpIgnoreIntersectionKHR:

Description:

Reserved.

Capability:
RayTracingKHR

Reserved.

Word Count Opcode Results Operands
1 4448

Test Case(s)

Example 1

//dxc IgnoreHit_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 IgnoreHit();
}

SPIRV Example(s):

Example 2

//dxc IgnoreHit_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 IgnoreHit();
}

HLSL:

Called from an any hit shader to reject the hit and end the shader. The hit search continues on without committing the distance and attributes for the current hit. The ReportHit call in the intersection shader, if there is one, will return false. Any modifications made to the ray payload up to this point in the any hit shader are preserved.

Syntax

void IgnoreHit();

Return Value

void

Remarks

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

See also

Direct3D 12 Raytracing HLSL Reference

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @farzonl

        Issue actions

          Implement the `IgnoreHit` HLSL Function · Issue #99181 · llvm/llvm-project