llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
26.8k stars 10.98k forks source link

Implement the `InstanceID` HLSL Function #97624

Open farzonl opened 4 days ago

farzonl commented 4 days ago

DirectX

DXIL Opcode DXIL OpName Shader Model Shader Stages
141 InstanceID 6.3 ('library', 'intersection', 'anyhit', 'closesthit')

SPIR-V

See https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/InstanceCustomIndexKHR.html

Test Case(s)

Example 1

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

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

SPIRV Example(s):

Example 2

//dxc InstanceID_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 = InstanceID();
}

HLSL:

The user-provided identifier for the instance on the bottom-level acceleration structure instance within the top-level structure.

Syntax

uint InstanceID();

Remarks

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

See also

[Direct3D 12 Raytracing HLSL Reference](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3d12/direct3d-12-raytracing-hlsl-reference.md)
farzonl commented 4 days ago

@EugeneZelenko These bugs were created via automation. There are going to be about 160+ of these coming in. This first run was just a test. Would you like me to add the metabug label to all the issues created by the bot?

EugeneZelenko commented 4 days ago

@farzonl: metabug label should be used for issues that are used for tracking multiple issues, so bot could apply the label to such issues.