Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions test/Feature/InlineRT/primitive-index.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#--- source.hlsl

[[vk::binding(0, 0)]] RaytracingAccelerationStructure Scene : register(t0);
[[vk::binding(1, 0)]] RWStructuredBuffer<uint> Output : register(u0);

[numthreads(3,1,1)]
void main(uint3 tid : SV_DispatchThreadID) {
// Three triangles tiled along x at x = -4, 0, 4. Each lane fires a ray
// straight down at its own triangle, so CommittedPrimitiveIndex() must
// be exactly the lane index. Also exercises divergent rays per thread.
RayDesc Ray;
Ray.Origin = float3((float(tid.x) - 1.0) * 4.0, 0, 1);
Ray.Direction = float3(0, 0, -1);
Ray.TMin = 0.0;
Ray.TMax = 100.0;
RayQuery<RAY_FLAG_NONE> Q;
Q.TraceRayInline(Scene, RAY_FLAG_NONE, 0xFF, Ray);
Q.Proceed();
Output[tid.x] = Q.CommittedStatus() == COMMITTED_TRIANGLE_HIT
? Q.CommittedPrimitiveIndex()
: 0xFFFFFFFF;
}
//--- pipeline.yaml
---
Shaders:
- Stage: Compute
Entry: main
Buffers:
- Name: Vertices
Format: Float32
Stride: 12
# Three triangles, one per lane, centered at x = -4, 0, +4.
Data: [ -4.0, 1.0, 0.0, -5.0, -1.0, 0.0, -3.0, -1.0, 0.0,
0.0, 1.0, 0.0, -1.0, -1.0, 0.0, 1.0, -1.0, 0.0,
4.0, 1.0, 0.0, 3.0, -1.0, 0.0, 5.0, -1.0, 0.0 ]
- Name: Output
Format: UInt32
Stride: 4
FillSize: 12
- Name: Expected
Format: UInt32
Stride: 4
Data: [ 0, 1, 2 ]
AccelerationStructures:
BLAS:
- Name: MultiTriangleBLAS
Triangles:
- VertexBuffer: Vertices
VertexFormat: RGB32Float
VertexStride: 12
VertexCount: 9
TLAS:
- Name: Scene
Instances:
- BLAS: MultiTriangleBLAS
DescriptorSets:
- Resources:
- Name: Scene
Kind: AccelerationStructure
DirectXBinding:
Register: 0
Space: 0
VulkanBinding:
Binding: 0
- Name: Output
Kind: RWStructuredBuffer
DirectXBinding:
Register: 0
Space: 0
VulkanBinding:
Binding: 1
Results:
- Result: PrimitiveIndex
Rule: BufferExact
Actual: Output
Expected: Expected
...
#--- end

# REQUIRES: acceleration-structure
# XFAIL: Clang

# RUN: split-file %s %t
# RUN: %dxc_target -T cs_6_5 -Fo %t.o %t/source.hlsl
# RUN: %offloader %t/pipeline.yaml %t.o
Loading