Skip to content

Commit c3fb8cd

Browse files
MarijnS95claude
andcommitted
Add RAY_FLAG_CULL_BACK_FACING_TRIANGLES test
Two rays at the existing single-triangle BLAS — one from +z (sees the front face per DX / VK / MTL's shared default winding convention) and one from -z (sees the back face) — with the RAY_FLAG_CULL_BACK_FACING_TRIANGLES template flag set. The +z ray must hit and the -z ray 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 c822105 commit c3fb8cd

1 file changed

Lines changed: 87 additions & 0 deletions

File tree

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
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(2,1,1)]
7+
void main(uint3 tid : SV_DispatchThreadID) {
8+
// The triangle vertices (0,1,0), (-1,-1,0), (1,-1,0) wind CW from +z and
9+
// CCW from -z (per the DX / VK / MTL convention all three backends share
10+
// for ray-traversal winding, which is the inverse of the math-CCW signed
11+
// area when viewing along the ray direction). With CCW = back-face by
12+
// default:
13+
// - lane 0 fires from +z toward -z → sees CW → FRONT face (must hit)
14+
// - lane 1 fires from -z toward +z → sees CCW → BACK face (must miss
15+
// under RAY_FLAG_CULL_BACK_FACING_TRIANGLES)
16+
RayDesc Ray;
17+
Ray.Origin = float3(0, 0, tid.x == 0 ? 1.0 : -1.0);
18+
Ray.Direction = float3(0, 0, tid.x == 0 ? -1.0 : 1.0);
19+
Ray.TMin = 0.0;
20+
Ray.TMax = 100.0;
21+
RayQuery<RAY_FLAG_CULL_BACK_FACING_TRIANGLES> Q;
22+
Q.TraceRayInline(Scene, RAY_FLAG_NONE, 0xFF, Ray);
23+
Q.Proceed();
24+
Output[tid.x] = (uint)Q.CommittedStatus();
25+
}
26+
//--- pipeline.yaml
27+
---
28+
Shaders:
29+
- Stage: Compute
30+
Entry: main
31+
Buffers:
32+
- Name: Vertices
33+
Format: Float32
34+
Stride: 12
35+
Data: [ 0.0, 1.0, 0.0, -1.0, -1.0, 0.0, 1.0, -1.0, 0.0 ]
36+
- Name: Output
37+
Format: UInt32
38+
Stride: 4
39+
FillSize: 8
40+
- Name: Expected
41+
Format: UInt32
42+
Stride: 4
43+
# Lane 0: front face → COMMITTED_TRIANGLE_HIT (1)
44+
# Lane 1: back face → COMMITTED_NOTHING (0)
45+
Data: [ 1, 0 ]
46+
AccelerationStructures:
47+
BLAS:
48+
- Name: TriangleBLAS
49+
Triangles:
50+
- VertexBuffer: Vertices
51+
VertexFormat: RGB32Float
52+
VertexStride: 12
53+
VertexCount: 3
54+
TLAS:
55+
- Name: Scene
56+
Instances:
57+
- BLAS: TriangleBLAS
58+
DescriptorSets:
59+
- Resources:
60+
- Name: Scene
61+
Kind: AccelerationStructure
62+
DirectXBinding:
63+
Register: 0
64+
Space: 0
65+
VulkanBinding:
66+
Binding: 0
67+
- Name: Output
68+
Kind: RWStructuredBuffer
69+
DirectXBinding:
70+
Register: 0
71+
Space: 0
72+
VulkanBinding:
73+
Binding: 1
74+
Results:
75+
- Result: CullBackFacing
76+
Rule: BufferExact
77+
Actual: Output
78+
Expected: Expected
79+
...
80+
#--- end
81+
82+
# REQUIRES: acceleration-structure
83+
# XFAIL: Clang
84+
85+
# RUN: split-file %s %t
86+
# RUN: %dxc_target -T cs_6_5 -Fo %t.o %t/source.hlsl
87+
# RUN: %offloader %t/pipeline.yaml %t.o

0 commit comments

Comments
 (0)