@@ -88,6 +88,99 @@ OpDecorate %int3_1 BuiltIn WorkgroupSize
88
88
EXPECT_THAT (SPV_SUCCESS, ValidateInstructions (env));
89
89
}
90
90
91
+ TEST_F (ValidateMode, GLComputeZeroWorkgroupSize) {
92
+ const std::string spirv = R"(
93
+ OpCapability Shader
94
+ OpMemoryModel Logical GLSL450
95
+ OpEntryPoint GLCompute %main "main"
96
+ OpDecorate %int3_1 BuiltIn WorkgroupSize
97
+ %int = OpTypeInt 32 0
98
+ %int3 = OpTypeVector %int 3
99
+ %int_0 = OpConstant %int 0
100
+ %int_1 = OpConstant %int 1
101
+ %int3_1 = OpConstantComposite %int3 %int_1 %int_0 %int_0
102
+ )" + kVoidFunction ;
103
+
104
+ CompileSuccessfully (spirv);
105
+ EXPECT_THAT (SPV_ERROR_INVALID_DATA, ValidateInstructions ());
106
+ EXPECT_THAT (
107
+ getDiagnosticString (),
108
+ HasSubstr (
109
+ " WorkgroupSize decorations must not have a static product of zero" ));
110
+ }
111
+
112
+ TEST_F (ValidateMode, GLComputeZeroSpecWorkgroupSize) {
113
+ const std::string spirv = R"(
114
+ OpCapability Shader
115
+ OpMemoryModel Logical GLSL450
116
+ OpEntryPoint GLCompute %main "main"
117
+ OpDecorate %int3_1 BuiltIn WorkgroupSize
118
+ %int = OpTypeInt 32 0
119
+ %int3 = OpTypeVector %int 3
120
+ %int_0 = OpSpecConstant %int 0
121
+ %int_1 = OpConstant %int 1
122
+ %int3_1 = OpConstantComposite %int3 %int_1 %int_0 %int_0
123
+ )" + kVoidFunction ;
124
+
125
+ CompileSuccessfully (spirv);
126
+ EXPECT_EQ (SPV_SUCCESS, ValidateInstructions ());
127
+ }
128
+
129
+ TEST_F (ValidateMode, GLComputeZeroSpecCompositeWorkgroupSize) {
130
+ const std::string spirv = R"(
131
+ OpCapability Shader
132
+ OpMemoryModel Logical GLSL450
133
+ OpEntryPoint GLCompute %main "main"
134
+ OpDecorate %int3_1 BuiltIn WorkgroupSize
135
+ %int = OpTypeInt 32 0
136
+ %int3 = OpTypeVector %int 3
137
+ %int_0 = OpSpecConstant %int 0
138
+ %int_1 = OpSpecConstant %int 1
139
+ %int3_1 = OpSpecConstantComposite %int3 %int_1 %int_0 %int_0
140
+ )" + kVoidFunction ;
141
+
142
+ CompileSuccessfully (spirv);
143
+ EXPECT_EQ (SPV_SUCCESS, ValidateInstructions ());
144
+ }
145
+
146
+ TEST_F (ValidateMode, KernelZeroWorkgroupSizeConstant) {
147
+ const std::string spirv = R"(
148
+ OpCapability Addresses
149
+ OpCapability Linkage
150
+ OpCapability Kernel
151
+ OpMemoryModel Physical32 OpenCL
152
+ OpEntryPoint Kernel %main "main"
153
+ OpDecorate %int3_1 BuiltIn WorkgroupSize
154
+ %int = OpTypeInt 32 0
155
+ %int3 = OpTypeVector %int 3
156
+ %int_0 = OpConstant %int 0
157
+ %int_1 = OpConstant %int 1
158
+ %int3_1 = OpConstantComposite %int3 %int_1 %int_0 %int_0
159
+ )" + kVoidFunction ;
160
+
161
+ CompileSuccessfully (spirv);
162
+ EXPECT_THAT (SPV_ERROR_INVALID_ID, ValidateInstructions ());
163
+ EXPECT_THAT (getDiagnosticString (), HasSubstr (" must be a variable" ));
164
+ }
165
+
166
+ TEST_F (ValidateMode, KernelZeroWorkgroupSizeVariable) {
167
+ const std::string spirv = R"(
168
+ OpCapability Addresses
169
+ OpCapability Linkage
170
+ OpCapability Kernel
171
+ OpMemoryModel Physical32 OpenCL
172
+ OpEntryPoint Kernel %main "main"
173
+ OpDecorate %var BuiltIn WorkgroupSize
174
+ %int = OpTypeInt 32 0
175
+ %int3 = OpTypeVector %int 3
176
+ %ptr = OpTypePointer Input %int3
177
+ %var = OpVariable %ptr Input
178
+ )" + kVoidFunction ;
179
+
180
+ CompileSuccessfully (spirv);
181
+ EXPECT_EQ (SPV_SUCCESS, ValidateInstructions ());
182
+ }
183
+
91
184
TEST_F (ValidateMode, GLComputeVulkanLocalSize) {
92
185
const std::string spirv = R"(
93
186
OpCapability Shader
@@ -101,6 +194,38 @@ OpExecutionMode %main LocalSize 1 1 1
101
194
EXPECT_THAT (SPV_SUCCESS, ValidateInstructions (env));
102
195
}
103
196
197
+ TEST_F (ValidateMode, GLComputeZeroLocalSize) {
198
+ const std::string spirv = R"(
199
+ OpCapability Shader
200
+ OpMemoryModel Logical GLSL450
201
+ OpEntryPoint GLCompute %main "main"
202
+ OpExecutionMode %main LocalSize 1 1 0
203
+ )" + kVoidFunction ;
204
+
205
+ CompileSuccessfully (spirv);
206
+ EXPECT_THAT (SPV_ERROR_INVALID_DATA, ValidateInstructions ());
207
+ EXPECT_THAT (
208
+ getDiagnosticString (),
209
+ HasSubstr (" Local Size execution mode must not have a product of zero" ));
210
+ }
211
+
212
+ TEST_F (ValidateMode, KernelZeroLocalSize) {
213
+ const std::string spirv = R"(
214
+ OpCapability Addresses
215
+ OpCapability Linkage
216
+ OpCapability Kernel
217
+ OpMemoryModel Physical32 OpenCL
218
+ OpEntryPoint Kernel %main "main"
219
+ OpExecutionMode %main LocalSize 1 1 0
220
+ )" + kVoidFunction ;
221
+
222
+ CompileSuccessfully (spirv);
223
+ EXPECT_THAT (SPV_ERROR_INVALID_DATA, ValidateInstructions ());
224
+ EXPECT_THAT (
225
+ getDiagnosticString (),
226
+ HasSubstr (" Local Size execution mode must not have a product of zero" ));
227
+ }
228
+
104
229
TEST_F (ValidateMode, GLComputeVulkanLocalSizeIdBad) {
105
230
const std::string spirv = R"(
106
231
OpCapability Shader
@@ -135,6 +260,64 @@ OpExecutionModeId %main LocalSizeId %int_1 %int_1 %int_1
135
260
EXPECT_THAT (SPV_SUCCESS, ValidateInstructions (env));
136
261
}
137
262
263
+ TEST_F (ValidateMode, GLComputeZeroLocalSizeId) {
264
+ const std::string spirv = R"(
265
+ OpCapability Shader
266
+ OpMemoryModel Logical GLSL450
267
+ OpEntryPoint GLCompute %main "main"
268
+ OpExecutionModeId %main LocalSizeId %int_1 %int_0 %int_1
269
+ %int = OpTypeInt 32 0
270
+ %int_1 = OpConstant %int 1
271
+ %int_0 = OpConstant %int 0
272
+ )" + kVoidFunction ;
273
+
274
+ spv_target_env env = SPV_ENV_UNIVERSAL_1_3;
275
+ CompileSuccessfully (spirv, env);
276
+ EXPECT_THAT (SPV_ERROR_INVALID_DATA, ValidateInstructions (env));
277
+ EXPECT_THAT (
278
+ getDiagnosticString (),
279
+ HasSubstr (
280
+ " Local Size Id execution mode must not have a product of zero" ));
281
+ }
282
+
283
+ TEST_F (ValidateMode, GLComputeZeroSpecLocalSizeId) {
284
+ const std::string spirv = R"(
285
+ OpCapability Shader
286
+ OpMemoryModel Logical GLSL450
287
+ OpEntryPoint GLCompute %main "main"
288
+ OpExecutionModeId %main LocalSizeId %int_1 %int_0 %int_1
289
+ %int = OpTypeInt 32 0
290
+ %int_1 = OpConstant %int 1
291
+ %int_0 = OpSpecConstant %int 0
292
+ )" + kVoidFunction ;
293
+
294
+ spv_target_env env = SPV_ENV_UNIVERSAL_1_3;
295
+ CompileSuccessfully (spirv, env);
296
+ EXPECT_EQ (SPV_SUCCESS, ValidateInstructions (env));
297
+ }
298
+
299
+ TEST_F (ValidateMode, KernelZeroLocalSizeId) {
300
+ const std::string spirv = R"(
301
+ OpCapability Addresses
302
+ OpCapability Linkage
303
+ OpCapability Kernel
304
+ OpMemoryModel Physical32 OpenCL
305
+ OpEntryPoint Kernel %main "main"
306
+ OpExecutionModeId %main LocalSizeId %int_1 %int_0 %int_1
307
+ %int = OpTypeInt 32 0
308
+ %int_1 = OpConstant %int 1
309
+ %int_0 = OpConstant %int 0
310
+ )" + kVoidFunction ;
311
+
312
+ spv_target_env env = SPV_ENV_UNIVERSAL_1_3;
313
+ CompileSuccessfully (spirv, env);
314
+ EXPECT_THAT (SPV_ERROR_INVALID_DATA, ValidateInstructions (env));
315
+ EXPECT_THAT (
316
+ getDiagnosticString (),
317
+ HasSubstr (
318
+ " Local Size Id execution mode must not have a product of zero" ));
319
+ }
320
+
138
321
TEST_F (ValidateMode, FragmentOriginLowerLeftVulkan) {
139
322
const std::string spirv = R"(
140
323
OpCapability Shader
0 commit comments