|
| 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 are centered around x=0, but a per-geometry |
| 9 | + // BLAS-bake transform translates them to x=5 at AS-build time. With an |
| 10 | + // identity-transform TLAS instance, only the ray at x=5 hits. |
| 11 | + RayDesc Ray; |
| 12 | + Ray.Origin = float3(tid.x == 0 ? 5.0 : 0.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] = (uint)Q.CommittedStatus(); |
| 20 | +} |
| 21 | +//--- pipeline.yaml |
| 22 | +--- |
| 23 | +Shaders: |
| 24 | + - Stage: Compute |
| 25 | + Entry: main |
| 26 | +Buffers: |
| 27 | + - Name: Vertices |
| 28 | + Format: Float32 |
| 29 | + Stride: 12 |
| 30 | + Data: [ 0.0, 1.0, 0.0, -1.0, -1.0, 0.0, 1.0, -1.0, 0.0 ] |
| 31 | + - Name: Output |
| 32 | + Format: UInt32 |
| 33 | + Stride: 4 |
| 34 | + FillSize: 8 |
| 35 | + - Name: Expected |
| 36 | + Format: UInt32 |
| 37 | + Stride: 4 |
| 38 | + # Lane 0: ray hits the baked-translated triangle → COMMITTED_TRIANGLE_HIT (1) |
| 39 | + # Lane 1: ray misses (triangle no longer at origin) → COMMITTED_NOTHING (0) |
| 40 | + Data: [ 1, 0 ] |
| 41 | +AccelerationStructures: |
| 42 | + BLAS: |
| 43 | + - Name: TriangleBLAS |
| 44 | + Triangles: |
| 45 | + - VertexBuffer: Vertices |
| 46 | + VertexFormat: RGB32Float |
| 47 | + VertexStride: 12 |
| 48 | + VertexCount: 3 |
| 49 | + # 3x4 row-major affine — translate x by +5. |
| 50 | + Transform: [1, 0, 0, 5, 0, 1, 0, 0, 0, 0, 1, 0] |
| 51 | + TLAS: |
| 52 | + - Name: Scene |
| 53 | + Instances: |
| 54 | + - BLAS: TriangleBLAS |
| 55 | +DescriptorSets: |
| 56 | + - Resources: |
| 57 | + - Name: Scene |
| 58 | + Kind: AccelerationStructure |
| 59 | + DirectXBinding: |
| 60 | + Register: 0 |
| 61 | + Space: 0 |
| 62 | + VulkanBinding: |
| 63 | + Binding: 0 |
| 64 | + - Name: Output |
| 65 | + Kind: RWStructuredBuffer |
| 66 | + DirectXBinding: |
| 67 | + Register: 0 |
| 68 | + Space: 0 |
| 69 | + VulkanBinding: |
| 70 | + Binding: 1 |
| 71 | +Results: |
| 72 | + - Result: GeometryTransform |
| 73 | + Rule: BufferExact |
| 74 | + Actual: Output |
| 75 | + Expected: Expected |
| 76 | +... |
| 77 | +#--- end |
| 78 | + |
| 79 | +# REQUIRES: acceleration-structure |
| 80 | +# XFAIL: Clang |
| 81 | + |
| 82 | +# RUN: split-file %s %t |
| 83 | +# RUN: %dxc_target -T cs_6_5 -Fo %t.o %t/source.hlsl |
| 84 | +# RUN: %offloader %t/pipeline.yaml %t.o |
0 commit comments