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