Skip to content

Commit d9e1ce9

Browse files
committed
remove obfuscation function. add matrix of row != col size
1 parent e683e20 commit d9e1ce9

File tree

3 files changed

+211
-11
lines changed

3 files changed

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

test/Basic/Matrix/matrix_single_subscript_basic.test

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ RWBuffer<int> Index : register(u1);
44
RWBuffer<int> Out : register(u2);
55
RWBuffer<int> Out2 : register(u3);
66

7-
int4 getMatrix(int4x4 M, int index) {
8-
return M[index];
9-
}
10-
117
[numthreads(1,1,1)]
128
void main() {
139
int4 A = int4(In[0], In[1], In[2], In[3]);
@@ -22,20 +18,18 @@ void main() {
2218
Mat[Index[3]] = D;
2319

2420
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]);
21+
Mat2[Index[3]] = Mat[Index[0]];
22+
Mat2[Index[2]] = Mat[Index[1]];
23+
Mat2[Index[1]] = Mat[Index[2]];
24+
Mat2[Index[0]] = Mat[Index[3]];
2925

3026
const uint COLS = 4;
3127
for(int i = 0; i < 16; i++) {
3228
uint row = i / COLS;
3329
uint col = i % COLS;
3430
Out[i] = Mat[row][col];
3531
Out2[i] = Mat2[row][col];
36-
}
37-
38-
32+
}
3933
}
4034
//--- pipeline.yaml
4135

0 commit comments

Comments
 (0)