|
| 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() % 3)) { |
| 9 | + case 0: { |
| 10 | + if ((WaveGetLaneIndex() < 8)) { |
| 11 | + result = (result + WaveActiveSum(1)); |
| 12 | + uint _participantCount = WaveActiveSum(1); |
| 13 | + bool _isCorrect = (_participantCount == 3); |
| 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 == 10); |
| 23 | + _participant_check_sum[tid.x] = (_participant_check_sum[tid.x] + (_isCorrect ? 1 : 0)); |
| 24 | + } |
| 25 | + break; |
| 26 | + } |
| 27 | + case 2: { |
| 28 | + switch ((WaveGetLaneIndex() % 3)) { |
| 29 | + case 0: { |
| 30 | + if ((WaveGetLaneIndex() < 8)) { |
| 31 | + result = (result + WaveActiveSum(1)); |
| 32 | + uint _participantCount = WaveActiveSum(1); |
| 33 | + bool _isCorrect = (_participantCount == 0); |
| 34 | + _participant_check_sum[tid.x] = (_participant_check_sum[tid.x] + (_isCorrect ? 1 : 0)); |
| 35 | + } |
| 36 | + break; |
| 37 | + } |
| 38 | + case 1: { |
| 39 | + if (((WaveGetLaneIndex() % 2) == 0)) { |
| 40 | + result = (result + WaveActiveSum(2)); |
| 41 | + uint _participantCount = WaveActiveSum(1); |
| 42 | + bool _isCorrect = (_participantCount == 0); |
| 43 | + _participant_check_sum[tid.x] = (_participant_check_sum[tid.x] + (_isCorrect ? 1 : 0)); |
| 44 | + } |
| 45 | + break; |
| 46 | + } |
| 47 | + case 2: { |
| 48 | + if (true) { |
| 49 | + result = (result + WaveActiveSum(3)); |
| 50 | + uint _participantCount = WaveActiveSum(1); |
| 51 | + bool _isCorrect = (_participantCount == 21); |
| 52 | + _participant_check_sum[tid.x] = (_participant_check_sum[tid.x] + (_isCorrect ? 1 : 0)); |
| 53 | + } |
| 54 | + break; |
| 55 | + } |
| 56 | + } |
| 57 | + break; |
| 58 | + } |
| 59 | + default: { |
| 60 | + result = (result + WaveActiveSum(99)); |
| 61 | + uint _participantCount = WaveActiveSum(1); |
| 62 | + bool _isCorrect = (_participantCount == 0); |
| 63 | + _participant_check_sum[tid.x] = (_participant_check_sum[tid.x] + (_isCorrect ? 1 : 0)); |
| 64 | + break; |
| 65 | + } |
| 66 | + } |
| 67 | + if ((WaveGetLaneIndex() == 11)) { |
| 68 | + if ((WaveGetLaneIndex() == 55)) { |
| 69 | + result = (result + WaveActiveSum(1)); |
| 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 | + uint counter0 = 0; |
| 75 | + while ((counter0 < 3)) { |
| 76 | + counter0 = (counter0 + 1); |
| 77 | + if ((((WaveGetLaneIndex() == 20) || (WaveGetLaneIndex() == 22)) || (WaveGetLaneIndex() == 48))) { |
| 78 | + result = (result + WaveActiveMax(WaveGetLaneIndex())); |
| 79 | + uint _participantCount = WaveActiveSum(1); |
| 80 | + bool _isCorrect = (_participantCount == 0); |
| 81 | + _participant_check_sum[tid.x] = (_participant_check_sum[tid.x] + (_isCorrect ? 1 : 0)); |
| 82 | + } |
| 83 | + for (uint i1 = 0; (i1 < 2); i1 = (i1 + 1)) { |
| 84 | + if ((WaveGetLaneIndex() == 48)) { |
| 85 | + result = (result + WaveActiveMax((WaveGetLaneIndex() + 1))); |
| 86 | + uint _participantCount = WaveActiveSum(1); |
| 87 | + bool _isCorrect = (_participantCount == 0); |
| 88 | + _participant_check_sum[tid.x] = (_participant_check_sum[tid.x] + (_isCorrect ? 1 : 0)); |
| 89 | + } |
| 90 | + switch ((WaveGetLaneIndex() % 2)) { |
| 91 | + case 0: { |
| 92 | + if ((WaveGetLaneIndex() < 8)) { |
| 93 | + result = (result + WaveActiveSum(1)); |
| 94 | + uint _participantCount = WaveActiveSum(1); |
| 95 | + bool _isCorrect = (_participantCount == 0); |
| 96 | + _participant_check_sum[tid.x] = (_participant_check_sum[tid.x] + (_isCorrect ? 1 : 0)); |
| 97 | + } |
| 98 | + break; |
| 99 | + } |
| 100 | + case 1: { |
| 101 | + if (((WaveGetLaneIndex() % 2) == 0)) { |
| 102 | + result = (result + WaveActiveSum(2)); |
| 103 | + uint _participantCount = WaveActiveSum(1); |
| 104 | + bool _isCorrect = (_participantCount == 0); |
| 105 | + _participant_check_sum[tid.x] = (_participant_check_sum[tid.x] + (_isCorrect ? 1 : 0)); |
| 106 | + } |
| 107 | + break; |
| 108 | + } |
| 109 | + } |
| 110 | + if ((i1 == 1)) { |
| 111 | + continue; |
| 112 | + } |
| 113 | + } |
| 114 | + if ((counter0 == 2)) { |
| 115 | + break; |
| 116 | + } |
| 117 | + } |
| 118 | + } |
| 119 | +} |
| 120 | + |
| 121 | +#--- pipeline.yaml |
| 122 | +--- |
| 123 | +Shaders: |
| 124 | + - Stage: Compute |
| 125 | + Entry: main |
| 126 | + DispatchSize: [1, 1, 1] # Single dispatch for 64 threads |
| 127 | +Buffers: |
| 128 | + - Name: _participant_check_sum |
| 129 | + Format: UInt32 |
| 130 | + Stride: 4 |
| 131 | + Fill: 0 |
| 132 | + Size: 64 |
| 133 | + - Name: expected_participants |
| 134 | + Format: UInt32 |
| 135 | + Stride: 4 |
| 136 | + Data: [1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0] |
| 137 | +Results: |
| 138 | + - Result: WaveOpValidation |
| 139 | + Rule: BufferExact |
| 140 | + Actual: _participant_check_sum |
| 141 | + Expected: expected_participants |
| 142 | +DescriptorSets: |
| 143 | + - Resources: |
| 144 | + - Name: _participant_check_sum |
| 145 | + Kind: RWStructuredBuffer |
| 146 | + DirectXBinding: |
| 147 | + Register: 1 |
| 148 | + Space: 0 |
| 149 | + VulkanBinding: |
| 150 | + Binding: 1 |
| 151 | +... |
| 152 | +#--- end |
| 153 | + |
| 154 | +# RUN: split-file %s %t |
| 155 | +# RUN: %dxc_target -T cs_6_0 -Fo %t.o %t/source.hlsl |
| 156 | +# RUN: %offloader %t/pipeline.yaml %t.o |
0 commit comments