|
| 1 | +#--- source.hlsl |
| 2 | +RWBuffer<int> In : register(u0); |
| 3 | +RWBuffer<int> Index : register(u1); |
| 4 | +RWBuffer<int> Out : register(u2); |
| 5 | +RWBuffer<int> Out2 : register(u3); |
| 6 | + |
| 7 | +int4 getMatrix(int4x4 M, int index) { |
| 8 | + return M[index]; |
| 9 | +} |
| 10 | + |
| 11 | +[numthreads(1,1,1)] |
| 12 | +void main() { |
| 13 | + int4 A = int4(In[0], In[1], In[2], In[3]); |
| 14 | + int4 B = int4(In[4], In[5], In[6], In[7]); |
| 15 | + int4 C = int4(In[8], In[9], In[10], In[11]); |
| 16 | + int4 D = int4(In[12], In[13], In[14], In[15]); |
| 17 | + |
| 18 | + int4x4 Mat; |
| 19 | + Mat[Index[0]] = A; |
| 20 | + Mat[Index[1]] = B; |
| 21 | + Mat[Index[2]] = C; |
| 22 | + Mat[Index[3]] = D; |
| 23 | + |
| 24 | + int4x4 Mat2; |
| 25 | + Mat2[Index[3]] = getMatrix(Mat, Index[0]); |
| 26 | + Mat2[Index[2]] = getMatrix(Mat, Index[1]); |
| 27 | + Mat2[Index[1]] = getMatrix(Mat, Index[2]); |
| 28 | + Mat2[Index[0]] = getMatrix(Mat, Index[3]); |
| 29 | + |
| 30 | + const uint COLS = 4; |
| 31 | + for(int i = 0; i < 16; i++) { |
| 32 | + uint row = i / COLS; |
| 33 | + uint col = i % COLS; |
| 34 | + Out[i] = Mat[row][col]; |
| 35 | + Out2[i] = Mat2[row][col]; |
| 36 | + } |
| 37 | + |
| 38 | + |
| 39 | +} |
| 40 | +//--- pipeline.yaml |
| 41 | + |
| 42 | +--- |
| 43 | +Shaders: |
| 44 | + - Stage: Compute |
| 45 | + Entry: main |
| 46 | + DispatchSize: [1, 1, 1] |
| 47 | +Buffers: |
| 48 | + - Name: In |
| 49 | + Format: Int32 |
| 50 | + Data: [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16] |
| 51 | + - Name: Index |
| 52 | + Format: Int32 |
| 53 | + Data: [ 2, 0, 3, 1 ] |
| 54 | + - Name: Out |
| 55 | + Format: Int32 |
| 56 | + FillSize: 64 |
| 57 | + - Name: ExpectedOut |
| 58 | + Format: Int32 |
| 59 | + Data: [ 5, 6, 7, 8, 13, 14, 15, 16, 1, 2, 3, 4, 9, 10, 11, 12] |
| 60 | + - Name: Out2 |
| 61 | + Format: Int32 |
| 62 | + FillSize: 64 |
| 63 | + - Name: ExpectedOut2 |
| 64 | + Format: Int32 |
| 65 | + Data: [ 9, 10, 11, 12, 1, 2, 3, 4, 13, 14, 15, 16, 5, 6, 7, 8] |
| 66 | +Results: |
| 67 | + - Result: Out |
| 68 | + Rule: BufferExact |
| 69 | + Actual: Out |
| 70 | + Expected: ExpectedOut |
| 71 | + - Result: Out2 |
| 72 | + Rule: BufferExact |
| 73 | + Actual: Out2 |
| 74 | + Expected: ExpectedOut2 |
| 75 | +DescriptorSets: |
| 76 | + - Resources: |
| 77 | + - Name: In |
| 78 | + Kind: RWBuffer |
| 79 | + DirectXBinding: |
| 80 | + Register: 0 |
| 81 | + Space: 0 |
| 82 | + VulkanBinding: |
| 83 | + Binding: 0 |
| 84 | + - Name: Index |
| 85 | + Kind: RWBuffer |
| 86 | + DirectXBinding: |
| 87 | + Register: 1 |
| 88 | + Space: 0 |
| 89 | + VulkanBinding: |
| 90 | + Binding: 1 |
| 91 | + - Name: Out |
| 92 | + Kind: RWBuffer |
| 93 | + DirectXBinding: |
| 94 | + Register: 2 |
| 95 | + Space: 0 |
| 96 | + VulkanBinding: |
| 97 | + Binding: 2 |
| 98 | + - Name: Out2 |
| 99 | + Kind: RWBuffer |
| 100 | + DirectXBinding: |
| 101 | + Register: 3 |
| 102 | + Space: 0 |
| 103 | + VulkanBinding: |
| 104 | + Binding: 3 |
| 105 | +... |
| 106 | +#--- end |
| 107 | + |
| 108 | +# Unimplemented: https://github.com/llvm/llvm-project/issues/170534 |
| 109 | +# XFAIL: Vulkan && Clang |
| 110 | + |
| 111 | +# RUN: split-file %s %t |
| 112 | +# RUN: %dxc_target -T cs_6_0 -Fo %t.o %t/source.hlsl |
| 113 | +# RUN: %offloader %t/pipeline.yaml %t.o |
0 commit comments