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