|
| 1 | +#--- source.hlsl |
| 2 | + |
| 3 | +[[vk::binding(0, 0)]] RaytracingAccelerationStructure Scene : register(t0); |
| 4 | +[[vk::binding(1, 0)]] RWStructuredBuffer<uint2> Output : register(u0); |
| 5 | + |
| 6 | +[numthreads(1,1,1)] |
| 7 | +void main() { |
| 8 | + // Triangle vertices V0=(0,1,0), V1=(-1,-1,0), V2=(1,-1,0). Aim the ray at |
| 9 | + // world (0,0,0); the barycentric weights (1-u-v, u, v) that reconstruct |
| 10 | + // that point are (0.5, 0.25, 0.25), so CommittedTriangleBarycentrics() |
| 11 | + // must return exactly (0.25, 0.25). |
| 12 | + RayDesc Ray; |
| 13 | + Ray.Origin = float3(0, 0, 1); |
| 14 | + Ray.Direction = float3(0, 0, -1); |
| 15 | + Ray.TMin = 0.0; |
| 16 | + Ray.TMax = 100.0; |
| 17 | + RayQuery<RAY_FLAG_NONE> Q; |
| 18 | + Q.TraceRayInline(Scene, RAY_FLAG_NONE, 0xFF, Ray); |
| 19 | + Q.Proceed(); |
| 20 | + Output[0] = asuint(Q.CommittedTriangleBarycentrics()); |
| 21 | +} |
| 22 | +//--- pipeline.yaml |
| 23 | +--- |
| 24 | +Shaders: |
| 25 | + - Stage: Compute |
| 26 | + Entry: main |
| 27 | +Buffers: |
| 28 | + - Name: Vertices |
| 29 | + Format: Float32 |
| 30 | + Stride: 12 |
| 31 | + Data: [ 0.0, 1.0, 0.0, -1.0, -1.0, 0.0, 1.0, -1.0, 0.0 ] |
| 32 | + - Name: Output |
| 33 | + Format: UInt32 |
| 34 | + Stride: 8 |
| 35 | + FillSize: 8 |
| 36 | + - Name: Expected |
| 37 | + Format: UInt32 |
| 38 | + Stride: 8 |
| 39 | + Data: [ 0x3e800000, 0x3e800000 ] # asuint((0.25, 0.25)) |
| 40 | +AccelerationStructures: |
| 41 | + BLAS: |
| 42 | + - Name: TriangleBLAS |
| 43 | + Triangles: |
| 44 | + - VertexBuffer: Vertices |
| 45 | + VertexFormat: RGB32Float |
| 46 | + VertexStride: 12 |
| 47 | + VertexCount: 3 |
| 48 | + TLAS: |
| 49 | + - Name: Scene |
| 50 | + Instances: |
| 51 | + - BLAS: TriangleBLAS |
| 52 | +DescriptorSets: |
| 53 | + - Resources: |
| 54 | + - Name: Scene |
| 55 | + Kind: AccelerationStructure |
| 56 | + DirectXBinding: |
| 57 | + Register: 0 |
| 58 | + Space: 0 |
| 59 | + VulkanBinding: |
| 60 | + Binding: 0 |
| 61 | + - Name: Output |
| 62 | + Kind: RWStructuredBuffer |
| 63 | + DirectXBinding: |
| 64 | + Register: 0 |
| 65 | + Space: 0 |
| 66 | + VulkanBinding: |
| 67 | + Binding: 1 |
| 68 | +Results: |
| 69 | + - Result: CommittedTriangleBarycentrics |
| 70 | + Rule: BufferExact |
| 71 | + Actual: Output |
| 72 | + Expected: Expected |
| 73 | +... |
| 74 | +#--- end |
| 75 | + |
| 76 | +# REQUIRES: acceleration-structure |
| 77 | +# XFAIL: Clang |
| 78 | + |
| 79 | +# RUN: split-file %s %t |
| 80 | +# RUN: %dxc_target -T cs_6_5 -Fo %t.o %t/source.hlsl |
| 81 | +# RUN: %offloader %t/pipeline.yaml %t.o |
0 commit comments