|
| 1 | +#--- source.hlsl |
| 2 | +RWStructuredBuffer<uint> _participant_check_sum : register(u1); |
| 3 | + |
| 4 | +[numthreads(64, 1, 1)] |
| 5 | +void main(uint3 tid : SV_DispatchThreadID) { |
| 6 | + _participant_check_sum[tid.x] = 0; |
| 7 | + uint result = 0; |
| 8 | + switch ((WaveGetLaneIndex() % 4)) { |
| 9 | + case 0: { |
| 10 | + if ((WaveGetLaneIndex() < 8)) { |
| 11 | + result = (result + WaveActiveSum(1)); |
| 12 | + uint _participantCount = WaveActiveSum(1); |
| 13 | + bool _isCorrect = (_participantCount == 2); |
| 14 | + _participant_check_sum[tid.x] = (_participant_check_sum[tid.x] + (_isCorrect ? 1 : 0)); |
| 15 | + } |
| 16 | + break; |
| 17 | + } |
| 18 | + case 1: { |
| 19 | + if (((WaveGetLaneIndex() % 2) == 0)) { |
| 20 | + result = (result + WaveActiveSum(2)); |
| 21 | + uint _participantCount = WaveActiveSum(1); |
| 22 | + bool _isCorrect = (_participantCount == 0); |
| 23 | + _participant_check_sum[tid.x] = (_participant_check_sum[tid.x] + (_isCorrect ? 1 : 0)); |
| 24 | + } |
| 25 | + break; |
| 26 | + } |
| 27 | + case 2: { |
| 28 | + if (true) { |
| 29 | + result = (result + WaveActiveSum(3)); |
| 30 | + uint _participantCount = WaveActiveSum(1); |
| 31 | + bool _isCorrect = (_participantCount == 16); |
| 32 | + _participant_check_sum[tid.x] = (_participant_check_sum[tid.x] + (_isCorrect ? 1 : 0)); |
| 33 | + } |
| 34 | + break; |
| 35 | + } |
| 36 | + case 3: { |
| 37 | + if ((WaveGetLaneIndex() < 20)) { |
| 38 | + result = (result + WaveActiveSum(4)); |
| 39 | + uint _participantCount = WaveActiveSum(1); |
| 40 | + bool _isCorrect = (_participantCount == 5); |
| 41 | + _participant_check_sum[tid.x] = (_participant_check_sum[tid.x] + (_isCorrect ? 1 : 0)); |
| 42 | + } |
| 43 | + break; |
| 44 | + } |
| 45 | + default: { |
| 46 | + result = (result + WaveActiveSum(99)); |
| 47 | + uint _participantCount = WaveActiveSum(1); |
| 48 | + bool _isCorrect = (_participantCount == 0); |
| 49 | + _participant_check_sum[tid.x] = (_participant_check_sum[tid.x] + (_isCorrect ? 1 : 0)); |
| 50 | + break; |
| 51 | + } |
| 52 | + } |
| 53 | + for (uint i0 = 0; (i0 < 2); i0 = (i0 + 1)) { |
| 54 | + if ((WaveGetLaneIndex() >= 40)) { |
| 55 | + result = (result + WaveActiveMin(result)); |
| 56 | + uint _participantCount = WaveActiveSum(1); |
| 57 | + bool _isCorrect = (_participantCount == 24); |
| 58 | + _participant_check_sum[tid.x] = (_participant_check_sum[tid.x] + (_isCorrect ? 1 : 0)); |
| 59 | + } |
| 60 | + for (uint i1 = 0; (i1 < 2); i1 = (i1 + 1)) { |
| 61 | + if (((WaveGetLaneIndex() & 1) == 0)) { |
| 62 | + if (((WaveGetLaneIndex() & 1) == 1)) { |
| 63 | + result = (result + WaveActiveMax(result)); |
| 64 | + uint _participantCount = WaveActiveSum(1); |
| 65 | + bool _isCorrect = (_participantCount == 0); |
| 66 | + _participant_check_sum[tid.x] = (_participant_check_sum[tid.x] + (_isCorrect ? 1 : 0)); |
| 67 | + } |
| 68 | + if (((WaveGetLaneIndex() & 1) == 1)) { |
| 69 | + result = (result + WaveActiveMin(9)); |
| 70 | + uint _participantCount = WaveActiveSum(1); |
| 71 | + bool _isCorrect = (_participantCount == 0); |
| 72 | + _participant_check_sum[tid.x] = (_participant_check_sum[tid.x] + (_isCorrect ? 1 : 0)); |
| 73 | + } |
| 74 | + } else { |
| 75 | + if (((WaveGetLaneIndex() == 6) || (WaveGetLaneIndex() == 37))) { |
| 76 | + result = (result + WaveActiveMin((WaveGetLaneIndex() + 1))); |
| 77 | + uint _participantCount = WaveActiveSum(1); |
| 78 | + bool _isCorrect = (_participantCount == 1); |
| 79 | + _participant_check_sum[tid.x] = (_participant_check_sum[tid.x] + (_isCorrect ? 1 : 0)); |
| 80 | + } |
| 81 | + } |
| 82 | + if ((WaveGetLaneIndex() == 27)) { |
| 83 | + result = (result + WaveActiveSum(6)); |
| 84 | + uint _participantCount = WaveActiveSum(1); |
| 85 | + bool _isCorrect = (_participantCount == 1); |
| 86 | + _participant_check_sum[tid.x] = (_participant_check_sum[tid.x] + (_isCorrect ? 1 : 0)); |
| 87 | + } |
| 88 | + if ((i1 == 1)) { |
| 89 | + continue; |
| 90 | + } |
| 91 | + } |
| 92 | + if ((i0 == 1)) { |
| 93 | + break; |
| 94 | + } |
| 95 | + } |
| 96 | + switch ((WaveGetLaneIndex() % 4)) { |
| 97 | + case 0: { |
| 98 | + if ((WaveGetLaneIndex() < 10)) { |
| 99 | + if ((WaveGetLaneIndex() < 13)) { |
| 100 | + result = (result + WaveActiveSum(result)); |
| 101 | + uint _participantCount = WaveActiveSum(1); |
| 102 | + bool _isCorrect = (_participantCount == 3); |
| 103 | + _participant_check_sum[tid.x] = (_participant_check_sum[tid.x] + (_isCorrect ? 1 : 0)); |
| 104 | + } |
| 105 | + switch ((WaveGetLaneIndex() % 3)) { |
| 106 | + case 0: { |
| 107 | + if (((WaveGetLaneIndex() < 17) || (WaveGetLaneIndex() >= 61))) { |
| 108 | + if (((WaveGetLaneIndex() < 4) || (WaveGetLaneIndex() >= 45))) { |
| 109 | + result = (result + WaveActiveSum(WaveGetLaneIndex())); |
| 110 | + uint _participantCount = WaveActiveSum(1); |
| 111 | + bool _isCorrect = (_participantCount == 1); |
| 112 | + _participant_check_sum[tid.x] = (_participant_check_sum[tid.x] + (_isCorrect ? 1 : 0)); |
| 113 | + } |
| 114 | + if (((WaveGetLaneIndex() < 10) || (WaveGetLaneIndex() >= 60))) { |
| 115 | + result = (result + WaveActiveSum((WaveGetLaneIndex() + 2))); |
| 116 | + uint _participantCount = WaveActiveSum(1); |
| 117 | + bool _isCorrect = (_participantCount == 1); |
| 118 | + _participant_check_sum[tid.x] = (_participant_check_sum[tid.x] + (_isCorrect ? 1 : 0)); |
| 119 | + } |
| 120 | + } |
| 121 | + break; |
| 122 | + } |
| 123 | + case 1: { |
| 124 | + if (((WaveGetLaneIndex() % 2) == 0)) { |
| 125 | + result = (result + WaveActiveSum(2)); |
| 126 | + uint _participantCount = WaveActiveSum(1); |
| 127 | + bool _isCorrect = (_participantCount == 1); |
| 128 | + _participant_check_sum[tid.x] = (_participant_check_sum[tid.x] + (_isCorrect ? 1 : 0)); |
| 129 | + } |
| 130 | + break; |
| 131 | + } |
| 132 | + case 2: { |
| 133 | + if (true) { |
| 134 | + result = (result + WaveActiveSum(3)); |
| 135 | + uint _participantCount = WaveActiveSum(1); |
| 136 | + bool _isCorrect = (_participantCount == 1); |
| 137 | + _participant_check_sum[tid.x] = (_participant_check_sum[tid.x] + (_isCorrect ? 1 : 0)); |
| 138 | + } |
| 139 | + break; |
| 140 | + } |
| 141 | + } |
| 142 | + } |
| 143 | + break; |
| 144 | + } |
| 145 | + case 1: { |
| 146 | + if (((WaveGetLaneIndex() % 2) == 0)) { |
| 147 | + result = (result + WaveActiveSum(2)); |
| 148 | + uint _participantCount = WaveActiveSum(1); |
| 149 | + bool _isCorrect = (_participantCount == 0); |
| 150 | + _participant_check_sum[tid.x] = (_participant_check_sum[tid.x] + (_isCorrect ? 1 : 0)); |
| 151 | + } |
| 152 | + break; |
| 153 | + } |
| 154 | + case 2: { |
| 155 | + if (((((WaveGetLaneIndex() == 16) || (WaveGetLaneIndex() == 22)) || (WaveGetLaneIndex() == 46)) || (WaveGetLaneIndex() == 34))) { |
| 156 | + if ((((WaveGetLaneIndex() == 9) || (WaveGetLaneIndex() == 58)) || (WaveGetLaneIndex() == 40))) { |
| 157 | + result = (result + WaveActiveMin(WaveGetLaneIndex())); |
| 158 | + uint _participantCount = WaveActiveSum(1); |
| 159 | + bool _isCorrect = (_participantCount == 0); |
| 160 | + _participant_check_sum[tid.x] = (_participant_check_sum[tid.x] + (_isCorrect ? 1 : 0)); |
| 161 | + } |
| 162 | + uint counter2 = 0; |
| 163 | + while ((counter2 < 3)) { |
| 164 | + counter2 = (counter2 + 1); |
| 165 | + if ((WaveGetLaneIndex() == 13)) { |
| 166 | + result = (result + WaveActiveSum(10)); |
| 167 | + uint _participantCount = WaveActiveSum(1); |
| 168 | + bool _isCorrect = (_participantCount == 0); |
| 169 | + _participant_check_sum[tid.x] = (_participant_check_sum[tid.x] + (_isCorrect ? 1 : 0)); |
| 170 | + } |
| 171 | + uint counter3 = 0; |
| 172 | + while ((counter3 < 2)) { |
| 173 | + counter3 = (counter3 + 1); |
| 174 | + if (((WaveGetLaneIndex() & 1) == 0)) { |
| 175 | + result = (result + WaveActiveMax((WaveGetLaneIndex() + 1))); |
| 176 | + uint _participantCount = WaveActiveSum(1); |
| 177 | + bool _isCorrect = (_participantCount == 3); |
| 178 | + _participant_check_sum[tid.x] = (_participant_check_sum[tid.x] + (_isCorrect ? 1 : 0)); |
| 179 | + } |
| 180 | + if ((counter3 == 1)) { |
| 181 | + break; |
| 182 | + } |
| 183 | + } |
| 184 | + if ((counter2 == 2)) { |
| 185 | + break; |
| 186 | + } |
| 187 | + } |
| 188 | + } |
| 189 | + break; |
| 190 | + } |
| 191 | + case 3: { |
| 192 | + if ((WaveGetLaneIndex() < 20)) { |
| 193 | + result = (result + WaveActiveSum(4)); |
| 194 | + uint _participantCount = WaveActiveSum(1); |
| 195 | + bool _isCorrect = (_participantCount == 5); |
| 196 | + _participant_check_sum[tid.x] = (_participant_check_sum[tid.x] + (_isCorrect ? 1 : 0)); |
| 197 | + } |
| 198 | + break; |
| 199 | + } |
| 200 | + } |
| 201 | +} |
| 202 | + |
| 203 | +#--- pipeline.yaml |
| 204 | +--- |
| 205 | +Shaders: |
| 206 | + - Stage: Compute |
| 207 | + Entry: main |
| 208 | + DispatchSize: [1, 1, 1] # Single dispatch for 64 threads |
| 209 | +Buffers: |
| 210 | + - Name: _participant_check_sum |
| 211 | + Format: UInt32 |
| 212 | + Stride: 4 |
| 213 | + Fill: 0 |
| 214 | + Size: 64 |
| 215 | + - Name: expected_participants |
| 216 | + Format: UInt32 |
| 217 | + Stride: 4 |
| 218 | + Data: [4, 0, 1, 2, 3, 0, 1, 2, 2, 0, 1, 2, 0, 0, 1, 2, 0, 0, 1, 2, 0, 0, 3, 0, 0, 0, 1, 4, 0, 0, 1, 0, 0, 0, 3, 0, 0, 4, 1, 0, 2, 2, 3, 2, 2, 2, 5, 2, 2, 2, 3, 2, 2, 2, 3, 2, 2, 2, 3, 2, 2, 2, 3, 2] |
| 219 | +Results: |
| 220 | + - Result: WaveOpValidation |
| 221 | + Rule: BufferExact |
| 222 | + Actual: _participant_check_sum |
| 223 | + Expected: expected_participants |
| 224 | +DescriptorSets: |
| 225 | + - Resources: |
| 226 | + - Name: _participant_check_sum |
| 227 | + Kind: RWStructuredBuffer |
| 228 | + DirectXBinding: |
| 229 | + Register: 1 |
| 230 | + Space: 0 |
| 231 | + VulkanBinding: |
| 232 | + Binding: 1 |
| 233 | +... |
| 234 | +#--- end |
| 235 | + |
| 236 | +# RUN: split-file %s %t |
| 237 | +# RUN: %dxc_target -T cs_6_0 -Fo %t.o %t/source.hlsl |
| 238 | +# RUN: %offloader %t/pipeline.yaml %t.o |
0 commit comments