|
| 1 | +#--- source.hlsl |
| 2 | +#define NUM_MASKS 1 |
| 3 | +#define NUM_THREADS 128 |
| 4 | + |
| 5 | +struct MaskStruct { |
| 6 | + int mask[NUM_THREADS]; |
| 7 | +}; |
| 8 | + |
| 9 | +StructuredBuffer<int4> In : register(t0); |
| 10 | +RWStructuredBuffer<int4> Out4 : register(u4); // test int4 |
| 11 | +RWStructuredBuffer<int4> Out5 : register(u5); // constant folding |
| 12 | +StructuredBuffer<MaskStruct> Masks : register(t6); |
| 13 | + |
| 14 | + |
| 15 | +[numthreads(NUM_THREADS,1,1)] |
| 16 | +void main(uint3 tid : SV_GroupThreadID) |
| 17 | +{ |
| 18 | + |
| 19 | + for (uint MaskIdx = 0; MaskIdx < NUM_MASKS; MaskIdx++) { |
| 20 | + int4 v = In[MaskIdx * NUM_THREADS + tid.x]; |
| 21 | + const uint OutIdx = MaskIdx * NUM_THREADS + tid.x; |
| 22 | + if (Masks[MaskIdx].mask[tid.x]) { |
| 23 | + Out4[OutIdx] = WaveReadLaneFirst( v ); |
| 24 | + } |
| 25 | + } |
| 26 | + |
| 27 | + // constant folding case |
| 28 | + Out5[0] = WaveReadLaneFirst(int4(1,2,3,4)); |
| 29 | +} |
| 30 | + |
| 31 | + |
| 32 | +//--- pipeline.yaml |
| 33 | + |
| 34 | +--- |
| 35 | +Shaders: |
| 36 | + - Stage: Compute |
| 37 | + Entry: main |
| 38 | + DispatchSize: [1, 1, 1] |
| 39 | +Buffers: |
| 40 | + - Name: In |
| 41 | + Format: Int32 |
| 42 | + Stride: 16 |
| 43 | + # 1 value set, 1 mask, 128 threads, each thread supplies int4(tid, tid+1, tid+2, tid+3) |
| 44 | + Data: [ |
| 45 | + 0,1,2,3, 1,2,3,4, 2,3,4,5, 3,4,5,6, 4,5,6,7, 5,6,7,8, 6,7,8,9, 7,8,9,10, |
| 46 | + 8,9,10,11, 9,10,11,12, 10,11,12,13, 11,12,13,14, 12,13,14,15, 13,14,15,16, |
| 47 | + 14,15,16,17, 15,16,17,18, 16,17,18,19, 17,18,19,20, 18,19,20,21, 19,20,21,22, |
| 48 | + 20,21,22,23, 21,22,23,24, 22,23,24,25, 23,24,25,26, 24,25,26,27, 25,26,27,28, |
| 49 | + 26,27,28,29, 27,28,29,30, 28,29,30,31, 29,30,31,32, 30,31,32,33, 31,32,33,34, |
| 50 | + 32,33,34,35, 33,34,35,36, 34,35,36,37, 35,36,37,38, 36,37,38,39, 37,38,39,40, |
| 51 | + 38,39,40,41, 39,40,41,42, 40,41,42,43, 41,42,43,44, 42,43,44,45, 43,44,45,46, |
| 52 | + 44,45,46,47, 45,46,47,48, 46,47,48,49, 47,48,49,50, 48,49,50,51, 49,50,51,52, |
| 53 | + 50,51,52,53, 51,52,53,54, 52,53,54,55, 53,54,55,56, 54,55,56,57, 55,56,57,58, |
| 54 | + 56,57,58,59, 57,58,59,60, 58,59,60,61, 59,60,61,62, 60,61,62,63, 61,62,63,64, |
| 55 | + 62,63,64,65, 63,64,65,66, 64,65,66,67, 65,66,67,68, 66,67,68,69, 67,68,69,70, |
| 56 | + 68,69,70,71, 69,70,71,72, 70,71,72,73, 71,72,73,74, 72,73,74,75, 73,74,75,76, |
| 57 | + 74,75,76,77, 75,76,77,78, 76,77,78,79, 77,78,79,80, 78,79,80,81, 79,80,81,82, |
| 58 | + 80,81,82,83, 81,82,83,84, 82,83,84,85, 83,84,85,86, 84,85,86,87, 85,86,87,88, |
| 59 | + 86,87,88,89, 87,88,89,90, 88,89,90,91, 89,90,91,92, 90,91,92,93, 91,92,93,94, |
| 60 | + 92,93,94,95, 93,94,95,96, 94,95,96,97, 95,96,97,98, 96,97,98,99, 97,98,99,100, |
| 61 | + 98,99,100,101, 99,100,101,102, 100,101,102,103, 101,102,103,104, 102,103,104,105, |
| 62 | + 103,104,105,106, 104,105,106,107, 105,106,107,108, 106,107,108,109, 107,108,109,110, |
| 63 | + 108,109,110,111, 109,110,111,112, 110,111,112,113, 111,112,113,114, 112,113,114,115, |
| 64 | + 113,114,115,116, 114,115,116,117, 115,116,117,118, 116,117,118,119, 117,118,119,120, |
| 65 | + 118,119,120,121, 119,120,121,122, 120,121,122,123, 121,122,123,124, 122,123,124,125, |
| 66 | + 123,124,125,126, 124,125,126,127, 125,126,127,128, 126,127,128,129, 127,128,129,130 |
| 67 | + ] |
| 68 | + |
| 69 | + - Name: Out4 |
| 70 | + Format: Int32 |
| 71 | + Stride: 16 |
| 72 | + FillSize: 2048 |
| 73 | + - Name: Out5 |
| 74 | + Format: Int32 |
| 75 | + Stride: 16 |
| 76 | + FillSize: 16 |
| 77 | + - Name: Masks |
| 78 | + Format: Int32 |
| 79 | + Stride: 16 |
| 80 | + Data: [ |
| 81 | + 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, |
| 82 | + 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, |
| 83 | + 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, |
| 84 | + 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0 ] |
| 85 | + |
| 86 | + - Name: ExpectedOut4 |
| 87 | + Format: Int32 |
| 88 | + Stride: 16 |
| 89 | + Data: [ 0,0,0,0, 1,2,3,4, 1,2,3,4, 0,0,0,0, 0,0,0,0, 1,2,3,4, 1,2,3,4, 0,0,0,0, 0,0,0,0, 1,2,3,4, 1,2,3,4, 0,0,0,0, 0,0,0,0, 1,2,3,4, 1,2,3,4, 0,0,0,0, 0,0,0,0, 1,2,3,4, 1,2,3,4, 0,0,0,0, 0,0,0,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95 | + Format: Int32 |
| 96 | + Stride: 8 |
| 97 | + Data: [ 1, 2, 3, 4 ] |
| 98 | +Results: |
| 99 | + - Result: ExpectedOut4 |
| 100 | + Rule: BufferExact |
| 101 | + Actual: Out4 |
| 102 | + Expected: ExpectedOut4 |
| 103 | + - Result: ExpectedOut5 |
| 104 | + Rule: BufferExact |
| 105 | + Actual: Out5 |
| 106 | + Expected: ExpectedOut5 |
| 107 | +DescriptorSets: |
| 108 | + - Resources: |
| 109 | + - Name: In |
| 110 | + Kind: StructuredBuffer |
| 111 | + DirectXBinding: |
| 112 | + Register: 0 |
| 113 | + Space: 0 |
| 114 | + VulkanBinding: |
| 115 | + Binding: 0 |
| 116 | + - Name: Out4 |
| 117 | + Kind: RWStructuredBuffer |
| 118 | + DirectXBinding: |
| 119 | + Register: 4 |
| 120 | + Space: 0 |
| 121 | + VulkanBinding: |
| 122 | + Binding: 4 |
| 123 | + - Name: Out5 |
| 124 | + Kind: RWStructuredBuffer |
| 125 | + DirectXBinding: |
| 126 | + Register: 5 |
| 127 | + Space: 0 |
| 128 | + VulkanBinding: |
| 129 | + Binding: 5 |
| 130 | + - Name: Masks |
| 131 | + Kind: StructuredBuffer |
| 132 | + DirectXBinding: |
| 133 | + Register: 6 |
| 134 | + Space: 0 |
| 135 | + VulkanBinding: |
| 136 | + Binding: 6 |
| 137 | + |
| 138 | +... |
| 139 | +#--- end |
| 140 | + |
| 141 | +# Bug https://github.com/llvm/llvm-project/issues/156775 |
| 142 | +# XFAIL: Clang |
| 143 | + |
| 144 | +# Bug https://github.com/llvm/offload-test-suite/issues/393 |
| 145 | +# XFAIL: Metal |
| 146 | + |
| 147 | +# RUN: split-file %s %t |
| 148 | +# RUN: %dxc_target -T cs_6_5 -Fo %t.o %t/source.hlsl |
| 149 | +# RUN: %offloader %t/pipeline.yaml %t.o |
0 commit comments