Skip to content

Commit 4a31231

Browse files
authored
add test for asint (#276)
Adds a test for asint testing int, uint, and float types. Closes #169
1 parent ba7565f commit 4a31231

File tree

1 file changed

+141
-0
lines changed

1 file changed

+141
-0
lines changed

test/Feature/HLSLLib/asint.test

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
#--- source.hlsl
2+
3+
StructuredBuffer<int4> In1 : register(t0);
4+
StructuredBuffer<uint4> In2 : register(t1);
5+
StructuredBuffer<float4> In3 : register(t2);
6+
RWStructuredBuffer<int4> Out1 : register(u3);
7+
RWStructuredBuffer<int4> Out2 : register(u4);
8+
RWStructuredBuffer<int4> Out3 : register(u5);
9+
10+
[numthreads(1,1,1)]
11+
void main() {
12+
// int
13+
Out1[0] = asint(int4(-1, 2, 0, 2147483647));
14+
Out1[1] = asint(In1[0]);
15+
int4 Tmp = {asint(In1[0].xyz), asint(In1[0].w)};
16+
Out1[2] = Tmp;
17+
Out1[3].xy = asint(In1[0].xy);
18+
19+
// uint
20+
Out2[0] = asint(uint4(2147483648, 0, 0xffffffff, 100));
21+
Out2[1] = asint(In2[0]);
22+
int4 Tmp2 = {asint(In2[0].xyz), asint(In2[0].w)};
23+
Out2[2] = Tmp2;
24+
Out2[3].xy = asint(In2[0].xy);
25+
26+
// float
27+
Out3[0] = asint(float4(10, 0, 5.57, 111.111));
28+
Out3[1] = asint(In3[0]);
29+
int4 Tmp3 = {asint(In3[0].xyz), asint(In3[0].w)};
30+
Out3[2] = Tmp3;
31+
Out3[3].xy = asint(In3[0].xy);
32+
}
33+
34+
//--- pipeline.yaml
35+
36+
---
37+
Shaders:
38+
- Stage: Compute
39+
Entry: main
40+
DispatchSize: [1, 1, 1]
41+
Buffers:
42+
- Name: In1
43+
Format: Int32
44+
Stride: 16
45+
Data: [-1, 0, -2147483648, 2147483647]
46+
- Name: In2
47+
Format: UInt32
48+
Stride: 16
49+
Data: [0xffffffff, 0, 0x80000000, 0x7FFFFFFF]
50+
# uint max, 0, 2147483648 , 2147483647
51+
- Name: In3
52+
Format: Float32
53+
Stride: 16
54+
Data: [10, 0.5, 0, 11.125]
55+
- Name: Out1
56+
Format: Int32
57+
Stride: 16
58+
ZeroInitSize: 64
59+
- Name: ExpectedOut1 # The result we expect
60+
Format: Int32
61+
Stride: 16
62+
Data: [-1, 2, 0, 2147483647, -1, 0, -2147483648, 2147483647, -1, 0, -2147483648, 2147483647, -1, 0, 0, 0, ]
63+
- Name: Out2
64+
Format: Int32
65+
Stride: 16
66+
ZeroInitSize: 64
67+
- Name: ExpectedOut2 # The result we expect
68+
Format: Int32
69+
Stride: 16
70+
Data: [-2147483648, 0, -1, 100, -1, 0, -2147483648, 2147483647, -1, 0, -2147483648, 2147483647, -1, 0, 0, 0]
71+
- Name: Out3
72+
Format: Int32
73+
Stride: 16
74+
ZeroInitSize: 64
75+
- Name: ExpectedOut3 # The result we expect
76+
Format: Int32
77+
Stride: 16
78+
Data: [ 1092616192, 0, 1085422961, 1121859797, 1092616192, 1056964608, 0, 1093795840, 1092616192, 1056964608, 0, 1093795840, 1092616192, 1056964608, 0, 0 ]
79+
Results:
80+
- Result: Test1
81+
Rule: BufferExact
82+
Actual: Out1
83+
Expected: ExpectedOut1
84+
- Result: Test2
85+
Rule: BufferExact
86+
Actual: Out2
87+
Expected: ExpectedOut2
88+
- Result: Test3
89+
Rule: BufferExact
90+
Actual: Out3
91+
Expected: ExpectedOut3
92+
DescriptorSets:
93+
- Resources:
94+
- Name: In1
95+
Kind: StructuredBuffer
96+
DirectXBinding:
97+
Register: 0
98+
Space: 0
99+
VulkanBinding:
100+
Binding: 0
101+
- Name: In2
102+
Kind: StructuredBuffer
103+
DirectXBinding:
104+
Register: 1
105+
Space: 0
106+
VulkanBinding:
107+
Binding: 1
108+
- Name: In3
109+
Kind: StructuredBuffer
110+
DirectXBinding:
111+
Register: 2
112+
Space: 0
113+
VulkanBinding:
114+
Binding: 2
115+
- Name: Out1
116+
Kind: RWStructuredBuffer
117+
DirectXBinding:
118+
Register: 3
119+
Space: 0
120+
VulkanBinding:
121+
Binding: 3
122+
- Name: Out2
123+
Kind: RWStructuredBuffer
124+
DirectXBinding:
125+
Register: 4
126+
Space: 0
127+
VulkanBinding:
128+
Binding: 4
129+
- Name: Out3
130+
Kind: RWStructuredBuffer
131+
DirectXBinding:
132+
Register: 5
133+
Space: 0
134+
VulkanBinding:
135+
Binding: 5
136+
...
137+
#--- end
138+
139+
# RUN: split-file %s %t
140+
# RUN: %dxc_target -T cs_6_5 -Fo %t.o %t/source.hlsl
141+
# RUN: %offloader %t/pipeline.yaml %t.o

0 commit comments

Comments
 (0)