|
| 1 | +#--- source.hlsl |
| 2 | + |
| 3 | +StructuredBuffer<uint32_t> X : register(t0); |
| 4 | +StructuredBuffer<uint32_t> Y : register(t1); |
| 5 | +RWStructuredBuffer<uint32_t> Result : register(u2); |
| 6 | + |
| 7 | +[numthreads(1,1,1)] |
| 8 | +void main() { |
| 9 | + // dot4add({1, 1, 1, 1}, {1, 2, -128, -86}, 0) = -211 = 0xFF2D |
| 10 | + Result[0] = dot4add_i8packed(X[0], Y[0], 0u); |
| 11 | + // dot4add({2, 4, 8, -1}, {2, 2, 2, 1}, -211) = -184 = 0xFF48 |
| 12 | + Result[1] = dot4add_i8packed(X[1], Y[1], Result[0]); |
| 13 | + |
| 14 | + // dot4add({1, 1, 1, 1}, {1, 2, 128, 170}, 0) = 301 = 0x012D |
| 15 | + Result[2] = dot4add_u8packed(X[0], Y[0], 0u); |
| 16 | + // dot4add({2, 4, 8, 255}, {2, 2, 2, 1}, 301) = 584 = 0x0248 |
| 17 | + Result[3] = dot4add_u8packed(X[1], Y[1], Result[2]); |
| 18 | +} |
| 19 | + |
| 20 | +//--- pipeline.yaml |
| 21 | + |
| 22 | +--- |
| 23 | +Shaders: |
| 24 | + - Stage: Compute |
| 25 | + Entry: main |
| 26 | + DispatchSize: [1, 1, 1] |
| 27 | +Buffers: |
| 28 | + - Name: X |
| 29 | + Format: Hex32 |
| 30 | + Stride: 4 |
| 31 | + Data: [ 0x01010101, 0x020408FF ] |
| 32 | + - Name: Y |
| 33 | + Format: Hex32 |
| 34 | + Stride: 4 |
| 35 | + Data: [ 0x010280AA, 0x02020201 ] |
| 36 | + - Name: Result |
| 37 | + Format: Hex32 |
| 38 | + Stride: 4 |
| 39 | + ZeroInitSize: 16 |
| 40 | + - Name: ExpectedResult |
| 41 | + Format: Hex32 |
| 42 | + Stride: 4 |
| 43 | + Data: [ 0xFFFFFF2D, 0xFFFFFF48, 0x0000012D, 0x00000248 ] |
| 44 | +Results: |
| 45 | + - Result: CheckResult |
| 46 | + Rule: BufferExact |
| 47 | + Actual: Result |
| 48 | + Expected: ExpectedResult |
| 49 | +DescriptorSets: |
| 50 | + - Resources: |
| 51 | + - Name: X |
| 52 | + Kind: StructuredBuffer |
| 53 | + DirectXBinding: |
| 54 | + Register: 0 |
| 55 | + Space: 0 |
| 56 | + VulkanBinding: |
| 57 | + Binding: 0 |
| 58 | + - Name: Y |
| 59 | + Kind: StructuredBuffer |
| 60 | + DirectXBinding: |
| 61 | + Register: 1 |
| 62 | + Space: 0 |
| 63 | + VulkanBinding: |
| 64 | + Binding: 1 |
| 65 | + - Name: Result |
| 66 | + Kind: RWStructuredBuffer |
| 67 | + DirectXBinding: |
| 68 | + Register: 2 |
| 69 | + Space: 0 |
| 70 | + VulkanBinding: |
| 71 | + Binding: 2 |
| 72 | +... |
| 73 | +#--- end |
| 74 | + |
| 75 | +# RUN: split-file %s %t |
| 76 | +# RUN: %dxc_target -T cs_6_5 -Fo %t.o %t/source.hlsl |
| 77 | +# RUN: %offloader %t/pipeline.yaml %t.o |
0 commit comments