|
| 1 | +#--- source.hlsl |
| 2 | +StructuredBuffer<half2> A : register(t0); |
| 3 | +StructuredBuffer<half2> B : register(t1); |
| 4 | +StructuredBuffer<float> Acc : register(t2); |
| 5 | + |
| 6 | +RWStructuredBuffer<float> Out : register(u3); |
| 7 | + |
| 8 | + |
| 9 | +[numthreads(1,1,1)] |
| 10 | +void main() { |
| 11 | + Out[0] = dot2add(A[0], B[0], Acc[0]); |
| 12 | + Out[1] = dot2add(A[1], B[1], Acc[1]); |
| 13 | + Out[2] = dot2add(A[2], B[2], Acc[2]); |
| 14 | + Out[3] = dot2add(A[3], B[3], Acc[3]); |
| 15 | + Out[4] = dot2add(A[4], B[4], Acc[4]); |
| 16 | + Out[5] = dot2add(A[5], B[5], Acc[5]); |
| 17 | + Out[6] = dot2add(A[6], B[6], Acc[6]); |
| 18 | + Out[7] = dot2add(A[7], B[7], Acc[7]); |
| 19 | + Out[8] = dot2add(A[8], B[8], Acc[8]); |
| 20 | + Out[9] = dot2add(A[9], B[9], Acc[9]); |
| 21 | + Out[10] = dot2add(A[10], B[10], Acc[10]); |
| 22 | + Out[11] = dot2add(A[11], B[11], Acc[11]); |
| 23 | + |
| 24 | + Out[12] = dot2add(half2(1, 2), half2(3, 4), float(0)); |
| 25 | + Out[13] = dot2add(half2(-1, 2), half2(3, -4), float(10)); |
| 26 | + Out[14] = dot2add(half2(65504, 1), half2(1, 65504), float(0)); |
| 27 | + Out[15] = dot2add(half2(1, -65504), half2(-65504, 1), float(-10000000)); |
| 28 | +} |
| 29 | +//--- pipeline.yaml |
| 30 | + |
| 31 | +--- |
| 32 | +Shaders: |
| 33 | + - Stage: Compute |
| 34 | + Entry: main |
| 35 | + DispatchSize: [1, 1, 1] |
| 36 | +Buffers: |
| 37 | + - Name: A |
| 38 | + Format: Float16 |
| 39 | + Stride: 4 |
| 40 | + Data: [ 0x3c00, 0x4000, 0x3c00, 0xc000, 0x3c00, 0x4000, 0xbc00, 0x4000, 0x3c00, 0x4000, 0xbc00, 0x4000, 0x3c00, 0x4000, 0xbc00, 0xc000, 0x7bff, 0x3c00, 0xfbff, 0x3c00, 0x3c00, 0x7bff, 0x3c00, 0xfbff ] |
| 41 | + # 1, 2, 1, -2, 1, 2, -1, 2, 1, 2, -1, 2, 1, 2, -1, -2, 65504, 1, -65504, 1, 1, 65504, 1, -65504 |
| 42 | + - Name: B |
| 43 | + Format: Float16 |
| 44 | + Stride: 4 |
| 45 | + Data: [ 0x4200, 0x4400, 0xc200, 0x4400, 0x4200, 0x4400, 0x4200, 0xc400, 0x4200, 0x4400, 0xc200, 0x4400, 0x4200, 0x4400, 0xc200, 0xc400, 0x3c00, 0x7bff, 0x3c00, 0xfbff, 0x7bff, 0x3c00, 0xfbff, 0x3c00 ] |
| 46 | + # 3, 4, -3, 4, 3, 4, 3, -4, 3, 4, -3, 4, 3, 4, -3, -4, 1, 65504, 1, -65504, 65504, 1, -65504, 1 |
| 47 | + - Name: Acc |
| 48 | + Format: Float32 |
| 49 | + Stride: 4 |
| 50 | + Data: [ 0, 0, 10, 10, -5, -5, -30, -30, 0, 0, 10000000, -10000000 ] |
| 51 | + - Name: Out |
| 52 | + Format: Float32 |
| 53 | + Stride: 4 |
| 54 | + ZeroInitSize: 64 |
| 55 | + - Name: ExpectedOut |
| 56 | + Format: Float32 |
| 57 | + Stride: 4 |
| 58 | + Data: [ 11, -11, 21, -1, 6, 6, -19, -19, 131008, -131008, 10131008, -10131008, 11, -1, 131008, -10131008 ] |
| 59 | +Results: |
| 60 | + - Result: Test0 |
| 61 | + Rule: BufferFloatEpsilon |
| 62 | + Epsilon: 0.008 |
| 63 | + Actual: Out |
| 64 | + Expected: ExpectedOut |
| 65 | +DescriptorSets: |
| 66 | + - Resources: |
| 67 | + - Name: A |
| 68 | + Kind: StructuredBuffer |
| 69 | + DirectXBinding: |
| 70 | + Register: 0 |
| 71 | + Space: 0 |
| 72 | + VulkanBinding: |
| 73 | + Binding: 0 |
| 74 | + - Name: B |
| 75 | + Kind: StructuredBuffer |
| 76 | + DirectXBinding: |
| 77 | + Register: 1 |
| 78 | + Space: 0 |
| 79 | + VulkanBinding: |
| 80 | + Binding: 1 |
| 81 | + - Name: Acc |
| 82 | + Kind: StructuredBuffer |
| 83 | + DirectXBinding: |
| 84 | + Register: 2 |
| 85 | + Space: 0 |
| 86 | + VulkanBinding: |
| 87 | + Binding: 2 |
| 88 | + - Name: Out |
| 89 | + Kind: RWStructuredBuffer |
| 90 | + DirectXBinding: |
| 91 | + Register: 3 |
| 92 | + Space: 0 |
| 93 | + VulkanBinding: |
| 94 | + Binding: 3 |
| 95 | +#--- end |
| 96 | + |
| 97 | +# REQUIRES: Half |
| 98 | +# RUN: split-file %s %t |
| 99 | +# RUN: %dxc_target -enable-16bit-types -T cs_6_5 -Fo %t.o %t/source.hlsl |
| 100 | +# RUN: %offloader %t/pipeline.yaml %t.o |
0 commit comments