1
+ // DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -shaderobj -output-using-type
2
+ // TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=DX11):-slang -compute -shaderobj -output-using-type -render-feature hardware-device
3
+ // TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=DX12):-slang -compute -dx12 -shaderobj -output-using-type
4
+ // TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=DX12CS6):-slang -compute -dx12 -profile cs_6_0 -use-dxil -shaderobj -output-using-type -xslang -DCS60
5
+ // TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=VK):-vk -emit-spirv-directly -compute -shaderobj -output-using-type -render-feature hardware-device -xslang -DVK
6
+ // DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -shaderobj -output-using-type
7
+
8
+ // TEST_INPUT: Texture1D(size=4, content = one):name t1D
9
+ Texture1D < float > t1D;
10
+ // TEST_INPUT: Texture2D(size=4, content = one):name t2D
11
+ Texture2D < float > t2D;
12
+ // TEST_INPUT: Texture3D(size=4, content = one):name t3D
13
+ Texture3D < float > t3D;
14
+ // TEST_INPUT: TextureCube(size=4, content = one):name tCube
15
+ TextureCube < float > tCube;
16
+
17
+ // TEST_INPUT: Texture1D(size=4, content = one, arrayLength=2):name t1DArray
18
+ Texture1DArray < float > t1DArray;
19
+ // TEST_INPUT: Texture2D(size=4, content = one, arrayLength=2):name t2DArray
20
+ Texture2DArray < float > t2DArray;
21
+ // TEST_INPUT: TextureCube(size=4, content = one, arrayLength=2):name tCubeArray
22
+ TextureCubeArray < float > tCubeArray;
23
+
24
+ // TEST_INPUT: Sampler:name samplerState
25
+ SamplerState samplerState;
26
+ // TEST_INPUT: Sampler:name shadowSampler
27
+ SamplerComparisonState shadowSampler;
28
+
29
+
30
+ // TEST_INPUT: ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer
31
+ RWStructuredBuffer < float > outputBuffer;
32
+
33
+ [numthreads(4 , 1 , 1 )]
34
+ void computeMain(int3 dispatchThreadID: SV_DispatchThreadID)
35
+ {
36
+ int idx = dispatchThreadID .x ;
37
+ float u = idx * (1 . 0 f / 4 );
38
+
39
+ float val = 0 . 0 f ;
40
+
41
+ uint width = 0 , height = 0 , depth = 0 ;
42
+ float fwidth = 0 . 0 f , fheight = 0 . 0 f , fdepth = 0 . 0 f ;
43
+ uint numLevels = 0 , elements = 0 ;
44
+ float fnumLevels = 0 . 0 f , felements = 0 . 0 f ;
45
+
46
+ /*
47
+ <Template Type> Object.SampleLevel()
48
+ */
49
+ val += t1D .SampleLevel (samplerState, u, 0 );
50
+ val += t2D .SampleLevel (samplerState, float2(u, u), 0 );
51
+ val += t3D .SampleLevel (samplerState, float3(u, u, u), 0 );
52
+ val += tCube .SampleLevel (samplerState, normalize(float3(u, 1 - u, u)), 0 );
53
+
54
+ val += t1DArray .SampleLevel (samplerState, float2(u, 0 ), 0 );
55
+ val += t2DArray .SampleLevel (samplerState, float3(u, u, 0 ), 0 );
56
+ val += tCubeArray .SampleLevel (samplerState, float4(u, u, u, 0 ), 0 );
57
+
58
+ // Offset variant
59
+ // NOTE: The "cpu" profile does not like these, so it's disabled for now
60
+ val += t1D .SampleLevel (samplerState, u, 0 , 1 );
61
+ val += t2D .SampleLevel (samplerState, float2(u, u), 0 , int2(1 , 1 ));
62
+ val += t3D .SampleLevel (samplerState, float3(u, u, u), 0 , int3(1 , 1 , 1 ));
63
+
64
+ val += t1DArray .SampleLevel (samplerState, float2(u, 0 ), 0 , 1 );
65
+ val += t2DArray .SampleLevel (samplerState, float3(u, u, 0 ), 0 , int2(1 , 1 ));
66
+
67
+ /*
68
+ float Object.SampleCmpLevelZero()
69
+ */
70
+ // NOTE: These are having issues with vulkan (glsl)
71
+ #ifndef VK
72
+ val += t1D .SampleCmpLevelZero (shadowSampler, u, 0 );
73
+ val += t2D .SampleCmpLevelZero (shadowSampler, float2(u, u), 0 );
74
+ val += tCube .SampleCmpLevelZero (shadowSampler, normalize(float3(u, 1 - u, u)), 0 );
75
+
76
+ // Offset variant
77
+ val += t1D .SampleCmpLevelZero (shadowSampler, u, 0 , 0 );
78
+ val += t2D .SampleCmpLevelZero (shadowSampler, float2(u, u), 0 , int2(0 , 0 ));
79
+ // TextureCube does not have an offset version of this
80
+ #endif
81
+
82
+ /*
83
+ void Object.GetDimensions()
84
+ */
85
+ t1D .GetDimensions (width);
86
+ val += width;
87
+
88
+ t1D .GetDimensions (fwidth);
89
+ val += fwidth;
90
+
91
+ t1D .GetDimensions (0 , width, numLevels);
92
+ val += width;
93
+ val += numLevels;
94
+
95
+ t1D .GetDimensions (0 , fwidth, fnumLevels);
96
+ val += fwidth;
97
+ val += fnumLevels;
98
+
99
+ t2D .GetDimensions (width, height);
100
+ val += width;
101
+ val += height;
102
+
103
+ t2D .GetDimensions (fwidth, fheight);
104
+ val += fwidth;
105
+ val += fheight;
106
+
107
+ t2D .GetDimensions (0 , width, height, numLevels);
108
+ val += width;
109
+ val += height;
110
+ val += numLevels;
111
+
112
+ t2D .GetDimensions (0 , fwidth, fheight, fnumLevels);
113
+ val += fwidth;
114
+ val += fheight;
115
+ val += fnumLevels;
116
+
117
+ t3D .GetDimensions (width, height, depth);
118
+ val += width;
119
+ val += height;
120
+ val += depth;
121
+
122
+ t3D .GetDimensions (fwidth, fheight, fdepth);
123
+ val += fwidth;
124
+ val += fheight;
125
+ val += fdepth;
126
+
127
+ t3D .GetDimensions (0 , width, height, depth, numLevels);
128
+ val += width;
129
+ val += height;
130
+ val += depth;
131
+ val += numLevels;
132
+
133
+ t3D .GetDimensions (0 , fwidth, fheight, fdepth, fnumLevels);
134
+ val += fwidth;
135
+ val += fheight;
136
+ val += fdepth;
137
+ val += fnumLevels;
138
+
139
+ tCube .GetDimensions (width, height);
140
+ val += width;
141
+ val += height;
142
+
143
+ tCube .GetDimensions (fwidth, fheight);
144
+ val += fwidth;
145
+ val += fheight;
146
+
147
+ tCube .GetDimensions (0 , width, height, numLevels);
148
+ val += width;
149
+ val += height;
150
+ val += numLevels;
151
+
152
+ tCube .GetDimensions (0 , fwidth, fheight, fnumLevels);
153
+ val += fwidth;
154
+ val += fheight;
155
+ val += fnumLevels;
156
+
157
+ t1DArray .GetDimensions (width, elements);
158
+ val += width;
159
+ val += elements;
160
+
161
+ t1DArray .GetDimensions (fwidth, felements);
162
+ val += fwidth;
163
+ val += felements;
164
+
165
+ t1DArray .GetDimensions (0 , width, elements, numLevels);
166
+ val += width;
167
+ val += elements;
168
+ val += numLevels;
169
+
170
+ t1DArray .GetDimensions (0 , fwidth, felements, fnumLevels);
171
+ val += fwidth;
172
+ val += felements;
173
+ val += fnumLevels;
174
+
175
+ t2DArray .GetDimensions (width, height, elements);
176
+ val += width;
177
+ val += height;
178
+ val += elements;
179
+
180
+ t2DArray .GetDimensions (fwidth, fheight, felements);
181
+ val += fwidth;
182
+ val += fheight;
183
+ val += felements;
184
+
185
+ t2DArray .GetDimensions (0 , width, height, elements, numLevels);
186
+ val += width;
187
+ val += height;
188
+ val += elements;
189
+ val += numLevels;
190
+
191
+ t2DArray .GetDimensions (0 , fwidth, fheight, felements, fnumLevels);
192
+ val += fwidth;
193
+ val += fheight;
194
+ val += felements;
195
+ val += fnumLevels;
196
+
197
+ tCubeArray .GetDimensions (width, height, elements);
198
+ val += width;
199
+ val += height;
200
+ val += elements;
201
+
202
+ // fxc 47.0: (95): error X4598: The array element count of GetDimensions on TextureCubeArray objects is unavailable on cs_5_0
203
+ #if defined (CS60 ) || defined (VK )
204
+ tCubeArray .GetDimensions (fwidth, fheight, felements);
205
+ val += fwidth;
206
+ val += fheight;
207
+ val += felements;
208
+ #endif
209
+
210
+ tCubeArray .GetDimensions (0 , width, height, elements, numLevels);
211
+ val += width;
212
+ val += height;
213
+ val += elements;
214
+ val += numLevels;
215
+
216
+ #if defined (CS60 ) || defined (VK )
217
+ tCubeArray .GetDimensions (0 , fwidth, fheight, felements, fnumLevels);
218
+ val += fwidth;
219
+ val += fheight;
220
+ val += felements;
221
+ val += fnumLevels;
222
+ #endif
223
+
224
+ /*
225
+ <Template Type>4 Object.Gather()
226
+ */
227
+ float4 f4 = t2D .Gather (samplerState, float2(u, u));
228
+ val += f4 .x ; val += f4 .y ; val += f4 .z ; val += f4 .w ;
229
+
230
+ f4 = tCube .Gather (samplerState, normalize(float3(u, 1 - u, u)));
231
+ val += f4 .x ; val += f4 .y ; val += f4 .z ; val += f4 .w ;
232
+
233
+ f4 = t2DArray .Gather (samplerState, float3(u, u, 0 ));
234
+ val += f4 .x ; val += f4 .y ; val += f4 .z ; val += f4 .w ;
235
+
236
+ f4 = tCubeArray .Gather (samplerState, float4(normalize(float3(u, 1 - u, u)), 0 ));
237
+ val += f4 .x ; val += f4 .y ; val += f4 .z ; val += f4 .w ;
238
+
239
+ // Offset variant
240
+ f4 = t2D .Gather (samplerState, float2(u, u), int2(0 , 0 ));
241
+ val += f4 .x ; val += f4 .y ; val += f4 .z ; val += f4 .w ;
242
+
243
+ f4 = t2DArray .Gather (samplerState, float3(u, u, 0 ), int2(0 , 0 ));
244
+ val += f4 .x ; val += f4 .y ; val += f4 .z ; val += f4 .w ;
245
+
246
+ /*
247
+ ret Object.Load()
248
+ */
249
+ val += t1D .Load (int2(0 , 0 ));
250
+ val += t2D .Load (int3(0 , 0 , 0 ));
251
+ val += t3D .Load (int4(0 , 0 , 0 , 0 ));
252
+
253
+ val += t1DArray .Load (int3(0 , 0 , 0 ));
254
+ val += t2DArray .Load (int4(0 , 0 , 0 , 0 ));
255
+
256
+ // Offset variant
257
+ val += t1D .Load (int2(0 , 0 ), 0 );
258
+ val += t2D .Load (int3(0 , 0 , 0 ), int2(0 ,0 ));
259
+ val += t3D .Load (int4(0 , 0 , 0 , 0 ), int3(0 , 0 , 0 ));
260
+
261
+ val += t1DArray .Load (int3(0 , 0 , 0 ), 0 );
262
+ val += t2DArray .Load (int4(0 , 0 , 0 , 0 ), int2(0 , 0 ));
263
+
264
+ /*
265
+ <Template Type> Object.SampleGrad()
266
+ */
267
+ float _ddx = 0 . 0 f , _ddy = 0 . 0 f ;
268
+ val += t1D .SampleGrad (samplerState, 0 . 0 f , _ddx, _ddy);
269
+ val += t2D .SampleGrad (samplerState, float2(u, u), float2(_ddx, _ddx), float2(_ddy, _ddy));
270
+ val += t3D .SampleGrad (samplerState, float3(u, u, u), float3(_ddx, _ddx, _ddx), float3(_ddy, _ddy, _ddy));
271
+ val += tCube .SampleGrad (samplerState, normalize(float3(u, 1 - u, u)), float3(_ddx, _ddx, _ddx), float3(_ddy, _ddy, _ddy));
272
+
273
+ val += t1DArray .SampleGrad (samplerState, float2(0 . 0 f , 0 . 0 f ), _ddx, _ddy);
274
+ val += t2DArray .SampleGrad (samplerState, float3(u, u, 0 . 0 f ), float2(_ddx, _ddx), float2(_ddy, _ddy));
275
+
276
+ // Offset variant
277
+ val += t1D .SampleGrad (samplerState, 0 . 0 f , _ddx, _ddy, 0 );
278
+ val += t2D .SampleGrad (samplerState, float2(u, u), float2(_ddx, _ddx), float2(_ddy, _ddy), int2(0 , 0 ));
279
+ val += t3D .SampleGrad (samplerState, float3(u, u, u), float3(_ddx, _ddx, _ddx), float3(_ddy, _ddy, _ddy), int3(0 , 0 , 0 ));
280
+
281
+ val += t1DArray .SampleGrad (samplerState, float2(0 . 0 f , 0 . 0 f ), _ddx, _ddy, 0 );
282
+ val += t2DArray .SampleGrad (samplerState, float3(u, u, 0 . 0 f ), float2(_ddx, _ddx), float2(_ddy, _ddy), int2(0 , 0 ));
283
+
284
+ outputBuffer [idx] = val;
285
+ }
286
+
287
+ // DX11: 313
288
+ // DX11: 313
289
+ // DX11: 313
290
+ // DX11: 313
291
+ // DX12: 313
292
+ // DX12: 313
293
+ // DX12: 313
294
+ // DX12: 313
295
+ // DX12CS6: 336
296
+ // DX12CS6: 336
297
+ // DX12CS6: 336
298
+ // DX12CS6: 336
299
+ // VK: 331
300
+ // VK: 331
301
+ // VK: 331
302
+ // VK: 331
0 commit comments