Skip to content

Commit adb0358

Browse files
committed
[Matrix] Add boolean operator tests
fixes #706 With the following PRs now merged - llvm/llvm-project#172384 - llvm/llvm-project#175809 - llvm/llvm-project#175245 - llvm/llvm-project#175633 We have a working base to test booleans on both DXC and Clang.
1 parent 2783ee8 commit adb0358

3 files changed

Lines changed: 451 additions & 0 deletions

File tree

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
#--- source.hlsl
2+
3+
RWStructuredBuffer<bool> In : register(u0);
4+
RWStructuredBuffer<bool> AndTrueTrueOut : register(u1);
5+
RWStructuredBuffer<bool> AndTrueFalseOut : register(u2);
6+
RWStructuredBuffer<bool> AndTrueMixOut : register(u3);
7+
RWStructuredBuffer<bool> AndTrueMix2Out : register(u4);
8+
9+
[numthreads(1,1,1)]
10+
void main() {
11+
bool2x3 MatFalse = bool2x3(In[0], In[1], In[2],
12+
In[0], In[1], In[2]);
13+
bool2x3 MatTrue = bool2x3(In[3], In[4], In[5],
14+
In[3], In[4], In[5]);
15+
bool2x3 MatMix = bool2x3(In[0], In[1], In[2],
16+
In[3], In[4], In[5]);
17+
bool2x3 MatMix2 = bool2x3(In[3], In[4], In[5],
18+
In[0], In[1], In[2]);
19+
20+
bool2x3 MatAndTrueTrue = and(MatTrue,MatTrue);
21+
bool2x3 MatAndTrueFalse = and(MatTrue,MatFalse);
22+
bool2x3 MatAndTrueMix1 = and(MatTrue,MatMix);
23+
bool2x3 MatAndTrueMix2 = and(MatTrue,MatMix2);
24+
25+
const uint COLS = 3; // bool2x3 => 2 rows, 3 columns
26+
for(uint i = 0; i < 6; i++) {
27+
uint row = i / COLS;
28+
uint col = i % COLS;
29+
AndTrueTrueOut[i] = MatAndTrueTrue[row][col];
30+
AndTrueFalseOut[i] = MatAndTrueFalse[row][col];
31+
AndTrueMixOut[i] = MatAndTrueMix1[row][col];
32+
AndTrueMix2Out[i] = MatAndTrueMix2[row][col];
33+
}
34+
}
35+
36+
//--- pipeline.yaml
37+
38+
---
39+
Shaders:
40+
- Stage: Compute
41+
Entry: main
42+
DispatchSize: [1, 1, 1]
43+
Buffers:
44+
- Name: In
45+
Format: Int32
46+
Data: [ 0, 0, 0, 1, 1, 1 ]
47+
- Name: AndTrueTrueOut
48+
Format: Int32
49+
FillSize: 24
50+
- Name: AndTrueTrueExpectedOut
51+
Format: Int32
52+
Data: [ 1, 1, 1, 1, 1, 1 ]
53+
- Name: AndTrueFalseOut
54+
Format: Int32
55+
FillSize: 24
56+
- Name: AndTrueFalseExpectedOut
57+
Format: Int32
58+
Data: [ 0, 0, 0, 0, 0, 0 ]
59+
- Name: AndTrueMixOut
60+
Format: Int32
61+
FillSize: 24
62+
- Name: AndTrueMixExpectedOut
63+
Format: Int32
64+
Data: [ 0, 0, 0, 1, 1, 1 ]
65+
- Name: AndTrueMix2Out
66+
Format: Int32
67+
FillSize: 24
68+
- Name: AndTrueMix2ExpectedOut
69+
Format: Int32
70+
Data: [ 1, 1, 1, 0, 0, 0 ]
71+
Results:
72+
- Result: AndTrueTrueOut
73+
Rule: BufferExact
74+
Actual: AndTrueTrueOut
75+
Expected: AndTrueTrueExpectedOut
76+
- Result: AndTrueFalseOut
77+
Rule: BufferExact
78+
Actual: AndTrueFalseOut
79+
Expected: AndTrueFalseExpectedOut
80+
- Result: AndTrueMixOut
81+
Rule: BufferExact
82+
Actual: AndTrueMixOut
83+
Expected: AndTrueMixExpectedOut
84+
- Result: AndTrueMix2Out
85+
Rule: BufferExact
86+
Actual: AndTrueMix2Out
87+
Expected: AndTrueMix2ExpectedOut
88+
DescriptorSets:
89+
- Resources:
90+
- Name: In
91+
Kind: RWBuffer
92+
DirectXBinding:
93+
Register: 0
94+
Space: 0
95+
VulkanBinding:
96+
Binding: 0
97+
- Name: AndTrueTrueOut
98+
Kind: RWBuffer
99+
DirectXBinding:
100+
Register: 1
101+
Space: 0
102+
VulkanBinding:
103+
Binding: 1
104+
- Name: AndTrueFalseOut
105+
Kind: RWBuffer
106+
DirectXBinding:
107+
Register: 2
108+
Space: 0
109+
VulkanBinding:
110+
Binding: 2
111+
- Name: AndTrueMixOut
112+
Kind: RWBuffer
113+
DirectXBinding:
114+
Register: 3
115+
Space: 0
116+
VulkanBinding:
117+
Binding: 3
118+
- Name: AndTrueMix2Out
119+
Kind: RWBuffer
120+
DirectXBinding:
121+
Register: 4
122+
Space: 0
123+
VulkanBinding:
124+
Binding: 4
125+
...
126+
#--- end
127+
128+
# Bug https://github.com/microsoft/DirectXShaderCompiler/issues/8129
129+
# XFAIL: DXC && Vulkan
130+
131+
# Bug https://github.com/llvm/offload-test-suite/issues/703
132+
# XFAIL: Clang && NV && Vulkan
133+
134+
# Bug https://github.com/llvm/offload-test-suite/issues/704
135+
# XFAIL: Clang && Intel && Vulkan
136+
137+
# Note: Metal does not support boolean matrix types. For
138+
# Vulkan KosmicKrisp and MoltenVK the output is always False.
139+
# UNSUPPORTED: Darwin
140+
141+
# RUN: split-file %s %t
142+
# RUN: %dxc_target -T cs_6_0 -Fo %t.o %t/source.hlsl
143+
# RUN: %offloader %t/pipeline.yaml %t.o
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
#--- source.hlsl
2+
3+
RWStructuredBuffer<bool> In : register(u0);
4+
RWStructuredBuffer<bool> AndTrueTrueOut : register(u1);
5+
RWStructuredBuffer<bool> AndTrueFalseOut : register(u2);
6+
RWStructuredBuffer<bool> AndTrueMixOut : register(u3);
7+
RWStructuredBuffer<bool> AndTrueMix2Out : register(u4);
8+
9+
[numthreads(6,1,1)]
10+
void main(uint GI : SV_GroupIndex) {
11+
bool2x3 MatFalse = bool2x3(In[0], In[1], In[2],
12+
In[0], In[1], In[2]);
13+
bool2x3 MatTrue = bool2x3(In[3], In[4], In[5],
14+
In[3], In[4], In[5]);
15+
bool2x3 MatMix = bool2x3(In[0], In[1], In[2],
16+
In[3], In[4], In[5]);
17+
bool2x3 MatMix2 = bool2x3(In[3], In[4], In[5],
18+
In[0], In[1], In[2]);
19+
20+
const uint COLS = 3; // bool2x3 => 2 rows, 3 columns
21+
uint row = GI / COLS; // 0..1
22+
uint col = GI % COLS; // 0..2
23+
24+
bool2x3 MatAndTrueTrue = and(MatTrue,MatTrue);
25+
bool2x3 MatAndTrueFalse = and(MatTrue,MatFalse);
26+
bool2x3 MatAndTrueMix1 = and(MatTrue,MatMix);
27+
bool2x3 MatAndTrueMix2 = and(MatTrue,MatMix2);
28+
29+
AndTrueTrueOut[GI] = MatAndTrueTrue[row][col];
30+
AndTrueFalseOut[GI] = MatAndTrueFalse[row][col];
31+
AndTrueMixOut[GI] = MatAndTrueMix1[row][col];
32+
AndTrueMix2Out[GI] = MatAndTrueMix2[row][col];
33+
}
34+
35+
//--- pipeline.yaml
36+
37+
---
38+
Shaders:
39+
- Stage: Compute
40+
Entry: main
41+
DispatchSize: [1, 1, 1]
42+
Buffers:
43+
- Name: In
44+
Format: Int32
45+
Data: [ 0, 0, 0, 1, 1, 1 ]
46+
- Name: AndTrueTrueOut
47+
Format: Int32
48+
FillSize: 24
49+
- Name: AndTrueTrueExpectedOut
50+
Format: Int32
51+
Data: [ 1, 1, 1, 1, 1, 1 ]
52+
- Name: AndTrueFalseOut
53+
Format: Int32
54+
FillSize: 24
55+
- Name: AndTrueFalseExpectedOut
56+
Format: Int32
57+
Data: [ 0, 0, 0, 0, 0, 0 ]
58+
- Name: AndTrueMixOut
59+
Format: Int32
60+
FillSize: 24
61+
- Name: AndTrueMixExpectedOut
62+
Format: Int32
63+
Data: [ 0, 0, 0, 1, 1, 1 ]
64+
- Name: AndTrueMix2Out
65+
Format: Int32
66+
FillSize: 24
67+
- Name: AndTrueMix2ExpectedOut
68+
Format: Int32
69+
Data: [ 1, 1, 1, 0, 0, 0 ]
70+
Results:
71+
- Result: AndTrueTrueOut
72+
Rule: BufferExact
73+
Actual: AndTrueTrueOut
74+
Expected: AndTrueTrueExpectedOut
75+
- Result: AndTrueFalseOut
76+
Rule: BufferExact
77+
Actual: AndTrueFalseOut
78+
Expected: AndTrueFalseExpectedOut
79+
- Result: AndTrueMixOut
80+
Rule: BufferExact
81+
Actual: AndTrueMixOut
82+
Expected: AndTrueMixExpectedOut
83+
- Result: AndTrueMix2Out
84+
Rule: BufferExact
85+
Actual: AndTrueMix2Out
86+
Expected: AndTrueMix2ExpectedOut
87+
DescriptorSets:
88+
- Resources:
89+
- Name: In
90+
Kind: RWBuffer
91+
DirectXBinding:
92+
Register: 0
93+
Space: 0
94+
VulkanBinding:
95+
Binding: 0
96+
- Name: AndTrueTrueOut
97+
Kind: RWBuffer
98+
DirectXBinding:
99+
Register: 1
100+
Space: 0
101+
VulkanBinding:
102+
Binding: 1
103+
- Name: AndTrueFalseOut
104+
Kind: RWBuffer
105+
DirectXBinding:
106+
Register: 2
107+
Space: 0
108+
VulkanBinding:
109+
Binding: 2
110+
- Name: AndTrueMixOut
111+
Kind: RWBuffer
112+
DirectXBinding:
113+
Register: 3
114+
Space: 0
115+
VulkanBinding:
116+
Binding: 3
117+
- Name: AndTrueMix2Out
118+
Kind: RWBuffer
119+
DirectXBinding:
120+
Register: 4
121+
Space: 0
122+
VulkanBinding:
123+
Binding: 4
124+
...
125+
#--- end
126+
127+
# Bug https://github.com/microsoft/DirectXShaderCompiler/issues/8129
128+
# XFAIL: DXC && Vulkan
129+
130+
# Bug https://github.com/llvm/offload-test-suite/issues/703
131+
# XFAIL: Clang && NV && Vulkan
132+
133+
# Bug https://github.com/llvm/offload-test-suite/issues/704
134+
# XFAIL: Clang && Intel && Vulkan
135+
136+
Bug https://github.com/llvm/offload-test-suite/issues/705
137+
# XFAIL: Clang && NV && DirectX
138+
139+
# Note: Metal does not support boolean matrix types. For
140+
# Vulkan KosmicKrisp and MoltenVK the output is always False.
141+
# UNSUPPORTED: Darwin
142+
143+
# RUN: split-file %s %t
144+
# RUN: %dxc_target -T cs_6_0 -Fo %t.o %t/source.hlsl
145+
# RUN: %offloader %t/pipeline.yaml %t.o

0 commit comments

Comments
 (0)