Description
- Implement
InstanceIndex
clang builtin,LinkInstanceIndex
clang builtin withhlsl_intrinsics.h
Add sema checks forInstanceIndex
toCheckHLSLBuiltinFunctionCall
inSemaChecking.cpp
Add codegen forInstanceIndex
toEmitHLSLBuiltinExpr
inCGBuiltin.cpp
Add codegen tests toclang/test/CodeGenHLSL/builtins/InstanceIndex.hlsl
Add sema tests toclang/test/SemaHLSL/BuiltIns/InstanceIndex-errors.hlsl
Create theint_dx_InstanceIndex
intrinsic inIntrinsicsDirectX.td
Create theDXILOpMapping
ofint_dx_InstanceIndex
to142
inDXIL.td
Create theInstanceIndex.ll
andInstanceIndex_errors.ll
tests inllvm/test/CodeGen/DirectX/
Create theint_spv_InstanceIndex
intrinsic inIntrinsicsSPIRV.td
In SPIRVInstructionSelector.cpp create theInstanceIndex
lowering and map it toint_spv_InstanceIndex
inSPIRVInstructionSelector::selectIntrinsic
.Create SPIR-V backend test case inllvm/test/CodeGen/SPIRV/hlsl-intrinsics/InstanceIndex.ll
DirectX
DXIL Opcode | DXIL OpName | Shader Model | Shader Stages |
---|---|---|---|
142 | InstanceIndex | 6.3 | ('library', 'intersection', 'anyhit', 'closesthit') |
SPIR-V
Description
InstanceId
Decorating a variable in an intersection, any-hit, or closest hit shader
with the InstanceId
decoration will make that variable contain the
index of the instance that intersects the current ray.
Valid Usage
-
VUID-InstanceId-InstanceId-04254
TheInstanceId
decoration must be used only within the
IntersectionKHR
,AnyHitKHR
, orClosestHitKHR
Execution
Model
-
VUID-InstanceId-InstanceId-04255
The variable decorated withInstanceId
must be declared using
theInput
Storage
Class
-
VUID-InstanceId-InstanceId-04256
The variable decorated withInstanceId
must be declared as a
scalar 32-bit integer value
Test Case(s)
Example 1
//dxc InstanceIndex_test.hlsl -T lib_6_8 -enable-16bit-types -O0
export uint fn() {
return InstanceIndex();
}
SPIRV Example(s):
Example 2
//dxc InstanceIndex_spirv_test.hlsl -T ps_6_8 -E fn -enable-16bit-types -spirv -fspv-target-env=universal1.5 -fcgl -O0
uint fn( ) : SV_Target {
return InstanceIndex();
}
HLSL:
The autogenerated index of the current instance in the top-level raytracing acceleration structure.
Syntax
uint InstanceIndex();
Remarks
This function can be called from the following raytracing shader types:
See also
Metadata
Metadata
Assignees
Type
Projects
Status
Activity