-
Notifications
You must be signed in to change notification settings - Fork 27
[Matrix] Add basic single subscript tests #631
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
farzonl
merged 4 commits into
llvm:main
from
farzonl:task/single-subscript-basic-issue-630
Dec 20, 2025
+493
−1
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
e683e20
[Matrix] Add basic single subscript tests
farzonl d9e1ce9
remove obfuscation function. add matrix of row != col size
farzonl 8202a1f
Add bug comments. Add i2x3 const swizzle test
farzonl bb6aab0
Address pr comments use both indices.
farzonl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
104 changes: 104 additions & 0 deletions
104
test/Basic/Matrix/matrix_const_single_subscript.i2x3.test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| #--- source.hlsl | ||
| RWBuffer<int> In : register(u0); | ||
| RWBuffer<int> Index : register(u1); | ||
| RWBuffer<int> Out : register(u2); | ||
| RWBuffer<int> Out2 : register(u3); | ||
|
|
||
| [numthreads(1,1,1)] | ||
| void main() { | ||
| int3 A = int3(In[0], In[1], In[2]); | ||
| int3 B = int3(In[3], In[4], In[5]); | ||
|
|
||
| int2x3 Mat; | ||
| Mat[1].xzy = A; | ||
| Mat[0] = B.zyx; | ||
|
|
||
| int2x3 Mat2; | ||
| Mat2[Index[0]] = Mat[1].yzx; | ||
| Mat2[0].zxy = Mat[Index[1]]; | ||
|
|
||
| const uint COLS = 3; | ||
| for(uint i = 0; i < 6; i++) { | ||
| uint row = i / COLS; | ||
| uint col = i % COLS; | ||
| Out[i] = Mat[row][col]; | ||
| Out2[i] = Mat2[row][col]; | ||
| } | ||
| } | ||
| //--- pipeline.yaml | ||
|
|
||
| --- | ||
| Shaders: | ||
| - Stage: Compute | ||
| Entry: main | ||
| DispatchSize: [1, 1, 1] | ||
| Buffers: | ||
| - Name: In | ||
| Format: Int32 | ||
| Data: [ 1, 2, 3, 4, 5, 6] | ||
| - Name: Index | ||
| Format: Int32 | ||
| Data: [ 1, 0] | ||
| - Name: Out | ||
| Format: Int32 | ||
| FillSize: 24 | ||
| - Name: ExpectedOut | ||
| Format: Int32 | ||
| Data: [ 6, 5, 4, 1, 3, 2 ] | ||
| - Name: Out2 | ||
| Format: Int32 | ||
| FillSize: 24 | ||
| - Name: ExpectedOut2 | ||
| Format: Int32 | ||
| Data: [ 5, 4, 6, 3, 2, 1 ] | ||
| Results: | ||
| - Result: Out | ||
| Rule: BufferExact | ||
| Actual: Out | ||
| Expected: ExpectedOut | ||
| - Result: Out2 | ||
| Rule: BufferExact | ||
| Actual: Out2 | ||
| Expected: ExpectedOut2 | ||
| DescriptorSets: | ||
| - Resources: | ||
| - Name: In | ||
| Kind: RWBuffer | ||
| DirectXBinding: | ||
| Register: 0 | ||
| Space: 0 | ||
| VulkanBinding: | ||
| Binding: 0 | ||
| - Name: Index | ||
| Kind: RWBuffer | ||
| DirectXBinding: | ||
| Register: 1 | ||
| Space: 0 | ||
| VulkanBinding: | ||
| Binding: 1 | ||
| - Name: Out | ||
| Kind: RWBuffer | ||
| DirectXBinding: | ||
| Register: 2 | ||
| Space: 0 | ||
| VulkanBinding: | ||
| Binding: 2 | ||
| - Name: Out2 | ||
| Kind: RWBuffer | ||
| DirectXBinding: | ||
| Register: 3 | ||
| Space: 0 | ||
| VulkanBinding: | ||
| Binding: 3 | ||
| ... | ||
| #--- end | ||
|
|
||
| # Unimplemented: https://github.com/llvm/llvm-project/issues/170534 | ||
| # XFAIL: Vulkan && Clang | ||
|
|
||
| # Bug: https://github.com/llvm/llvm-project/issues/172805 | ||
| # XFAIL: Clang | ||
|
|
||
| # RUN: split-file %s %t | ||
| # RUN: %dxc_target -T cs_6_0 -Fo %t.o %t/source.hlsl | ||
| # RUN: %offloader %t/pipeline.yaml %t.o | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| #--- source.hlsl | ||
| RWBuffer<int> In : register(u0); | ||
| RWBuffer<int> Out : register(u1); | ||
|
|
||
| [numthreads(1,1,1)] | ||
| void main() { | ||
| int4x4 A = int4x4(In[0], In[1], In[2], In[3], | ||
| In[4], In[5], In[6], In[7], | ||
| In[8], In[9], In[10], In[11], | ||
| In[12], In[13], In[14], In[15]); | ||
| int4x4 B; | ||
|
|
||
| B[0] = A[3]; | ||
| B[1].rbag = A[1]; | ||
| B[2] = A[2].bagr; | ||
| B[3] = A[0]; | ||
|
|
||
| const uint COLS = 4; | ||
| for(int i = 0; i < 16; i++) { | ||
| uint row = i / COLS; | ||
| uint col = i % COLS; | ||
| Out[i] = B[row][col]; | ||
| } | ||
| } | ||
| //--- pipeline.yaml | ||
|
|
||
| --- | ||
| Shaders: | ||
| - Stage: Compute | ||
| Entry: main | ||
| DispatchSize: [1, 1, 1] | ||
| Buffers: | ||
| - Name: In | ||
| Format: Int32 | ||
| Data: [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16] | ||
| - Name: Out | ||
| Format: Int32 | ||
| FillSize: 64 | ||
| - Name: ExpectedOut | ||
| Format: Int32 | ||
| Data: [ 13, 14, 15, 16, 5, 8, 6, 7, 11, 12, 10, 9, 1, 2, 3, 4 ] | ||
| Results: | ||
| - Result: Out | ||
| Rule: BufferExact | ||
| Actual: Out | ||
| Expected: ExpectedOut | ||
| DescriptorSets: | ||
| - Resources: | ||
| - Name: In | ||
| Kind: RWBuffer | ||
| DirectXBinding: | ||
| Register: 0 | ||
| Space: 0 | ||
| VulkanBinding: | ||
| Binding: 0 | ||
| - Name: Out | ||
| Kind: RWBuffer | ||
| DirectXBinding: | ||
| Register: 1 | ||
| Space: 0 | ||
| VulkanBinding: | ||
| Binding: 1 | ||
| ... | ||
| #--- end | ||
|
|
||
| # Unimplemented: https://github.com/llvm/llvm-project/issues/170534 | ||
| # XFAIL: Vulkan && Clang | ||
|
|
||
| # Bug: https://github.com/llvm/llvm-project/issues/172805 | ||
| # XFAIL: Clang | ||
|
|
||
| # RUN: split-file %s %t | ||
| # RUN: %dxc_target -T cs_6_0 -Fo %t.o %t/source.hlsl | ||
| # RUN: %offloader %t/pipeline.yaml %t.o |
101 changes: 101 additions & 0 deletions
101
test/Basic/Matrix/matrix_single_subscript_basic.i2x3.test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| #--- source.hlsl | ||
| RWBuffer<int> In : register(u0); | ||
| RWBuffer<int> Index : register(u1); | ||
| RWBuffer<int> Out : register(u2); | ||
| RWBuffer<int> Out2 : register(u3); | ||
|
|
||
| [numthreads(1,1,1)] | ||
| void main() { | ||
| int3 A = int3(In[0], In[1], In[2]); | ||
| int3 B = int3(In[3], In[4], In[5]); | ||
|
|
||
| int2x3 Mat; | ||
| Mat[Index[0]] = A; | ||
| Mat[Index[1]] = B; | ||
|
|
||
| int2x3 Mat2; | ||
| Mat2[Index[1]] = Mat[Index[0]]; | ||
| Mat2[Index[0]] = Mat[Index[1]]; | ||
|
|
||
| const uint COLS = 3; | ||
| for(uint i = 0; i < 6; i++) { | ||
| uint row = i / COLS; | ||
| uint col = i % COLS; | ||
| Out[i] = Mat[row][col]; | ||
| Out2[i] = Mat2[row][col]; | ||
| } | ||
| } | ||
| //--- pipeline.yaml | ||
|
|
||
| --- | ||
| Shaders: | ||
| - Stage: Compute | ||
| Entry: main | ||
| DispatchSize: [1, 1, 1] | ||
| Buffers: | ||
| - Name: In | ||
| Format: Int32 | ||
| Data: [ 1, 2, 3, 4, 5, 6] | ||
| - Name: Index | ||
| Format: Int32 | ||
| Data: [ 1, 0] | ||
| - Name: Out | ||
| Format: Int32 | ||
| FillSize: 24 | ||
| - Name: ExpectedOut | ||
| Format: Int32 | ||
| Data: [ 4, 5, 6, 1, 2, 3] | ||
| - Name: Out2 | ||
| Format: Int32 | ||
| FillSize: 24 | ||
| - Name: ExpectedOut2 | ||
| Format: Int32 | ||
| Data: [ 1, 2, 3, 4, 5, 6] | ||
| Results: | ||
| - Result: Out | ||
| Rule: BufferExact | ||
| Actual: Out | ||
| Expected: ExpectedOut | ||
| - Result: Out2 | ||
| Rule: BufferExact | ||
| Actual: Out2 | ||
| Expected: ExpectedOut2 | ||
| DescriptorSets: | ||
| - Resources: | ||
| - Name: In | ||
| Kind: RWBuffer | ||
| DirectXBinding: | ||
| Register: 0 | ||
| Space: 0 | ||
| VulkanBinding: | ||
| Binding: 0 | ||
| - Name: Index | ||
| Kind: RWBuffer | ||
| DirectXBinding: | ||
| Register: 1 | ||
| Space: 0 | ||
| VulkanBinding: | ||
| Binding: 1 | ||
| - Name: Out | ||
| Kind: RWBuffer | ||
| DirectXBinding: | ||
| Register: 2 | ||
| Space: 0 | ||
| VulkanBinding: | ||
| Binding: 2 | ||
| - Name: Out2 | ||
| Kind: RWBuffer | ||
| DirectXBinding: | ||
| Register: 3 | ||
| Space: 0 | ||
| VulkanBinding: | ||
| Binding: 3 | ||
| ... | ||
| #--- end | ||
|
|
||
| # Unimplemented: https://github.com/llvm/llvm-project/issues/170534 | ||
| # XFAIL: Vulkan && Clang | ||
|
|
||
| # RUN: split-file %s %t | ||
| # RUN: %dxc_target -T cs_6_0 -Fo %t.o %t/source.hlsl | ||
| # RUN: %offloader %t/pipeline.yaml %t.o |
105 changes: 105 additions & 0 deletions
105
test/Basic/Matrix/matrix_single_subscript_basic.i3x2.test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| #--- source.hlsl | ||
| RWBuffer<int> In : register(u0); | ||
| RWBuffer<int> Index : register(u1); | ||
| RWBuffer<int> Out : register(u2); | ||
| RWBuffer<int> Out2 : register(u3); | ||
|
|
||
| [numthreads(1,1,1)] | ||
| void main() { | ||
| int2 A = int2(In[0], In[1]); | ||
| int2 B = int2(In[2], In[3]); | ||
| int2 C = int2(In[4], In[5]); | ||
|
|
||
| int3x2 Mat; | ||
| Mat[Index[0]] = A; | ||
| Mat[Index[1]] = B; | ||
| Mat[Index[2]] = C; | ||
|
|
||
| int3x2 Mat2; | ||
| Mat2[Index[2]] = Mat[Index[0]]; | ||
| Mat2[Index[1]] = Mat[Index[1]]; | ||
| Mat2[Index[0]] = Mat[Index[2]]; | ||
|
|
||
|
|
||
| const uint COLS = 2; | ||
| for(uint i = 0; i < 6; i++) { | ||
| uint row = i / COLS; | ||
| uint col = i % COLS; | ||
| Out[i] = Mat[row][col]; | ||
| Out2[i] = Mat2[row][col]; | ||
| } | ||
| } | ||
| //--- pipeline.yaml | ||
|
|
||
| --- | ||
| Shaders: | ||
| - Stage: Compute | ||
| Entry: main | ||
| DispatchSize: [1, 1, 1] | ||
| Buffers: | ||
| - Name: In | ||
| Format: Int32 | ||
| Data: [ 1, 2, 3, 4, 5, 6] | ||
| - Name: Index | ||
| Format: Int32 | ||
| Data: [ 1, 0, 2] | ||
| - Name: Out | ||
| Format: Int32 | ||
| FillSize: 24 | ||
| - Name: ExpectedOut | ||
| Format: Int32 | ||
| Data: [ 3, 4, 1, 2, 5, 6] | ||
| - Name: Out2 | ||
| Format: Int32 | ||
| FillSize: 24 | ||
| - Name: ExpectedOut2 | ||
| Format: Int32 | ||
| Data: [ 3, 4, 5, 6, 1, 2] | ||
| Results: | ||
| - Result: Out | ||
| Rule: BufferExact | ||
| Actual: Out | ||
| Expected: ExpectedOut | ||
| - Result: Out2 | ||
| Rule: BufferExact | ||
| Actual: Out2 | ||
| Expected: ExpectedOut2 | ||
| DescriptorSets: | ||
| - Resources: | ||
| - Name: In | ||
| Kind: RWBuffer | ||
| DirectXBinding: | ||
| Register: 0 | ||
| Space: 0 | ||
| VulkanBinding: | ||
| Binding: 0 | ||
| - Name: Index | ||
| Kind: RWBuffer | ||
| DirectXBinding: | ||
| Register: 1 | ||
| Space: 0 | ||
| VulkanBinding: | ||
| Binding: 1 | ||
| - Name: Out | ||
| Kind: RWBuffer | ||
| DirectXBinding: | ||
| Register: 2 | ||
| Space: 0 | ||
| VulkanBinding: | ||
| Binding: 2 | ||
| - Name: Out2 | ||
| Kind: RWBuffer | ||
| DirectXBinding: | ||
| Register: 3 | ||
| Space: 0 | ||
| VulkanBinding: | ||
| Binding: 3 | ||
| ... | ||
| #--- end | ||
|
|
||
| # Unimplemented: https://github.com/llvm/llvm-project/issues/170534 | ||
| # XFAIL: Vulkan && Clang | ||
|
|
||
| # RUN: split-file %s %t | ||
| # RUN: %dxc_target -T cs_6_0 -Fo %t.o %t/source.hlsl | ||
| # RUN: %offloader %t/pipeline.yaml %t.o |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.