Skip to content

Commit dd553d1

Browse files
MarijnS95claude
andcommitted
Add CommittedPrimitiveIndex test on a multi-triangle BLAS
Introduces a 3-triangle BLAS (tiled along x at x = -4, 0, +4) and a 3-lane dispatch that fires one ray per lane straight down at its own triangle. Each lane's CommittedPrimitiveIndex() must equal its lane index. Also exercises divergent rays per thread. Part of the inline-RT test coverage epic (#1258). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 8cb2da5 commit dd553d1

1 file changed

Lines changed: 85 additions & 0 deletions

File tree

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
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 triangles tiled along x at x = -4, 0, 4. Each lane fires a ray
9+
// straight down at its own triangle, so CommittedPrimitiveIndex() must
10+
// be exactly the lane index. Also exercises divergent rays per thread.
11+
RayDesc Ray;
12+
Ray.Origin = float3((float(tid.x) - 1.0) * 4.0, 0, 1);
13+
Ray.Direction = float3(0, 0, -1);
14+
Ray.TMin = 0.0;
15+
Ray.TMax = 100.0;
16+
RayQuery<RAY_FLAG_NONE> Q;
17+
Q.TraceRayInline(Scene, RAY_FLAG_NONE, 0xFF, Ray);
18+
Q.Proceed();
19+
Output[tid.x] = Q.CommittedStatus() == COMMITTED_TRIANGLE_HIT
20+
? Q.CommittedPrimitiveIndex()
21+
: 0xFFFFFFFF;
22+
}
23+
//--- pipeline.yaml
24+
---
25+
Shaders:
26+
- Stage: Compute
27+
Entry: main
28+
Buffers:
29+
- Name: Vertices
30+
Format: Float32
31+
Stride: 12
32+
# Three triangles, one per lane, centered at x = -4, 0, +4.
33+
Data: [ -4.0, 1.0, 0.0, -5.0, -1.0, 0.0, -3.0, -1.0, 0.0,
34+
0.0, 1.0, 0.0, -1.0, -1.0, 0.0, 1.0, -1.0, 0.0,
35+
4.0, 1.0, 0.0, 3.0, -1.0, 0.0, 5.0, -1.0, 0.0 ]
36+
- Name: Output
37+
Format: UInt32
38+
Stride: 4
39+
FillSize: 12
40+
- Name: Expected
41+
Format: UInt32
42+
Stride: 4
43+
Data: [ 0, 1, 2 ]
44+
AccelerationStructures:
45+
BLAS:
46+
- Name: MultiTriangleBLAS
47+
Triangles:
48+
- VertexBuffer: Vertices
49+
VertexFormat: RGB32Float
50+
VertexStride: 12
51+
VertexCount: 9
52+
TLAS:
53+
- Name: Scene
54+
Instances:
55+
- BLAS: MultiTriangleBLAS
56+
DescriptorSets:
57+
- Resources:
58+
- Name: Scene
59+
Kind: AccelerationStructure
60+
DirectXBinding:
61+
Register: 0
62+
Space: 0
63+
VulkanBinding:
64+
Binding: 0
65+
- Name: Output
66+
Kind: RWStructuredBuffer
67+
DirectXBinding:
68+
Register: 0
69+
Space: 0
70+
VulkanBinding:
71+
Binding: 1
72+
Results:
73+
- Result: PrimitiveIndex
74+
Rule: BufferExact
75+
Actual: Output
76+
Expected: Expected
77+
...
78+
#--- end
79+
80+
# REQUIRES: acceleration-structure
81+
# XFAIL: Clang
82+
83+
# RUN: split-file %s %t
84+
# RUN: %dxc_target -T cs_6_5 -Fo %t.o %t/source.hlsl
85+
# RUN: %offloader %t/pipeline.yaml %t.o

0 commit comments

Comments
 (0)