|
| 1 | +#--- source.hlsl |
| 2 | + |
| 3 | +// This test tests four different distance scenarios |
| 4 | +// One in 1D, 2D, 3D, and 4D |
| 5 | + |
| 6 | +StructuredBuffer<half4> X : register(t0); |
| 7 | +StructuredBuffer<half4> Y : register(t1); |
| 8 | + |
| 9 | +RWStructuredBuffer<half> Result : register(u2); |
| 10 | + |
| 11 | +[numthreads(1,1,1)] |
| 12 | +void main() { |
| 13 | + // distance ({1.125}, {2.375}) = 1.25 |
| 14 | + half R0 = distance(X[0].x, Y[0].x); |
| 15 | + Result[0] = R0; |
| 16 | + half R0_constant = distance(half(1.125), half(2.375)); |
| 17 | + Result[1] = R0_constant; |
| 18 | + |
| 19 | + // distance({1.125, 2.5}, {2.375, 5.25}) = 3.02076 |
| 20 | + half R1 = distance(X[0].xy, Y[0].xy); |
| 21 | + Result[2] = R1; |
| 22 | + half R1_constant = distance(half2(1.125, 2.5), half2(2.375, 5.25)); |
| 23 | + Result[3] = R1_constant; |
| 24 | + |
| 25 | + // distance({1.125, 2.5, 4.75}, {2.375, 5.25, 8.375}) = 4.71865 |
| 26 | + half R2 = distance(X[0].xyz, Y[0].xyz); |
| 27 | + Result[4] = R2; |
| 28 | + half R2_constant = distance(half3(1.125, 2.5, 4.75), half3(2.375, 5.25, 8.375)); |
| 29 | + Result[5] = R2_constant; |
| 30 | + |
| 31 | + // distance({1.125, 2.5, 4.75, 6.625}, {2.375, 5.25, 8.375, 5.30}) = 4.90115 |
| 32 | + half R3 = distance(X[0], Y[0]); |
| 33 | + Result[6] = R3; |
| 34 | + half R3_constant = distance(half4(1.125, 2.5, 4.75, 6.625), half4(2.375, 5.25, 8.375, 5.30)); |
| 35 | + Result[7] = R3_constant; |
| 36 | + |
| 37 | + // distance ({-7.29}, {-12.29}) = 5.0 |
| 38 | + half R4 = distance(X[1].x, Y[1].x); |
| 39 | + Result[8] = R4; |
| 40 | + half R4_constant = distance(half(-7.29), half(-12.29)); |
| 41 | + Result[9] = R4_constant; |
| 42 | + |
| 43 | + // distance({-7.29, 137.14}, {-12.29, -4.0}) = 141.2303 |
| 44 | + half R5 = distance(X[1].xy, Y[1].xy); |
| 45 | + Result[10] = R5; |
| 46 | + half R5_constant = distance(half2(-7.29, 137.14), half2(-12.29, -4.0)); |
| 47 | + Result[11] = R5_constant; |
| 48 | + |
| 49 | + // distance({-7.29, 137.14, 1.1}, {-12.29, -4.0, -2.1}) = 141.2406 |
| 50 | + half R6 = distance(X[1].xyz, Y[1].xyz); |
| 51 | + Result[12] = R6; |
| 52 | + half R6_constant = distance(half3(-7.29, 137.14, 1.1), half3(-12.29, -4.0, -2.1)); |
| 53 | + Result[13] = R6_constant; |
| 54 | + |
| 55 | + // distance({-7.29, 137.14, 1.1, -3.5}, {-12.29, -4.0, -2.1, -2.5}) = 141.2445 |
| 56 | + half R7 = distance(X[1], Y[1]); |
| 57 | + Result[14] = R7; |
| 58 | + half R7_constant = distance(half4(-7.29, 137.14, 11.1, -30.5), half4(-12.29, -4.0, -2.1, -2.5)); |
| 59 | + Result[15] = R7_constant; |
| 60 | +} |
| 61 | + |
| 62 | +//--- pipeline.yaml |
| 63 | + |
| 64 | +--- |
| 65 | +Shaders: |
| 66 | + - Stage: Compute |
| 67 | + Entry: main |
| 68 | + DispatchSize: [1, 1, 1] |
| 69 | +Buffers: |
| 70 | + - Name: X |
| 71 | + Format: Float16 |
| 72 | + Stride: 8 |
| 73 | + Data: [ 0x3c80, 0x4100, 0x44c0, 0x46a0, 0xc74a, 0x5849, 0x498d, 0xcfa0 ] |
| 74 | + # 1.125, 2.5, 4.75, 6.625, -7.29, 137.14, 11.1, -30.5 |
| 75 | + - Name: Y |
| 76 | + Format: Float16 |
| 77 | + Stride: 8 |
| 78 | + Data: [ 0x40c0, 0x4540, 0x4830, 0x454d, 0xca25, 0xc400, 0xc033, 0xc100 ] |
| 79 | + # 2.375, 5.25, 8.375, 5.30, -12.29, -4.0, -2.1, -2.5 |
| 80 | + - Name: Result |
| 81 | + Format: Float16 |
| 82 | + Stride: 2 |
| 83 | + ZeroInitSize: 32 |
| 84 | + - Name: ExpectedResult |
| 85 | + Format: Float16 |
| 86 | + Stride: 2 |
| 87 | + Data: [ 0x3d00, 0x3d00, 0x420b, 0x420b, 0x44b8, 0x44b8, 0x44e7, 0x44e7, 0x4500, 0x4500, 0x586a, 0x586a, 0x586f, 0x586f, 0x5885, 0x5885 ] |
| 88 | + # 1.25, 1.25, 3.02076, 3.02076, 4.71865, 4.71865, 4.90115, 4.90115, 5.0, 5.0, 141.229, 141.229, 141.844, 141.844, 144.581, 144.581 |
| 89 | +Results: |
| 90 | + - Result: CheckResult |
| 91 | + Rule: BufferFloatULP |
| 92 | + ULPT: 5 |
| 93 | + Actual: Result |
| 94 | + Expected: ExpectedResult |
| 95 | +DescriptorSets: |
| 96 | + - Resources: |
| 97 | + - Name: X |
| 98 | + Kind: StructuredBuffer |
| 99 | + DirectXBinding: |
| 100 | + Register: 0 |
| 101 | + Space: 0 |
| 102 | + VulkanBinding: |
| 103 | + Binding: 0 |
| 104 | + - Name: Y |
| 105 | + Kind: StructuredBuffer |
| 106 | + DirectXBinding: |
| 107 | + Register: 1 |
| 108 | + Space: 0 |
| 109 | + VulkanBinding: |
| 110 | + Binding: 1 |
| 111 | + - Name: Result |
| 112 | + Kind: RWStructuredBuffer |
| 113 | + DirectXBinding: |
| 114 | + Register: 2 |
| 115 | + Space: 0 |
| 116 | + VulkanBinding: |
| 117 | + Binding: 2 |
| 118 | +... |
| 119 | +#--- end |
| 120 | + |
| 121 | +# UNSUPPORTED: Clang-Vulkan |
| 122 | +# Clang-Vulkan is unsupported because of two validation errors |
| 123 | +# This issue tracks its resolution: https://github.com/llvm/offload-test-suite/issues/285 |
| 124 | +# REQUIRES: Half |
| 125 | +# RUN: split-file %s %t |
| 126 | +# RUN: %dxc_target -enable-16bit-types -T cs_6_5 -Fo %t.o %t/source.hlsl |
| 127 | +# RUN: %offloader %t/pipeline.yaml %t.o |
0 commit comments