Skip to content

Commit eaf5b31

Browse files
MarijnS95claude
andcommitted
Add InstanceInclusionMask filtering test
Three TLAS instances at x = -5, 0, +5 with InstanceMasks 0x01 / 0x02 / 0x04 and InstanceIDs 0 / 1 / 2. A 3-lane dispatch fires one ray per lane straight down at its own instance column, but every ray uses InstanceInclusionMask = 0x02 — so only the middle instance survives the mask test. Lane 1 must report InstanceID 1; lanes 0 and 2 must miss. Part of the inline-RT test coverage epic (#1258). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent c8cbb51 commit eaf5b31

1 file changed

Lines changed: 95 additions & 0 deletions

File tree

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
#--- source.hlsl
2+
3+
[[vk::binding(0, 0)]] RaytracingAccelerationStructure Scene : register(t0);
4+
[[vk::binding(1, 0)]] RWStructuredBuffer<uint> Output : register(u0);
5+
6+
[numthreads(3,1,1)]
7+
void main(uint3 tid : SV_DispatchThreadID) {
8+
// Three instances live at x = -5, 0, +5 with InstanceMasks
9+
// 0x01 / 0x02 / 0x04 and InstanceIDs 0 / 1 / 2 respectively. Each lane
10+
// fires a ray at its own instance's column but with
11+
// InstanceInclusionMask = 0x02, so only the middle instance survives
12+
// the mask test: lane 1 must hit InstanceID 1, lanes 0 and 2 must miss.
13+
RayDesc Ray;
14+
Ray.Origin = float3((float(tid.x) - 1.0) * 5.0, 0, 1);
15+
Ray.Direction = float3(0, 0, -1);
16+
Ray.TMin = 0.0;
17+
Ray.TMax = 100.0;
18+
RayQuery<RAY_FLAG_NONE> Q;
19+
Q.TraceRayInline(Scene, RAY_FLAG_NONE, 0x02, Ray);
20+
Q.Proceed();
21+
Output[tid.x] = Q.CommittedStatus() == COMMITTED_TRIANGLE_HIT
22+
? Q.CommittedInstanceID()
23+
: 0xFFFFFFFF;
24+
}
25+
//--- pipeline.yaml
26+
---
27+
Shaders:
28+
- Stage: Compute
29+
Entry: main
30+
Buffers:
31+
- Name: Vertices
32+
Format: Float32
33+
Stride: 12
34+
Data: [ 0.0, 1.0, 0.0, -1.0, -1.0, 0.0, 1.0, -1.0, 0.0 ]
35+
- Name: Output
36+
Format: UInt32
37+
Stride: 4
38+
FillSize: 12
39+
- Name: Expected
40+
Format: UInt32
41+
Stride: 4
42+
Data: [ 0xFFFFFFFF, 1, 0xFFFFFFFF ]
43+
AccelerationStructures:
44+
BLAS:
45+
- Name: TriangleBLAS
46+
Triangles:
47+
- VertexBuffer: Vertices
48+
VertexFormat: RGB32Float
49+
VertexStride: 12
50+
VertexCount: 3
51+
TLAS:
52+
- Name: Scene
53+
Instances:
54+
- BLAS: TriangleBLAS
55+
InstanceID: 0
56+
InstanceMask: 0x01
57+
Transform: [1, 0, 0, -5, 0, 1, 0, 0, 0, 0, 1, 0]
58+
- BLAS: TriangleBLAS
59+
InstanceID: 1
60+
InstanceMask: 0x02
61+
Transform: [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0]
62+
- BLAS: TriangleBLAS
63+
InstanceID: 2
64+
InstanceMask: 0x04
65+
Transform: [1, 0, 0, 5, 0, 1, 0, 0, 0, 0, 1, 0]
66+
DescriptorSets:
67+
- Resources:
68+
- Name: Scene
69+
Kind: AccelerationStructure
70+
DirectXBinding:
71+
Register: 0
72+
Space: 0
73+
VulkanBinding:
74+
Binding: 0
75+
- Name: Output
76+
Kind: RWStructuredBuffer
77+
DirectXBinding:
78+
Register: 0
79+
Space: 0
80+
VulkanBinding:
81+
Binding: 1
82+
Results:
83+
- Result: InstanceMaskFilter
84+
Rule: BufferExact
85+
Actual: Output
86+
Expected: Expected
87+
...
88+
#--- end
89+
90+
# REQUIRES: acceleration-structure
91+
# XFAIL: Clang
92+
93+
# RUN: split-file %s %t
94+
# RUN: %dxc_target -T cs_6_5 -Fo %t.o %t/source.hlsl
95+
# RUN: %offloader %t/pipeline.yaml %t.o

0 commit comments

Comments
 (0)