Debian Codegraph @

test/val/val_builtins_test.cpp

raw
1 // Copyright (c) 2018 Google LLC.
2 // Modifications Copyright (C) 2020 Advanced Micro Devices, Inc. All rights
3 // reserved.
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16
17 // Tests validation rules of GLSL.450.std and OpenCL.std extended instructions.
18 // Doesn't test OpenCL.std vector size 2, 3, 4, 8 or 16 rules (not supported
19 // by standard SPIR-V).
20
21 #include <cstring>
22 #include <sstream>
23 #include <string>
24 #include <tuple>
25 #include <utility>
26 #include <vector>
27
28 #include "gmock/gmock.h"
29 #include "test/val/val_code_generator.h"
30 #include "test/val/val_fixtures.h"
31
32 namespace spvtools {
33 namespace val {
34 namespace {
35
36 struct TestResult {
37 TestResult(spv_result_t in_validation_result = SPV_SUCCESS,
38 const char* in_error_str = nullptr,
39 const char* in_error_str2 = nullptr)
40 : validation_result(in_validation_result),
41 error_str(in_error_str),
42 error_str2(in_error_str2) {}
43 spv_result_t validation_result;
44 const char* error_str;
45 const char* error_str2;
46 };
47
48 using ::testing::Combine;
49 using ::testing::HasSubstr;
50 using ::testing::Not;
51 using ::testing::Values;
52 using ::testing::ValuesIn;
53
54 using ValidateBuiltIns = spvtest::ValidateBase<bool>;
55 using ValidateVulkanSubgroupBuiltIns =
56 spvtest::ValidateBase<std::tuple<const char*, const char*, const char*,
57 const char*, const char*, TestResult>>;
58 using ValidateVulkanCombineBuiltInExecutionModelDataTypeResult =
59 spvtest::ValidateBase<std::tuple<const char*, const char*, const char*,
60 const char*, const char*, TestResult>>;
61 using ValidateVulkanCombineBuiltInArrayedVariable =
62 spvtest::ValidateBase<std::tuple<const char*, const char*, const char*,
63 const char*, const char*, TestResult>>;
64 using ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult =
65 spvtest::ValidateBase<
66 std::tuple<const char*, const char*, const char*, const char*,
67 const char*, const char*, const char*, TestResult>>;
68
69 using ValidateGenericCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult =
70 spvtest::ValidateBase<std::tuple<spv_target_env, const char*, const char*,
71 const char*, const char*, const char*,
72 const char*, const char*, TestResult>>;
73
74 bool InitializerRequired(const char* const storage_class) {
75 return (strncmp(storage_class, "Output", 6) == 0 ||
76 strncmp(storage_class, "Private", 7) == 0 ||
77 strncmp(storage_class, "Function", 8) == 0);
78 }
79
80 CodeGenerator GetInMainCodeGenerator(const char* const built_in,
81 const char* const execution_model,
82 const char* const storage_class,
83 const char* const capabilities,
84 const char* const extensions,
85 const char* const data_type) {
86 CodeGenerator generator = CodeGenerator::GetDefaultShaderCodeGenerator();
87
88 if (capabilities) {
89 generator.capabilities_ += capabilities;
90 }
91 if (extensions) {
92 generator.extensions_ += extensions;
93 }
94
95 generator.before_types_ = R"(OpDecorate %built_in_type Block
96 OpMemberDecorate %built_in_type 0 BuiltIn )";
97 generator.before_types_ += built_in;
98 generator.before_types_ += "\n";
99
100 if (strncmp(built_in, "TessLevel", 9) == 0) {
101 generator.before_types_ += "OpMemberDecorate %built_in_type 0 Patch\n";
102 }
103
104 std::ostringstream after_types;
105
106 after_types << "%built_in_type = OpTypeStruct " << data_type << "\n";
107 if (InitializerRequired(storage_class)) {
108 after_types << "%built_in_null = OpConstantNull %built_in_type\n";
109 }
110 after_types << "%built_in_ptr = OpTypePointer " << storage_class
111 << " %built_in_type\n";
112 after_types << "%built_in_var = OpVariable %built_in_ptr " << storage_class;
113 if (InitializerRequired(storage_class)) {
114 after_types << " %built_in_null";
115 }
116 after_types << "\n";
117 after_types << "%data_ptr = OpTypePointer " << storage_class << " "
118 << data_type << "\n";
119 generator.after_types_ = after_types.str();
120
121 EntryPoint entry_point;
122 entry_point.name = "main";
123 entry_point.execution_model = execution_model;
124 if (strncmp(storage_class, "Input", 5) == 0 ||
125 strncmp(storage_class, "Output", 6) == 0) {
126 entry_point.interfaces = "%built_in_var";
127 }
128
129 std::ostringstream execution_modes;
130 if (0 == std::strcmp(execution_model, "Fragment")) {
131 execution_modes << "OpExecutionMode %" << entry_point.name
132 << " OriginUpperLeft\n";
133 if (0 == std::strcmp(built_in, "FragDepth")) {
134 execution_modes << "OpExecutionMode %" << entry_point.name
135 << " DepthReplacing\n";
136 }
137 }
138 if (0 == std::strcmp(execution_model, "Geometry")) {
139 execution_modes << "OpExecutionMode %" << entry_point.name
140 << " InputPoints\n";
141 execution_modes << "OpExecutionMode %" << entry_point.name
142 << " OutputPoints\n";
143 }
144 if (0 == std::strcmp(execution_model, "GLCompute") ||
145 0 == std::strcmp(execution_model, "MeshEXT") ||
146 0 == std::strcmp(execution_model, "MeshNV") ||
147 0 == std::strcmp(execution_model, "MeshEXT") ||
148 0 == std::strcmp(execution_model, "TaskNV")) {
149 execution_modes << "OpExecutionMode %" << entry_point.name
150 << " LocalSize 1 1 1\n";
151 }
152 entry_point.execution_modes = execution_modes.str();
153
154 entry_point.body = R"(
155 %ptr = OpAccessChain %data_ptr %built_in_var %u32_0
156 )";
157 generator.entry_points_.push_back(std::move(entry_point));
158
159 return generator;
160 }
161
162 TEST_P(ValidateVulkanCombineBuiltInExecutionModelDataTypeResult, InMain) {
163 const char* const built_in = std::get<0>(GetParam());
164 const char* const execution_model = std::get<1>(GetParam());
165 const char* const storage_class = std::get<2>(GetParam());
166 const char* const data_type = std::get<3>(GetParam());
167 const char* const vuid = std::get<4>(GetParam());
168 const TestResult& test_result = std::get<5>(GetParam());
169
170 CodeGenerator generator = GetInMainCodeGenerator(
171 built_in, execution_model, storage_class, NULL, NULL, data_type);
172
173 CompileSuccessfully(generator.Build(), SPV_ENV_VULKAN_1_0);
174 ASSERT_EQ(test_result.validation_result,
175 ValidateInstructions(SPV_ENV_VULKAN_1_0));
176 if (test_result.error_str) {
177 EXPECT_THAT(getDiagnosticString(), HasSubstr(test_result.error_str));
178 }
179 if (test_result.error_str2) {
180 EXPECT_THAT(getDiagnosticString(), HasSubstr(test_result.error_str2));
181 }
182 if (vuid) {
183 EXPECT_THAT(getDiagnosticString(), AnyVUID(vuid));
184 }
185 }
186
187 TEST_P(
188 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
189 InMain) {
190 const char* const built_in = std::get<0>(GetParam());
191 const char* const execution_model = std::get<1>(GetParam());
192 const char* const storage_class = std::get<2>(GetParam());
193 const char* const data_type = std::get<3>(GetParam());
194 const char* const capabilities = std::get<4>(GetParam());
195 const char* const extensions = std::get<5>(GetParam());
196 const char* const vuid = std::get<6>(GetParam());
197 const TestResult& test_result = std::get<7>(GetParam());
198
199 CodeGenerator generator =
200 GetInMainCodeGenerator(built_in, execution_model, storage_class,
201 capabilities, extensions, data_type);
202
203 CompileSuccessfully(generator.Build(), SPV_ENV_VULKAN_1_0);
204 ASSERT_EQ(test_result.validation_result,
205 ValidateInstructions(SPV_ENV_VULKAN_1_0));
206 if (test_result.error_str) {
207 EXPECT_THAT(getDiagnosticString(), HasSubstr(test_result.error_str));
208 }
209 if (test_result.error_str2) {
210 EXPECT_THAT(getDiagnosticString(), HasSubstr(test_result.error_str2));
211 }
212 if (vuid) {
213 EXPECT_THAT(getDiagnosticString(), AnyVUID(vuid));
214 }
215 }
216
217 TEST_P(
218 ValidateGenericCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
219 InMain) {
220 const spv_target_env env = std::get<0>(GetParam());
221 const char* const built_in = std::get<1>(GetParam());
222 const char* const execution_model = std::get<2>(GetParam());
223 const char* const storage_class = std::get<3>(GetParam());
224 const char* const data_type = std::get<4>(GetParam());
225 const char* const capabilities = std::get<5>(GetParam());
226 const char* const extensions = std::get<6>(GetParam());
227 const char* const vuid = std::get<7>(GetParam());
228 const TestResult& test_result = std::get<8>(GetParam());
229
230 CodeGenerator generator =
231 GetInMainCodeGenerator(built_in, execution_model, storage_class,
232 capabilities, extensions, data_type);
233
234 CompileSuccessfully(generator.Build(), env);
235 ASSERT_EQ(test_result.validation_result, ValidateInstructions(env));
236 if (test_result.error_str) {
237 EXPECT_THAT(getDiagnosticString(), HasSubstr(test_result.error_str));
238 }
239 if (test_result.error_str2) {
240 EXPECT_THAT(getDiagnosticString(), HasSubstr(test_result.error_str2));
241 }
242 if (vuid) {
243 EXPECT_THAT(getDiagnosticString(), AnyVUID(vuid));
244 }
245 }
246
247 CodeGenerator GetInFunctionCodeGenerator(const char* const built_in,
248 const char* const execution_model,
249 const char* const storage_class,
250 const char* const capabilities,
251 const char* const extensions,
252 const char* const data_type) {
253 CodeGenerator generator = CodeGenerator::GetDefaultShaderCodeGenerator();
254
255 if (capabilities) {
256 generator.capabilities_ += capabilities;
257 }
258 if (extensions) {
259 generator.extensions_ += extensions;
260 }
261
262 generator.before_types_ = R"(OpDecorate %built_in_type Block
263 OpMemberDecorate %built_in_type 0 BuiltIn )";
264 generator.before_types_ += built_in;
265 generator.before_types_ += "\n";
266
267 if (strncmp(built_in, "TessLevel", 9) == 0) {
268 generator.before_types_ += "OpMemberDecorate %built_in_type 0 Patch\n";
269 }
270
271 std::ostringstream after_types;
272 after_types << "%built_in_type = OpTypeStruct " << data_type << "\n";
273 if (InitializerRequired(storage_class)) {
274 after_types << "%built_in_null = OpConstantNull %built_in_type\n";
275 }
276 after_types << "%built_in_ptr = OpTypePointer " << storage_class
277 << " %built_in_type\n";
278 after_types << "%built_in_var = OpVariable %built_in_ptr " << storage_class;
279 if (InitializerRequired(storage_class)) {
280 after_types << " %built_in_null";
281 }
282 after_types << "\n";
283 after_types << "%data_ptr = OpTypePointer " << storage_class << " "
284 << data_type << "\n";
285 generator.after_types_ = after_types.str();
286
287 EntryPoint entry_point;
288 entry_point.name = "main";
289 entry_point.execution_model = execution_model;
290 if (strncmp(storage_class, "Input", 5) == 0 ||
291 strncmp(storage_class, "Output", 6) == 0) {
292 entry_point.interfaces = "%built_in_var";
293 }
294
295 std::ostringstream execution_modes;
296 if (0 == std::strcmp(execution_model, "Fragment")) {
297 execution_modes << "OpExecutionMode %" << entry_point.name
298 << " OriginUpperLeft\n";
299 if (0 == std::strcmp(built_in, "FragDepth")) {
300 execution_modes << "OpExecutionMode %" << entry_point.name
301 << " DepthReplacing\n";
302 }
303 }
304 if (0 == std::strcmp(execution_model, "Geometry")) {
305 execution_modes << "OpExecutionMode %" << entry_point.name
306 << " InputPoints\n";
307 execution_modes << "OpExecutionMode %" << entry_point.name
308 << " OutputPoints\n";
309 }
310 if (0 == std::strcmp(execution_model, "GLCompute") ||
311 0 == std::strcmp(execution_model, "MeshEXT") ||
312 0 == std::strcmp(execution_model, "MeshNV") ||
313 0 == std::strcmp(execution_model, "MeshEXT") ||
314 0 == std::strcmp(execution_model, "TaskNV")) {
315 execution_modes << "OpExecutionMode %" << entry_point.name
316 << " LocalSize 1 1 1\n";
317 }
318 entry_point.execution_modes = execution_modes.str();
319
320 entry_point.body = R"(
321 %val2 = OpFunctionCall %void %foo
322 )";
323
324 std::string function_body = R"(
325 %foo = OpFunction %void None %func
326 %foo_entry = OpLabel
327 %ptr = OpAccessChain %data_ptr %built_in_var %u32_0
328 OpReturn
329 OpFunctionEnd
330 )";
331
332 generator.add_at_the_end_ = function_body;
333
334 generator.entry_points_.push_back(std::move(entry_point));
335
336 return generator;
337 }
338
339 TEST_P(ValidateVulkanCombineBuiltInExecutionModelDataTypeResult, InFunction) {
340 const char* const built_in = std::get<0>(GetParam());
341 const char* const execution_model = std::get<1>(GetParam());
342 const char* const storage_class = std::get<2>(GetParam());
343 const char* const data_type = std::get<3>(GetParam());
344 const char* const vuid = std::get<4>(GetParam());
345 const TestResult& test_result = std::get<5>(GetParam());
346
347 CodeGenerator generator = GetInFunctionCodeGenerator(
348 built_in, execution_model, storage_class, NULL, NULL, data_type);
349
350 CompileSuccessfully(generator.Build(), SPV_ENV_VULKAN_1_0);
351 ASSERT_EQ(test_result.validation_result,
352 ValidateInstructions(SPV_ENV_VULKAN_1_0));
353 if (test_result.error_str) {
354 EXPECT_THAT(getDiagnosticString(), HasSubstr(test_result.error_str));
355 }
356 if (test_result.error_str2) {
357 EXPECT_THAT(getDiagnosticString(), HasSubstr(test_result.error_str2));
358 }
359 if (vuid) {
360 EXPECT_THAT(getDiagnosticString(), AnyVUID(vuid));
361 }
362 }
363
364 TEST_P(
365 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
366 InFunction) {
367 const char* const built_in = std::get<0>(GetParam());
368 const char* const execution_model = std::get<1>(GetParam());
369 const char* const storage_class = std::get<2>(GetParam());
370 const char* const data_type = std::get<3>(GetParam());
371 const char* const capabilities = std::get<4>(GetParam());
372 const char* const extensions = std::get<5>(GetParam());
373 const char* const vuid = std::get<6>(GetParam());
374 const TestResult& test_result = std::get<7>(GetParam());
375
376 CodeGenerator generator =
377 GetInFunctionCodeGenerator(built_in, execution_model, storage_class,
378 capabilities, extensions, data_type);
379
380 CompileSuccessfully(generator.Build(), SPV_ENV_VULKAN_1_0);
381 ASSERT_EQ(test_result.validation_result,
382 ValidateInstructions(SPV_ENV_VULKAN_1_0));
383 if (test_result.error_str) {
384 EXPECT_THAT(getDiagnosticString(), HasSubstr(test_result.error_str));
385 }
386 if (test_result.error_str2) {
387 EXPECT_THAT(getDiagnosticString(), HasSubstr(test_result.error_str2));
388 }
389 if (vuid) {
390 EXPECT_THAT(getDiagnosticString(), AnyVUID(vuid));
391 }
392 }
393
394 CodeGenerator GetVariableCodeGenerator(const char* const built_in,
395 const char* const execution_model,
396 const char* const storage_class,
397 const char* const capabilities,
398 const char* const extensions,
399 const char* const data_type) {
400 CodeGenerator generator = CodeGenerator::GetDefaultShaderCodeGenerator();
401
402 if (capabilities) {
403 generator.capabilities_ += capabilities;
404 }
405 if (extensions) {
406 generator.extensions_ += extensions;
407 }
408
409 generator.before_types_ = "OpDecorate %built_in_var BuiltIn ";
410 generator.before_types_ += built_in;
411 generator.before_types_ += "\n";
412
413 if (strncmp(built_in, "TessLevel", 9) == 0) {
414 generator.before_types_ += "OpDecorate %built_in_var Patch\n";
415 }
416
417 if ((0 == std::strcmp(storage_class, "Input")) &&
418 (0 == std::strcmp(execution_model, "Fragment"))) {
419 // ensure any needed input types that might require Flat
420 generator.before_types_ += "OpDecorate %built_in_var Flat\n";
421 }
422
423 std::ostringstream after_types;
424 if (InitializerRequired(storage_class)) {
425 after_types << "%built_in_null = OpConstantNull " << data_type << "\n";
426 }
427 after_types << "%built_in_ptr = OpTypePointer " << storage_class << " "
428 << data_type << "\n";
429 after_types << "%built_in_var = OpVariable %built_in_ptr " << storage_class;
430 if (InitializerRequired(storage_class)) {
431 after_types << " %built_in_null";
432 }
433 after_types << "\n";
434 generator.after_types_ = after_types.str();
435
436 EntryPoint entry_point;
437 entry_point.name = "main";
438 entry_point.execution_model = execution_model;
439 if (strncmp(storage_class, "Input", 5) == 0 ||
440 strncmp(storage_class, "Output", 6) == 0) {
441 entry_point.interfaces = "%built_in_var";
442 }
443 // Any kind of reference would do.
444 entry_point.body = R"(
445 %val = OpCopyObject %built_in_ptr %built_in_var
446 )";
447
448 std::ostringstream execution_modes;
449 if (0 == std::strcmp(execution_model, "Fragment")) {
450 execution_modes << "OpExecutionMode %" << entry_point.name
451 << " OriginUpperLeft\n";
452 if (0 == std::strcmp(built_in, "FragDepth")) {
453 execution_modes << "OpExecutionMode %" << entry_point.name
454 << " DepthReplacing\n";
455 }
456 }
457 if (0 == std::strcmp(execution_model, "Geometry")) {
458 execution_modes << "OpExecutionMode %" << entry_point.name
459 << " InputPoints\n";
460 execution_modes << "OpExecutionMode %" << entry_point.name
461 << " OutputPoints\n";
462 }
463 if (0 == std::strcmp(execution_model, "GLCompute") ||
464 0 == std::strcmp(execution_model, "MeshEXT") ||
465 0 == std::strcmp(execution_model, "MeshNV") ||
466 0 == std::strcmp(execution_model, "MeshEXT") ||
467 0 == std::strcmp(execution_model, "TaskNV")) {
468 execution_modes << "OpExecutionMode %" << entry_point.name
469 << " LocalSize 1 1 1\n";
470 }
471 entry_point.execution_modes = execution_modes.str();
472
473 generator.entry_points_.push_back(std::move(entry_point));
474
475 return generator;
476 }
477
478 TEST_P(ValidateVulkanCombineBuiltInExecutionModelDataTypeResult, Variable) {
479 const char* const built_in = std::get<0>(GetParam());
480 const char* const execution_model = std::get<1>(GetParam());
481 const char* const storage_class = std::get<2>(GetParam());
482 const char* const data_type = std::get<3>(GetParam());
483 const char* const vuid = std::get<4>(GetParam());
484 const TestResult& test_result = std::get<5>(GetParam());
485
486 CodeGenerator generator = GetVariableCodeGenerator(
487 built_in, execution_model, storage_class, NULL, NULL, data_type);
488
489 CompileSuccessfully(generator.Build(), SPV_ENV_VULKAN_1_0);
490 ASSERT_EQ(test_result.validation_result,
491 ValidateInstructions(SPV_ENV_VULKAN_1_0));
492 if (test_result.error_str) {
493 EXPECT_THAT(getDiagnosticString(), HasSubstr(test_result.error_str));
494 }
495 if (test_result.error_str2) {
496 EXPECT_THAT(getDiagnosticString(), HasSubstr(test_result.error_str2));
497 }
498 if (vuid) {
499 EXPECT_THAT(getDiagnosticString(), AnyVUID(vuid));
500 }
501 }
502
503 TEST_P(
504 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
505 Variable) {
506 const char* const built_in = std::get<0>(GetParam());
507 const char* const execution_model = std::get<1>(GetParam());
508 const char* const storage_class = std::get<2>(GetParam());
509 const char* const data_type = std::get<3>(GetParam());
510 const char* const capabilities = std::get<4>(GetParam());
511 const char* const extensions = std::get<5>(GetParam());
512 const char* const vuid = std::get<6>(GetParam());
513 const TestResult& test_result = std::get<7>(GetParam());
514
515 CodeGenerator generator =
516 GetVariableCodeGenerator(built_in, execution_model, storage_class,
517 capabilities, extensions, data_type);
518
519 CompileSuccessfully(generator.Build(), SPV_ENV_VULKAN_1_0);
520 ASSERT_EQ(test_result.validation_result,
521 ValidateInstructions(SPV_ENV_VULKAN_1_0));
522 if (test_result.error_str) {
523 EXPECT_THAT(getDiagnosticString(), HasSubstr(test_result.error_str));
524 }
525 if (test_result.error_str2) {
526 EXPECT_THAT(getDiagnosticString(), HasSubstr(test_result.error_str2));
527 }
528 if (vuid) {
529 EXPECT_THAT(getDiagnosticString(), AnyVUID(vuid));
530 }
531 }
532
533 INSTANTIATE_TEST_SUITE_P(
534 ClipAndCullDistanceOutputSuccess,
535 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
536 Combine(Values("ClipDistance", "CullDistance"),
537 Values("Vertex", "Geometry", "TessellationControl",
538 "TessellationEvaluation"),
539 Values("Output"), Values("%f32arr2", "%f32arr4"), Values(nullptr),
540 Values(TestResult())));
541
542 INSTANTIATE_TEST_SUITE_P(
543 ClipAndCullDistanceInputSuccess,
544 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
545 Combine(Values("ClipDistance", "CullDistance"),
546 Values("Fragment", "Geometry", "TessellationControl",
547 "TessellationEvaluation"),
548 Values("Input"), Values("%f32arr2", "%f32arr4"), Values(nullptr),
549 Values(TestResult())));
550
551 INSTANTIATE_TEST_SUITE_P(
552 ClipAndCullDistanceInvalidStorageClass,
553 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
554 Combine(Values("ClipDistance", "CullDistance"),
555 Values("Vertex", "Geometry", "TessellationControl",
556 "TessellationEvaluation"),
557 Values("Private"), Values("%f32arr2", "%f32arr4"),
558 Values("VUID-ClipDistance-ClipDistance-04190 "
559 "VUID-CullDistance-CullDistance-04199"),
560 Values(TestResult(
561 SPV_ERROR_INVALID_DATA,
562 "to be only used for variables with Input or Output storage "
563 "class."))));
564
565 INSTANTIATE_TEST_SUITE_P(
566 ClipAndCullDistanceFragmentOutput,
567 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
568 Combine(Values("ClipDistance", "CullDistance"), Values("Fragment"),
569 Values("Output"), Values("%f32arr4"),
570 Values("VUID-ClipDistance-ClipDistance-04189 "
571 "VUID-CullDistance-CullDistance-04198"),
572 Values(TestResult(
573 SPV_ERROR_INVALID_DATA,
574 "Vulkan spec doesn't allow BuiltIn ClipDistance/CullDistance "
575 "to be used for variables with Output storage class if "
576 "execution model is Fragment.",
577 "which is called with execution model Fragment."))));
578
579 INSTANTIATE_TEST_SUITE_P(
580 VertexIdVertexInput,
581 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
582 Combine(
583 Values("VertexId"), Values("Vertex"), Values("Input"), Values("%u32"),
584 Values(nullptr),
585 Values(TestResult(SPV_ERROR_INVALID_DATA,
586 "Vulkan spec doesn't allow BuiltIn VertexId to be "
587 "used."))));
588
589 INSTANTIATE_TEST_SUITE_P(
590 ClipAndCullDistanceVertexInput,
591 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
592 Combine(Values("ClipDistance", "CullDistance"), Values("Vertex"),
593 Values("Input"), Values("%f32arr4"),
594 Values("VUID-ClipDistance-ClipDistance-04188 "
595 "VUID-CullDistance-CullDistance-04197"),
596 Values(TestResult(
597 SPV_ERROR_INVALID_DATA,
598 "Vulkan spec doesn't allow BuiltIn ClipDistance/CullDistance "
599 "to be used for variables with Input storage class if "
600 "execution model is Vertex.",
601 "which is called with execution model Vertex."))));
602
603 INSTANTIATE_TEST_SUITE_P(
604 ClipAndCullInvalidExecutionModel,
605 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
606 Combine(Values("ClipDistance", "CullDistance"), Values("GLCompute"),
607 Values("Input", "Output"), Values("%f32arr4"),
608 Values("VUID-ClipDistance-ClipDistance-04187 "
609 "VUID-CullDistance-CullDistance-04196"),
610 Values(TestResult(
611 SPV_ERROR_INVALID_DATA,
612 "to be used only with Fragment, Vertex, TessellationControl, "
613 "TessellationEvaluation or Geometry execution models"))));
614
615 INSTANTIATE_TEST_SUITE_P(
616 ClipAndCullDistanceNotArray,
617 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
618 Combine(Values("ClipDistance", "CullDistance"), Values("Fragment"),
619 Values("Input"), Values("%f32vec2", "%f32vec4", "%f32"),
620 Values("VUID-ClipDistance-ClipDistance-04191 "
621 "VUID-CullDistance-CullDistance-04200"),
622 Values(TestResult(SPV_ERROR_INVALID_DATA,
623 "needs to be a 32-bit float array",
624 "is not an array"))));
625
626 INSTANTIATE_TEST_SUITE_P(
627 ClipAndCullDistanceNotFloatArray,
628 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
629 Combine(Values("ClipDistance", "CullDistance"), Values("Fragment"),
630 Values("Input"), Values("%u32arr2", "%u64arr4"),
631 Values("VUID-ClipDistance-ClipDistance-04191 "
632 "VUID-CullDistance-CullDistance-04200"),
633 Values(TestResult(SPV_ERROR_INVALID_DATA,
634 "needs to be a 32-bit float array",
635 "components are not float scalar"))));
636
637 INSTANTIATE_TEST_SUITE_P(
638 ClipAndCullDistanceNotF32Array,
639 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
640 Combine(Values("ClipDistance", "CullDistance"), Values("Fragment"),
641 Values("Input"), Values("%f64arr2", "%f64arr4"),
642 Values("VUID-ClipDistance-ClipDistance-04191 "
643 "VUID-CullDistance-CullDistance-04200"),
644 Values(TestResult(SPV_ERROR_INVALID_DATA,
645 "needs to be a 32-bit float array",
646 "has components with bit width 64"))));
647
648 INSTANTIATE_TEST_SUITE_P(
649 FragCoordSuccess, ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
650 Combine(Values("FragCoord"), Values("Fragment"), Values("Input"),
651 Values("%f32vec4"), Values(nullptr), Values(TestResult())));
652
653 INSTANTIATE_TEST_SUITE_P(
654 FragCoordNotFragment,
655 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
656 Combine(
657 Values("FragCoord"),
658 Values("Vertex", "GLCompute", "Geometry", "TessellationControl",
659 "TessellationEvaluation"),
660 Values("Input"), Values("%f32vec4"),
661 Values("VUID-FragCoord-FragCoord-04210"),
662 Values(TestResult(SPV_ERROR_INVALID_DATA,
663 "to be used only with Fragment execution model"))));
664
665 INSTANTIATE_TEST_SUITE_P(
666 FragCoordNotInput, ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
667 Combine(Values("FragCoord"), Values("Fragment"), Values("Output"),
668 Values("%f32vec4"), Values("VUID-FragCoord-FragCoord-04211"),
669 Values(TestResult(
670 SPV_ERROR_INVALID_DATA,
671 "to be only used for variables with Input storage class",
672 "uses storage class Output"))));
673
674 INSTANTIATE_TEST_SUITE_P(
675 FragCoordNotFloatVector,
676 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
677 Combine(Values("FragCoord"), Values("Fragment"), Values("Input"),
678 Values("%f32arr4", "%u32vec4"),
679 Values("VUID-FragCoord-FragCoord-04212"),
680 Values(TestResult(SPV_ERROR_INVALID_DATA,
681 "needs to be a 4-component 32-bit float vector",
682 "is not a float vector"))));
683
684 INSTANTIATE_TEST_SUITE_P(
685 FragCoordNotFloatVec4,
686 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
687 Combine(Values("FragCoord"), Values("Fragment"), Values("Input"),
688 Values("%f32vec3"), Values("VUID-FragCoord-FragCoord-04212"),
689 Values(TestResult(SPV_ERROR_INVALID_DATA,
690 "needs to be a 4-component 32-bit float vector",
691 "has 3 components"))));
692
693 INSTANTIATE_TEST_SUITE_P(
694 FragCoordNotF32Vec4,
695 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
696 Combine(Values("FragCoord"), Values("Fragment"), Values("Input"),
697 Values("%f64vec4"), Values("VUID-FragCoord-FragCoord-04212"),
698 Values(TestResult(SPV_ERROR_INVALID_DATA,
699 "needs to be a 4-component 32-bit float vector",
700 "has components with bit width 64"))));
701
702 INSTANTIATE_TEST_SUITE_P(
703 FragDepthSuccess, ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
704 Combine(Values("FragDepth"), Values("Fragment"), Values("Output"),
705 Values("%f32"), Values(nullptr), Values(TestResult())));
706
707 INSTANTIATE_TEST_SUITE_P(
708 FragDepthNotFragment,
709 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
710 Combine(
711 Values("FragDepth"),
712 Values("Vertex", "GLCompute", "Geometry", "TessellationControl",
713 "TessellationEvaluation"),
714 Values("Output"), Values("%f32"),
715 Values("VUID-FragDepth-FragDepth-04213"),
716 Values(TestResult(SPV_ERROR_INVALID_DATA,
717 "to be used only with Fragment execution model"))));
718
719 INSTANTIATE_TEST_SUITE_P(
720 FragDepthNotOutput,
721 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
722 Combine(Values("FragDepth"), Values("Fragment"), Values("Input"),
723 Values("%f32"), Values("VUID-FragDepth-FragDepth-04214"),
724 Values(TestResult(
725 SPV_ERROR_INVALID_DATA,
726 "to be only used for variables with Output storage class",
727 "uses storage class Input"))));
728
729 INSTANTIATE_TEST_SUITE_P(
730 FragDepthNotFloatScalar,
731 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
732 Combine(Values("FragDepth"), Values("Fragment"), Values("Output"),
733 Values("%f32vec4", "%u32"),
734 Values("VUID-FragDepth-FragDepth-04215"),
735 Values(TestResult(SPV_ERROR_INVALID_DATA,
736 "needs to be a 32-bit float scalar",
737 "is not a float scalar"))));
738
739 INSTANTIATE_TEST_SUITE_P(
740 FragDepthNotF32, ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
741 Combine(Values("FragDepth"), Values("Fragment"), Values("Output"),
742 Values("%f64"), Values("VUID-FragDepth-FragDepth-04215"),
743 Values(TestResult(SPV_ERROR_INVALID_DATA,
744 "needs to be a 32-bit float scalar",
745 "has bit width 64"))));
746
747 INSTANTIATE_TEST_SUITE_P(
748 FrontFacingAndHelperInvocationSuccess,
749 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
750 Combine(Values("FrontFacing", "HelperInvocation"), Values("Fragment"),
751 Values("Input"), Values("%bool"), Values(nullptr),
752 Values(TestResult())));
753
754 INSTANTIATE_TEST_SUITE_P(
755 FrontFacingAndHelperInvocationNotFragment,
756 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
757 Combine(
758 Values("FrontFacing", "HelperInvocation"),
759 Values("Vertex", "GLCompute", "Geometry", "TessellationControl",
760 "TessellationEvaluation"),
761 Values("Input"), Values("%bool"),
762 Values("VUID-FrontFacing-FrontFacing-04229 "
763 "VUID-HelperInvocation-HelperInvocation-04239"),
764 Values(TestResult(SPV_ERROR_INVALID_DATA,
765 "to be used only with Fragment execution model"))));
766
767 INSTANTIATE_TEST_SUITE_P(
768 FrontFacingAndHelperInvocationNotInput,
769 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
770 Combine(Values("FrontFacing", "HelperInvocation"), Values("Fragment"),
771 Values("Output"), Values("%bool"),
772 Values("VUID-FrontFacing-FrontFacing-04230 "
773 "VUID-HelperInvocation-HelperInvocation-04240"),
774 Values(TestResult(
775 SPV_ERROR_INVALID_DATA,
776 "to be only used for variables with Input storage class",
777 "uses storage class Output"))));
778
779 INSTANTIATE_TEST_SUITE_P(
780 FrontFacingAndHelperInvocationNotBool,
781 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
782 Combine(Values("FrontFacing", "HelperInvocation"), Values("Fragment"),
783 Values("Input"), Values("%f32", "%u32"),
784 Values("VUID-FrontFacing-FrontFacing-04231 "
785 "VUID-HelperInvocation-HelperInvocation-04241"),
786 Values(TestResult(SPV_ERROR_INVALID_DATA,
787 "needs to be a bool scalar",
788 "is not a bool scalar"))));
789
790 INSTANTIATE_TEST_SUITE_P(
791 ComputeShaderInputInt32Vec3Success,
792 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
793 Combine(Values("GlobalInvocationId", "LocalInvocationId", "NumWorkgroups",
794 "WorkgroupId"),
795 Values("GLCompute"), Values("Input"), Values("%u32vec3"),
796 Values(nullptr), Values(TestResult())));
797
798 INSTANTIATE_TEST_SUITE_P(
799 ComputeShaderInputInt32Vec3NotGLCompute,
800 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
801 Combine(Values("GlobalInvocationId", "LocalInvocationId", "NumWorkgroups",
802 "WorkgroupId"),
803 Values("Vertex", "Fragment", "Geometry", "TessellationControl",
804 "TessellationEvaluation"),
805 Values("Input"), Values("%u32vec3"),
806 Values("VUID-GlobalInvocationId-GlobalInvocationId-04236 "
807 "VUID-LocalInvocationId-LocalInvocationId-04281 "
808 "VUID-NumWorkgroups-NumWorkgroups-04296 "
809 "VUID-WorkgroupId-WorkgroupId-04422"),
810 Values(TestResult(SPV_ERROR_INVALID_DATA,
811 "to be used only with GLCompute, MeshNV, "
812 "TaskNV, MeshEXT or TaskEXT execution model"))));
813
814 INSTANTIATE_TEST_SUITE_P(
815 ComputeShaderInputInt32Vec3NotInput,
816 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
817 Combine(Values("GlobalInvocationId", "LocalInvocationId", "NumWorkgroups",
818 "WorkgroupId"),
819 Values("GLCompute"), Values("Output"), Values("%u32vec3"),
820 Values("VUID-GlobalInvocationId-GlobalInvocationId-04237 "
821 "VUID-LocalInvocationId-LocalInvocationId-04282 "
822 "VUID-NumWorkgroups-NumWorkgroups-04297 "
823 "VUID-WorkgroupId-WorkgroupId-04423"),
824 Values(TestResult(
825 SPV_ERROR_INVALID_DATA,
826 "to be only used for variables with Input storage class",
827 "uses storage class Output"))));
828
829 INSTANTIATE_TEST_SUITE_P(
830 ComputeShaderInputInt32Vec3NotIntVector,
831 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
832 Combine(Values("GlobalInvocationId", "LocalInvocationId", "NumWorkgroups",
833 "WorkgroupId"),
834 Values("GLCompute"), Values("Input"),
835 Values("%u32arr3", "%f32vec3"),
836 Values("VUID-GlobalInvocationId-GlobalInvocationId-04238 "
837 "VUID-LocalInvocationId-LocalInvocationId-04283 "
838 "VUID-NumWorkgroups-NumWorkgroups-04298 "
839 "VUID-WorkgroupId-WorkgroupId-04424"),
840 Values(TestResult(SPV_ERROR_INVALID_DATA,
841 "needs to be a 3-component 32-bit int vector",
842 "is not an int vector"))));
843
844 INSTANTIATE_TEST_SUITE_P(
845 ComputeShaderInputInt32Vec3NotIntVec3,
846 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
847 Combine(Values("GlobalInvocationId", "LocalInvocationId", "NumWorkgroups",
848 "WorkgroupId"),
849 Values("GLCompute"), Values("Input"), Values("%u32vec4"),
850 Values("VUID-GlobalInvocationId-GlobalInvocationId-04238 "
851 "VUID-LocalInvocationId-LocalInvocationId-04283 "
852 "VUID-NumWorkgroups-NumWorkgroups-04298 "
853 "VUID-WorkgroupId-WorkgroupId-04424"),
854 Values(TestResult(SPV_ERROR_INVALID_DATA,
855 "needs to be a 3-component 32-bit int vector",
856 "has 4 components"))));
857
858 INSTANTIATE_TEST_SUITE_P(
859 ComputeShaderInputInt32Vec3NotInt32Vec,
860 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
861 Combine(Values("GlobalInvocationId", "LocalInvocationId", "NumWorkgroups",
862 "WorkgroupId"),
863 Values("GLCompute"), Values("Input"), Values("%u64vec3"),
864 Values("VUID-GlobalInvocationId-GlobalInvocationId-04238 "
865 "VUID-LocalInvocationId-LocalInvocationId-04283 "
866 "VUID-NumWorkgroups-NumWorkgroups-04298 "
867 "VUID-WorkgroupId-WorkgroupId-04424"),
868 Values(TestResult(SPV_ERROR_INVALID_DATA,
869 "needs to be a 3-component 32-bit int vector",
870 "has components with bit width 64"))));
871
872 INSTANTIATE_TEST_SUITE_P(
873 LocalInvocationIndexSuccess,
874 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
875 Combine(Values("LocalInvocationIndex"), Values("GLCompute"),
876 Values("Input"), Values("%u32"), Values(nullptr),
877 Values(TestResult())));
878
879 INSTANTIATE_TEST_SUITE_P(
880 LocalInvocationIndexNotGLCompute,
881 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
882 Combine(Values("LocalInvocationIndex"),
883 Values("Vertex", "Fragment", "Geometry", "TessellationControl",
884 "TessellationEvaluation"),
885 Values("Input"), Values("%u32"),
886 Values("VUID-LocalInvocationIndex-LocalInvocationIndex-04284"),
887 Values(TestResult(SPV_ERROR_INVALID_DATA,
888 "to be used only with GLCompute, MeshNV, "
889 "TaskNV, MeshEXT or TaskEXT execution model"))));
890
891 INSTANTIATE_TEST_SUITE_P(
892 LocalInvocationIndexNotInput,
893 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
894 Combine(Values("LocalInvocationIndex"), Values("GLCompute"),
895 Values("Output"), Values("%u32"),
896 Values("VUID-LocalInvocationIndex-LocalInvocationIndex-04285"),
897 Values(TestResult(
898 SPV_ERROR_INVALID_DATA,
899 "to be only used for variables with Input storage class",
900 "uses storage class Output"))));
901
902 INSTANTIATE_TEST_SUITE_P(
903 LocalInvocationIndexNot32Int,
904 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
905 Combine(Values("LocalInvocationIndex"), Values("GLCompute"),
906 Values("Input"), Values("%u32vec3", "%f32"),
907 Values("VUID-LocalInvocationIndex-LocalInvocationIndex-04286"),
908 Values(TestResult(SPV_ERROR_INVALID_DATA,
909 "needs to be a 32-bit int scalar"))));
910
911 INSTANTIATE_TEST_SUITE_P(
912 InvocationIdSuccess,
913 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
914 Combine(Values("InvocationId"), Values("Geometry", "TessellationControl"),
915 Values("Input"), Values("%u32"), Values(nullptr),
916 Values(TestResult())));
917
918 INSTANTIATE_TEST_SUITE_P(
919 InvocationIdInvalidExecutionModel,
920 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
921 Combine(Values("InvocationId"),
922 Values("Vertex", "Fragment", "GLCompute", "TessellationEvaluation"),
923 Values("Input"), Values("%u32"),
924 Values("VUID-InvocationId-InvocationId-04257"),
925 Values(TestResult(SPV_ERROR_INVALID_DATA,
926 "to be used only with TessellationControl or "
927 "Geometry execution models"))));
928
929 INSTANTIATE_TEST_SUITE_P(
930 InvocationIdNotInput,
931 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
932 Combine(Values("InvocationId"), Values("Geometry", "TessellationControl"),
933 Values("Output"), Values("%u32"),
934 Values("VUID-InvocationId-InvocationId-04258"),
935 Values(TestResult(
936 SPV_ERROR_INVALID_DATA,
937 "to be only used for variables with Input storage class",
938 "uses storage class Output"))));
939
940 INSTANTIATE_TEST_SUITE_P(
941 InvocationIdNotIntScalar,
942 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
943 Combine(Values("InvocationId"), Values("Geometry", "TessellationControl"),
944 Values("Input"), Values("%f32", "%u32vec3"),
945 Values("VUID-InvocationId-InvocationId-04259"),
946 Values(TestResult(SPV_ERROR_INVALID_DATA,
947 "needs to be a 32-bit int scalar",
948 "is not an int scalar"))));
949
950 INSTANTIATE_TEST_SUITE_P(
951 InvocationIdNotInt32,
952 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
953 Combine(Values("InvocationId"), Values("Geometry", "TessellationControl"),
954 Values("Input"), Values("%u64"),
955 Values("VUID-InvocationId-InvocationId-04259"),
956 Values(TestResult(SPV_ERROR_INVALID_DATA,
957 "needs to be a 32-bit int scalar",
958 "has bit width 64"))));
959
960 INSTANTIATE_TEST_SUITE_P(
961 InstanceIndexSuccess,
962 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
963 Combine(Values("InstanceIndex"), Values("Vertex"), Values("Input"),
964 Values("%u32"), Values(nullptr), Values(TestResult())));
965
966 INSTANTIATE_TEST_SUITE_P(
967 InstanceIndexInvalidExecutionModel,
968 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
969 Combine(Values("InstanceIndex"),
970 Values("Geometry", "Fragment", "GLCompute", "TessellationControl",
971 "TessellationEvaluation"),
972 Values("Input"), Values("%u32"),
973 Values("VUID-InstanceIndex-InstanceIndex-04263"),
974 Values(TestResult(SPV_ERROR_INVALID_DATA,
975 "to be used only with Vertex execution model"))));
976
977 INSTANTIATE_TEST_SUITE_P(
978 InstanceIndexNotInput,
979 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
980 Combine(Values("InstanceIndex"), Values("Vertex"), Values("Output"),
981 Values("%u32"), Values("VUID-InstanceIndex-InstanceIndex-04264"),
982 Values(TestResult(
983 SPV_ERROR_INVALID_DATA,
984 "to be only used for variables with Input storage class",
985 "uses storage class Output"))));
986
987 INSTANTIATE_TEST_SUITE_P(
988 InstanceIndexNotIntScalar,
989 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
990 Combine(Values("InstanceIndex"), Values("Vertex"), Values("Input"),
991 Values("%f32", "%u32vec3"),
992 Values("VUID-InstanceIndex-InstanceIndex-04265"),
993 Values(TestResult(SPV_ERROR_INVALID_DATA,
994 "needs to be a 32-bit int scalar",
995 "is not an int scalar"))));
996
997 INSTANTIATE_TEST_SUITE_P(
998 InstanceIndexNotInt32,
999 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1000 Combine(Values("InstanceIndex"), Values("Vertex"), Values("Input"),
1001 Values("%u64"), Values("VUID-InstanceIndex-InstanceIndex-04265"),
1002 Values(TestResult(SPV_ERROR_INVALID_DATA,
1003 "needs to be a 32-bit int scalar",
1004 "has bit width 64"))));
1005
1006 INSTANTIATE_TEST_SUITE_P(
1007 LayerAndViewportIndexInputSuccess,
1008 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1009 Combine(Values("Layer", "ViewportIndex"), Values("Fragment"),
1010 Values("Input"), Values("%u32"), Values(nullptr),
1011 Values(TestResult())));
1012
1013 INSTANTIATE_TEST_SUITE_P(
1014 LayerAndViewportIndexOutputSuccess,
1015 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1016 Combine(Values("Layer", "ViewportIndex"), Values("Geometry"),
1017 Values("Output"), Values("%u32"), Values(nullptr),
1018 Values(TestResult())));
1019
1020 INSTANTIATE_TEST_SUITE_P(
1021 LayerAndViewportIndexInvalidExecutionModel,
1022 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1023 Combine(
1024 Values("Layer", "ViewportIndex"),
1025 Values("TessellationControl", "GLCompute"), Values("Input"),
1026 Values("%u32"),
1027 Values("VUID-Layer-Layer-04272 VUID-ViewportIndex-ViewportIndex-04404"),
1028 Values(
1029 TestResult(SPV_ERROR_INVALID_DATA,
1030 "to be used only with Vertex, TessellationEvaluation, "
1031 "Geometry, or Fragment execution models"))));
1032
1033 INSTANTIATE_TEST_SUITE_P(
1034 ViewportIndexExecutionModelEnabledByCapability,
1035 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1036 Combine(Values("ViewportIndex"), Values("Vertex", "TessellationEvaluation"),
1037 Values("Output"), Values("%u32"),
1038 Values("VUID-ViewportIndex-ViewportIndex-04405"),
1039 Values(TestResult(
1040 SPV_ERROR_INVALID_DATA,
1041 "ShaderViewportIndexLayerEXT or ShaderViewportIndex"))));
1042
1043 INSTANTIATE_TEST_SUITE_P(
1044 LayerExecutionModelEnabledByCapability,
1045 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1046 Combine(Values("Layer"), Values("Vertex", "TessellationEvaluation"),
1047 Values("Output"), Values("%u32"), Values("VUID-Layer-Layer-04273"),
1048 Values(TestResult(SPV_ERROR_INVALID_DATA,
1049 "ShaderViewportIndexLayerEXT or ShaderLayer"))));
1050
1051 INSTANTIATE_TEST_SUITE_P(
1052 LayerAndViewportIndexFragmentNotInput,
1053 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1054 Combine(
1055 Values("Layer", "ViewportIndex"), Values("Fragment"), Values("Output"),
1056 Values("%u32"),
1057 Values("VUID-Layer-Layer-04275 VUID-ViewportIndex-ViewportIndex-04407"),
1058 Values(TestResult(SPV_ERROR_INVALID_DATA,
1059 "Output storage class if execution model is Fragment",
1060 "which is called with execution model Fragment"))));
1061
1062 INSTANTIATE_TEST_SUITE_P(
1063 LayerAndViewportIndexGeometryNotOutput,
1064 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1065 Combine(
1066 Values("Layer", "ViewportIndex"),
1067 Values("Vertex", "TessellationEvaluation", "Geometry"), Values("Input"),
1068 Values("%u32"),
1069 Values("VUID-Layer-Layer-04274 VUID-ViewportIndex-ViewportIndex-04406"),
1070 Values(TestResult(SPV_ERROR_INVALID_DATA,
1071 "Input storage class if execution model is Vertex, "
1072 "TessellationEvaluation, Geometry, MeshNV or MeshEXT",
1073 "which is called with execution model"))));
1074
1075 INSTANTIATE_TEST_SUITE_P(
1076 LayerAndViewportIndexNotIntScalar,
1077 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1078 Combine(
1079 Values("Layer", "ViewportIndex"), Values("Fragment"), Values("Input"),
1080 Values("%f32", "%u32vec3"),
1081 Values("VUID-Layer-Layer-04276 VUID-ViewportIndex-ViewportIndex-04408"),
1082 Values(TestResult(SPV_ERROR_INVALID_DATA,
1083 "needs to be a 32-bit int scalar",
1084 "is not an int scalar"))));
1085
1086 INSTANTIATE_TEST_SUITE_P(
1087 LayerAndViewportIndexNotInt32,
1088 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1089 Combine(
1090 Values("Layer", "ViewportIndex"), Values("Fragment"), Values("Input"),
1091 Values("%u64"),
1092 Values("VUID-Layer-Layer-04276 VUID-ViewportIndex-ViewportIndex-04408"),
1093 Values(TestResult(SPV_ERROR_INVALID_DATA,
1094 "needs to be a 32-bit int scalar",
1095 "has bit width 64"))));
1096
1097 INSTANTIATE_TEST_SUITE_P(
1098 LayerCapability,
1099 ValidateGenericCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
1100 Combine(Values(SPV_ENV_VULKAN_1_2), Values("Layer"), Values("Vertex"),
1101 Values("Output"), Values("%u32"),
1102 Values("OpCapability ShaderLayer\n"), Values(nullptr),
1103 Values(nullptr), Values(TestResult())));
1104
1105 INSTANTIATE_TEST_SUITE_P(
1106 ViewportIndexCapability,
1107 ValidateGenericCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
1108 Combine(Values(SPV_ENV_VULKAN_1_2), Values("ViewportIndex"),
1109 Values("Vertex"), Values("Output"), Values("%u32"),
1110 Values("OpCapability ShaderViewportIndex\n"), Values(nullptr),
1111 Values(nullptr), Values(TestResult())));
1112
1113 INSTANTIATE_TEST_SUITE_P(
1114 PatchVerticesSuccess,
1115 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1116 Combine(Values("PatchVertices"),
1117 Values("TessellationEvaluation", "TessellationControl"),
1118 Values("Input"), Values("%u32"), Values(nullptr),
1119 Values(TestResult())));
1120
1121 INSTANTIATE_TEST_SUITE_P(
1122 PatchVerticesInvalidExecutionModel,
1123 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1124 Combine(Values("PatchVertices"),
1125 Values("Vertex", "Fragment", "GLCompute", "Geometry"),
1126 Values("Input"), Values("%u32"),
1127 Values("VUID-PatchVertices-PatchVertices-04308"),
1128 Values(TestResult(SPV_ERROR_INVALID_DATA,
1129 "to be used only with TessellationControl or "
1130 "TessellationEvaluation execution models"))));
1131
1132 INSTANTIATE_TEST_SUITE_P(
1133 PatchVerticesNotInput,
1134 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1135 Combine(Values("PatchVertices"),
1136 Values("TessellationEvaluation", "TessellationControl"),
1137 Values("Output"), Values("%u32"),
1138 Values("VUID-PatchVertices-PatchVertices-04309"),
1139 Values(TestResult(
1140 SPV_ERROR_INVALID_DATA,
1141 "to be only used for variables with Input storage class",
1142 "uses storage class Output"))));
1143
1144 INSTANTIATE_TEST_SUITE_P(
1145 PatchVerticesNotIntScalar,
1146 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1147 Combine(Values("PatchVertices"),
1148 Values("TessellationEvaluation", "TessellationControl"),
1149 Values("Input"), Values("%f32", "%u32vec3"),
1150 Values("VUID-PatchVertices-PatchVertices-04310"),
1151 Values(TestResult(SPV_ERROR_INVALID_DATA,
1152 "needs to be a 32-bit int scalar",
1153 "is not an int scalar"))));
1154
1155 INSTANTIATE_TEST_SUITE_P(
1156 PatchVerticesNotInt32,
1157 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1158 Combine(Values("PatchVertices"),
1159 Values("TessellationEvaluation", "TessellationControl"),
1160 Values("Input"), Values("%u64"),
1161 Values("VUID-PatchVertices-PatchVertices-04310"),
1162 Values(TestResult(SPV_ERROR_INVALID_DATA,
1163 "needs to be a 32-bit int scalar",
1164 "has bit width 64"))));
1165
1166 INSTANTIATE_TEST_SUITE_P(
1167 PointCoordSuccess, ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1168 Combine(Values("PointCoord"), Values("Fragment"), Values("Input"),
1169 Values("%f32vec2"), Values(nullptr), Values(TestResult())));
1170
1171 INSTANTIATE_TEST_SUITE_P(
1172 PointCoordNotFragment,
1173 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1174 Combine(
1175 Values("PointCoord"),
1176 Values("Vertex", "GLCompute", "Geometry", "TessellationControl",
1177 "TessellationEvaluation"),
1178 Values("Input"), Values("%f32vec2"),
1179 Values("VUID-PointCoord-PointCoord-04311"),
1180 Values(TestResult(SPV_ERROR_INVALID_DATA,
1181 "to be used only with Fragment execution model"))));
1182
1183 INSTANTIATE_TEST_SUITE_P(
1184 PointCoordNotInput,
1185 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1186 Combine(Values("PointCoord"), Values("Fragment"), Values("Output"),
1187 Values("%f32vec2"), Values("VUID-PointCoord-PointCoord-04312"),
1188 Values(TestResult(
1189 SPV_ERROR_INVALID_DATA,
1190 "to be only used for variables with Input storage class",
1191 "uses storage class Output"))));
1192
1193 INSTANTIATE_TEST_SUITE_P(
1194 PointCoordNotFloatVector,
1195 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1196 Combine(Values("PointCoord"), Values("Fragment"), Values("Input"),
1197 Values("%f32arr2", "%u32vec2"),
1198 Values("VUID-PointCoord-PointCoord-04313"),
1199 Values(TestResult(SPV_ERROR_INVALID_DATA,
1200 "needs to be a 2-component 32-bit float vector",
1201 "is not a float vector"))));
1202
1203 INSTANTIATE_TEST_SUITE_P(
1204 PointCoordNotFloatVec3,
1205 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1206 Combine(Values("PointCoord"), Values("Fragment"), Values("Input"),
1207 Values("%f32vec3"), Values("VUID-PointCoord-PointCoord-04313"),
1208 Values(TestResult(SPV_ERROR_INVALID_DATA,
1209 "needs to be a 2-component 32-bit float vector",
1210 "has 3 components"))));
1211
1212 INSTANTIATE_TEST_SUITE_P(
1213 PointCoordNotF32Vec4,
1214 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1215 Combine(Values("PointCoord"), Values("Fragment"), Values("Input"),
1216 Values("%f64vec2"), Values("VUID-PointCoord-PointCoord-04313"),
1217 Values(TestResult(SPV_ERROR_INVALID_DATA,
1218 "needs to be a 2-component 32-bit float vector",
1219 "has components with bit width 64"))));
1220
1221 INSTANTIATE_TEST_SUITE_P(
1222 PointSizeOutputSuccess,
1223 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1224 Combine(Values("PointSize"),
1225 Values("Vertex", "Geometry", "TessellationControl",
1226 "TessellationEvaluation"),
1227 Values("Output"), Values("%f32"), Values(nullptr),
1228 Values(TestResult())));
1229
1230 INSTANTIATE_TEST_SUITE_P(
1231 PointSizeInputSuccess,
1232 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1233 Combine(Values("PointSize"),
1234 Values("Geometry", "TessellationControl", "TessellationEvaluation"),
1235 Values("Input"), Values("%f32"), Values(nullptr),
1236 Values(TestResult())));
1237
1238 INSTANTIATE_TEST_SUITE_P(
1239 PointSizeVertexInput,
1240 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1241 Combine(Values("PointSize"), Values("Vertex"), Values("Input"),
1242 Values("%f32"), Values("VUID-PointSize-PointSize-04315"),
1243 Values(TestResult(
1244 SPV_ERROR_INVALID_DATA,
1245 "Vulkan spec doesn't allow BuiltIn PointSize "
1246 "to be used for variables with Input storage class if "
1247 "execution model is Vertex.",
1248 "which is called with execution model Vertex."))));
1249
1250 INSTANTIATE_TEST_SUITE_P(
1251 PointSizeInvalidExecutionModel,
1252 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1253 Combine(Values("PointSize"), Values("GLCompute", "Fragment"),
1254 Values("Input", "Output"), Values("%f32"),
1255 Values("VUID-PointSize-PointSize-04314"),
1256 Values(TestResult(
1257 SPV_ERROR_INVALID_DATA,
1258 "to be used only with Vertex, TessellationControl, "
1259 "TessellationEvaluation or Geometry execution models"))));
1260
1261 INSTANTIATE_TEST_SUITE_P(
1262 PointSizeNotFloatScalar,
1263 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1264 Combine(Values("PointSize"), Values("Vertex"), Values("Output"),
1265 Values("%f32vec4", "%u32"),
1266 Values("VUID-PointSize-PointSize-04317"),
1267 Values(TestResult(SPV_ERROR_INVALID_DATA,
1268 "needs to be a 32-bit float scalar",
1269 "is not a float scalar"))));
1270
1271 INSTANTIATE_TEST_SUITE_P(
1272 PointSizeNotF32, ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1273 Combine(Values("PointSize"), Values("Vertex"), Values("Output"),
1274 Values("%f64"), Values("VUID-PointSize-PointSize-04317"),
1275 Values(TestResult(SPV_ERROR_INVALID_DATA,
1276 "needs to be a 32-bit float scalar",
1277 "has bit width 64"))));
1278
1279 INSTANTIATE_TEST_SUITE_P(
1280 PositionOutputSuccess,
1281 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1282 Combine(Values("Position"),
1283 Values("Vertex", "Geometry", "TessellationControl",
1284 "TessellationEvaluation"),
1285 Values("Output"), Values("%f32vec4"), Values(nullptr),
1286 Values(TestResult())));
1287
1288 INSTANTIATE_TEST_SUITE_P(
1289 PositionInputSuccess,
1290 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1291 Combine(Values("Position"),
1292 Values("Geometry", "TessellationControl", "TessellationEvaluation"),
1293 Values("Input"), Values("%f32vec4"), Values(nullptr),
1294 Values(TestResult())));
1295
1296 INSTANTIATE_TEST_SUITE_P(
1297 PositionInvalidStorageClass,
1298 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1299 Combine(Values("Position"),
1300 Values("Geometry", "TessellationControl", "TessellationEvaluation"),
1301 Values("Private"), Values("%f32vec4"),
1302 Values("VUID-Position-Position-04320"),
1303 Values(TestResult(
1304 SPV_ERROR_INVALID_DATA,
1305 "Vulkan spec allows BuiltIn Position to be only used for "
1306 "variables with Input or Output storage class."))));
1307
1308 INSTANTIATE_TEST_SUITE_P(
1309 PositionVertexInput,
1310 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1311 Combine(Values("Position"), Values("Vertex"), Values("Input"),
1312 Values("%f32vec4"), Values("VUID-Position-Position-04319"),
1313 Values(TestResult(
1314 SPV_ERROR_INVALID_DATA,
1315 "Vulkan spec doesn't allow BuiltIn Position "
1316 "to be used for variables with Input storage class if "
1317 "execution model is Vertex.",
1318 "which is called with execution model Vertex."))));
1319
1320 INSTANTIATE_TEST_SUITE_P(
1321 PositionInvalidExecutionModel,
1322 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1323 Combine(Values("Position"), Values("GLCompute", "Fragment"),
1324 Values("Input", "Output"), Values("%f32vec4"),
1325 Values("VUID-Position-Position-04318"),
1326 Values(TestResult(
1327 SPV_ERROR_INVALID_DATA,
1328 "to be used only with Vertex, TessellationControl, "
1329 "TessellationEvaluation or Geometry execution models"))));
1330
1331 INSTANTIATE_TEST_SUITE_P(
1332 PositionNotFloatVector,
1333 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1334 Combine(Values("Position"), Values("Geometry"), Values("Input"),
1335 Values("%f32arr4", "%u32vec4"),
1336 Values("VUID-Position-Position-04321"),
1337 Values(TestResult(SPV_ERROR_INVALID_DATA,
1338 "needs to be a 4-component 32-bit float vector",
1339 "is not a float vector"))));
1340
1341 INSTANTIATE_TEST_SUITE_P(
1342 PositionNotFloatVec4,
1343 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1344 Combine(Values("Position"), Values("Geometry"), Values("Input"),
1345 Values("%f32vec3"), Values("VUID-Position-Position-04321"),
1346 Values(TestResult(SPV_ERROR_INVALID_DATA,
1347 "needs to be a 4-component 32-bit float vector",
1348 "has 3 components"))));
1349
1350 INSTANTIATE_TEST_SUITE_P(
1351 PositionNotF32Vec4,
1352 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1353 Combine(Values("Position"), Values("Geometry"), Values("Input"),
1354 Values("%f64vec4"), Values("VUID-Position-Position-04321"),
1355 Values(TestResult(SPV_ERROR_INVALID_DATA,
1356 "needs to be a 4-component 32-bit float vector",
1357 "has components with bit width 64"))));
1358
1359 INSTANTIATE_TEST_SUITE_P(
1360 PrimitiveIdInputSuccess,
1361 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1362 Combine(Values("PrimitiveId"),
1363 Values("Fragment", "TessellationControl", "TessellationEvaluation",
1364 "Geometry"),
1365 Values("Input"), Values("%u32"), Values(nullptr),
1366 Values(TestResult())));
1367
1368 INSTANTIATE_TEST_SUITE_P(
1369 PrimitiveIdOutputSuccess,
1370 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1371 Combine(Values("PrimitiveId"), Values("Geometry"), Values("Output"),
1372 Values("%u32"), Values(nullptr), Values(TestResult())));
1373
1374 INSTANTIATE_TEST_SUITE_P(
1375 PrimitiveIdInvalidExecutionModel,
1376 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1377 Combine(
1378 Values("PrimitiveId"), Values("Vertex", "GLCompute"), Values("Input"),
1379 Values("%u32"), Values("VUID-PrimitiveId-PrimitiveId-04330"),
1380 Values(TestResult(SPV_ERROR_INVALID_DATA,
1381 "to be used only with Fragment, TessellationControl, "
1382 "TessellationEvaluation, Geometry, MeshNV, MeshEXT, "
1383 "IntersectionKHR, "
1384 "AnyHitKHR, and ClosestHitKHR execution models"))));
1385
1386 INSTANTIATE_TEST_SUITE_P(
1387 PrimitiveIdFragmentNotInput,
1388 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1389 Combine(
1390 Values("PrimitiveId"), Values("Fragment"), Values("Output"),
1391 Values("%u32"), Values("VUID-PrimitiveId-PrimitiveId-04334"),
1392 Values(TestResult(SPV_ERROR_INVALID_DATA,
1393 "Output storage class if execution model is Fragment",
1394 "which is called with execution model Fragment"))));
1395
1396 INSTANTIATE_TEST_SUITE_P(
1397 PrimitiveIdTessellationNotInput,
1398 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1399 Combine(Values("PrimitiveId"),
1400 Values("TessellationControl", "TessellationEvaluation"),
1401 Values("Output"), Values("%u32"),
1402 Values("VUID-PrimitiveId-PrimitiveId-04334"),
1403 Values(TestResult(
1404 SPV_ERROR_INVALID_DATA,
1405 "Output storage class if execution model is Tessellation",
1406 "which is called with execution model Tessellation"))));
1407
1408 INSTANTIATE_TEST_SUITE_P(
1409 PrimitiveIdNotIntScalar,
1410 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1411 Combine(Values("PrimitiveId"), Values("Fragment"), Values("Input"),
1412 Values("%f32", "%u32vec3"),
1413 Values("VUID-PrimitiveId-PrimitiveId-04337"),
1414 Values(TestResult(SPV_ERROR_INVALID_DATA,
1415 "needs to be a 32-bit int scalar",
1416 "is not an int scalar"))));
1417
1418 INSTANTIATE_TEST_SUITE_P(
1419 PrimitiveIdNotInt32,
1420 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1421 Combine(Values("PrimitiveId"), Values("Fragment"), Values("Input"),
1422 Values("%u64"), Values("VUID-PrimitiveId-PrimitiveId-04337"),
1423 Values(TestResult(SPV_ERROR_INVALID_DATA,
1424 "needs to be a 32-bit int scalar",
1425 "has bit width 64"))));
1426
1427 INSTANTIATE_TEST_SUITE_P(
1428 SampleIdSuccess, ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1429 Combine(Values("SampleId"), Values("Fragment"), Values("Input"),
1430 Values("%u32"), Values(nullptr), Values(TestResult())));
1431
1432 INSTANTIATE_TEST_SUITE_P(
1433 SampleIdInvalidExecutionModel,
1434 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1435 Combine(
1436 Values("SampleId"),
1437 Values("Vertex", "GLCompute", "Geometry", "TessellationControl",
1438 "TessellationEvaluation"),
1439 Values("Input"), Values("%u32"), Values("VUID-SampleId-SampleId-04354"),
1440 Values(TestResult(SPV_ERROR_INVALID_DATA,
1441 "to be used only with Fragment execution model"))));
1442
1443 INSTANTIATE_TEST_SUITE_P(
1444 SampleIdNotInput, ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1445 Combine(
1446 Values("SampleId"), Values("Fragment"), Values("Output"),
1447 Values("%u32"), Values("VUID-SampleId-SampleId-04355"),
1448 Values(TestResult(SPV_ERROR_INVALID_DATA,
1449 "Vulkan spec allows BuiltIn SampleId to be only used "
1450 "for variables with Input storage class"))));
1451
1452 INSTANTIATE_TEST_SUITE_P(
1453 SampleIdNotIntScalar,
1454 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1455 Combine(Values("SampleId"), Values("Fragment"), Values("Input"),
1456 Values("%f32", "%u32vec3"), Values("VUID-SampleId-SampleId-04356"),
1457 Values(TestResult(SPV_ERROR_INVALID_DATA,
1458 "needs to be a 32-bit int scalar",
1459 "is not an int scalar"))));
1460
1461 INSTANTIATE_TEST_SUITE_P(
1462 SampleIdNotInt32, ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1463 Combine(Values("SampleId"), Values("Fragment"), Values("Input"),
1464 Values("%u64"), Values("VUID-SampleId-SampleId-04356"),
1465 Values(TestResult(SPV_ERROR_INVALID_DATA,
1466 "needs to be a 32-bit int scalar",
1467 "has bit width 64"))));
1468
1469 INSTANTIATE_TEST_SUITE_P(
1470 SampleMaskSuccess, ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1471 Combine(Values("SampleMask"), Values("Fragment"), Values("Input", "Output"),
1472 Values("%u32arr2", "%u32arr4"), Values(nullptr),
1473 Values(TestResult())));
1474
1475 INSTANTIATE_TEST_SUITE_P(
1476 SampleMaskInvalidExecutionModel,
1477 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1478 Combine(
1479 Values("SampleMask"),
1480 Values("Vertex", "GLCompute", "Geometry", "TessellationControl",
1481 "TessellationEvaluation"),
1482 Values("Input"), Values("%u32arr2"),
1483 Values("VUID-SampleMask-SampleMask-04357"),
1484 Values(TestResult(SPV_ERROR_INVALID_DATA,
1485 "to be used only with Fragment execution model"))));
1486
1487 INSTANTIATE_TEST_SUITE_P(
1488 SampleMaskNotArray,
1489 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1490 Combine(Values("SampleMask"), Values("Fragment"), Values("Input"),
1491 Values("%f32", "%u32vec3"),
1492 Values("VUID-SampleMask-SampleMask-04359"),
1493 Values(TestResult(SPV_ERROR_INVALID_DATA,
1494 "needs to be a 32-bit int array",
1495 "is not an array"))));
1496
1497 INSTANTIATE_TEST_SUITE_P(
1498 SampleMaskNotIntArray,
1499 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1500 Combine(Values("SampleMask"), Values("Fragment"), Values("Input"),
1501 Values("%f32arr2"), Values("VUID-SampleMask-SampleMask-04359"),
1502 Values(TestResult(SPV_ERROR_INVALID_DATA,
1503 "needs to be a 32-bit int array",
1504 "components are not int scalar"))));
1505
1506 INSTANTIATE_TEST_SUITE_P(
1507 SampleMaskNotInt32Array,
1508 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1509 Combine(Values("SampleMask"), Values("Fragment"), Values("Input"),
1510 Values("%u64arr2"), Values("VUID-SampleMask-SampleMask-04359"),
1511 Values(TestResult(SPV_ERROR_INVALID_DATA,
1512 "needs to be a 32-bit int array",
1513 "has components with bit width 64"))));
1514
1515 INSTANTIATE_TEST_SUITE_P(
1516 SamplePositionSuccess,
1517 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1518 Combine(Values("SamplePosition"), Values("Fragment"), Values("Input"),
1519 Values("%f32vec2"), Values(nullptr), Values(TestResult())));
1520
1521 INSTANTIATE_TEST_SUITE_P(
1522 SamplePositionNotFragment,
1523 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1524 Combine(
1525 Values("SamplePosition"),
1526 Values("Vertex", "GLCompute", "Geometry", "TessellationControl",
1527 "TessellationEvaluation"),
1528 Values("Input"), Values("%f32vec2"),
1529 Values("VUID-SamplePosition-SamplePosition-04360"),
1530 Values(TestResult(SPV_ERROR_INVALID_DATA,
1531 "to be used only with Fragment execution model"))));
1532
1533 INSTANTIATE_TEST_SUITE_P(
1534 SamplePositionNotInput,
1535 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1536 Combine(Values("SamplePosition"), Values("Fragment"), Values("Output"),
1537 Values("%f32vec2"),
1538 Values("VUID-SamplePosition-SamplePosition-04361"),
1539 Values(TestResult(
1540 SPV_ERROR_INVALID_DATA,
1541 "to be only used for variables with Input storage class",
1542 "uses storage class Output"))));
1543
1544 INSTANTIATE_TEST_SUITE_P(
1545 SamplePositionNotFloatVector,
1546 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1547 Combine(Values("SamplePosition"), Values("Fragment"), Values("Input"),
1548 Values("%f32arr2", "%u32vec4"),
1549 Values("VUID-SamplePosition-SamplePosition-04362"),
1550 Values(TestResult(SPV_ERROR_INVALID_DATA,
1551 "needs to be a 2-component 32-bit float vector",
1552 "is not a float vector"))));
1553
1554 INSTANTIATE_TEST_SUITE_P(
1555 SamplePositionNotFloatVec2,
1556 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1557 Combine(Values("SamplePosition"), Values("Fragment"), Values("Input"),
1558 Values("%f32vec3"),
1559 Values("VUID-SamplePosition-SamplePosition-04362"),
1560 Values(TestResult(SPV_ERROR_INVALID_DATA,
1561 "needs to be a 2-component 32-bit float vector",
1562 "has 3 components"))));
1563
1564 INSTANTIATE_TEST_SUITE_P(
1565 SamplePositionNotF32Vec2,
1566 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1567 Combine(Values("SamplePosition"), Values("Fragment"), Values("Input"),
1568 Values("%f64vec2"),
1569 Values("VUID-SamplePosition-SamplePosition-04362"),
1570 Values(TestResult(SPV_ERROR_INVALID_DATA,
1571 "needs to be a 2-component 32-bit float vector",
1572 "has components with bit width 64"))));
1573
1574 INSTANTIATE_TEST_SUITE_P(
1575 TessCoordSuccess, ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1576 Combine(Values("TessCoord"), Values("TessellationEvaluation"),
1577 Values("Input"), Values("%f32vec3"), Values(nullptr),
1578 Values(TestResult())));
1579
1580 INSTANTIATE_TEST_SUITE_P(
1581 TessCoordNotFragment,
1582 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1583 Combine(
1584 Values("TessCoord"),
1585 Values("Vertex", "GLCompute", "Geometry", "TessellationControl",
1586 "Fragment"),
1587 Values("Input"), Values("%f32vec3"),
1588 Values("VUID-TessCoord-TessCoord-04387"),
1589 Values(TestResult(
1590 SPV_ERROR_INVALID_DATA,
1591 "to be used only with TessellationEvaluation execution model"))));
1592
1593 INSTANTIATE_TEST_SUITE_P(
1594 TessCoordNotInput, ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1595 Combine(Values("TessCoord"), Values("Fragment"), Values("Output"),
1596 Values("%f32vec3"), Values("VUID-TessCoord-TessCoord-04388"),
1597 Values(TestResult(
1598 SPV_ERROR_INVALID_DATA,
1599 "to be only used for variables with Input storage class",
1600 "uses storage class Output"))));
1601
1602 INSTANTIATE_TEST_SUITE_P(
1603 TessCoordNotFloatVector,
1604 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1605 Combine(Values("TessCoord"), Values("Fragment"), Values("Input"),
1606 Values("%f32arr3", "%u32vec4"),
1607 Values("VUID-TessCoord-TessCoord-04389"),
1608 Values(TestResult(SPV_ERROR_INVALID_DATA,
1609 "needs to be a 3-component 32-bit float vector",
1610 "is not a float vector"))));
1611
1612 INSTANTIATE_TEST_SUITE_P(
1613 TessCoordNotFloatVec3,
1614 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1615 Combine(Values("TessCoord"), Values("Fragment"), Values("Input"),
1616 Values("%f32vec2"), Values("VUID-TessCoord-TessCoord-04389"),
1617 Values(TestResult(SPV_ERROR_INVALID_DATA,
1618 "needs to be a 3-component 32-bit float vector",
1619 "has 2 components"))));
1620
1621 INSTANTIATE_TEST_SUITE_P(
1622 TessCoordNotF32Vec3,
1623 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1624 Combine(Values("TessCoord"), Values("Fragment"), Values("Input"),
1625 Values("%f64vec3"), Values("VUID-TessCoord-TessCoord-04389"),
1626 Values(TestResult(SPV_ERROR_INVALID_DATA,
1627 "needs to be a 3-component 32-bit float vector",
1628 "has components with bit width 64"))));
1629
1630 INSTANTIATE_TEST_SUITE_P(
1631 TessLevelOuterTeseInputSuccess,
1632 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1633 Combine(Values("TessLevelOuter"), Values("TessellationEvaluation"),
1634 Values("Input"), Values("%f32arr4"), Values(nullptr),
1635 Values(TestResult())));
1636
1637 INSTANTIATE_TEST_SUITE_P(
1638 TessLevelOuterTescOutputSuccess,
1639 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1640 Combine(Values("TessLevelOuter"), Values("TessellationControl"),
1641 Values("Output"), Values("%f32arr4"), Values(nullptr),
1642 Values(TestResult())));
1643
1644 INSTANTIATE_TEST_SUITE_P(
1645 TessLevelOuterInvalidExecutionModel,
1646 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1647 Combine(Values("TessLevelOuter"),
1648 Values("Vertex", "GLCompute", "Geometry", "Fragment"),
1649 Values("Input"), Values("%f32arr4"),
1650 Values("VUID-TessLevelOuter-TessLevelOuter-04390"),
1651 Values(TestResult(SPV_ERROR_INVALID_DATA,
1652 "to be used only with TessellationControl or "
1653 "TessellationEvaluation execution models."))));
1654
1655 INSTANTIATE_TEST_SUITE_P(
1656 TessLevelOuterOutputTese,
1657 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1658 Combine(Values("TessLevelOuter"), Values("TessellationEvaluation"),
1659 Values("Output"), Values("%f32arr4"),
1660 Values("VUID-TessLevelOuter-TessLevelOuter-04392"),
1661 Values(TestResult(
1662 SPV_ERROR_INVALID_DATA,
1663 "Vulkan spec doesn't allow TessLevelOuter/TessLevelInner to be "
1664 "used for variables with Output storage class if execution "
1665 "model is TessellationEvaluation."))));
1666
1667 INSTANTIATE_TEST_SUITE_P(
1668 TessLevelOuterInputTesc,
1669 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1670 Combine(Values("TessLevelOuter"), Values("TessellationControl"),
1671 Values("Input"), Values("%f32arr4"),
1672 Values("VUID-TessLevelOuter-TessLevelOuter-04391"),
1673 Values(TestResult(
1674 SPV_ERROR_INVALID_DATA,
1675 "Vulkan spec doesn't allow TessLevelOuter/TessLevelInner to be "
1676 "used for variables with Input storage class if execution "
1677 "model is TessellationControl."))));
1678
1679 INSTANTIATE_TEST_SUITE_P(
1680 TessLevelOuterNotArray,
1681 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1682 Combine(Values("TessLevelOuter"), Values("TessellationEvaluation"),
1683 Values("Input"), Values("%f32vec4", "%f32"),
1684 Values("VUID-TessLevelOuter-TessLevelOuter-04393"),
1685 Values(TestResult(SPV_ERROR_INVALID_DATA,
1686 "needs to be a 4-component 32-bit float array",
1687 "is not an array"))));
1688
1689 INSTANTIATE_TEST_SUITE_P(
1690 TessLevelOuterNotFloatArray,
1691 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1692 Combine(Values("TessLevelOuter"), Values("TessellationEvaluation"),
1693 Values("Input"), Values("%u32arr4"),
1694 Values("VUID-TessLevelOuter-TessLevelOuter-04393"),
1695 Values(TestResult(SPV_ERROR_INVALID_DATA,
1696 "needs to be a 4-component 32-bit float array",
1697 "components are not float scalar"))));
1698
1699 INSTANTIATE_TEST_SUITE_P(
1700 TessLevelOuterNotFloatArr4,
1701 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1702 Combine(Values("TessLevelOuter"), Values("TessellationEvaluation"),
1703 Values("Input"), Values("%f32arr3"),
1704 Values("VUID-TessLevelOuter-TessLevelOuter-04393"),
1705 Values(TestResult(SPV_ERROR_INVALID_DATA,
1706 "needs to be a 4-component 32-bit float array",
1707 "has 3 components"))));
1708
1709 INSTANTIATE_TEST_SUITE_P(
1710 TessLevelOuterNotF32Arr4,
1711 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1712 Combine(Values("TessLevelOuter"), Values("TessellationEvaluation"),
1713 Values("Input"), Values("%f64arr4"),
1714 Values("VUID-TessLevelOuter-TessLevelOuter-04393"),
1715 Values(TestResult(SPV_ERROR_INVALID_DATA,
1716 "needs to be a 4-component 32-bit float array",
1717 "has components with bit width 64"))));
1718
1719 INSTANTIATE_TEST_SUITE_P(
1720 TessLevelInnerTeseInputSuccess,
1721 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1722 Combine(Values("TessLevelInner"), Values("TessellationEvaluation"),
1723 Values("Input"), Values("%f32arr2"), Values(nullptr),
1724 Values(TestResult())));
1725
1726 INSTANTIATE_TEST_SUITE_P(
1727 TessLevelInnerTescOutputSuccess,
1728 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1729 Combine(Values("TessLevelInner"), Values("TessellationControl"),
1730 Values("Output"), Values("%f32arr2"), Values(nullptr),
1731 Values(TestResult())));
1732
1733 INSTANTIATE_TEST_SUITE_P(
1734 TessLevelInnerInvalidExecutionModel,
1735 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1736 Combine(Values("TessLevelInner"),
1737 Values("Vertex", "GLCompute", "Geometry", "Fragment"),
1738 Values("Input"), Values("%f32arr2"),
1739 Values("VUID-TessLevelInner-TessLevelInner-04394"),
1740 Values(TestResult(SPV_ERROR_INVALID_DATA,
1741 "to be used only with TessellationControl or "
1742 "TessellationEvaluation execution models."))));
1743
1744 INSTANTIATE_TEST_SUITE_P(
1745 TessLevelInnerOutputTese,
1746 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1747 Combine(Values("TessLevelInner"), Values("TessellationEvaluation"),
1748 Values("Output"), Values("%f32arr2"),
1749 Values("VUID-TessLevelInner-TessLevelInner-04396"),
1750 Values(TestResult(
1751 SPV_ERROR_INVALID_DATA,
1752 "Vulkan spec doesn't allow TessLevelOuter/TessLevelInner to be "
1753 "used for variables with Output storage class if execution "
1754 "model is TessellationEvaluation."))));
1755
1756 INSTANTIATE_TEST_SUITE_P(
1757 TessLevelInnerInputTesc,
1758 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1759 Combine(Values("TessLevelInner"), Values("TessellationControl"),
1760 Values("Input"), Values("%f32arr2"),
1761 Values("VUID-TessLevelInner-TessLevelInner-04395"),
1762 Values(TestResult(
1763 SPV_ERROR_INVALID_DATA,
1764 "Vulkan spec doesn't allow TessLevelOuter/TessLevelInner to be "
1765 "used for variables with Input storage class if execution "
1766 "model is TessellationControl."))));
1767
1768 INSTANTIATE_TEST_SUITE_P(
1769 TessLevelInnerNotArray,
1770 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1771 Combine(Values("TessLevelInner"), Values("TessellationEvaluation"),
1772 Values("Input"), Values("%f32vec2", "%f32"),
1773 Values("VUID-TessLevelInner-TessLevelInner-04397"),
1774 Values(TestResult(SPV_ERROR_INVALID_DATA,
1775 "needs to be a 2-component 32-bit float array",
1776 "is not an array"))));
1777
1778 INSTANTIATE_TEST_SUITE_P(
1779 TessLevelInnerNotFloatArray,
1780 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1781 Combine(Values("TessLevelInner"), Values("TessellationEvaluation"),
1782 Values("Input"), Values("%u32arr2"),
1783 Values("VUID-TessLevelInner-TessLevelInner-04397"),
1784 Values(TestResult(SPV_ERROR_INVALID_DATA,
1785 "needs to be a 2-component 32-bit float array",
1786 "components are not float scalar"))));
1787
1788 INSTANTIATE_TEST_SUITE_P(
1789 TessLevelInnerNotFloatArr2,
1790 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1791 Combine(Values("TessLevelInner"), Values("TessellationEvaluation"),
1792 Values("Input"), Values("%f32arr3"),
1793 Values("VUID-TessLevelInner-TessLevelInner-04397"),
1794 Values(TestResult(SPV_ERROR_INVALID_DATA,
1795 "needs to be a 2-component 32-bit float array",
1796 "has 3 components"))));
1797
1798 INSTANTIATE_TEST_SUITE_P(
1799 TessLevelInnerNotF32Arr2,
1800 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1801 Combine(Values("TessLevelInner"), Values("TessellationEvaluation"),
1802 Values("Input"), Values("%f64arr2"),
1803 Values("VUID-TessLevelInner-TessLevelInner-04397"),
1804 Values(TestResult(SPV_ERROR_INVALID_DATA,
1805 "needs to be a 2-component 32-bit float array",
1806 "has components with bit width 64"))));
1807
1808 INSTANTIATE_TEST_SUITE_P(
1809 VertexIndexSuccess,
1810 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1811 Combine(Values("VertexIndex"), Values("Vertex"), Values("Input"),
1812 Values("%u32"), Values(nullptr), Values(TestResult())));
1813
1814 INSTANTIATE_TEST_SUITE_P(
1815 VertexIndexInvalidExecutionModel,
1816 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1817 Combine(Values("VertexIndex"),
1818 Values("Fragment", "GLCompute", "Geometry", "TessellationControl",
1819 "TessellationEvaluation"),
1820 Values("Input"), Values("%u32"),
1821 Values("VUID-VertexIndex-VertexIndex-04398"),
1822 Values(TestResult(SPV_ERROR_INVALID_DATA,
1823 "to be used only with Vertex execution model"))));
1824
1825 INSTANTIATE_TEST_SUITE_P(
1826 VertexIndexNotInput,
1827 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1828 Combine(
1829 Values("VertexIndex"), Values("Vertex"), Values("Output"),
1830 Values("%u32"), Values("VUID-VertexIndex-VertexIndex-04399"),
1831 Values(TestResult(SPV_ERROR_INVALID_DATA,
1832 "Vulkan spec allows BuiltIn VertexIndex to be only "
1833 "used for variables with Input storage class"))));
1834
1835 INSTANTIATE_TEST_SUITE_P(
1836 VertexIndexNotIntScalar,
1837 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1838 Combine(Values("VertexIndex"), Values("Vertex"), Values("Input"),
1839 Values("%f32", "%u32vec3"),
1840 Values("VUID-VertexIndex-VertexIndex-04400"),
1841 Values(TestResult(SPV_ERROR_INVALID_DATA,
1842 "needs to be a 32-bit int scalar",
1843 "is not an int scalar"))));
1844
1845 INSTANTIATE_TEST_SUITE_P(
1846 VertexIndexNotInt32,
1847 ValidateVulkanCombineBuiltInExecutionModelDataTypeResult,
1848 Combine(Values("VertexIndex"), Values("Vertex"), Values("Input"),
1849 Values("%u64"), Values("VUID-VertexIndex-VertexIndex-04400"),
1850 Values(TestResult(SPV_ERROR_INVALID_DATA,
1851 "needs to be a 32-bit int scalar",
1852 "has bit width 64"))));
1853
1854 INSTANTIATE_TEST_SUITE_P(
1855 BaseInstanceOrVertexSuccess,
1856 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
1857 Combine(Values("BaseInstance", "BaseVertex"), Values("Vertex"),
1858 Values("Input"), Values("%u32"),
1859 Values("OpCapability DrawParameters\n"),
1860 Values("OpExtension \"SPV_KHR_shader_draw_parameters\"\n"),
1861 Values(nullptr), Values(TestResult())));
1862
1863 INSTANTIATE_TEST_SUITE_P(
1864 BaseInstanceOrVertexInvalidExecutionModel,
1865 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
1866 Combine(Values("BaseInstance", "BaseVertex"),
1867 Values("Fragment", "GLCompute", "Geometry", "TessellationControl",
1868 "TessellationEvaluation"),
1869 Values("Input"), Values("%u32"),
1870 Values("OpCapability DrawParameters\n"),
1871 Values("OpExtension \"SPV_KHR_shader_draw_parameters\"\n"),
1872 Values("VUID-BaseInstance-BaseInstance-04181 "
1873 "VUID-BaseVertex-BaseVertex-04184"),
1874 Values(TestResult(SPV_ERROR_INVALID_DATA,
1875 "to be used only with Vertex execution model"))));
1876
1877 INSTANTIATE_TEST_SUITE_P(
1878 BaseInstanceOrVertexNotInput,
1879 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
1880 Combine(Values("BaseInstance", "BaseVertex"), Values("Vertex"),
1881 Values("Output"), Values("%u32"),
1882 Values("OpCapability DrawParameters\n"),
1883 Values("OpExtension \"SPV_KHR_shader_draw_parameters\"\n"),
1884 Values("VUID-BaseInstance-BaseInstance-04182 "
1885 "VUID-BaseVertex-BaseVertex-04185"),
1886 Values(TestResult(SPV_ERROR_INVALID_DATA, "Vulkan spec allows",
1887 "used for variables with Input storage class"))));
1888
1889 INSTANTIATE_TEST_SUITE_P(
1890 BaseInstanceOrVertexNotIntScalar,
1891 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
1892 Combine(Values("BaseInstance", "BaseVertex"), Values("Vertex"),
1893 Values("Input"), Values("%f32", "%u32vec3"),
1894 Values("OpCapability DrawParameters\n"),
1895 Values("OpExtension \"SPV_KHR_shader_draw_parameters\"\n"),
1896 Values("VUID-BaseInstance-BaseInstance-04183 "
1897 "VUID-BaseVertex-BaseVertex-04186"),
1898 Values(TestResult(SPV_ERROR_INVALID_DATA,
1899 "needs to be a 32-bit int scalar",
1900 "is not an int scalar"))));
1901
1902 INSTANTIATE_TEST_SUITE_P(
1903 DrawIndexSuccess,
1904 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
1905 Combine(Values("DrawIndex"), Values("Vertex"), Values("Input"),
1906 Values("%u32"), Values("OpCapability DrawParameters\n"),
1907 Values("OpExtension \"SPV_KHR_shader_draw_parameters\"\n"),
1908 Values(nullptr), Values(TestResult())));
1909
1910 INSTANTIATE_TEST_SUITE_P(
1911 DrawIndexMeshSuccess,
1912 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
1913 Combine(
1914 Values("DrawIndex"), Values("MeshNV", "TaskNV"), Values("Input"),
1915 Values("%u32"), Values("OpCapability MeshShadingNV\n"),
1916 Values("OpExtension \"SPV_KHR_shader_draw_parameters\"\nOpExtension "
1917 "\"SPV_NV_mesh_shader\"\n"),
1918 Values(nullptr), Values(TestResult())));
1919
1920 INSTANTIATE_TEST_SUITE_P(
1921 DrawIndexInvalidExecutionModel,
1922 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
1923 Combine(
1924 Values("DrawIndex"),
1925 Values("Fragment", "GLCompute", "Geometry", "TessellationControl",
1926 "TessellationEvaluation"),
1927 Values("Input"), Values("%u32"),
1928 Values("OpCapability DrawParameters\n"),
1929 Values("OpExtension \"SPV_KHR_shader_draw_parameters\"\n"),
1930 Values("VUID-DrawIndex-DrawIndex-04207"),
1931 Values(TestResult(
1932 SPV_ERROR_INVALID_DATA,
1933 "to be used only with Vertex, MeshNV, TaskNV , MeshEXT or TaskEXT "
1934 "execution model"))));
1935
1936 INSTANTIATE_TEST_SUITE_P(
1937 DrawIndexNotInput,
1938 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
1939 Combine(Values("DrawIndex"), Values("Vertex"), Values("Output"),
1940 Values("%u32"), Values("OpCapability DrawParameters\n"),
1941 Values("OpExtension \"SPV_KHR_shader_draw_parameters\"\n"),
1942 Values("VUID-DrawIndex-DrawIndex-04208"),
1943 Values(TestResult(SPV_ERROR_INVALID_DATA, "Vulkan spec allows",
1944 "used for variables with Input storage class"))));
1945
1946 INSTANTIATE_TEST_SUITE_P(
1947 DrawIndexNotIntScalar,
1948 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
1949 Combine(Values("DrawIndex"), Values("Vertex"), Values("Input"),
1950 Values("%f32", "%u32vec3"), Values("OpCapability DrawParameters\n"),
1951 Values("OpExtension \"SPV_KHR_shader_draw_parameters\"\n"),
1952 Values("VUID-DrawIndex-DrawIndex-04209"),
1953 Values(TestResult(SPV_ERROR_INVALID_DATA,
1954 "needs to be a 32-bit int scalar",
1955 "is not an int scalar"))));
1956
1957 INSTANTIATE_TEST_SUITE_P(
1958 ViewIndexSuccess,
1959 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
1960 Combine(Values("ViewIndex"),
1961 Values("Fragment", "Vertex", "Geometry", "TessellationControl",
1962 "TessellationEvaluation"),
1963 Values("Input"), Values("%u32"), Values("OpCapability MultiView\n"),
1964 Values("OpExtension \"SPV_KHR_multiview\"\n"), Values(nullptr),
1965 Values(TestResult())));
1966
1967 INSTANTIATE_TEST_SUITE_P(
1968 ViewIndexInvalidExecutionModel,
1969 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
1970 Combine(Values("ViewIndex"), Values("GLCompute"), Values("Input"),
1971 Values("%u32"), Values("OpCapability MultiView\n"),
1972 Values("OpExtension \"SPV_KHR_multiview\"\n"),
1973 Values("VUID-ViewIndex-ViewIndex-04401"),
1974 Values(TestResult(
1975 SPV_ERROR_INVALID_DATA,
1976 "to be not be used with GLCompute execution model"))));
1977
1978 INSTANTIATE_TEST_SUITE_P(
1979 ViewIndexNotInput,
1980 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
1981 Combine(Values("ViewIndex"), Values("Vertex"), Values("Output"),
1982 Values("%u32"), Values("OpCapability MultiView\n"),
1983 Values("OpExtension \"SPV_KHR_multiview\"\n"),
1984 Values("VUID-ViewIndex-ViewIndex-04402"),
1985 Values(TestResult(SPV_ERROR_INVALID_DATA, "Vulkan spec allows",
1986 "used for variables with Input storage class"))));
1987
1988 INSTANTIATE_TEST_SUITE_P(
1989 ViewIndexNotIntScalar,
1990 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
1991 Combine(Values("ViewIndex"), Values("Vertex"), Values("Input"),
1992 Values("%f32", "%u32vec3"), Values("OpCapability MultiView\n"),
1993 Values("OpExtension \"SPV_KHR_multiview\"\n"),
1994 Values("VUID-ViewIndex-ViewIndex-04403"),
1995 Values(TestResult(SPV_ERROR_INVALID_DATA,
1996 "needs to be a 32-bit int scalar",
1997 "is not an int scalar"))));
1998
1999 INSTANTIATE_TEST_SUITE_P(
2000 DeviceIndexSuccess,
2001 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2002 Combine(Values("DeviceIndex"),
2003 Values("Fragment", "Vertex", "Geometry", "TessellationControl",
2004 "TessellationEvaluation", "GLCompute"),
2005 Values("Input"), Values("%u32"),
2006 Values("OpCapability DeviceGroup\n"),
2007 Values("OpExtension \"SPV_KHR_device_group\"\n"), Values(nullptr),
2008 Values(TestResult())));
2009
2010 INSTANTIATE_TEST_SUITE_P(
2011 DeviceIndexNotInput,
2012 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2013 Combine(Values("DeviceIndex"), Values("Fragment", "Vertex", "GLCompute"),
2014 Values("Output"), Values("%u32"),
2015 Values("OpCapability DeviceGroup\n"),
2016 Values("OpExtension \"SPV_KHR_device_group\"\n"),
2017 Values("VUID-DeviceIndex-DeviceIndex-04205"),
2018 Values(TestResult(SPV_ERROR_INVALID_DATA, "Vulkan spec allows",
2019 "used for variables with Input storage class"))));
2020
2021 INSTANTIATE_TEST_SUITE_P(
2022 DeviceIndexNotIntScalar,
2023 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2024 Combine(Values("DeviceIndex"), Values("Fragment", "Vertex", "GLCompute"),
2025 Values("Input"), Values("%f32", "%u32vec3"),
2026 Values("OpCapability DeviceGroup\n"),
2027 Values("OpExtension \"SPV_KHR_device_group\"\n"),
2028 Values("VUID-DeviceIndex-DeviceIndex-04206"),
2029 Values(TestResult(SPV_ERROR_INVALID_DATA,
2030 "needs to be a 32-bit int scalar",
2031 "is not an int scalar"))));
2032
2033 // Test HitKind in NV RT shaders
2034 INSTANTIATE_TEST_SUITE_P(
2035 HitKindNVSuccess,
2036 ValidateGenericCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2037 Combine(Values(SPV_ENV_VULKAN_1_2), Values("HitKindNV"),
2038 Values("AnyHitNV", "ClosestHitNV"), Values("Input"), Values("%u32"),
2039 Values("OpCapability RayTracingNV\n"),
2040 Values("OpExtension \"SPV_NV_ray_tracing\"\n"), Values(nullptr),
2041 Values(TestResult())));
2042
2043 // HitKind is valid in AH, CH shaders as input i32 scalar
2044 INSTANTIATE_TEST_SUITE_P(
2045 HitKindSuccess,
2046 ValidateGenericCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2047 Combine(Values(SPV_ENV_VULKAN_1_2), Values("HitKindKHR"),
2048 Values("AnyHitKHR", "ClosestHitKHR"), Values("Input"),
2049 Values("%u32"), Values("OpCapability RayTracingKHR\n"),
2050 Values("OpExtension \"SPV_KHR_ray_tracing\"\n"), Values(nullptr),
2051 Values(TestResult())));
2052
2053 INSTANTIATE_TEST_SUITE_P(
2054 HitKindNotExecutionMode,
2055 ValidateGenericCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2056 Combine(Values(SPV_ENV_VULKAN_1_2), Values("HitKindKHR"),
2057 Values("Vertex", "Fragment", "TessellationControl",
2058 "TessellationEvaluation", "Geometry", "Fragment",
2059 "GLCompute", "RayGenerationKHR", "IntersectionKHR",
2060 "MissKHR", "CallableKHR"),
2061 Values("Input"), Values("%u32"),
2062 Values("OpCapability RayTracingKHR\n"),
2063 Values("OpExtension \"SPV_KHR_ray_tracing\"\n"),
2064 Values("VUID-HitKindKHR-HitKindKHR-04242"),
2065 Values(TestResult(SPV_ERROR_INVALID_DATA,
2066 "Vulkan spec does not allow BuiltIn",
2067 "to be used with the execution model"))));
2068
2069 INSTANTIATE_TEST_SUITE_P(
2070 HitKindNotInput,
2071 ValidateGenericCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2072 Combine(Values(SPV_ENV_VULKAN_1_2), Values("HitKindKHR"),
2073 Values("AnyHitKHR", "ClosestHitKHR"), Values("Output"),
2074 Values("%u32"), Values("OpCapability RayTracingKHR\n"),
2075 Values("OpExtension \"SPV_KHR_ray_tracing\"\n"),
2076 Values("VUID-HitKindKHR-HitKindKHR-04243"),
2077 Values(TestResult(SPV_ERROR_INVALID_DATA, "Vulkan spec allows",
2078 "used for variables with Input storage class"))));
2079
2080 INSTANTIATE_TEST_SUITE_P(
2081 HitKindNotIntScalar,
2082 ValidateGenericCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2083 Combine(Values(SPV_ENV_VULKAN_1_2), Values("HitKindKHR"),
2084 Values("AnyHitKHR", "ClosestHitKHR"), Values("Input"),
2085 Values("%f32", "%u32vec3"), Values("OpCapability RayTracingKHR\n"),
2086 Values("OpExtension \"SPV_KHR_ray_tracing\"\n"),
2087 Values("VUID-HitKindKHR-HitKindKHR-04244"),
2088 Values(TestResult(SPV_ERROR_INVALID_DATA,
2089 "needs to be a 32-bit int scalar",
2090 "is not an int scalar"))));
2091
2092 // Ensure HitT is not supported in KHR RT shaders
2093 INSTANTIATE_TEST_SUITE_P(
2094 HitTNVNotSupportedInKHR,
2095 ValidateGenericCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2096 Combine(Values(SPV_ENV_VULKAN_1_2), Values("HitTNV"),
2097 Values("AnyHitKHR", "ClosestHitKHR"), Values("Input"),
2098 Values("%u32"), Values("OpCapability RayTracingKHR\n"),
2099 Values("OpExtension \"SPV_KHR_ray_tracing\"\n"), Values(nullptr),
2100 Values(TestResult(
2101 SPV_ERROR_INVALID_CAPABILITY,
2102 "of MemberDecorate requires one of these capabilities"))));
2103
2104 // HitT is valid in AH, CH shaders as input f32 scalar (NV RT only)
2105 INSTANTIATE_TEST_SUITE_P(
2106 HitTNVSuccess,
2107 ValidateGenericCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2108 Combine(Values(SPV_ENV_VULKAN_1_2), Values("HitTNV"),
2109 Values("AnyHitNV", "ClosestHitNV"), Values("Input"), Values("%f32"),
2110 Values("OpCapability RayTracingNV\n"),
2111 Values("OpExtension \"SPV_NV_ray_tracing\"\n"), Values(nullptr),
2112 Values(TestResult())));
2113
2114 INSTANTIATE_TEST_SUITE_P(
2115 HitTNVNotExecutionMode,
2116 ValidateGenericCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2117 Combine(Values(SPV_ENV_VULKAN_1_2), Values("HitTNV"),
2118 Values("Vertex", "Fragment", "TessellationControl",
2119 "TessellationEvaluation", "Geometry", "Fragment",
2120 "GLCompute", "RayGenerationNV", "IntersectionNV", "MissNV",
2121 "CallableNV"),
2122 Values("Input"), Values("%f32"),
2123 Values("OpCapability RayTracingNV\n"),
2124 Values("OpExtension \"SPV_NV_ray_tracing\"\n"),
2125 Values("VUID-HitTNV-HitTNV-04245"),
2126 Values(TestResult(SPV_ERROR_INVALID_DATA,
2127 "Vulkan spec does not allow BuiltIn",
2128 "to be used with the execution model"))));
2129
2130 INSTANTIATE_TEST_SUITE_P(
2131 HitTNVNotInput,
2132 ValidateGenericCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2133 Combine(Values(SPV_ENV_VULKAN_1_2), Values("HitTNV"),
2134 Values("AnyHitNV", "ClosestHitNV"), Values("Output"),
2135 Values("%f32"), Values("OpCapability RayTracingNV\n"),
2136 Values("OpExtension \"SPV_NV_ray_tracing\"\n"),
2137 Values("VUID-HitTNV-HitTNV-04246"),
2138 Values(TestResult(SPV_ERROR_INVALID_DATA, "Vulkan spec allows",
2139 "used for variables with Input storage class"))));
2140 INSTANTIATE_TEST_SUITE_P(
2141 HitTNVNotIntScalar,
2142 ValidateGenericCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2143 Combine(Values(SPV_ENV_VULKAN_1_2), Values("HitTNV"),
2144 Values("AnyHitNV", "ClosestHitNV"), Values("Input"),
2145 Values("%u32", "%f32vec3"), Values("OpCapability RayTracingNV\n"),
2146 Values("OpExtension \"SPV_NV_ray_tracing\"\n"),
2147 Values("VUID-HitTNV-HitTNV-04247"),
2148 Values(TestResult(SPV_ERROR_INVALID_DATA,
2149 "needs to be a 32-bit float scalar",
2150 "is not a float scalar"))));
2151
2152 // InstanceCustomIndexKHR, InstanceId, PrimitiveId, RayGeometryIndexKHR are
2153 // valid in IS, AH, CH shaders as input i32 scalars
2154 INSTANTIATE_TEST_SUITE_P(
2155 RTBuiltIn3StageI32Success,
2156 ValidateGenericCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2157 Combine(Values(SPV_ENV_VULKAN_1_2),
2158 Values("InstanceCustomIndexKHR", "RayGeometryIndexKHR",
2159 "InstanceId", "PrimitiveId"),
2160 Values("AnyHitKHR", "ClosestHitKHR", "IntersectionKHR"),
2161 Values("Input"), Values("%u32"),
2162 Values("OpCapability RayTracingKHR\n"),
2163 Values("OpExtension \"SPV_KHR_ray_tracing\"\n"), Values(nullptr),
2164 Values(TestResult())));
2165
2166 INSTANTIATE_TEST_SUITE_P(
2167 RTBuiltIn3StageI32NotExecutionMode,
2168 ValidateGenericCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2169 Combine(Values(SPV_ENV_VULKAN_1_2),
2170 Values("InstanceCustomIndexKHR", "RayGeometryIndexKHR",
2171 "InstanceId"),
2172 Values("Vertex", "Fragment", "TessellationControl",
2173 "TessellationEvaluation", "Geometry", "Fragment",
2174 "GLCompute", "RayGenerationKHR", "MissKHR", "CallableKHR"),
2175 Values("Input"), Values("%u32"),
2176 Values("OpCapability RayTracingKHR\n"),
2177 Values("OpExtension \"SPV_KHR_ray_tracing\"\n"),
2178 Values("VUID-InstanceCustomIndexKHR-InstanceCustomIndexKHR-04251 "
2179 "VUID-RayGeometryIndexKHR-RayGeometryIndexKHR-04345 "
2180 "VUID-InstanceId-InstanceId-04254 "),
2181 Values(TestResult(SPV_ERROR_INVALID_DATA,
2182 "Vulkan spec does not allow BuiltIn",
2183 "to be used with the execution model"))));
2184
2185 INSTANTIATE_TEST_SUITE_P(
2186 RTBuiltIn3StageI32NotInput,
2187 ValidateGenericCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2188 Combine(Values(SPV_ENV_VULKAN_1_2),
2189 Values("InstanceCustomIndexKHR", "RayGeometryIndexKHR",
2190 "InstanceId"),
2191 Values("AnyHitKHR", "ClosestHitKHR", "IntersectionKHR"),
2192 Values("Output"), Values("%u32"),
2193 Values("OpCapability RayTracingKHR\n"),
2194 Values("OpExtension \"SPV_KHR_ray_tracing\"\n"),
2195 Values("VUID-InstanceCustomIndexKHR-InstanceCustomIndexKHR-04252 "
2196 "VUID-RayGeometryIndexKHR-RayGeometryIndexKHR-04346 "
2197 "VUID-InstanceId-InstanceId-04255 "),
2198 Values(TestResult(SPV_ERROR_INVALID_DATA, "Vulkan spec allows",
2199 "used for variables with Input storage class"))));
2200
2201 INSTANTIATE_TEST_SUITE_P(
2202 RTBuiltIn3StageI32NotIntScalar,
2203 ValidateGenericCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2204 Combine(Values(SPV_ENV_VULKAN_1_2),
2205 Values("InstanceCustomIndexKHR", "RayGeometryIndexKHR",
2206 "InstanceId"),
2207 Values("AnyHitKHR", "ClosestHitKHR", "IntersectionKHR"),
2208 Values("Input"), Values("%f32", "%u32vec3"),
2209 Values("OpCapability RayTracingKHR\n"),
2210 Values("OpExtension \"SPV_KHR_ray_tracing\"\n"),
2211 Values("VUID-InstanceCustomIndexKHR-InstanceCustomIndexKHR-04253 "
2212 "VUID-RayGeometryIndexKHR-RayGeometryIndexKHR-04347 "
2213 "VUID-InstanceId-InstanceId-04256 "),
2214 Values(TestResult(SPV_ERROR_INVALID_DATA,
2215 "needs to be a 32-bit int scalar",
2216 "is not an int scalar"))));
2217
2218 // PrimitiveId needs special negative testing because it has non-RT uses
2219 INSTANTIATE_TEST_SUITE_P(
2220 PrimitiveIdRTNotExecutionMode,
2221 ValidateGenericCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2222 Combine(
2223 Values(SPV_ENV_VULKAN_1_2), Values("PrimitiveId"),
2224 Values("RayGenerationKHR", "MissKHR", "CallableKHR"), Values("Input"),
2225 Values("%u32"), Values("OpCapability RayTracingKHR\n"),
2226 Values("OpExtension \"SPV_KHR_ray_tracing\"\n"),
2227 Values("VUID-PrimitiveId-PrimitiveId-04330"),
2228 Values(TestResult(SPV_ERROR_INVALID_DATA,
2229 "to be used only with Fragment, TessellationControl, "
2230 "TessellationEvaluation, Geometry, MeshNV, MeshEXT, "
2231 "IntersectionKHR, "
2232 "AnyHitKHR, and ClosestHitKHR execution models"))));
2233
2234 INSTANTIATE_TEST_SUITE_P(
2235 PrimitiveIdRTNotInput,
2236 ValidateGenericCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2237 Combine(Values(SPV_ENV_VULKAN_1_2), Values("PrimitiveId"),
2238 Values("AnyHitKHR", "ClosestHitKHR", "IntersectionKHR"),
2239 Values("Output"), Values("%u32"),
2240 Values("OpCapability RayTracingKHR\n"),
2241 Values("OpExtension \"SPV_KHR_ray_tracing\"\n"),
2242 Values("VUID-PrimitiveId-PrimitiveId-04334"),
2243 Values(TestResult(SPV_ERROR_INVALID_DATA,
2244 "Output storage class if execution model is "))));
2245
2246 INSTANTIATE_TEST_SUITE_P(
2247 PrimitiveIdRTNotIntScalar,
2248 ValidateGenericCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2249 Combine(Values(SPV_ENV_VULKAN_1_2), Values("PrimitiveId"),
2250 Values("AnyHitKHR", "ClosestHitKHR", "IntersectionKHR"),
2251 Values("Input"), Values("%f32", "%u32vec3"),
2252 Values("OpCapability RayTracingKHR\n"),
2253 Values("OpExtension \"SPV_KHR_ray_tracing\"\n"),
2254 Values("VUID-PrimitiveId-PrimitiveId-04337"),
2255 Values(TestResult(SPV_ERROR_INVALID_DATA,
2256 "needs to be a 32-bit int scalar",
2257 "is not an int scalar"))));
2258
2259 // ObjectRayDirectionKHR and ObjectRayOriginKHR valid
2260 // in IS, AH, CH shaders as input 32-bit float vec3
2261 INSTANTIATE_TEST_SUITE_P(
2262 ObjectRayDirectionAndOriginSuccess,
2263 ValidateGenericCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2264 Combine(Values(SPV_ENV_VULKAN_1_2),
2265 Values("ObjectRayDirectionKHR", "ObjectRayOriginKHR"),
2266 Values("AnyHitKHR", "ClosestHitKHR", "IntersectionKHR"),
2267 Values("Input"), Values("%f32vec3"),
2268 Values("OpCapability RayTracingKHR\n"),
2269 Values("OpExtension \"SPV_KHR_ray_tracing\"\n"), Values(nullptr),
2270 Values(TestResult())));
2271
2272 INSTANTIATE_TEST_SUITE_P(
2273 ObjectRayDirectionAndOriginNotExecutionMode,
2274 ValidateGenericCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2275 Combine(Values(SPV_ENV_VULKAN_1_2),
2276 Values("ObjectRayDirectionKHR", "ObjectRayOriginKHR"),
2277 Values("Vertex", "Fragment", "TessellationControl",
2278 "TessellationEvaluation", "Geometry", "Fragment",
2279 "GLCompute", "RayGenerationKHR", "MissKHR", "CallableKHR"),
2280 Values("Input"), Values("%f32vec3"),
2281 Values("OpCapability RayTracingKHR\n"),
2282 Values("OpExtension \"SPV_KHR_ray_tracing\"\n"),
2283 Values("VUID-ObjectRayDirectionKHR-ObjectRayDirectionKHR-04299 "
2284 "VUID-ObjectRayOriginKHR-ObjectRayOriginKHR-04302 "),
2285 Values(TestResult(SPV_ERROR_INVALID_DATA,
2286 "Vulkan spec does not allow BuiltIn",
2287 "to be used with the execution model"))));
2288
2289 INSTANTIATE_TEST_SUITE_P(
2290 ObjectRayDirectionAndOriginNotInput,
2291 ValidateGenericCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2292 Combine(Values(SPV_ENV_VULKAN_1_2),
2293 Values("ObjectRayDirectionKHR", "ObjectRayOriginKHR"),
2294 Values("AnyHitKHR", "ClosestHitKHR", "IntersectionKHR"),
2295 Values("Output"), Values("%f32vec3"),
2296 Values("OpCapability RayTracingKHR\n"),
2297 Values("OpExtension \"SPV_KHR_ray_tracing\"\n"),
2298 Values("VUID-ObjectRayDirectionKHR-ObjectRayDirectionKHR-04300 "
2299 "VUID-ObjectRayOriginKHR-ObjectRayOriginKHR-04303 "),
2300 Values(TestResult(SPV_ERROR_INVALID_DATA, "Vulkan spec allows",
2301 "used for variables with Input storage class"))));
2302
2303 INSTANTIATE_TEST_SUITE_P(
2304 ObjectRayDirectionAndOriginNotFloatVec3,
2305 ValidateGenericCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2306 Combine(
2307 Values(SPV_ENV_VULKAN_1_2),
2308 Values("ObjectRayDirectionKHR", "ObjectRayOriginKHR"),
2309 Values("AnyHitKHR", "ClosestHitKHR", "IntersectionKHR"),
2310 Values("Input"), Values("%u32vec3", "%f32", "%f32vec2", "%f32vec4"),
2311 Values("OpCapability RayTracingKHR\n"),
2312 Values("OpExtension \"SPV_KHR_ray_tracing\"\n"),
2313 Values("VUID-ObjectRayDirectionKHR-ObjectRayDirectionKHR-04301 "
2314 "VUID-ObjectRayOriginKHR-ObjectRayOriginKHR-04304 "),
2315 Values(TestResult(SPV_ERROR_INVALID_DATA,
2316 "needs to be a 3-component 32-bit float vector"))));
2317
2318 // ObjectToWorldKHR and WorldToObjectKHR valid
2319 // in IS, AH, CH shaders as input mat4x3
2320 INSTANTIATE_TEST_SUITE_P(
2321 RTObjectMatrixSuccess,
2322 ValidateGenericCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2323 Combine(Values(SPV_ENV_VULKAN_1_2),
2324 Values("ObjectToWorldKHR", "WorldToObjectKHR"),
2325 Values("AnyHitKHR", "ClosestHitKHR", "IntersectionKHR"),
2326 Values("Input"), Values("%f32mat34"),
2327 Values("OpCapability RayTracingKHR\n"),
2328 Values("OpExtension \"SPV_KHR_ray_tracing\"\n"), Values(nullptr),
2329 Values(TestResult())));
2330
2331 INSTANTIATE_TEST_SUITE_P(
2332 RTObjectMatrixNotExecutionMode,
2333 ValidateGenericCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2334 Combine(Values(SPV_ENV_VULKAN_1_2),
2335 Values("ObjectToWorldKHR", "WorldToObjectKHR"),
2336 Values("Vertex", "Fragment", "TessellationControl",
2337 "TessellationEvaluation", "Geometry", "Fragment",
2338 "GLCompute", "RayGenerationKHR", "MissKHR", "CallableKHR"),
2339 Values("Input"), Values("%f32mat34"),
2340 Values("OpCapability RayTracingKHR\n"),
2341 Values("OpExtension \"SPV_KHR_ray_tracing\"\n"),
2342 Values("VUID-ObjectToWorldKHR-ObjectToWorldKHR-04305 "
2343 "VUID-WorldToObjectKHR-WorldToObjectKHR-04434 "),
2344 Values(TestResult(SPV_ERROR_INVALID_DATA,
2345 "Vulkan spec does not allow BuiltIn",
2346 "to be used with the execution model"))));
2347
2348 INSTANTIATE_TEST_SUITE_P(
2349 RTObjectMatrixNotInput,
2350 ValidateGenericCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2351 Combine(Values(SPV_ENV_VULKAN_1_2),
2352 Values("ObjectToWorldKHR", "WorldToObjectKHR"),
2353 Values("AnyHitKHR", "ClosestHitKHR", "IntersectionKHR"),
2354 Values("Output"), Values("%f32mat34"),
2355 Values("OpCapability RayTracingKHR\n"),
2356 Values("OpExtension \"SPV_KHR_ray_tracing\"\n"),
2357 Values("VUID-ObjectToWorldKHR-ObjectToWorldKHR-04306 "
2358 "VUID-WorldToObjectKHR-WorldToObjectKHR-04435 "),
2359 Values(TestResult(SPV_ERROR_INVALID_DATA, "Vulkan spec allows",
2360 "used for variables with Input storage class"))));
2361
2362 INSTANTIATE_TEST_SUITE_P(
2363 RTObjectMatrixNotMat4x3,
2364 ValidateGenericCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2365 Combine(Values(SPV_ENV_VULKAN_1_2),
2366 Values("ObjectToWorldKHR", "WorldToObjectKHR"),
2367 Values("AnyHitKHR", "ClosestHitKHR", "IntersectionKHR"),
2368 Values("Input"), Values("%f32mat43", "%f32mat44", "%f32vec4"),
2369 Values("OpCapability RayTracingKHR\n"),
2370 Values("OpExtension \"SPV_KHR_ray_tracing\"\n"),
2371 Values("VUID-ObjectToWorldKHR-ObjectToWorldKHR-04307 "
2372 "VUID-WorldToObjectKHR-WorldToObjectKHR-04436 "),
2373 Values(TestResult(
2374 SPV_ERROR_INVALID_DATA,
2375 "variable needs to be a matrix with "
2376 "4 columns of 3-component vectors of 32-bit floats"))));
2377
2378 // IncomingRayFlagsKHR is valid
2379 // in IS, AH, CH, MS shaders as an input i32 scalar
2380 INSTANTIATE_TEST_SUITE_P(
2381 IncomingRayFlagsSuccess,
2382 ValidateGenericCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2383 Combine(Values(SPV_ENV_VULKAN_1_2), Values("IncomingRayFlagsKHR"),
2384 Values("AnyHitKHR", "ClosestHitKHR", "IntersectionKHR", "MissKHR"),
2385 Values("Input"), Values("%u32"),
2386 Values("OpCapability RayTracingKHR\n"),
2387 Values("OpExtension \"SPV_KHR_ray_tracing\"\n"), Values(nullptr),
2388 Values(TestResult())));
2389
2390 INSTANTIATE_TEST_SUITE_P(
2391 IncomingRayFlagsNotExecutionMode,
2392 ValidateGenericCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2393 Combine(Values(SPV_ENV_VULKAN_1_2), Values("IncomingRayFlagsKHR"),
2394 Values("Vertex", "Fragment", "TessellationControl",
2395 "TessellationEvaluation", "Geometry", "Fragment",
2396 "GLCompute", "RayGenerationKHR", "CallableKHR"),
2397 Values("Input"), Values("%u32"),
2398 Values("OpCapability RayTracingKHR\n"),
2399 Values("OpExtension \"SPV_KHR_ray_tracing\"\n"),
2400 Values("VUID-IncomingRayFlagsKHR-IncomingRayFlagsKHR-04248 "
2401 "VUID-RayTmaxKHR-RayTmaxKHR-04348 "
2402 "VUID-RayTminKHR-RayTminKHR-04351 "),
2403 Values(TestResult(SPV_ERROR_INVALID_DATA,
2404 "Vulkan spec does not allow BuiltIn",
2405 "to be used with the execution model"))));
2406
2407 INSTANTIATE_TEST_SUITE_P(
2408 IncomingRayFlagsNotInput,
2409 ValidateGenericCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2410 Combine(Values(SPV_ENV_VULKAN_1_2), Values("IncomingRayFlagsKHR"),
2411 Values("AnyHitKHR", "ClosestHitKHR", "IntersectionKHR", "MissKHR"),
2412 Values("Output"), Values("%u32"),
2413 Values("OpCapability RayTracingKHR\n"),
2414 Values("OpExtension \"SPV_KHR_ray_tracing\"\n"),
2415 Values("VUID-IncomingRayFlagsKHR-IncomingRayFlagsKHR-04249 "
2416 "VUID-RayTmaxKHR-RayTmaxKHR-04349 "
2417 "VUID-RayTminKHR-RayTminKHR-04352 "),
2418 Values(TestResult(SPV_ERROR_INVALID_DATA, "Vulkan spec allows",
2419 "used for variables with Input storage class"))));
2420 INSTANTIATE_TEST_SUITE_P(
2421 IncomingRayFlagsNotIntScalar,
2422 ValidateGenericCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2423 Combine(Values(SPV_ENV_VULKAN_1_2), Values("IncomingRayFlagsKHR"),
2424 Values("AnyHitKHR", "ClosestHitKHR", "IntersectionKHR", "MissKHR"),
2425 Values("Input"), Values("%f32", "%u32vec3"),
2426 Values("OpCapability RayTracingKHR\n"),
2427 Values("OpExtension \"SPV_KHR_ray_tracing\"\n"),
2428 Values("VUID-IncomingRayFlagsKHR-IncomingRayFlagsKHR-04250 "
2429 "VUID-RayTmaxKHR-RayTmaxKHR-04350 "
2430 "VUID-RayTminKHR-RayTminKHR-04353 "),
2431 Values(TestResult(SPV_ERROR_INVALID_DATA,
2432 "needs to be a 32-bit int scalar",
2433 "is not an int scalar"))));
2434
2435 // CullMaskKHR is valid
2436 // in IS, AH, CH, MS shaders as an input i32 scalar
2437 INSTANTIATE_TEST_SUITE_P(
2438 CullMaskSuccess,
2439 ValidateGenericCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2440 Combine(Values(SPV_ENV_VULKAN_1_2), Values("CullMaskKHR"),
2441 Values("AnyHitKHR", "ClosestHitKHR", "IntersectionKHR", "MissKHR"),
2442 Values("Input"), Values("%u32"),
2443 Values("OpCapability RayTracingKHR\nOpCapability RayCullMaskKHR\n"),
2444 Values("OpExtension \"SPV_KHR_ray_tracing\"\nOpExtension "
2445 "\"SPV_KHR_ray_cull_mask\"\n"),
2446 Values(nullptr), Values(TestResult())));
2447
2448 INSTANTIATE_TEST_SUITE_P(
2449 CullMaskNotExecutionMode,
2450 ValidateGenericCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2451 Combine(Values(SPV_ENV_VULKAN_1_2), Values("CullMaskKHR"),
2452 Values("Vertex", "Fragment", "TessellationControl",
2453 "TessellationEvaluation", "Geometry", "Fragment",
2454 "GLCompute", "RayGenerationKHR", "CallableKHR"),
2455 Values("Input"), Values("%u32"),
2456 Values("OpCapability RayTracingKHR\nOpCapability RayCullMaskKHR\n"),
2457 Values("OpExtension \"SPV_KHR_ray_tracing\"\nOpExtension "
2458 "\"SPV_KHR_ray_cull_mask\"\n"),
2459 Values("VUID-CullMaskKHR-CullMaskKHR-06735 "
2460 "VUID-RayTmaxKHR-RayTmaxKHR-04348 "
2461 "VUID-RayTminKHR-RayTminKHR-04351 "),
2462 Values(TestResult(SPV_ERROR_INVALID_DATA,
2463 "Vulkan spec does not allow BuiltIn",
2464 "to be used with the execution model"))));
2465
2466 INSTANTIATE_TEST_SUITE_P(
2467 ICullMaskNotInput,
2468 ValidateGenericCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2469 Combine(Values(SPV_ENV_VULKAN_1_2), Values("CullMaskKHR"),
2470 Values("AnyHitKHR", "ClosestHitKHR", "IntersectionKHR", "MissKHR"),
2471 Values("Output"), Values("%u32"),
2472 Values("OpCapability RayTracingKHR\nOpCapability RayCullMaskKHR\n"),
2473 Values("OpExtension \"SPV_KHR_ray_tracing\"\nOpExtension "
2474 "\"SPV_KHR_ray_cull_mask\"\n"),
2475 Values("VUID-CullMaskKHR-CullMaskKHR-06736 "
2476 "VUID-RayTmaxKHR-RayTmaxKHR-04349 "
2477 "VUID-RayTminKHR-RayTminKHR-04352 "),
2478 Values(TestResult(SPV_ERROR_INVALID_DATA, "Vulkan spec allows",
2479 "used for variables with Input storage class"))));
2480 INSTANTIATE_TEST_SUITE_P(
2481 CullMaskNotIntScalar,
2482 ValidateGenericCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2483 Combine(Values(SPV_ENV_VULKAN_1_2), Values("CullMaskKHR"),
2484 Values("AnyHitKHR", "ClosestHitKHR", "IntersectionKHR", "MissKHR"),
2485 Values("Input"), Values("%f32", "%u32vec3"),
2486 Values("OpCapability RayTracingKHR\nOpCapability RayCullMaskKHR\n"),
2487 Values("OpExtension \"SPV_KHR_ray_tracing\"\nOpExtension "
2488 "\"SPV_KHR_ray_cull_mask\"\n"),
2489 Values("VUID-CullMaskKHR-CullMaskKHR-06737 "
2490 "VUID-RayTmaxKHR-RayTmaxKHR-04350 "
2491 "VUID-RayTminKHR-RayTminKHR-04353 "),
2492 Values(TestResult(SPV_ERROR_INVALID_DATA,
2493 "needs to be a 32-bit int scalar",
2494 "is not an int scalar"))));
2495
2496 // RayTmaxKHR, RayTminKHR are all valid
2497 // in IS, AH, CH, MS shaders as input f32 scalars
2498 INSTANTIATE_TEST_SUITE_P(
2499 RayTSuccess,
2500 ValidateGenericCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2501 Combine(Values(SPV_ENV_VULKAN_1_2), Values("RayTmaxKHR", "RayTminKHR"),
2502 Values("AnyHitKHR", "ClosestHitKHR", "IntersectionKHR", "MissKHR"),
2503 Values("Input"), Values("%f32"),
2504 Values("OpCapability RayTracingKHR\n"),
2505 Values("OpExtension \"SPV_KHR_ray_tracing\"\n"), Values(nullptr),
2506 Values(TestResult())));
2507
2508 INSTANTIATE_TEST_SUITE_P(
2509 RayTNotExecutionMode,
2510 ValidateGenericCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2511 Combine(Values(SPV_ENV_VULKAN_1_2), Values("RayTmaxKHR", "RayTminKHR"),
2512 Values("Vertex", "Fragment", "TessellationControl",
2513 "TessellationEvaluation", "Geometry", "Fragment",
2514 "GLCompute", "RayGenerationKHR", "CallableKHR"),
2515 Values("Input"), Values("%f32"),
2516 Values("OpCapability RayTracingKHR\n"),
2517 Values("OpExtension \"SPV_KHR_ray_tracing\"\n"),
2518 Values("VUID-IncomingRayFlagsKHR-IncomingRayFlagsKHR-04248 "
2519 "VUID-RayTmaxKHR-RayTmaxKHR-04348 "
2520 "VUID-RayTminKHR-RayTminKHR-04351 "),
2521 Values(TestResult(SPV_ERROR_INVALID_DATA,
2522 "Vulkan spec does not allow BuiltIn",
2523 "to be used with the execution model"))));
2524
2525 INSTANTIATE_TEST_SUITE_P(
2526 RayTNotInput,
2527 ValidateGenericCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2528 Combine(Values(SPV_ENV_VULKAN_1_2), Values("RayTmaxKHR", "RayTminKHR"),
2529 Values("AnyHitKHR", "ClosestHitKHR", "IntersectionKHR", "MissKHR"),
2530 Values("Output"), Values("%f32"),
2531 Values("OpCapability RayTracingKHR\n"),
2532 Values("OpExtension \"SPV_KHR_ray_tracing\"\n"),
2533 Values("VUID-IncomingRayFlagsKHR-IncomingRayFlagsKHR-04249 "
2534 "VUID-RayTmaxKHR-RayTmaxKHR-04349 "
2535 "VUID-RayTminKHR-RayTminKHR-04352 "),
2536 Values(TestResult(SPV_ERROR_INVALID_DATA, "Vulkan spec allows",
2537 "used for variables with Input storage class"))));
2538 INSTANTIATE_TEST_SUITE_P(
2539 RayTNotFloatScalar,
2540 ValidateGenericCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2541 Combine(Values(SPV_ENV_VULKAN_1_2), Values("RayTmaxKHR", "RayTminKHR"),
2542 Values("AnyHitKHR", "ClosestHitKHR", "IntersectionKHR", "MissKHR"),
2543 Values("Input"), Values("%u32", "%f32vec3"),
2544 Values("OpCapability RayTracingKHR\n"),
2545 Values("OpExtension \"SPV_KHR_ray_tracing\"\n"),
2546 Values("VUID-IncomingRayFlagsKHR-IncomingRayFlagsKHR-04250 "
2547 "VUID-RayTmaxKHR-RayTmaxKHR-04350 "
2548 "VUID-RayTminKHR-RayTminKHR-04353 "),
2549 Values(TestResult(SPV_ERROR_INVALID_DATA,
2550 "needs to be a 32-bit float scalar",
2551 "is not a float scalar"))));
2552
2553 // WorldRayDirectionKHR and WorldRayOriginKHR are valid
2554 // in IS, AH, CH, MS shaders as input 32-bit float vec3
2555 INSTANTIATE_TEST_SUITE_P(
2556 WorldRayDirectionAndOriginSuccess,
2557 ValidateGenericCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2558 Combine(Values(SPV_ENV_VULKAN_1_2),
2559 Values("WorldRayDirectionKHR", "WorldRayOriginKHR"),
2560 Values("AnyHitKHR", "ClosestHitKHR", "IntersectionKHR", "MissKHR"),
2561 Values("Input"), Values("%f32vec3"),
2562 Values("OpCapability RayTracingKHR\n"),
2563 Values("OpExtension \"SPV_KHR_ray_tracing\"\n"), Values(nullptr),
2564 Values(TestResult())));
2565
2566 INSTANTIATE_TEST_SUITE_P(
2567 WorldRayDirectionAndOriginNotExecutionMode,
2568 ValidateGenericCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2569 Combine(Values(SPV_ENV_VULKAN_1_2),
2570 Values("WorldRayDirectionKHR", "WorldRayOriginKHR"),
2571 Values("Vertex", "Fragment", "TessellationControl",
2572 "TessellationEvaluation", "Geometry", "Fragment",
2573 "GLCompute", "RayGenerationKHR", "CallableKHR"),
2574 Values("Input"), Values("%f32vec3"),
2575 Values("OpCapability RayTracingKHR\n"),
2576 Values("OpExtension \"SPV_KHR_ray_tracing\"\n"),
2577 Values("VUID-WorldRayDirectionKHR-WorldRayDirectionKHR-04428 "
2578 "VUID-WorldRayOriginKHR-WorldRayOriginKHR-04431 "),
2579 Values(TestResult(SPV_ERROR_INVALID_DATA,
2580 "Vulkan spec does not allow BuiltIn",
2581 "to be used with the execution model"))));
2582
2583 INSTANTIATE_TEST_SUITE_P(
2584 WorldRayDirectionAndOriginNotInput,
2585 ValidateGenericCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2586 Combine(Values(SPV_ENV_VULKAN_1_2),
2587 Values("WorldRayDirectionKHR", "WorldRayOriginKHR"),
2588 Values("AnyHitKHR", "ClosestHitKHR", "IntersectionKHR", "MissKHR"),
2589 Values("Output"), Values("%f32vec3"),
2590 Values("OpCapability RayTracingKHR\n"),
2591 Values("OpExtension \"SPV_KHR_ray_tracing\"\n"),
2592 Values("VUID-WorldRayDirectionKHR-WorldRayDirectionKHR-04429 "
2593 "VUID-WorldRayOriginKHR-WorldRayOriginKHR-04432 "),
2594 Values(TestResult(SPV_ERROR_INVALID_DATA, "Vulkan spec allows",
2595 "used for variables with Input storage class"))));
2596
2597 INSTANTIATE_TEST_SUITE_P(
2598 WorldRayDirectionAndOriginNotFloatVec3,
2599 ValidateGenericCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2600 Combine(
2601 Values(SPV_ENV_VULKAN_1_2),
2602 Values("WorldRayDirectionKHR", "WorldRayOriginKHR"),
2603 Values("AnyHitKHR", "ClosestHitKHR", "IntersectionKHR", "MissKHR"),
2604 Values("Input"), Values("%u32vec3", "%f32", "%f32vec2", "%f32vec4"),
2605 Values("OpCapability RayTracingKHR\n"),
2606 Values("OpExtension \"SPV_KHR_ray_tracing\"\n"),
2607 Values("VUID-WorldRayDirectionKHR-WorldRayDirectionKHR-04430 "
2608 "VUID-WorldRayOriginKHR-WorldRayOriginKHR-04433 "),
2609 Values(TestResult(SPV_ERROR_INVALID_DATA,
2610 "needs to be a 3-component 32-bit float vector"))));
2611
2612 // LaunchIdKHR and LaunchSizeKHR are valid
2613 // in RG, IS, AH, CH, MS shaders as input 32-bit ivec3
2614 INSTANTIATE_TEST_SUITE_P(
2615 LaunchRTSuccess,
2616 ValidateGenericCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2617 Combine(Values(SPV_ENV_VULKAN_1_2), Values("LaunchIdKHR", "LaunchSizeKHR"),
2618 Values("RayGenerationKHR", "AnyHitKHR", "ClosestHitKHR",
2619 "IntersectionKHR", "MissKHR", "CallableKHR"),
2620 Values("Input"), Values("%u32vec3"),
2621 Values("OpCapability RayTracingKHR\n"),
2622 Values("OpExtension \"SPV_KHR_ray_tracing\"\n"), Values(nullptr),
2623 Values(TestResult())));
2624
2625 INSTANTIATE_TEST_SUITE_P(
2626 LaunchRTNotExecutionMode,
2627 ValidateGenericCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2628 Combine(Values(SPV_ENV_VULKAN_1_2), Values("LaunchIdKHR", "LaunchSizeKHR"),
2629 Values("Vertex", "Fragment", "TessellationControl",
2630 "TessellationEvaluation", "Geometry", "Fragment",
2631 "GLCompute"),
2632 Values("Input"), Values("%u32vec3"),
2633 Values("OpCapability RayTracingKHR\n"),
2634 Values("OpExtension \"SPV_KHR_ray_tracing\"\n"),
2635 Values("VUID-LaunchIdKHR-LaunchIdKHR-04266 "
2636 "VUID-LaunchSizeKHR-LaunchSizeKHR-04269 "),
2637 Values(TestResult(SPV_ERROR_INVALID_DATA,
2638 "Vulkan spec does not allow BuiltIn",
2639 "to be used with the execution model"))));
2640
2641 INSTANTIATE_TEST_SUITE_P(
2642 LaunchRTNotInput,
2643 ValidateGenericCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2644 Combine(Values(SPV_ENV_VULKAN_1_2), Values("LaunchIdKHR", "LaunchSizeKHR"),
2645 Values("RayGenerationKHR", "AnyHitKHR", "ClosestHitKHR",
2646 "IntersectionKHR", "MissKHR", "CallableKHR"),
2647 Values("Output"), Values("%u32vec3"),
2648 Values("OpCapability RayTracingKHR\n"),
2649 Values("OpExtension \"SPV_KHR_ray_tracing\"\n"),
2650 Values("VUID-LaunchIdKHR-LaunchIdKHR-04267 "
2651 "VUID-LaunchSizeKHR-LaunchSizeKHR-04270 "),
2652 Values(TestResult(SPV_ERROR_INVALID_DATA, "Vulkan spec allows",
2653 "used for variables with Input storage class"))));
2654
2655 INSTANTIATE_TEST_SUITE_P(
2656 LaunchRTNotIntVec3,
2657 ValidateGenericCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2658 Combine(Values(SPV_ENV_VULKAN_1_2), Values("LaunchIdKHR", "LaunchSizeKHR"),
2659 Values("RayGenerationKHR", "AnyHitKHR", "ClosestHitKHR",
2660 "IntersectionKHR", "MissKHR", "CallableKHR"),
2661 Values("Input"), Values("%f32vec3", "%u32", "%u32vec2", "%u32vec4"),
2662 Values("OpCapability RayTracingKHR\n"),
2663 Values("OpExtension \"SPV_KHR_ray_tracing\"\n"),
2664 Values("VUID-LaunchIdKHR-LaunchIdKHR-04268 "
2665 "VUID-LaunchSizeKHR-LaunchSizeKHR-04271 "),
2666 Values(TestResult(SPV_ERROR_INVALID_DATA,
2667 "needs to be a 3-component 32-bit int vector"))));
2668
2669 CodeGenerator GetArrayedVariableCodeGenerator(const char* const built_in,
2670 const char* const execution_model,
2671 const char* const storage_class,
2672 const char* const data_type) {
2673 CodeGenerator generator = CodeGenerator::GetDefaultShaderCodeGenerator();
2674
2675 generator.before_types_ = "OpDecorate %built_in_var BuiltIn ";
2676 generator.before_types_ += built_in;
2677 generator.before_types_ += "\n";
2678
2679 std::ostringstream after_types;
2680 after_types << "%built_in_array = OpTypeArray " << data_type << " %u32_3\n";
2681 if (InitializerRequired(storage_class)) {
2682 after_types << "%built_in_array_null = OpConstantNull %built_in_array\n";
2683 }
2684
2685 after_types << "%built_in_ptr = OpTypePointer " << storage_class
2686 << " %built_in_array\n";
2687 after_types << "%built_in_var = OpVariable %built_in_ptr " << storage_class;
2688 if (InitializerRequired(storage_class)) {
2689 after_types << " %built_in_array_null";
2690 }
2691 after_types << "\n";
2692 generator.after_types_ = after_types.str();
2693
2694 EntryPoint entry_point;
2695 entry_point.name = "main";
2696 entry_point.execution_model = execution_model;
2697 entry_point.interfaces = "%built_in_var";
2698 // Any kind of reference would do.
2699 entry_point.body = R"(
2700 %val = OpCopyObject %built_in_ptr %built_in_var
2701 )";
2702
2703 std::ostringstream execution_modes;
2704 if (0 == std::strcmp(execution_model, "Fragment")) {
2705 execution_modes << "OpExecutionMode %" << entry_point.name
2706 << " OriginUpperLeft\n";
2707 if (0 == std::strcmp(built_in, "FragDepth")) {
2708 execution_modes << "OpExecutionMode %" << entry_point.name
2709 << " DepthReplacing\n";
2710 }
2711 }
2712 if (0 == std::strcmp(execution_model, "Geometry")) {
2713 execution_modes << "OpExecutionMode %" << entry_point.name
2714 << " InputPoints\n";
2715 execution_modes << "OpExecutionMode %" << entry_point.name
2716 << " OutputPoints\n";
2717 }
2718 if (0 == std::strcmp(execution_model, "GLCompute") ||
2719 0 == std::strcmp(execution_model, "MeshEXT") ||
2720 0 == std::strcmp(execution_model, "MeshNV") ||
2721 0 == std::strcmp(execution_model, "MeshEXT") ||
2722 0 == std::strcmp(execution_model, "TaskNV")) {
2723 execution_modes << "OpExecutionMode %" << entry_point.name
2724 << " LocalSize 1 1 1\n";
2725 }
2726 entry_point.execution_modes = execution_modes.str();
2727
2728 generator.entry_points_.push_back(std::move(entry_point));
2729
2730 return generator;
2731 }
2732
2733 TEST_P(ValidateVulkanCombineBuiltInArrayedVariable, Variable) {
2734 const char* const built_in = std::get<0>(GetParam());
2735 const char* const execution_model = std::get<1>(GetParam());
2736 const char* const storage_class = std::get<2>(GetParam());
2737 const char* const data_type = std::get<3>(GetParam());
2738 const char* const vuid = std::get<4>(GetParam());
2739 const TestResult& test_result = std::get<5>(GetParam());
2740
2741 CodeGenerator generator = GetArrayedVariableCodeGenerator(
2742 built_in, execution_model, storage_class, data_type);
2743
2744 CompileSuccessfully(generator.Build(), SPV_ENV_VULKAN_1_0);
2745 ASSERT_EQ(test_result.validation_result,
2746 ValidateInstructions(SPV_ENV_VULKAN_1_0));
2747 if (test_result.error_str) {
2748 EXPECT_THAT(getDiagnosticString(), HasSubstr(test_result.error_str));
2749 }
2750 if (test_result.error_str2) {
2751 EXPECT_THAT(getDiagnosticString(), HasSubstr(test_result.error_str2));
2752 }
2753 if (vuid) {
2754 EXPECT_THAT(getDiagnosticString(), AnyVUID(vuid));
2755 }
2756 }
2757
2758 INSTANTIATE_TEST_SUITE_P(
2759 PointSizeArrayedF32TessControl, ValidateVulkanCombineBuiltInArrayedVariable,
2760 Combine(Values("PointSize"), Values("TessellationControl"), Values("Input"),
2761 Values("%f32"), Values(nullptr), Values(TestResult())));
2762
2763 INSTANTIATE_TEST_SUITE_P(
2764 PointSizeArrayedF64TessControl, ValidateVulkanCombineBuiltInArrayedVariable,
2765 Combine(Values("PointSize"), Values("TessellationControl"), Values("Input"),
2766 Values("%f64"), Values("VUID-PointSize-PointSize-04317"),
2767 Values(TestResult(SPV_ERROR_INVALID_DATA,
2768 "needs to be a 32-bit float scalar",
2769 "has bit width 64"))));
2770
2771 INSTANTIATE_TEST_SUITE_P(
2772 PointSizeArrayedF32Vertex, ValidateVulkanCombineBuiltInArrayedVariable,
2773 Combine(Values("PointSize"), Values("Vertex"), Values("Output"),
2774 Values("%f32"), Values("VUID-PointSize-PointSize-04317"),
2775 Values(TestResult(SPV_ERROR_INVALID_DATA,
2776 "needs to be a 32-bit float scalar",
2777 "is not a float scalar"))));
2778
2779 INSTANTIATE_TEST_SUITE_P(PositionArrayedF32Vec4TessControl,
2780 ValidateVulkanCombineBuiltInArrayedVariable,
2781 Combine(Values("Position"),
2782 Values("TessellationControl"), Values("Input"),
2783 Values("%f32vec4"), Values(nullptr),
2784 Values(TestResult())));
2785
2786 INSTANTIATE_TEST_SUITE_P(
2787 PositionArrayedF32Vec3TessControl,
2788 ValidateVulkanCombineBuiltInArrayedVariable,
2789 Combine(Values("Position"), Values("TessellationControl"), Values("Input"),
2790 Values("%f32vec3"), Values("VUID-Position-Position-04321"),
2791 Values(TestResult(SPV_ERROR_INVALID_DATA,
2792 "needs to be a 4-component 32-bit float vector",
2793 "has 3 components"))));
2794
2795 INSTANTIATE_TEST_SUITE_P(
2796 PositionArrayedF32Vec4Vertex, ValidateVulkanCombineBuiltInArrayedVariable,
2797 Combine(Values("Position"), Values("Vertex"), Values("Output"),
2798 Values("%f32vec4"), Values("VUID-Position-Position-04321"),
2799 Values(TestResult(SPV_ERROR_INVALID_DATA,
2800 "needs to be a 4-component 32-bit float vector",
2801 "is not a float vector"))));
2802
2803 INSTANTIATE_TEST_SUITE_P(
2804 ClipAndCullDistanceOutputSuccess,
2805 ValidateVulkanCombineBuiltInArrayedVariable,
2806 Combine(Values("ClipDistance", "CullDistance"),
2807 Values("Geometry", "TessellationControl", "TessellationEvaluation"),
2808 Values("Output"), Values("%f32arr2", "%f32arr4"), Values(nullptr),
2809 Values(TestResult())));
2810
2811 INSTANTIATE_TEST_SUITE_P(
2812 ClipAndCullDistanceVertexInput, ValidateVulkanCombineBuiltInArrayedVariable,
2813 Combine(Values("ClipDistance", "CullDistance"), Values("Fragment"),
2814 Values("Input"), Values("%f32arr4"),
2815 Values("VUID-ClipDistance-ClipDistance-04191 "
2816 "VUID-CullDistance-CullDistance-04200"),
2817 Values(TestResult(SPV_ERROR_INVALID_DATA,
2818 "needs to be a 32-bit float array",
2819 "components are not float scalar"))));
2820
2821 INSTANTIATE_TEST_SUITE_P(
2822 ClipAndCullDistanceNotArray, ValidateVulkanCombineBuiltInArrayedVariable,
2823 Combine(Values("ClipDistance", "CullDistance"),
2824 Values("Geometry", "TessellationControl", "TessellationEvaluation"),
2825 Values("Input"), Values("%f32vec2", "%f32vec4"),
2826 Values("VUID-ClipDistance-ClipDistance-04191 "
2827 "VUID-CullDistance-CullDistance-04200"),
2828 Values(TestResult(SPV_ERROR_INVALID_DATA,
2829 "needs to be a 32-bit float array",
2830 "components are not float scalar"))));
2831
2832 INSTANTIATE_TEST_SUITE_P(
2833 SMBuiltinsInputSuccess,
2834 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2835 Combine(Values("SMCountNV", "SMIDNV", "WarpsPerSMNV", "WarpIDNV"),
2836 Values("Vertex", "Fragment", "TessellationControl",
2837 "TessellationEvaluation", "Geometry", "GLCompute"),
2838 Values("Input"), Values("%u32"),
2839 Values("OpCapability ShaderSMBuiltinsNV\n"),
2840 Values("OpExtension \"SPV_NV_shader_sm_builtins\"\n"),
2841 Values(nullptr), Values(TestResult())));
2842
2843 INSTANTIATE_TEST_SUITE_P(
2844 SMBuiltinsInputMeshSuccess,
2845 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2846 Combine(
2847 Values("SMCountNV", "SMIDNV", "WarpsPerSMNV", "WarpIDNV"),
2848 Values("MeshNV", "TaskNV"), Values("Input"), Values("%u32"),
2849 Values("OpCapability ShaderSMBuiltinsNV\nOpCapability MeshShadingNV\n"),
2850 Values("OpExtension \"SPV_NV_shader_sm_builtins\"\nOpExtension "
2851 "\"SPV_NV_mesh_shader\"\n"),
2852 Values(nullptr), Values(TestResult())));
2853
2854 INSTANTIATE_TEST_SUITE_P(
2855 SMBuiltinsInputRaySuccess,
2856 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2857 Combine(
2858 Values("SMCountNV", "SMIDNV", "WarpsPerSMNV", "WarpIDNV"),
2859 Values("RayGenerationNV", "IntersectionNV", "AnyHitNV", "ClosestHitNV",
2860 "MissNV", "CallableNV"),
2861 Values("Input"), Values("%u32"),
2862 Values("OpCapability ShaderSMBuiltinsNV\nOpCapability RayTracingNV\n"),
2863 Values("OpExtension \"SPV_NV_shader_sm_builtins\"\nOpExtension "
2864 "\"SPV_NV_ray_tracing\"\n"),
2865 Values(nullptr), Values(TestResult())));
2866
2867 INSTANTIATE_TEST_SUITE_P(
2868 SMBuiltinsNotInput,
2869 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2870 Combine(Values("SMCountNV", "SMIDNV", "WarpsPerSMNV", "WarpIDNV"),
2871 Values("Vertex", "Fragment", "TessellationControl",
2872 "TessellationEvaluation", "Geometry", "GLCompute"),
2873 Values("Output"), Values("%u32"),
2874 Values("OpCapability ShaderSMBuiltinsNV\n"),
2875 Values("OpExtension \"SPV_NV_shader_sm_builtins\"\n"),
2876 Values(nullptr),
2877 Values(TestResult(
2878 SPV_ERROR_INVALID_DATA,
2879 "to be only used for variables with Input storage class",
2880 "uses storage class Output"))));
2881
2882 INSTANTIATE_TEST_SUITE_P(
2883 SMBuiltinsNotIntScalar,
2884 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2885 Combine(Values("SMCountNV", "SMIDNV", "WarpsPerSMNV", "WarpIDNV"),
2886 Values("Vertex", "Fragment", "TessellationControl",
2887 "TessellationEvaluation", "Geometry", "GLCompute"),
2888 Values("Input"), Values("%f32", "%u32vec3"),
2889 Values("OpCapability ShaderSMBuiltinsNV\n"),
2890 Values("OpExtension \"SPV_NV_shader_sm_builtins\"\n"),
2891 Values(nullptr),
2892 Values(TestResult(SPV_ERROR_INVALID_DATA,
2893 "needs to be a 32-bit int scalar",
2894 "is not an int scalar"))));
2895
2896 INSTANTIATE_TEST_SUITE_P(
2897 SMBuiltinsNotInt32,
2898 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2899 Combine(Values("SMCountNV", "SMIDNV", "WarpsPerSMNV", "WarpIDNV"),
2900 Values("Vertex", "Fragment", "TessellationControl",
2901 "TessellationEvaluation", "Geometry", "GLCompute"),
2902 Values("Input"), Values("%u64"),
2903 Values("OpCapability ShaderSMBuiltinsNV\n"),
2904 Values("OpExtension \"SPV_NV_shader_sm_builtins\"\n"),
2905 Values(nullptr),
2906 Values(TestResult(SPV_ERROR_INVALID_DATA,
2907 "needs to be a 32-bit int scalar",
2908 "has bit width 64"))));
2909
2910 INSTANTIATE_TEST_SUITE_P(
2911 ArmCoreBuiltinsInputSuccess,
2912 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2913 Combine(Values("CoreIDARM", "CoreCountARM", "CoreMaxIDARM", "WarpIDARM",
2914 "WarpMaxIDARM"),
2915 Values("Vertex", "Fragment", "TessellationControl",
2916 "TessellationEvaluation", "Geometry", "GLCompute"),
2917 Values("Input"), Values("%u32"),
2918 Values("OpCapability CoreBuiltinsARM\n"),
2919 Values("OpExtension \"SPV_ARM_core_builtins\"\n"), Values(nullptr),
2920 Values(TestResult())));
2921
2922 INSTANTIATE_TEST_SUITE_P(
2923 ArmCoreBuiltinsNotInput,
2924 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2925 Combine(Values("CoreIDARM", "CoreCountARM", "CoreMaxIDARM", "WarpIDARM",
2926 "WarpMaxIDARM"),
2927 Values("Vertex", "Fragment", "TessellationControl",
2928 "TessellationEvaluation", "Geometry", "GLCompute"),
2929 Values("Output"), Values("%u32"),
2930 Values("OpCapability CoreBuiltinsARM\n"),
2931 Values("OpExtension \"SPV_ARM_core_builtins\"\n"), Values(nullptr),
2932 Values(TestResult(
2933 SPV_ERROR_INVALID_DATA,
2934 "to be only used for variables with Input storage class",
2935 "uses storage class Output"))));
2936
2937 INSTANTIATE_TEST_SUITE_P(
2938 ArmCoreBuiltinsNotIntScalar,
2939 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2940 Combine(Values("CoreIDARM", "CoreCountARM", "CoreMaxIDARM", "WarpIDARM",
2941 "WarpMaxIDARM"),
2942 Values("Vertex", "Fragment", "TessellationControl",
2943 "TessellationEvaluation", "Geometry", "GLCompute"),
2944 Values("Input"), Values("%f32", "%u32vec3"),
2945 Values("OpCapability CoreBuiltinsARM\n"),
2946 Values("OpExtension \"SPV_ARM_core_builtins\"\n"), Values(nullptr),
2947 Values(TestResult(SPV_ERROR_INVALID_DATA,
2948 "needs to be a 32-bit int scalar",
2949 "is not an int scalar"))));
2950
2951 INSTANTIATE_TEST_SUITE_P(
2952 ArmCoreBuiltinsNotInt32,
2953 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
2954 Combine(Values("CoreIDARM", "CoreCountARM", "CoreMaxIDARM", "WarpIDARM",
2955 "WarpMaxIDARM"),
2956 Values("Vertex", "Fragment", "TessellationControl",
2957 "TessellationEvaluation", "Geometry", "GLCompute"),
2958 Values("Input"), Values("%u64"),
2959 Values("OpCapability CoreBuiltinsARM\n"),
2960 Values("OpExtension \"SPV_ARM_core_builtins\"\n"), Values(nullptr),
2961 Values(TestResult(SPV_ERROR_INVALID_DATA,
2962 "needs to be a 32-bit int scalar",
2963 "has bit width 64"))));
2964
2965 CodeGenerator GetWorkgroupSizeSuccessGenerator() {
2966 CodeGenerator generator = CodeGenerator::GetDefaultShaderCodeGenerator();
2967
2968 generator.before_types_ = R"(
2969 OpDecorate %workgroup_size BuiltIn WorkgroupSize
2970 )";
2971
2972 generator.after_types_ = R"(
2973 %workgroup_size = OpConstantComposite %u32vec3 %u32_1 %u32_1 %u32_1
2974 )";
2975
2976 EntryPoint entry_point;
2977 entry_point.name = "main";
2978 entry_point.execution_model = "GLCompute";
2979 entry_point.body = R"(
2980 %copy = OpCopyObject %u32vec3 %workgroup_size
2981 )";
2982 generator.entry_points_.push_back(std::move(entry_point));
2983
2984 return generator;
2985 }
2986
2987 TEST_F(ValidateBuiltIns, VulkanWorkgroupSizeSuccess) {
2988 CodeGenerator generator = GetWorkgroupSizeSuccessGenerator();
2989 CompileSuccessfully(generator.Build(), SPV_ENV_VULKAN_1_0);
2990 ASSERT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_0));
2991 }
2992
2993 CodeGenerator GetWorkgroupSizeFragmentGenerator() {
2994 CodeGenerator generator = CodeGenerator::GetDefaultShaderCodeGenerator();
2995
2996 generator.before_types_ = R"(
2997 OpDecorate %workgroup_size BuiltIn WorkgroupSize
2998 )";
2999
3000 generator.after_types_ = R"(
3001 %workgroup_size = OpConstantComposite %u32vec3 %u32_1 %u32_1 %u32_1
3002 )";
3003
3004 EntryPoint entry_point;
3005 entry_point.name = "main";
3006 entry_point.execution_model = "Fragment";
3007 entry_point.execution_modes = "OpExecutionMode %main OriginUpperLeft";
3008 entry_point.body = R"(
3009 %copy = OpCopyObject %u32vec3 %workgroup_size
3010 )";
3011 generator.entry_points_.push_back(std::move(entry_point));
3012
3013 return generator;
3014 }
3015
3016 TEST_F(ValidateBuiltIns, VulkanWorkgroupSizeFragment) {
3017 CodeGenerator generator = GetWorkgroupSizeFragmentGenerator();
3018
3019 CompileSuccessfully(generator.Build(), SPV_ENV_VULKAN_1_0);
3020 ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0));
3021 EXPECT_THAT(getDiagnosticString(),
3022 HasSubstr("Vulkan spec allows BuiltIn WorkgroupSize to be used "
3023 "only with GLCompute, MeshNV, TaskNV, MeshEXT or "
3024 "TaskEXT execution model"));
3025 EXPECT_THAT(getDiagnosticString(),
3026 HasSubstr("is referencing ID <2> (OpConstantComposite) which is "
3027 "decorated with BuiltIn WorkgroupSize in function <1> "
3028 "called with execution model Fragment"));
3029 EXPECT_THAT(getDiagnosticString(),
3030 AnyVUID("VUID-WorkgroupSize-WorkgroupSize-04425 "
3031 "VUID-WorkgroupSize-WorkgroupSize-04427"));
3032 }
3033
3034 TEST_F(ValidateBuiltIns, WorkgroupSizeNotConstant) {
3035 CodeGenerator generator = CodeGenerator::GetDefaultShaderCodeGenerator();
3036 generator.before_types_ = R"(
3037 OpDecorate %copy BuiltIn WorkgroupSize
3038 )";
3039
3040 generator.after_types_ = R"(
3041 %workgroup_size = OpConstantComposite %u32vec3 %u32_1 %u32_1 %u32_1
3042 )";
3043
3044 EntryPoint entry_point;
3045 entry_point.name = "main";
3046 entry_point.execution_model = "GLCompute";
3047 entry_point.body = R"(
3048 %copy = OpCopyObject %u32vec3 %workgroup_size
3049 )";
3050 generator.entry_points_.push_back(std::move(entry_point));
3051
3052 CompileSuccessfully(generator.Build(), SPV_ENV_VULKAN_1_0);
3053 ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0));
3054 EXPECT_THAT(getDiagnosticString(),
3055 HasSubstr("BuiltIns can only target variables, structure "
3056 "members or constants"));
3057 }
3058
3059 CodeGenerator GetWorkgroupSizeNotVectorGenerator() {
3060 CodeGenerator generator = CodeGenerator::GetDefaultShaderCodeGenerator();
3061
3062 generator.before_types_ = R"(
3063 OpDecorate %workgroup_size BuiltIn WorkgroupSize
3064 )";
3065
3066 generator.after_types_ = R"(
3067 %workgroup_size = OpConstant %u32 16
3068 )";
3069
3070 EntryPoint entry_point;
3071 entry_point.name = "main";
3072 entry_point.execution_model = "GLCompute";
3073 entry_point.body = R"(
3074 %copy = OpCopyObject %u32 %workgroup_size
3075 )";
3076 generator.entry_points_.push_back(std::move(entry_point));
3077
3078 return generator;
3079 }
3080
3081 TEST_F(ValidateBuiltIns, VulkanWorkgroupSizeNotVector) {
3082 CodeGenerator generator = GetWorkgroupSizeNotVectorGenerator();
3083
3084 CompileSuccessfully(generator.Build(), SPV_ENV_VULKAN_1_0);
3085 ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0));
3086 EXPECT_THAT(getDiagnosticString(),
3087 HasSubstr("According to the Vulkan spec BuiltIn WorkgroupSize "
3088 "variable needs to be a 3-component 32-bit int vector. "
3089 "ID <2> (OpConstant) is not an int vector."));
3090 EXPECT_THAT(getDiagnosticString(),
3091 AnyVUID("VUID-WorkgroupSize-WorkgroupSize-04427"));
3092 }
3093
3094 CodeGenerator GetWorkgroupSizeNotIntVectorGenerator() {
3095 CodeGenerator generator = CodeGenerator::GetDefaultShaderCodeGenerator();
3096
3097 generator.before_types_ = R"(
3098 OpDecorate %workgroup_size BuiltIn WorkgroupSize
3099 )";
3100
3101 generator.after_types_ = R"(
3102 %workgroup_size = OpConstantComposite %f32vec3 %f32_1 %f32_1 %f32_1
3103 )";
3104
3105 EntryPoint entry_point;
3106 entry_point.name = "main";
3107 entry_point.execution_model = "GLCompute";
3108 entry_point.body = R"(
3109 %copy = OpCopyObject %f32vec3 %workgroup_size
3110 )";
3111 generator.entry_points_.push_back(std::move(entry_point));
3112
3113 return generator;
3114 }
3115
3116 TEST_F(ValidateBuiltIns, VulkanWorkgroupSizeNotIntVector) {
3117 CodeGenerator generator = GetWorkgroupSizeNotIntVectorGenerator();
3118
3119 CompileSuccessfully(generator.Build(), SPV_ENV_VULKAN_1_0);
3120 ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0));
3121 EXPECT_THAT(getDiagnosticString(),
3122 HasSubstr("According to the Vulkan spec BuiltIn WorkgroupSize "
3123 "variable needs to be a 3-component 32-bit int vector. "
3124 "ID <2> (OpConstantComposite) is not an int vector."));
3125 EXPECT_THAT(getDiagnosticString(),
3126 AnyVUID("VUID-WorkgroupSize-WorkgroupSize-04427"));
3127 }
3128
3129 CodeGenerator GetWorkgroupSizeNotVec3Generator() {
3130 CodeGenerator generator = CodeGenerator::GetDefaultShaderCodeGenerator();
3131
3132 generator.before_types_ = R"(
3133 OpDecorate %workgroup_size BuiltIn WorkgroupSize
3134 )";
3135
3136 generator.after_types_ = R"(
3137 %workgroup_size = OpConstantComposite %u32vec2 %u32_1 %u32_1
3138 )";
3139
3140 EntryPoint entry_point;
3141 entry_point.name = "main";
3142 entry_point.execution_model = "GLCompute";
3143 entry_point.body = R"(
3144 %copy = OpCopyObject %u32vec2 %workgroup_size
3145 )";
3146 generator.entry_points_.push_back(std::move(entry_point));
3147
3148 return generator;
3149 }
3150
3151 TEST_F(ValidateBuiltIns, VulkanWorkgroupSizeNotVec3) {
3152 CodeGenerator generator = GetWorkgroupSizeNotVec3Generator();
3153
3154 CompileSuccessfully(generator.Build(), SPV_ENV_VULKAN_1_0);
3155 ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0));
3156 EXPECT_THAT(getDiagnosticString(),
3157 HasSubstr("According to the Vulkan spec BuiltIn WorkgroupSize "
3158 "variable needs to be a 3-component 32-bit int vector. "
3159 "ID <2> (OpConstantComposite) has 2 components."));
3160 EXPECT_THAT(getDiagnosticString(),
3161 AnyVUID("VUID-WorkgroupSize-WorkgroupSize-04427"));
3162 }
3163
3164 TEST_F(ValidateBuiltIns, WorkgroupSizeNotInt32Vec) {
3165 CodeGenerator generator = CodeGenerator::GetDefaultShaderCodeGenerator();
3166 generator.before_types_ = R"(
3167 OpDecorate %workgroup_size BuiltIn WorkgroupSize
3168 )";
3169
3170 generator.after_types_ = R"(
3171 %workgroup_size = OpConstantComposite %u64vec3 %u64_1 %u64_1 %u64_1
3172 )";
3173
3174 EntryPoint entry_point;
3175 entry_point.name = "main";
3176 entry_point.execution_model = "GLCompute";
3177 entry_point.body = R"(
3178 %copy = OpCopyObject %u64vec3 %workgroup_size
3179 )";
3180 generator.entry_points_.push_back(std::move(entry_point));
3181
3182 CompileSuccessfully(generator.Build(), SPV_ENV_VULKAN_1_0);
3183 ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0));
3184 EXPECT_THAT(
3185 getDiagnosticString(),
3186 HasSubstr("According to the Vulkan spec BuiltIn WorkgroupSize variable "
3187 "needs to be a 3-component 32-bit int vector. ID <2> "
3188 "(OpConstantComposite) has components with bit width 64."));
3189 EXPECT_THAT(getDiagnosticString(),
3190 AnyVUID("VUID-WorkgroupSize-WorkgroupSize-04427"));
3191 }
3192
3193 TEST_F(ValidateBuiltIns, WorkgroupSizePrivateVar) {
3194 CodeGenerator generator = CodeGenerator::GetDefaultShaderCodeGenerator();
3195 generator.before_types_ = R"(
3196 OpDecorate %workgroup_size BuiltIn WorkgroupSize
3197 )";
3198
3199 generator.after_types_ = R"(
3200 %workgroup_size = OpConstantComposite %u32vec3 %u32_1 %u32_1 %u32_1
3201 %private_ptr_u32vec3 = OpTypePointer Private %u32vec3
3202 %var = OpVariable %private_ptr_u32vec3 Private %workgroup_size
3203 )";
3204
3205 EntryPoint entry_point;
3206 entry_point.name = "main";
3207 entry_point.execution_model = "GLCompute";
3208 entry_point.body = R"(
3209 )";
3210 generator.entry_points_.push_back(std::move(entry_point));
3211
3212 CompileSuccessfully(generator.Build(), SPV_ENV_VULKAN_1_0);
3213 ASSERT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_0));
3214 }
3215
3216 TEST_F(ValidateBuiltIns, GeometryPositionInOutSuccess) {
3217 CodeGenerator generator = CodeGenerator::GetDefaultShaderCodeGenerator();
3218
3219 generator.before_types_ = R"(
3220 OpDecorate %input_type Block
3221 OpMemberDecorate %input_type 0 BuiltIn Position
3222 OpDecorate %output_type Block
3223 OpMemberDecorate %output_type 0 BuiltIn Position
3224 )";
3225
3226 generator.after_types_ = R"(
3227 %input_type = OpTypeStruct %f32vec4
3228 %arrayed_input_type = OpTypeArray %input_type %u32_3
3229 %input_ptr = OpTypePointer Input %arrayed_input_type
3230 %input = OpVariable %input_ptr Input
3231 %input_f32vec4_ptr = OpTypePointer Input %f32vec4
3232 %output_type = OpTypeStruct %f32vec4
3233 %output_ptr = OpTypePointer Output %output_type
3234 %output = OpVariable %output_ptr Output
3235 %output_f32vec4_ptr = OpTypePointer Output %f32vec4
3236 )";
3237
3238 EntryPoint entry_point;
3239 entry_point.name = "main";
3240 entry_point.execution_model = "Geometry";
3241 entry_point.interfaces = "%input %output";
3242 entry_point.body = R"(
3243 %input_pos = OpAccessChain %input_f32vec4_ptr %input %u32_0 %u32_0
3244 %output_pos = OpAccessChain %output_f32vec4_ptr %output %u32_0
3245 %pos = OpLoad %f32vec4 %input_pos
3246 OpStore %output_pos %pos
3247 )";
3248 generator.entry_points_.push_back(std::move(entry_point));
3249 generator.entry_points_[0].execution_modes =
3250 "OpExecutionMode %main InputPoints\nOpExecutionMode %main OutputPoints\n";
3251
3252 CompileSuccessfully(generator.Build(), SPV_ENV_VULKAN_1_0);
3253 ASSERT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_0));
3254 }
3255
3256 TEST_F(ValidateBuiltIns, WorkgroupIdNotVec3) {
3257 CodeGenerator generator = CodeGenerator::GetDefaultShaderCodeGenerator();
3258 generator.before_types_ = R"(
3259 OpDecorate %workgroup_size BuiltIn WorkgroupSize
3260 OpDecorate %workgroup_id BuiltIn WorkgroupId
3261 )";
3262
3263 generator.after_types_ = R"(
3264 %workgroup_size = OpConstantComposite %u32vec3 %u32_1 %u32_1 %u32_1
3265 %input_ptr = OpTypePointer Input %u32vec2
3266 %workgroup_id = OpVariable %input_ptr Input
3267 )";
3268
3269 EntryPoint entry_point;
3270 entry_point.name = "main";
3271 entry_point.execution_model = "GLCompute";
3272 entry_point.interfaces = "%workgroup_id";
3273 entry_point.body = R"(
3274 %copy_size = OpCopyObject %u32vec3 %workgroup_size
3275 %load_id = OpLoad %u32vec2 %workgroup_id
3276 )";
3277 generator.entry_points_.push_back(std::move(entry_point));
3278
3279 CompileSuccessfully(generator.Build(), SPV_ENV_VULKAN_1_0);
3280 ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0));
3281 EXPECT_THAT(getDiagnosticString(),
3282 HasSubstr("According to the Vulkan spec BuiltIn WorkgroupId "
3283 "variable needs to be a 3-component 32-bit int vector. "
3284 "ID <2> (OpVariable) has 2 components."));
3285 }
3286
3287 TEST_F(ValidateBuiltIns, TwoBuiltInsFirstFails) {
3288 CodeGenerator generator = CodeGenerator::GetDefaultShaderCodeGenerator();
3289
3290 generator.before_types_ = R"(
3291 OpDecorate %input_type Block
3292 OpDecorate %output_type Block
3293 OpMemberDecorate %input_type 0 BuiltIn FragCoord
3294 OpMemberDecorate %output_type 0 BuiltIn Position
3295 )";
3296
3297 generator.after_types_ = R"(
3298 %input_type = OpTypeStruct %f32vec4
3299 %input_ptr = OpTypePointer Input %input_type
3300 %input = OpVariable %input_ptr Input
3301 %input_f32vec4_ptr = OpTypePointer Input %f32vec4
3302 %output_type = OpTypeStruct %f32vec4
3303 %output_ptr = OpTypePointer Output %output_type
3304 %output = OpVariable %output_ptr Output
3305 %output_f32vec4_ptr = OpTypePointer Output %f32vec4
3306 )";
3307
3308 EntryPoint entry_point;
3309 entry_point.name = "main";
3310 entry_point.execution_model = "Geometry";
3311 entry_point.interfaces = "%input %output";
3312 entry_point.body = R"(
3313 %input_pos = OpAccessChain %input_f32vec4_ptr %input %u32_0
3314 %output_pos = OpAccessChain %output_f32vec4_ptr %output %u32_0
3315 %pos = OpLoad %f32vec4 %input_pos
3316 OpStore %output_pos %pos
3317 )";
3318 generator.entry_points_.push_back(std::move(entry_point));
3319 generator.entry_points_[0].execution_modes =
3320 "OpExecutionMode %main InputPoints\nOpExecutionMode %main OutputPoints\n";
3321
3322 CompileSuccessfully(generator.Build(), SPV_ENV_VULKAN_1_0);
3323 ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0));
3324 EXPECT_THAT(getDiagnosticString(),
3325 HasSubstr("Vulkan spec allows BuiltIn FragCoord to be used only "
3326 "with Fragment execution model"));
3327 }
3328
3329 TEST_F(ValidateBuiltIns, TwoBuiltInsSecondFails) {
3330 CodeGenerator generator = CodeGenerator::GetDefaultShaderCodeGenerator();
3331
3332 generator.before_types_ = R"(
3333 OpDecorate %input_type Block
3334 OpDecorate %output_type Block
3335 OpMemberDecorate %input_type 0 BuiltIn Position
3336 OpMemberDecorate %output_type 0 BuiltIn FragCoord
3337 )";
3338
3339 generator.after_types_ = R"(
3340 %input_type = OpTypeStruct %f32vec4
3341 %input_ptr = OpTypePointer Input %input_type
3342 %input = OpVariable %input_ptr Input
3343 %input_f32vec4_ptr = OpTypePointer Input %f32vec4
3344 %output_type = OpTypeStruct %f32vec4
3345 %output_ptr = OpTypePointer Output %output_type
3346 %output = OpVariable %output_ptr Output
3347 %output_f32vec4_ptr = OpTypePointer Output %f32vec4
3348 )";
3349
3350 EntryPoint entry_point;
3351 entry_point.name = "main";
3352 entry_point.execution_model = "Geometry";
3353 entry_point.interfaces = "%input %output";
3354 entry_point.body = R"(
3355 %input_pos = OpAccessChain %input_f32vec4_ptr %input %u32_0
3356 %output_pos = OpAccessChain %output_f32vec4_ptr %output %u32_0
3357 %pos = OpLoad %f32vec4 %input_pos
3358 OpStore %output_pos %pos
3359 )";
3360 generator.entry_points_.push_back(std::move(entry_point));
3361 generator.entry_points_[0].execution_modes =
3362 "OpExecutionMode %main InputPoints\nOpExecutionMode %main OutputPoints\n";
3363
3364 CompileSuccessfully(generator.Build(), SPV_ENV_VULKAN_1_0);
3365 ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0));
3366 EXPECT_THAT(getDiagnosticString(),
3367 HasSubstr("Vulkan spec allows BuiltIn FragCoord to be only used "
3368 "for variables with Input storage class"));
3369 }
3370
3371 TEST_F(ValidateBuiltIns, VertexPositionVariableSuccess) {
3372 CodeGenerator generator = CodeGenerator::GetDefaultShaderCodeGenerator();
3373 generator.before_types_ = R"(
3374 OpDecorate %position BuiltIn Position
3375 )";
3376
3377 generator.after_types_ = R"(
3378 %f32vec4_ptr_output = OpTypePointer Output %f32vec4
3379 %position = OpVariable %f32vec4_ptr_output Output
3380 )";
3381
3382 EntryPoint entry_point;
3383 entry_point.name = "main";
3384 entry_point.execution_model = "Vertex";
3385 entry_point.interfaces = "%position";
3386 entry_point.body = R"(
3387 OpStore %position %f32vec4_0123
3388 )";
3389 generator.entry_points_.push_back(std::move(entry_point));
3390
3391 CompileSuccessfully(generator.Build(), SPV_ENV_VULKAN_1_0);
3392 ASSERT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_0));
3393 }
3394
3395 TEST_F(ValidateBuiltIns, FragmentPositionTwoEntryPoints) {
3396 CodeGenerator generator = CodeGenerator::GetDefaultShaderCodeGenerator();
3397 generator.before_types_ = R"(
3398 OpDecorate %output_type Block
3399 OpMemberDecorate %output_type 0 BuiltIn Position
3400 )";
3401
3402 generator.after_types_ = R"(
3403 %output_type = OpTypeStruct %f32vec4
3404 %output_ptr = OpTypePointer Output %output_type
3405 %output = OpVariable %output_ptr Output
3406 %output_f32vec4_ptr = OpTypePointer Output %f32vec4
3407 )";
3408
3409 EntryPoint entry_point;
3410 entry_point.name = "vmain";
3411 entry_point.execution_model = "Vertex";
3412 entry_point.interfaces = "%output";
3413 entry_point.body = R"(
3414 %val1 = OpFunctionCall %void %foo
3415 )";
3416 generator.entry_points_.push_back(std::move(entry_point));
3417
3418 entry_point.name = "fmain";
3419 entry_point.execution_model = "Fragment";
3420 entry_point.interfaces = "%output";
3421 entry_point.execution_modes = "OpExecutionMode %fmain OriginUpperLeft";
3422 entry_point.body = R"(
3423 %val2 = OpFunctionCall %void %foo
3424 )";
3425 generator.entry_points_.push_back(std::move(entry_point));
3426
3427 generator.add_at_the_end_ = R"(
3428 %foo = OpFunction %void None %func
3429 %foo_entry = OpLabel
3430 %position = OpAccessChain %output_f32vec4_ptr %output %u32_0
3431 OpStore %position %f32vec4_0123
3432 OpReturn
3433 OpFunctionEnd
3434 )";
3435
3436 CompileSuccessfully(generator.Build(), SPV_ENV_VULKAN_1_0);
3437 ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0));
3438 EXPECT_THAT(getDiagnosticString(),
3439 HasSubstr("Vulkan spec allows BuiltIn Position to be used only "
3440 "with Vertex, TessellationControl, "
3441 "TessellationEvaluation or Geometry execution models"));
3442 EXPECT_THAT(getDiagnosticString(),
3443 HasSubstr("called with execution model Fragment"));
3444 }
3445
3446 CodeGenerator GetNoDepthReplacingGenerator() {
3447 CodeGenerator generator = CodeGenerator::GetDefaultShaderCodeGenerator();
3448
3449 generator.before_types_ = R"(
3450 OpDecorate %output_type Block
3451 OpMemberDecorate %output_type 0 BuiltIn FragDepth
3452 )";
3453
3454 generator.after_types_ = R"(
3455 %output_type = OpTypeStruct %f32
3456 %output_null = OpConstantNull %output_type
3457 %output_ptr = OpTypePointer Output %output_type
3458 %output = OpVariable %output_ptr Output %output_null
3459 %output_f32_ptr = OpTypePointer Output %f32
3460 )";
3461
3462 EntryPoint entry_point;
3463 entry_point.name = "main";
3464 entry_point.execution_model = "Fragment";
3465 entry_point.interfaces = "%output";
3466 entry_point.execution_modes = "OpExecutionMode %main OriginUpperLeft";
3467 entry_point.body = R"(
3468 %val2 = OpFunctionCall %void %foo
3469 )";
3470 generator.entry_points_.push_back(std::move(entry_point));
3471
3472 const std::string function_body = R"(
3473 %foo = OpFunction %void None %func
3474 %foo_entry = OpLabel
3475 %frag_depth = OpAccessChain %output_f32_ptr %output %u32_0
3476 OpStore %frag_depth %f32_1
3477 OpReturn
3478 OpFunctionEnd
3479 )";
3480
3481 generator.add_at_the_end_ = function_body;
3482
3483 return generator;
3484 }
3485
3486 TEST_F(ValidateBuiltIns, VulkanFragmentFragDepthNoDepthReplacing) {
3487 CodeGenerator generator = GetNoDepthReplacingGenerator();
3488
3489 CompileSuccessfully(generator.Build(), SPV_ENV_VULKAN_1_0);
3490 ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0));
3491 EXPECT_THAT(getDiagnosticString(),
3492 HasSubstr("Vulkan spec requires DepthReplacing execution mode to "
3493 "be declared when using BuiltIn FragDepth"));
3494 EXPECT_THAT(getDiagnosticString(),
3495 HasSubstr("VUID-FragDepth-FragDepth-04216"));
3496 }
3497
3498 CodeGenerator GetOneMainHasDepthReplacingOtherHasntGenerator() {
3499 CodeGenerator generator = CodeGenerator::GetDefaultShaderCodeGenerator();
3500
3501 generator.before_types_ = R"(
3502 OpDecorate %output_type Block
3503 OpMemberDecorate %output_type 0 BuiltIn FragDepth
3504 )";
3505
3506 generator.after_types_ = R"(
3507 %output_type = OpTypeStruct %f32
3508 %output_null = OpConstantNull %output_type
3509 %output_ptr = OpTypePointer Output %output_type
3510 %output = OpVariable %output_ptr Output %output_null
3511 %output_f32_ptr = OpTypePointer Output %f32
3512 )";
3513
3514 EntryPoint entry_point;
3515 entry_point.name = "main_d_r";
3516 entry_point.execution_model = "Fragment";
3517 entry_point.interfaces = "%output";
3518 entry_point.execution_modes =
3519 "OpExecutionMode %main_d_r OriginUpperLeft\n"
3520 "OpExecutionMode %main_d_r DepthReplacing";
3521 entry_point.body = R"(
3522 %val2 = OpFunctionCall %void %foo
3523 )";
3524 generator.entry_points_.push_back(std::move(entry_point));
3525
3526 entry_point.name = "main_no_d_r";
3527 entry_point.execution_model = "Fragment";
3528 entry_point.interfaces = "%output";
3529 entry_point.execution_modes = "OpExecutionMode %main_no_d_r OriginUpperLeft";
3530 entry_point.body = R"(
3531 %val3 = OpFunctionCall %void %foo
3532 )";
3533 generator.entry_points_.push_back(std::move(entry_point));
3534
3535 const std::string function_body = R"(
3536 %foo = OpFunction %void None %func
3537 %foo_entry = OpLabel
3538 %frag_depth = OpAccessChain %output_f32_ptr %output %u32_0
3539 OpStore %frag_depth %f32_1
3540 OpReturn
3541 OpFunctionEnd
3542 )";
3543
3544 generator.add_at_the_end_ = function_body;
3545
3546 return generator;
3547 }
3548
3549 TEST_F(ValidateBuiltIns,
3550 VulkanFragmentFragDepthOneMainHasDepthReplacingOtherHasnt) {
3551 CodeGenerator generator = GetOneMainHasDepthReplacingOtherHasntGenerator();
3552
3553 CompileSuccessfully(generator.Build(), SPV_ENV_VULKAN_1_0);
3554 ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0));
3555 EXPECT_THAT(getDiagnosticString(),
3556 HasSubstr("Vulkan spec requires DepthReplacing execution mode to "
3557 "be declared when using BuiltIn FragDepth"));
3558 EXPECT_THAT(getDiagnosticString(),
3559 HasSubstr("VUID-FragDepth-FragDepth-04216"));
3560 }
3561
3562 TEST_F(ValidateBuiltIns, AllowInstanceIdWithIntersectionShader) {
3563 CodeGenerator generator = CodeGenerator::GetDefaultShaderCodeGenerator();
3564 generator.capabilities_ += R"(
3565 OpCapability RayTracingNV
3566 )";
3567
3568 generator.extensions_ = R"(
3569 OpExtension "SPV_NV_ray_tracing"
3570 )";
3571
3572 generator.before_types_ = R"(
3573 OpDecorate %input_type Block
3574 OpMemberDecorate %input_type 0 BuiltIn InstanceId
3575 )";
3576
3577 generator.after_types_ = R"(
3578 %input_type = OpTypeStruct %u32
3579 %input_ptr = OpTypePointer Input %input_type
3580 %input = OpVariable %input_ptr Input
3581 )";
3582
3583 EntryPoint entry_point;
3584 entry_point.name = "main_d_r";
3585 entry_point.execution_model = "IntersectionNV";
3586 entry_point.interfaces = "%input";
3587 entry_point.body = R"(
3588 %val2 = OpFunctionCall %void %foo
3589 )";
3590 generator.entry_points_.push_back(std::move(entry_point));
3591
3592 generator.add_at_the_end_ = R"(
3593 %foo = OpFunction %void None %func
3594 %foo_entry = OpLabel
3595 OpReturn
3596 OpFunctionEnd
3597 )";
3598
3599 CompileSuccessfully(generator.Build(), SPV_ENV_VULKAN_1_0);
3600 EXPECT_THAT(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_0));
3601 }
3602
3603 TEST_F(ValidateBuiltIns, ValidBuiltinsForMeshShader) {
3604 CodeGenerator generator = CodeGenerator::GetDefaultShaderCodeGenerator();
3605 generator.capabilities_ += R"(
3606 OpCapability MeshShadingNV
3607 )";
3608
3609 generator.extensions_ = R"(
3610 OpExtension "SPV_NV_mesh_shader"
3611 )";
3612
3613 generator.before_types_ = R"(
3614 OpDecorate %gl_PrimitiveID BuiltIn PrimitiveId
3615 OpDecorate %gl_PrimitiveID PerPrimitiveNV
3616 OpDecorate %gl_Layer BuiltIn Layer
3617 OpDecorate %gl_Layer PerPrimitiveNV
3618 OpDecorate %gl_ViewportIndex BuiltIn ViewportIndex
3619 OpDecorate %gl_ViewportIndex PerPrimitiveNV
3620 )";
3621
3622 generator.after_types_ = R"(
3623 %u32_81 = OpConstant %u32 81
3624 %_arr_int_uint_81 = OpTypeArray %i32 %u32_81
3625 %_ptr_Output__arr_int_uint_81 = OpTypePointer Output %_arr_int_uint_81
3626 %gl_PrimitiveID = OpVariable %_ptr_Output__arr_int_uint_81 Output
3627 %gl_Layer = OpVariable %_ptr_Output__arr_int_uint_81 Output
3628 %gl_ViewportIndex = OpVariable %_ptr_Output__arr_int_uint_81 Output
3629 )";
3630
3631 EntryPoint entry_point;
3632 entry_point.name = "main_d_r";
3633 entry_point.execution_model = "MeshNV";
3634 entry_point.execution_modes = "OpExecutionMode %main_d_r LocalSize 1 1 1";
3635 entry_point.interfaces = "%gl_PrimitiveID %gl_Layer %gl_ViewportIndex";
3636 generator.entry_points_.push_back(std::move(entry_point));
3637
3638 CompileSuccessfully(generator.Build(), SPV_ENV_VULKAN_1_1);
3639 ASSERT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_1));
3640 }
3641
3642 TEST_F(ValidateBuiltIns, InvalidBuiltinsForMeshShader) {
3643 CodeGenerator generator = CodeGenerator::GetDefaultShaderCodeGenerator();
3644 generator.capabilities_ += R"(
3645 OpCapability MeshShadingNV
3646 )";
3647
3648 generator.extensions_ = R"(
3649 OpExtension "SPV_NV_mesh_shader"
3650 )";
3651
3652 generator.before_types_ = R"(
3653 OpDecorate %gl_PrimitiveID BuiltIn PrimitiveId
3654 OpDecorate %gl_PrimitiveID PerPrimitiveNV
3655 OpDecorate %gl_Layer BuiltIn Layer
3656 OpDecorate %gl_Layer PerPrimitiveNV
3657 OpDecorate %gl_ViewportIndex BuiltIn ViewportIndex
3658 OpDecorate %gl_ViewportIndex PerPrimitiveNV
3659 )";
3660
3661 generator.after_types_ = R"(
3662 %u32_81 = OpConstant %u32 81
3663 %_arr_float_uint_81 = OpTypeArray %f32 %u32_81
3664 %_ptr_Output__arr_float_uint_81 = OpTypePointer Output %_arr_float_uint_81
3665 %gl_PrimitiveID = OpVariable %_ptr_Output__arr_float_uint_81 Output
3666 %gl_Layer = OpVariable %_ptr_Output__arr_float_uint_81 Output
3667 %gl_ViewportIndex = OpVariable %_ptr_Output__arr_float_uint_81 Output
3668 )";
3669
3670 EntryPoint entry_point;
3671 entry_point.name = "main_d_r";
3672 entry_point.execution_model = "MeshNV";
3673 entry_point.execution_modes = "OpExecutionMode %main_d_r LocalSize 1 1 1";
3674 entry_point.interfaces = "%gl_PrimitiveID %gl_Layer %gl_ViewportIndex";
3675 entry_point.body = "%ref_load = OpLoad %_arr_float_uint_81 %gl_PrimitiveID";
3676 generator.entry_points_.push_back(std::move(entry_point));
3677
3678 CompileSuccessfully(generator.Build(), SPV_ENV_VULKAN_1_1);
3679 ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_1));
3680 EXPECT_THAT(getDiagnosticString(),
3681 HasSubstr("needs to be a 32-bit int scalar"));
3682 EXPECT_THAT(getDiagnosticString(), HasSubstr("is not an int scalar"));
3683 }
3684
3685 TEST_P(ValidateVulkanSubgroupBuiltIns, InMain) {
3686 const char* const built_in = std::get<0>(GetParam());
3687 const char* const execution_model = std::get<1>(GetParam());
3688 const char* const storage_class = std::get<2>(GetParam());
3689 const char* const data_type = std::get<3>(GetParam());
3690 const char* const vuid = std::get<4>(GetParam());
3691 const TestResult& test_result = std::get<5>(GetParam());
3692
3693 CodeGenerator generator = CodeGenerator::GetDefaultShaderCodeGenerator();
3694 generator.capabilities_ += R"(
3695 OpCapability GroupNonUniformBallot
3696 )";
3697
3698 generator.before_types_ = "OpDecorate %built_in_var BuiltIn ";
3699 generator.before_types_ += built_in;
3700 generator.before_types_ += "\n";
3701
3702 std::ostringstream after_types;
3703 after_types << "%built_in_ptr = OpTypePointer " << storage_class << " "
3704 << data_type << "\n";
3705 after_types << "%built_in_var = OpVariable %built_in_ptr " << storage_class;
3706 after_types << "\n";
3707 generator.after_types_ = after_types.str();
3708
3709 EntryPoint entry_point;
3710 entry_point.name = "main";
3711 entry_point.execution_model = execution_model;
3712 if (strncmp(storage_class, "Input", 5) == 0 ||
3713 strncmp(storage_class, "Output", 6) == 0) {
3714 entry_point.interfaces = "%built_in_var";
3715 }
3716 entry_point.body =
3717 std::string("%ld = OpLoad ") + data_type + " %built_in_var\n";
3718
3719 std::ostringstream execution_modes;
3720 if (0 == std::strcmp(execution_model, "Fragment")) {
3721 execution_modes << "OpExecutionMode %" << entry_point.name
3722 << " OriginUpperLeft\n";
3723 if (0 == std::strcmp(built_in, "FragDepth")) {
3724 execution_modes << "OpExecutionMode %" << entry_point.name
3725 << " DepthReplacing\n";
3726 }
3727 }
3728 if (0 == std::strcmp(execution_model, "Geometry")) {
3729 execution_modes << "OpExecutionMode %" << entry_point.name
3730 << " InputPoints\n";
3731 execution_modes << "OpExecutionMode %" << entry_point.name
3732 << " OutputPoints\n";
3733 }
3734 if (0 == std::strcmp(execution_model, "GLCompute")) {
3735 execution_modes << "OpExecutionMode %" << entry_point.name
3736 << " LocalSize 1 1 1\n";
3737 }
3738 entry_point.execution_modes = execution_modes.str();
3739
3740 generator.entry_points_.push_back(std::move(entry_point));
3741
3742 CompileSuccessfully(generator.Build(), SPV_ENV_VULKAN_1_1);
3743 ASSERT_EQ(test_result.validation_result,
3744 ValidateInstructions(SPV_ENV_VULKAN_1_1));
3745 if (test_result.error_str) {
3746 EXPECT_THAT(getDiagnosticString(), HasSubstr(test_result.error_str));
3747 }
3748 if (test_result.error_str2) {
3749 EXPECT_THAT(getDiagnosticString(), HasSubstr(test_result.error_str2));
3750 }
3751 if (vuid) {
3752 EXPECT_THAT(getDiagnosticString(), AnyVUID(vuid));
3753 }
3754 }
3755
3756 INSTANTIATE_TEST_SUITE_P(
3757 SubgroupMaskNotVec4, ValidateVulkanSubgroupBuiltIns,
3758 Combine(Values("SubgroupEqMask", "SubgroupGeMask", "SubgroupGtMask",
3759 "SubgroupLeMask", "SubgroupLtMask"),
3760 Values("GLCompute"), Values("Input"), Values("%u32vec3"),
3761 Values("VUID-SubgroupEqMask-SubgroupEqMask-04371 "
3762 "VUID-SubgroupGeMask-SubgroupGeMask-04373 "
3763 "VUID-SubgroupGtMask-SubgroupGtMask-04375 "
3764 "VUID-SubgroupLeMask-SubgroupLeMask-04377 "
3765 "VUID-SubgroupLtMask-SubgroupLtMask-04379"),
3766 Values(TestResult(SPV_ERROR_INVALID_DATA,
3767 "needs to be a 4-component 32-bit int vector"))));
3768
3769 INSTANTIATE_TEST_SUITE_P(
3770 SubgroupMaskNotU32, ValidateVulkanSubgroupBuiltIns,
3771 Combine(Values("SubgroupEqMask", "SubgroupGeMask", "SubgroupGtMask",
3772 "SubgroupLeMask", "SubgroupLtMask"),
3773 Values("GLCompute"), Values("Input"), Values("%f32vec4"),
3774 Values("VUID-SubgroupEqMask-SubgroupEqMask-04371 "
3775 "VUID-SubgroupGeMask-SubgroupGeMask-04373 "
3776 "VUID-SubgroupGtMask-SubgroupGtMask-04375 "
3777 "VUID-SubgroupLeMask-SubgroupLeMask-04377 "
3778 "VUID-SubgroupLtMask-SubgroupLtMask-04379"),
3779 Values(TestResult(SPV_ERROR_INVALID_DATA,
3780 "needs to be a 4-component 32-bit int vector"))));
3781
3782 INSTANTIATE_TEST_SUITE_P(
3783 SubgroupMaskNotInput, ValidateVulkanSubgroupBuiltIns,
3784 Combine(Values("SubgroupEqMask", "SubgroupGeMask", "SubgroupGtMask",
3785 "SubgroupLeMask", "SubgroupLtMask"),
3786 Values("GLCompute"), Values("Output", "Workgroup", "Private"),
3787 Values("%u32vec4"),
3788 Values("VUID-SubgroupEqMask-SubgroupEqMask-04370 "
3789 "VUID-SubgroupGeMask-SubgroupGeMask-04372 "
3790 "VUID-SubgroupGtMask-SubgroupGtMask-04374 "
3791 "VUID-SubgroupLeMask-SubgroupLeMask-04376 "
3792 "VUID-SubgroupLtMask-SubgroupLtMask-04378"),
3793 Values(TestResult(
3794 SPV_ERROR_INVALID_DATA,
3795 "to be only used for variables with Input storage class"))));
3796
3797 INSTANTIATE_TEST_SUITE_P(SubgroupMaskOk, ValidateVulkanSubgroupBuiltIns,
3798 Combine(Values("SubgroupEqMask", "SubgroupGeMask",
3799 "SubgroupGtMask", "SubgroupLeMask",
3800 "SubgroupLtMask"),
3801 Values("GLCompute"), Values("Input"),
3802 Values("%u32vec4"), Values(nullptr),
3803 Values(TestResult(SPV_SUCCESS, ""))));
3804
3805 TEST_F(ValidateBuiltIns, SubgroupMaskMemberDecorate) {
3806 const std::string text = R"(
3807 OpCapability Shader
3808 OpCapability GroupNonUniformBallot
3809 OpMemoryModel Logical GLSL450
3810 OpEntryPoint GLCompute %foo "foo"
3811 OpExecutionMode %foo LocalSize 1 1 1
3812 OpDecorate %struct Block
3813 OpMemberDecorate %struct 0 BuiltIn SubgroupEqMask
3814 %void = OpTypeVoid
3815 %int = OpTypeInt 32 0
3816 %struct = OpTypeStruct %int
3817 %void_fn = OpTypeFunction %void
3818 %foo = OpFunction %void None %void_fn
3819 %entry = OpLabel
3820 OpReturn
3821 OpFunctionEnd
3822 )";
3823
3824 CompileSuccessfully(text, SPV_ENV_VULKAN_1_1);
3825 EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_1));
3826 EXPECT_THAT(
3827 getDiagnosticString(),
3828 HasSubstr(
3829 "BuiltIn SubgroupEqMask cannot be used as a member decoration"));
3830 }
3831
3832 INSTANTIATE_TEST_SUITE_P(
3833 SubgroupInvocationIdAndSizeNotU32, ValidateVulkanSubgroupBuiltIns,
3834 Combine(
3835 Values("SubgroupLocalInvocationId", "SubgroupSize"),
3836 Values("GLCompute"), Values("Input"), Values("%f32"),
3837 Values("VUID-SubgroupLocalInvocationId-SubgroupLocalInvocationId-04381 "
3838 "VUID-SubgroupSize-SubgroupSize-04383"),
3839 Values(TestResult(SPV_ERROR_INVALID_DATA,
3840 "needs to be a 32-bit int"))));
3841
3842 INSTANTIATE_TEST_SUITE_P(
3843 SubgroupInvocationIdAndSizeNotInput, ValidateVulkanSubgroupBuiltIns,
3844 Combine(
3845 Values("SubgroupLocalInvocationId", "SubgroupSize"),
3846 Values("GLCompute"), Values("Output", "Workgroup", "Private"),
3847 Values("%u32"),
3848 Values("VUID-SubgroupLocalInvocationId-SubgroupLocalInvocationId-04380 "
3849 "VUID-SubgroupSize-SubgroupSize-04382"),
3850 Values(TestResult(
3851 SPV_ERROR_INVALID_DATA,
3852 "to be only used for variables with Input storage class"))));
3853
3854 INSTANTIATE_TEST_SUITE_P(
3855 SubgroupInvocationIdAndSizeOk, ValidateVulkanSubgroupBuiltIns,
3856 Combine(Values("SubgroupLocalInvocationId", "SubgroupSize"),
3857 Values("GLCompute"), Values("Input"), Values("%u32"),
3858 Values(nullptr), Values(TestResult(SPV_SUCCESS, ""))));
3859
3860 TEST_F(ValidateBuiltIns, SubgroupSizeMemberDecorate) {
3861 const std::string text = R"(
3862 OpCapability Shader
3863 OpCapability GroupNonUniform
3864 OpMemoryModel Logical GLSL450
3865 OpEntryPoint GLCompute %foo "foo"
3866 OpExecutionMode %foo LocalSize 1 1 1
3867 OpDecorate %struct Block
3868 OpMemberDecorate %struct 0 BuiltIn SubgroupSize
3869 %void = OpTypeVoid
3870 %int = OpTypeInt 32 0
3871 %struct = OpTypeStruct %int
3872 %void_fn = OpTypeFunction %void
3873 %foo = OpFunction %void None %void_fn
3874 %entry = OpLabel
3875 OpReturn
3876 OpFunctionEnd
3877 )";
3878
3879 CompileSuccessfully(text, SPV_ENV_VULKAN_1_1);
3880 EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_1));
3881 EXPECT_THAT(
3882 getDiagnosticString(),
3883 HasSubstr("BuiltIn SubgroupSize cannot be used as a member decoration"));
3884 }
3885
3886 INSTANTIATE_TEST_SUITE_P(
3887 SubgroupNumAndIdNotCompute, ValidateVulkanSubgroupBuiltIns,
3888 Combine(Values("SubgroupId", "NumSubgroups"), Values("Vertex"),
3889 Values("Input"), Values("%u32"),
3890 Values("VUID-SubgroupId-SubgroupId-04367 "
3891 "VUID-NumSubgroups-NumSubgroups-04293"),
3892 Values(TestResult(SPV_ERROR_INVALID_DATA,
3893 "to be used only with GLCompute, MeshNV, "
3894 "TaskNV, MeshEXT or TaskEXT execution model"))));
3895
3896 INSTANTIATE_TEST_SUITE_P(
3897 SubgroupNumAndIdNotU32, ValidateVulkanSubgroupBuiltIns,
3898 Combine(Values("SubgroupId", "NumSubgroups"), Values("GLCompute"),
3899 Values("Input"), Values("%f32"),
3900 Values("VUID-SubgroupId-SubgroupId-04369 "
3901 "VUID-NumSubgroups-NumSubgroups-04295"),
3902 Values(TestResult(SPV_ERROR_INVALID_DATA,
3903 "needs to be a 32-bit int"))));
3904
3905 INSTANTIATE_TEST_SUITE_P(
3906 SubgroupNumAndIdNotInput, ValidateVulkanSubgroupBuiltIns,
3907 Combine(Values("SubgroupId", "NumSubgroups"), Values("GLCompute"),
3908 Values("Output", "Workgroup", "Private"), Values("%u32"),
3909 Values("VUID-SubgroupId-SubgroupId-04368 "
3910 "VUID-NumSubgroups-NumSubgroups-04294"),
3911 Values(TestResult(
3912 SPV_ERROR_INVALID_DATA,
3913 "to be only used for variables with Input storage class"))));
3914
3915 INSTANTIATE_TEST_SUITE_P(SubgroupNumAndIdOk, ValidateVulkanSubgroupBuiltIns,
3916 Combine(Values("SubgroupId", "NumSubgroups"),
3917 Values("GLCompute"), Values("Input"),
3918 Values("%u32"), Values(nullptr),
3919 Values(TestResult(SPV_SUCCESS, ""))));
3920
3921 TEST_F(ValidateBuiltIns, SubgroupIdMemberDecorate) {
3922 const std::string text = R"(
3923 OpCapability Shader
3924 OpCapability GroupNonUniform
3925 OpMemoryModel Logical GLSL450
3926 OpEntryPoint GLCompute %foo "foo"
3927 OpExecutionMode %foo LocalSize 1 1 1
3928 OpDecorate %struct Block
3929 OpMemberDecorate %struct 0 BuiltIn SubgroupId
3930 %void = OpTypeVoid
3931 %int = OpTypeInt 32 0
3932 %struct = OpTypeStruct %int
3933 %void_fn = OpTypeFunction %void
3934 %foo = OpFunction %void None %void_fn
3935 %entry = OpLabel
3936 OpReturn
3937 OpFunctionEnd
3938 )";
3939
3940 CompileSuccessfully(text, SPV_ENV_VULKAN_1_1);
3941 EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_1));
3942 EXPECT_THAT(
3943 getDiagnosticString(),
3944 HasSubstr("BuiltIn SubgroupId cannot be used as a member decoration"));
3945 }
3946
3947 TEST_F(ValidateBuiltIns, TargetIsType) {
3948 const std::string text = R"(
3949 OpCapability Shader
3950 OpCapability Linkage
3951 OpMemoryModel Logical GLSL450
3952 OpDecorate %void BuiltIn Position
3953 %void = OpTypeVoid
3954 )";
3955
3956 CompileSuccessfully(text);
3957 EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
3958 EXPECT_THAT(getDiagnosticString(),
3959 HasSubstr("BuiltIns can only target variables, structure members "
3960 "or constants"));
3961 }
3962
3963 TEST_F(ValidateBuiltIns, TargetIsVariable) {
3964 const std::string text = R"(
3965 OpCapability Shader
3966 OpCapability Linkage
3967 OpMemoryModel Logical GLSL450
3968 OpDecorate %wg_var BuiltIn Position
3969 %int = OpTypeInt 32 0
3970 %int_wg_ptr = OpTypePointer Workgroup %int
3971 %wg_var = OpVariable %int_wg_ptr Workgroup
3972 )";
3973
3974 CompileSuccessfully(text);
3975 EXPECT_EQ(SPV_SUCCESS, ValidateInstructions());
3976 }
3977
3978 INSTANTIATE_TEST_SUITE_P(
3979 PrimitiveShadingRateOutputSuccess,
3980 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
3981 Combine(Values("PrimitiveShadingRateKHR"), Values("Vertex", "Geometry"),
3982 Values("Output"), Values("%u32"),
3983 Values("OpCapability FragmentShadingRateKHR\n"),
3984 Values("OpExtension \"SPV_KHR_fragment_shading_rate\"\n"),
3985 Values(nullptr), Values(TestResult())));
3986
3987 INSTANTIATE_TEST_SUITE_P(
3988 PrimitiveShadingRateMeshOutputSuccess,
3989 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
3990 Combine(Values("PrimitiveShadingRateKHR"), Values("MeshNV"),
3991 Values("Output"), Values("%u32"),
3992 Values("OpCapability FragmentShadingRateKHR\nOpCapability "
3993 "MeshShadingNV\n"),
3994 Values("OpExtension \"SPV_KHR_fragment_shading_rate\"\nOpExtension "
3995 "\"SPV_NV_mesh_shader\"\n"),
3996 Values(nullptr), Values(TestResult())));
3997
3998 INSTANTIATE_TEST_SUITE_P(
3999 PrimitiveShadingRateInvalidExecutionModel,
4000 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
4001 Combine(
4002 Values("PrimitiveShadingRateKHR"), Values("Fragment"), Values("Output"),
4003 Values("%u32"), Values("OpCapability FragmentShadingRateKHR\n"),
4004 Values("OpExtension \"SPV_KHR_fragment_shading_rate\"\n"),
4005 Values("VUID-PrimitiveShadingRateKHR-PrimitiveShadingRateKHR-04484 "),
4006 Values(TestResult(
4007 SPV_ERROR_INVALID_DATA,
4008 "Vulkan spec allows BuiltIn PrimitiveShadingRateKHR to be used "
4009 "only with Vertex, Geometry, MeshNV or MeshEXT execution "
4010 "models."))));
4011
4012 INSTANTIATE_TEST_SUITE_P(
4013 PrimitiveShadingRateInvalidStorageClass,
4014 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
4015 Combine(
4016 Values("PrimitiveShadingRateKHR"), Values("Vertex"), Values("Input"),
4017 Values("%u32"), Values("OpCapability FragmentShadingRateKHR\n"),
4018 Values("OpExtension \"SPV_KHR_fragment_shading_rate\"\n"),
4019 Values("VUID-PrimitiveShadingRateKHR-PrimitiveShadingRateKHR-04485 "),
4020 Values(TestResult(
4021 SPV_ERROR_INVALID_DATA,
4022 "Vulkan spec allows BuiltIn PrimitiveShadingRateKHR to be only "
4023 "used for variables with Output storage class."))));
4024
4025 INSTANTIATE_TEST_SUITE_P(
4026 PrimitiveShadingRateInvalidType,
4027 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
4028 Combine(
4029 Values("PrimitiveShadingRateKHR"), Values("Vertex"), Values("Output"),
4030 Values("%f32"), Values("OpCapability FragmentShadingRateKHR\n"),
4031 Values("OpExtension \"SPV_KHR_fragment_shading_rate\"\n"),
4032 Values("VUID-PrimitiveShadingRateKHR-PrimitiveShadingRateKHR-04486 "),
4033 Values(TestResult(
4034 SPV_ERROR_INVALID_DATA,
4035 "According to the Vulkan spec BuiltIn PrimitiveShadingRateKHR "
4036 "variable needs to be a 32-bit int scalar."))));
4037
4038 INSTANTIATE_TEST_SUITE_P(
4039 ShadingRateInputSuccess,
4040 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
4041 Combine(Values("ShadingRateKHR"), Values("Fragment"), Values("Input"),
4042 Values("%u32"), Values("OpCapability FragmentShadingRateKHR\n"),
4043 Values("OpExtension \"SPV_KHR_fragment_shading_rate\"\n"),
4044 Values(nullptr), Values(TestResult())));
4045
4046 INSTANTIATE_TEST_SUITE_P(
4047 ShadingRateInvalidExecutionModel,
4048 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
4049 Combine(Values("ShadingRateKHR"), Values("Vertex"), Values("Input"),
4050 Values("%u32"), Values("OpCapability FragmentShadingRateKHR\n"),
4051 Values("OpExtension \"SPV_KHR_fragment_shading_rate\"\n"),
4052 Values("VUID-ShadingRateKHR-ShadingRateKHR-04490 "),
4053 Values(TestResult(
4054 SPV_ERROR_INVALID_DATA,
4055 "Vulkan spec allows BuiltIn ShadingRateKHR to be used "
4056 "only with the Fragment execution model."))));
4057
4058 INSTANTIATE_TEST_SUITE_P(
4059 ShadingRateInvalidStorageClass,
4060 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
4061 Combine(Values("ShadingRateKHR"), Values("Fragment"), Values("Output"),
4062 Values("%u32"), Values("OpCapability FragmentShadingRateKHR\n"),
4063 Values("OpExtension \"SPV_KHR_fragment_shading_rate\"\n"),
4064 Values("VUID-ShadingRateKHR-ShadingRateKHR-04491 "),
4065 Values(TestResult(
4066 SPV_ERROR_INVALID_DATA,
4067 "Vulkan spec allows BuiltIn ShadingRateKHR to be only "
4068 "used for variables with Input storage class."))));
4069
4070 INSTANTIATE_TEST_SUITE_P(
4071 ShadingRateInvalidType,
4072 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
4073 Combine(
4074 Values("ShadingRateKHR"), Values("Fragment"), Values("Input"),
4075 Values("%f32"), Values("OpCapability FragmentShadingRateKHR\n"),
4076 Values("OpExtension \"SPV_KHR_fragment_shading_rate\"\n"),
4077 Values("VUID-ShadingRateKHR-ShadingRateKHR-04492 "),
4078 Values(TestResult(SPV_ERROR_INVALID_DATA,
4079 "According to the Vulkan spec BuiltIn ShadingRateKHR "
4080 "variable needs to be a 32-bit int scalar."))));
4081
4082 INSTANTIATE_TEST_SUITE_P(
4083 FragInvocationCountInputSuccess,
4084 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
4085 Combine(Values("FragInvocationCountEXT"), Values("Fragment"),
4086 Values("Input"), Values("%u32"),
4087 Values("OpCapability FragmentDensityEXT\n"),
4088 Values("OpExtension \"SPV_EXT_fragment_invocation_density\"\n"),
4089 Values(nullptr), Values(TestResult())));
4090
4091 INSTANTIATE_TEST_SUITE_P(
4092 FragInvocationCountInvalidExecutionModel,
4093 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
4094 Combine(
4095 Values("FragInvocationCountEXT"), Values("Vertex"), Values("Input"),
4096 Values("%u32"), Values("OpCapability FragmentDensityEXT\n"),
4097 Values("OpExtension \"SPV_EXT_fragment_invocation_density\"\n"),
4098 Values("VUID-FragInvocationCountEXT-FragInvocationCountEXT-04217"),
4099 Values(TestResult(SPV_ERROR_INVALID_DATA,
4100 "Vulkan spec allows BuiltIn FragInvocationCountEXT "
4101 "to be used only with Fragment execution model."))));
4102
4103 INSTANTIATE_TEST_SUITE_P(
4104 FragInvocationCountInvalidStorageClass,
4105 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
4106 Combine(Values("FragInvocationCountEXT"), Values("Fragment"),
4107 Values("Output"), Values("%u32"),
4108 Values("OpCapability FragmentDensityEXT\n"),
4109 Values("OpExtension \"SPV_EXT_fragment_invocation_density\"\n"),
4110 Values("VUID-FragInvocationCountEXT-FragInvocationCountEXT-04218"),
4111 Values(TestResult(
4112 SPV_ERROR_INVALID_DATA,
4113 "Vulkan spec allows BuiltIn FragInvocationCountEXT to be only "
4114 "used for variables with Input storage class."))));
4115
4116 INSTANTIATE_TEST_SUITE_P(
4117 FragInvocationCountInvalidType,
4118 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
4119 Combine(Values("FragInvocationCountEXT"), Values("Fragment"),
4120 Values("Input"), Values("%f32"),
4121 Values("OpCapability FragmentDensityEXT\n"),
4122 Values("OpExtension \"SPV_EXT_fragment_invocation_density\"\n"),
4123 Values("VUID-FragInvocationCountEXT-FragInvocationCountEXT-04219"),
4124 Values(TestResult(
4125 SPV_ERROR_INVALID_DATA,
4126 "According to the Vulkan spec BuiltIn FragInvocationCountEXT "
4127 "variable needs to be a 32-bit int scalar."))));
4128
4129 INSTANTIATE_TEST_SUITE_P(
4130 FragSizeInputSuccess,
4131 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
4132 Combine(Values("FragSizeEXT"), Values("Fragment"), Values("Input"),
4133 Values("%u32vec2"), Values("OpCapability FragmentDensityEXT\n"),
4134 Values("OpExtension \"SPV_EXT_fragment_invocation_density\"\n"),
4135 Values(nullptr), Values(TestResult())));
4136
4137 INSTANTIATE_TEST_SUITE_P(
4138 FragSizeInvalidExecutionModel,
4139 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
4140 Combine(Values("FragSizeEXT"), Values("Vertex"), Values("Input"),
4141 Values("%u32vec2"), Values("OpCapability FragmentDensityEXT\n"),
4142 Values("OpExtension \"SPV_EXT_fragment_invocation_density\"\n"),
4143 Values("VUID-FragSizeEXT-FragSizeEXT-04220"),
4144 Values(TestResult(SPV_ERROR_INVALID_DATA,
4145 "Vulkan spec allows BuiltIn FragSizeEXT to be "
4146 "used only with Fragment execution model."))));
4147
4148 INSTANTIATE_TEST_SUITE_P(
4149 FragSizeInvalidStorageClass,
4150 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
4151 Combine(
4152 Values("FragSizeEXT"), Values("Fragment"), Values("Output"),
4153 Values("%u32vec2"), Values("OpCapability FragmentDensityEXT\n"),
4154 Values("OpExtension \"SPV_EXT_fragment_invocation_density\"\n"),
4155 Values("VUID-FragSizeEXT-FragSizeEXT-04221"),
4156 Values(TestResult(SPV_ERROR_INVALID_DATA,
4157 "Vulkan spec allows BuiltIn FragSizeEXT to be only "
4158 "used for variables with Input storage class."))));
4159
4160 INSTANTIATE_TEST_SUITE_P(
4161 FragSizeInvalidType,
4162 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
4163 Combine(Values("FragSizeEXT"), Values("Fragment"), Values("Input"),
4164 Values("%u32vec3"), Values("OpCapability FragmentDensityEXT\n"),
4165 Values("OpExtension \"SPV_EXT_fragment_invocation_density\"\n"),
4166 Values("VUID-FragSizeEXT-FragSizeEXT-04222"),
4167 Values(TestResult(
4168 SPV_ERROR_INVALID_DATA,
4169 "According to the Vulkan spec BuiltIn FragSizeEXT variable "
4170 "needs to be a 2-component 32-bit int vector."))));
4171
4172 INSTANTIATE_TEST_SUITE_P(
4173 FragStencilRefOutputSuccess,
4174 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
4175 Combine(Values("FragStencilRefEXT"), Values("Fragment"), Values("Output"),
4176 Values("%u32", "%u64"), Values("OpCapability StencilExportEXT\n"),
4177 Values("OpExtension \"SPV_EXT_shader_stencil_export\"\n"),
4178 Values(nullptr), Values(TestResult())));
4179
4180 INSTANTIATE_TEST_SUITE_P(
4181 FragStencilRefInvalidExecutionModel,
4182 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
4183 Combine(Values("FragStencilRefEXT"), Values("Vertex"), Values("Output"),
4184 Values("%u32", "%u64"), Values("OpCapability StencilExportEXT\n"),
4185 Values("OpExtension \"SPV_EXT_shader_stencil_export\"\n"),
4186 Values("VUID-FragStencilRefEXT-FragStencilRefEXT-04223"),
4187 Values(TestResult(SPV_ERROR_INVALID_DATA,
4188 "Vulkan spec allows BuiltIn FragStencilRefEXT to "
4189 "be used only with Fragment execution model."))));
4190
4191 INSTANTIATE_TEST_SUITE_P(
4192 FragStencilRefInvalidStorageClass,
4193 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
4194 Combine(Values("FragStencilRefEXT"), Values("Fragment"), Values("Input"),
4195 Values("%u32", "%u64"), Values("OpCapability StencilExportEXT\n"),
4196 Values("OpExtension \"SPV_EXT_shader_stencil_export\"\n"),
4197 Values("VUID-FragStencilRefEXT-FragStencilRefEXT-04224"),
4198 Values(TestResult(
4199 SPV_ERROR_INVALID_DATA,
4200 "Vulkan spec allows BuiltIn FragStencilRefEXT to be only used "
4201 "for variables with Output storage class."))));
4202
4203 INSTANTIATE_TEST_SUITE_P(
4204 FragStencilRefInvalidType,
4205 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
4206 Combine(Values("FragStencilRefEXT"), Values("Fragment"), Values("Output"),
4207 Values("%f32", "%f64", "%u32vec2"),
4208 Values("OpCapability StencilExportEXT\n"),
4209 Values("OpExtension \"SPV_EXT_shader_stencil_export\"\n"),
4210 Values("VUID-FragStencilRefEXT-FragStencilRefEXT-04225"),
4211 Values(TestResult(
4212 SPV_ERROR_INVALID_DATA,
4213 "According to the Vulkan spec BuiltIn FragStencilRefEXT "
4214 "variable needs to be a int scalar."))));
4215
4216 INSTANTIATE_TEST_SUITE_P(
4217 FullyCoveredEXTInputSuccess,
4218 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
4219 Combine(Values("FullyCoveredEXT"), Values("Fragment"), Values("Input"),
4220 Values("%bool"), Values("OpCapability FragmentFullyCoveredEXT\n"),
4221 Values("OpExtension \"SPV_EXT_fragment_fully_covered\"\n"),
4222 Values(nullptr), Values(TestResult())));
4223
4224 INSTANTIATE_TEST_SUITE_P(
4225 FullyCoveredEXTInvalidExecutionModel,
4226 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
4227 Combine(Values("FullyCoveredEXT"), Values("Vertex"), Values("Input"),
4228 Values("%bool"), Values("OpCapability FragmentFullyCoveredEXT\n"),
4229 Values("OpExtension \"SPV_EXT_fragment_fully_covered\"\n"),
4230 Values("VUID-FullyCoveredEXT-FullyCoveredEXT-04232"),
4231 Values(TestResult(SPV_ERROR_INVALID_DATA,
4232 "Vulkan spec allows BuiltIn FullyCoveredEXT to "
4233 "be used only with Fragment execution model."))));
4234
4235 INSTANTIATE_TEST_SUITE_P(
4236 FullyCoveredEXTInvalidStorageClass,
4237 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
4238 Combine(Values("FullyCoveredEXT"), Values("Fragment"), Values("Output"),
4239 Values("%bool"), Values("OpCapability FragmentFullyCoveredEXT\n"),
4240 Values("OpExtension \"SPV_EXT_fragment_fully_covered\"\n"),
4241 Values("VUID-FullyCoveredEXT-FullyCoveredEXT-04233"),
4242 Values(TestResult(
4243 SPV_ERROR_INVALID_DATA,
4244 "Vulkan spec allows BuiltIn FullyCoveredEXT to be only used "
4245 "for variables with Input storage class."))));
4246
4247 INSTANTIATE_TEST_SUITE_P(
4248 FullyCoveredEXTInvalidType,
4249 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
4250 Combine(Values("FullyCoveredEXT"), Values("Fragment"), Values("Input"),
4251 Values("%f32"), Values("OpCapability FragmentFullyCoveredEXT\n"),
4252 Values("OpExtension \"SPV_EXT_fragment_fully_covered\"\n"),
4253 Values("VUID-FullyCoveredEXT-FullyCoveredEXT-04234"),
4254 Values(TestResult(
4255 SPV_ERROR_INVALID_DATA,
4256 "According to the Vulkan spec BuiltIn FullyCoveredEXT variable "
4257 "needs to be a bool scalar."))));
4258
4259 INSTANTIATE_TEST_SUITE_P(
4260 BaryCoordNotFragment,
4261 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
4262 Combine(
4263 Values("BaryCoordKHR", "BaryCoordNoPerspKHR"), Values("Vertex"),
4264 Values("Input"), Values("%f32vec3"),
4265 Values("OpCapability FragmentBarycentricKHR\n"),
4266 Values("OpExtension \"SPV_KHR_fragment_shader_barycentric\"\n"),
4267 Values("VUID-BaryCoordKHR-BaryCoordKHR-04154 "
4268 "VUID-BaryCoordNoPerspKHR-BaryCoordNoPerspKHR-04160 "),
4269 Values(TestResult(SPV_ERROR_INVALID_DATA, "Vulkan spec allows BuiltIn",
4270 "to be used only with Fragment execution model"))));
4271
4272 INSTANTIATE_TEST_SUITE_P(
4273 BaryCoordNotInput,
4274 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
4275 Combine(Values("BaryCoordKHR", "BaryCoordNoPerspKHR"), Values("Fragment"),
4276 Values("Output"), Values("%f32vec3"),
4277 Values("OpCapability FragmentBarycentricKHR\n"),
4278 Values("OpExtension \"SPV_KHR_fragment_shader_barycentric\"\n"),
4279 Values("VUID-BaryCoordKHR-BaryCoordKHR-04155 "
4280 "VUID-BaryCoordNoPerspKHR-BaryCoordNoPerspKHR-04161 "),
4281 Values(TestResult(
4282 SPV_ERROR_INVALID_DATA, "Vulkan spec allows BuiltIn",
4283 "to be only used for variables with Input storage class"))));
4284
4285 INSTANTIATE_TEST_SUITE_P(
4286 BaryCoordNotFloatVector,
4287 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
4288 Combine(
4289 Values("BaryCoordKHR", "BaryCoordNoPerspKHR"), Values("Fragment"),
4290 Values("Output"), Values("%f32arr3", "%u32vec4"),
4291 Values("OpCapability FragmentBarycentricKHR\n"),
4292 Values("OpExtension \"SPV_KHR_fragment_shader_barycentric\"\n"),
4293 Values("VUID-BaryCoordKHR-BaryCoordKHR-04156 "
4294 "VUID-BaryCoordNoPerspKHR-BaryCoordNoPerspKHR-04162 "),
4295 Values(TestResult(SPV_ERROR_INVALID_DATA,
4296 "needs to be a 3-component 32-bit float vector"))));
4297
4298 INSTANTIATE_TEST_SUITE_P(
4299 BaryCoordNotFloatVec3,
4300 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
4301 Combine(
4302 Values("BaryCoordKHR", "BaryCoordNoPerspKHR"), Values("Fragment"),
4303 Values("Output"), Values("%f32vec2"),
4304 Values("OpCapability FragmentBarycentricKHR\n"),
4305 Values("OpExtension \"SPV_KHR_fragment_shader_barycentric\"\n"),
4306 Values("VUID-BaryCoordKHR-BaryCoordKHR-04156 "
4307 "VUID-BaryCoordNoPerspKHR-BaryCoordNoPerspKHR-04162 "),
4308 Values(TestResult(SPV_ERROR_INVALID_DATA,
4309 "needs to be a 3-component 32-bit float vector"))));
4310
4311 INSTANTIATE_TEST_SUITE_P(
4312 BaryCoordNotF32Vec3,
4313 ValidateVulkanCombineBuiltInExecutionModelDataTypeCapabilityExtensionResult,
4314 Combine(
4315 Values("BaryCoordKHR", "BaryCoordNoPerspKHR"), Values("Fragment"),
4316 Values("Output"), Values("%f64vec3"),
4317 Values("OpCapability FragmentBarycentricKHR\n"),
4318 Values("OpExtension \"SPV_KHR_fragment_shader_barycentric\"\n"),
4319 Values("VUID-BaryCoordKHR-BaryCoordKHR-04156 "
4320 "VUID-BaryCoordNoPerspKHR-BaryCoordNoPerspKHR-04162 "),
4321 Values(TestResult(SPV_ERROR_INVALID_DATA,
4322 "needs to be a 3-component 32-bit float vector"))));
4323
4324 std::string GenerateMeshShadingCode(const std::string& built_in,
4325 const std::string& execution_mode,
4326 const std::string& body,
4327 const std::string& declarations = "") {
4328 std::ostringstream ss;
4329 ss << R"(
4330 OpCapability MeshShadingEXT
4331 OpExtension "SPV_EXT_mesh_shader"
4332 OpMemoryModel Logical GLSL450
4333 OpEntryPoint MeshEXT %main "main" %var
4334 OpExecutionMode %main LocalSize 1 1 1
4335 OpExecutionMode %main OutputVertices 1
4336 OpExecutionMode %main OutputPrimitivesEXT 16
4337 )";
4338 ss << "OpExecutionMode %main " << execution_mode << "\n";
4339 ss << "OpDecorate %var BuiltIn " << built_in << "\n";
4340
4341 ss << R"(
4342 %void = OpTypeVoid
4343 %func = OpTypeFunction %void
4344 %bool = OpTypeBool
4345 %int = OpTypeInt 32 1
4346 %uint = OpTypeInt 32 0
4347 %v2uint = OpTypeVector %uint 2
4348 %v3uint = OpTypeVector %uint 3
4349
4350 %int_0 = OpConstant %int 0
4351 %uint_16 = OpConstant %uint 16
4352 )";
4353
4354 ss << declarations;
4355
4356 ss << R"(
4357 %main = OpFunction %void None %func
4358 %main_entry = OpLabel
4359 )";
4360
4361 ss << body;
4362
4363 ss << R"(
4364 OpReturn
4365 OpFunctionEnd)";
4366 return ss.str();
4367 }
4368
4369 TEST_F(ValidateBuiltIns, VulkanPrimitiveTriangleIndicesEXTSuccess) {
4370 const std::string declarations = R"(
4371 %array = OpTypeArray %v3uint %uint_16
4372 %array_ptr = OpTypePointer Output %array
4373 %var = OpVariable %array_ptr Output
4374 %ptr = OpTypePointer Output %v3uint
4375 )";
4376 const std::string body = R"(
4377 %access = OpAccessChain %ptr %var %int_0
4378 )";
4379
4380 CompileSuccessfully(
4381 GenerateMeshShadingCode("PrimitiveTriangleIndicesEXT",
4382 "OutputTrianglesEXT", body, declarations)
4383 .c_str(),
4384 SPV_ENV_VULKAN_1_2);
4385 EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_2));
4386 }
4387
4388 TEST_F(ValidateBuiltIns,
4389 VulkanPrimitiveTriangleIndicesEXTInvalidExecutionMode) {
4390 const std::string declarations = R"(
4391 %array = OpTypeArray %v3uint %uint_16
4392 %array_ptr = OpTypePointer Output %array
4393 %var = OpVariable %array_ptr Output
4394 %ptr = OpTypePointer Output %v3uint
4395 )";
4396 const std::string body = R"(
4397 %access = OpAccessChain %ptr %var %int_0
4398 )";
4399
4400 CompileSuccessfully(
4401 GenerateMeshShadingCode("PrimitiveTriangleIndicesEXT", "OutputPoints",
4402 body, declarations)
4403 .c_str(),
4404 SPV_ENV_VULKAN_1_2);
4405 EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_2));
4406 EXPECT_THAT(getDiagnosticString(),
4407 AnyVUID("VUID-PrimitiveTriangleIndicesEXT-"
4408 "PrimitiveTriangleIndicesEXT-07054"));
4409 }
4410
4411 TEST_F(ValidateBuiltIns, VulkanPrimitiveTriangleIndicesEXTStorageClass) {
4412 const std::string declarations = R"(
4413 %array = OpTypeArray %v3uint %uint_16
4414 %array_ptr = OpTypePointer Input %array
4415 %var = OpVariable %array_ptr Input
4416 %ptr = OpTypePointer Input %v3uint
4417 )";
4418 const std::string body = R"(
4419 %access = OpAccessChain %ptr %var %int_0
4420 )";
4421
4422 CompileSuccessfully(
4423 GenerateMeshShadingCode("PrimitiveTriangleIndicesEXT",
4424 "OutputTrianglesEXT", body, declarations)
4425 .c_str(),
4426 SPV_ENV_VULKAN_1_2);
4427 ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_2));
4428 EXPECT_THAT(getDiagnosticString(),
4429 AnyVUID("VUID-PrimitiveTriangleIndicesEXT-"
4430 "PrimitiveTriangleIndicesEXT-07055"));
4431 }
4432
4433 TEST_F(ValidateBuiltIns, VulkanPrimitiveTriangleIndicesEXTVectorSize) {
4434 const std::string declarations = R"(
4435 %array = OpTypeArray %v2uint %uint_16
4436 %array_ptr = OpTypePointer Output %array
4437 %var = OpVariable %array_ptr Output
4438 %ptr = OpTypePointer Output %v2uint
4439 )";
4440 const std::string body = R"(
4441 %access = OpAccessChain %ptr %var %int_0
4442 )";
4443
4444 CompileSuccessfully(
4445 GenerateMeshShadingCode("PrimitiveTriangleIndicesEXT",
4446 "OutputTrianglesEXT", body, declarations)
4447 .c_str(),
4448 SPV_ENV_VULKAN_1_2);
4449 ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_2));
4450 EXPECT_THAT(getDiagnosticString(),
4451 AnyVUID("VUID-PrimitiveTriangleIndicesEXT-"
4452 "PrimitiveTriangleIndicesEXT-07056"));
4453 }
4454
4455 TEST_F(ValidateBuiltIns, VulkanPrimitiveTriangleIndicesEXTNonArray) {
4456 const std::string declarations = R"(
4457 %ptr = OpTypePointer Output %v3uint
4458 %var = OpVariable %ptr Output
4459 )";
4460 const std::string body = R"(
4461 %load = OpLoad %v3uint %var
4462 )";
4463
4464 CompileSuccessfully(
4465 GenerateMeshShadingCode("PrimitiveTriangleIndicesEXT",
4466 "OutputTrianglesEXT", body, declarations)
4467 .c_str(),
4468 SPV_ENV_VULKAN_1_2);
4469 ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_2));
4470 EXPECT_THAT(getDiagnosticString(),
4471 AnyVUID("VUID-PrimitiveTriangleIndicesEXT-"
4472 "PrimitiveTriangleIndicesEXT-07056"));
4473 }
4474
4475 TEST_F(ValidateBuiltIns, VulkanPrimitiveLineIndicesEXTSuccess) {
4476 const std::string declarations = R"(
4477 %array = OpTypeArray %v2uint %uint_16
4478 %array_ptr = OpTypePointer Output %array
4479 %var = OpVariable %array_ptr Output
4480 %ptr = OpTypePointer Output %v2uint
4481 )";
4482 const std::string body = R"(
4483 %access = OpAccessChain %ptr %var %int_0
4484 )";
4485
4486 CompileSuccessfully(
4487 GenerateMeshShadingCode("PrimitiveLineIndicesEXT", "OutputLinesEXT", body,
4488 declarations)
4489 .c_str(),
4490 SPV_ENV_VULKAN_1_2);
4491 EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_2));
4492 }
4493
4494 TEST_F(ValidateBuiltIns, VulkanPrimitiveLineIndicesEXTInvalidExecutionMode) {
4495 const std::string declarations = R"(
4496 %array = OpTypeArray %v2uint %uint_16
4497 %array_ptr = OpTypePointer Output %array
4498 %var = OpVariable %array_ptr Output
4499 %ptr = OpTypePointer Output %v2uint
4500 )";
4501 const std::string body = R"(
4502 %access = OpAccessChain %ptr %var %int_0
4503 )";
4504
4505 CompileSuccessfully(
4506 GenerateMeshShadingCode("PrimitiveLineIndicesEXT", "OutputPoints", body,
4507 declarations)
4508 .c_str(),
4509 SPV_ENV_VULKAN_1_2);
4510 EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_2));
4511 EXPECT_THAT(
4512 getDiagnosticString(),
4513 AnyVUID("VUID-PrimitiveLineIndicesEXT-PrimitiveLineIndicesEXT-07048"));
4514 }
4515
4516 TEST_F(ValidateBuiltIns, VulkanPrimitiveLineIndicesEXTStorageClass) {
4517 const std::string declarations = R"(
4518 %array = OpTypeArray %v2uint %uint_16
4519 %array_ptr = OpTypePointer Input %array
4520 %var = OpVariable %array_ptr Input
4521 %ptr = OpTypePointer Input %v2uint
4522 )";
4523 const std::string body = R"(
4524 %access = OpAccessChain %ptr %var %int_0
4525 )";
4526
4527 CompileSuccessfully(
4528 GenerateMeshShadingCode("PrimitiveLineIndicesEXT", "OutputLinesEXT", body,
4529 declarations)
4530 .c_str(),
4531 SPV_ENV_VULKAN_1_2);
4532 EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_2));
4533 EXPECT_THAT(
4534 getDiagnosticString(),
4535 AnyVUID("VUID-PrimitiveLineIndicesEXT-PrimitiveLineIndicesEXT-07049"));
4536 }
4537
4538 TEST_F(ValidateBuiltIns, VulkanPrimitiveLineIndicesEXTType) {
4539 const std::string declarations = R"(
4540 %array = OpTypeArray %v3uint %uint_16
4541 %array_ptr = OpTypePointer Input %array
4542 %var = OpVariable %array_ptr Input
4543 %ptr = OpTypePointer Input %v3uint
4544 )";
4545 const std::string body = R"(
4546 %access = OpAccessChain %ptr %var %int_0
4547 )";
4548
4549 CompileSuccessfully(
4550 GenerateMeshShadingCode("PrimitiveLineIndicesEXT", "OutputLinesEXT", body,
4551 declarations)
4552 .c_str(),
4553 SPV_ENV_VULKAN_1_2);
4554 EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_2));
4555 EXPECT_THAT(
4556 getDiagnosticString(),
4557 AnyVUID("VUID-PrimitiveLineIndicesEXT-PrimitiveLineIndicesEXT-07050"));
4558 }
4559
4560 TEST_F(ValidateBuiltIns, VulkanPrimitivePointIndicesEXTSuccess) {
4561 const std::string declarations = R"(
4562 %array = OpTypeArray %uint %uint_16
4563 %array_ptr = OpTypePointer Output %array
4564 %var = OpVariable %array_ptr Output
4565 %ptr = OpTypePointer Output %uint
4566 )";
4567 const std::string body = R"(
4568 %access = OpAccessChain %ptr %var %int_0
4569 )";
4570
4571 CompileSuccessfully(
4572 GenerateMeshShadingCode("PrimitivePointIndicesEXT", "OutputPoints", body,
4573 declarations)
4574 .c_str(),
4575 SPV_ENV_VULKAN_1_2);
4576 EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_2));
4577 }
4578
4579 TEST_F(ValidateBuiltIns, VulkanPrimitivePointIndicesEXTInvalidExecutionMode) {
4580 const std::string declarations = R"(
4581 %array = OpTypeArray %uint %uint_16
4582 %array_ptr = OpTypePointer Output %array
4583 %var = OpVariable %array_ptr Output
4584 %ptr = OpTypePointer Output %uint
4585 )";
4586 const std::string body = R"(
4587 %access = OpAccessChain %ptr %var %int_0
4588 )";
4589
4590 CompileSuccessfully(
4591 GenerateMeshShadingCode("PrimitivePointIndicesEXT", "OutputTrianglesNV",
4592 body, declarations)
4593 .c_str(),
4594 SPV_ENV_VULKAN_1_2);
4595 EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_2));
4596 EXPECT_THAT(
4597 getDiagnosticString(),
4598 AnyVUID("VUID-PrimitivePointIndicesEXT-PrimitivePointIndicesEXT-07042"));
4599 }
4600
4601 TEST_F(ValidateBuiltIns, VulkanPrimitivePointIndicesEXTStorageClass) {
4602 const std::string declarations = R"(
4603 %array = OpTypeArray %uint %uint_16
4604 %array_ptr = OpTypePointer Input %array
4605 %var = OpVariable %array_ptr Input
4606 %ptr = OpTypePointer Input %uint
4607 )";
4608 const std::string body = R"(
4609 %access = OpAccessChain %ptr %var %int_0
4610 )";
4611
4612 CompileSuccessfully(
4613 GenerateMeshShadingCode("PrimitivePointIndicesEXT", "OutputPoints", body,
4614 declarations)
4615 .c_str(),
4616 SPV_ENV_VULKAN_1_2);
4617 EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_2));
4618 EXPECT_THAT(
4619 getDiagnosticString(),
4620 AnyVUID("VUID-PrimitivePointIndicesEXT-PrimitivePointIndicesEXT-07043"));
4621 }
4622
4623 TEST_F(ValidateBuiltIns, VulkanPrimitivePointIndicesEXTType) {
4624 const std::string declarations = R"(
4625 %array = OpTypeArray %v3uint %uint_16
4626 %array_ptr = OpTypePointer Output %array
4627 %var = OpVariable %array_ptr Output
4628 %ptr = OpTypePointer Output %v3uint
4629 )";
4630 const std::string body = R"(
4631 %access = OpAccessChain %ptr %var %int_0
4632 )";
4633
4634 CompileSuccessfully(
4635 GenerateMeshShadingCode("PrimitivePointIndicesEXT", "OutputPoints", body,
4636 declarations)
4637 .c_str(),
4638 SPV_ENV_VULKAN_1_2);
4639 EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_2));
4640 EXPECT_THAT(
4641 getDiagnosticString(),
4642 AnyVUID("VUID-PrimitivePointIndicesEXT-PrimitivePointIndicesEXT-07044"));
4643 }
4644
4645 TEST_F(ValidateBuiltIns, VulkanBuiltinPrimtiveIDWithPerPrimitiveEXT) {
4646 const std::string text = R"(
4647 OpCapability MeshShadingEXT
4648 OpCapability Shader
4649 OpExtension "SPV_EXT_mesh_shader"
4650 OpMemoryModel Logical GLSL450
4651 OpEntryPoint MeshEXT %MainMesh "MainMesh" %gl_PrimitiveID
4652 OpExecutionMode %MainMesh OutputPrimitivesNV 1
4653 OpExecutionMode %MainMesh OutputVertices 3
4654 OpExecutionMode %MainMesh OutputTrianglesNV
4655 OpExecutionMode %MainMesh LocalSize 1 1 1
4656 OpSource Slang 1
4657 OpName %MainMesh "MainMesh"
4658 OpDecorate %gl_PrimitiveID BuiltIn PrimitiveId
4659 OpDecorate %gl_PrimitiveID PerPrimitiveNV
4660 %void = OpTypeVoid
4661 %9 = OpTypeFunction %void
4662 %uint = OpTypeInt 32 0
4663 %uint_3 = OpConstant %uint 3
4664 %uint_1 = OpConstant %uint 1
4665 %float = OpTypeFloat 32
4666 %v4float = OpTypeVector %float 4
4667 %int = OpTypeInt 32 1
4668 %int_1 = OpConstant %int 1
4669 %int_3 = OpConstant %int 3
4670 %_ptr_Output_v4float = OpTypePointer Output %v4float
4671 %uint_0 = OpConstant %uint 0
4672 %v3float = OpTypeVector %float 3
4673 %_ptr_Output_v3float = OpTypePointer Output %v3float
4674 %v3uint = OpTypeVector %uint 3
4675 %_ptr_Output_v3uint = OpTypePointer Output %v3uint
4676 %_ptr_Output_int = OpTypePointer Output %int
4677 %_arr_int_int_1 = OpTypeArray %int %int_1
4678 %_ptr_Output__arr_int_int_1 = OpTypePointer Output %_arr_int_int_1
4679 %gl_PrimitiveID = OpVariable %_ptr_Output__arr_int_int_1 Output
4680 %MainMesh = OpFunction %void None %9
4681 %25 = OpLabel
4682 OpSetMeshOutputsEXT %uint_3 %uint_1
4683 OpReturn
4684 OpFunctionEnd
4685 )";
4686
4687 CompileSuccessfully(text, SPV_ENV_VULKAN_1_2);
4688 EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_2));
4689 }
4690
4691 TEST_F(ValidateBuiltIns, BadVulkanBuiltinPrimtiveIDWithPerPrimitiveEXT) {
4692 const std::string text = R"(
4693 OpCapability MeshShadingEXT
4694 OpCapability Shader
4695 OpExtension "SPV_EXT_mesh_shader"
4696 OpMemoryModel Logical GLSL450
4697 OpEntryPoint MeshEXT %MainMesh "MainMesh" %gl_PrimitiveID
4698 OpExecutionMode %MainMesh OutputPrimitivesNV 1
4699 OpExecutionMode %MainMesh OutputVertices 3
4700 OpExecutionMode %MainMesh OutputTrianglesNV
4701 OpExecutionMode %MainMesh LocalSize 1 1 1
4702 OpSource Slang 1
4703 OpName %MainMesh "MainMesh"
4704 OpDecorate %gl_PrimitiveID BuiltIn PrimitiveId
4705 %void = OpTypeVoid
4706 %9 = OpTypeFunction %void
4707 %uint = OpTypeInt 32 0
4708 %uint_3 = OpConstant %uint 3
4709 %uint_1 = OpConstant %uint 1
4710 %float = OpTypeFloat 32
4711 %v4float = OpTypeVector %float 4
4712 %int = OpTypeInt 32 1
4713 %int_1 = OpConstant %int 1
4714 %int_3 = OpConstant %int 3
4715 %_ptr_Output_v4float = OpTypePointer Output %v4float
4716 %uint_0 = OpConstant %uint 0
4717 %v3float = OpTypeVector %float 3
4718 %_ptr_Output_v3float = OpTypePointer Output %v3float
4719 %v3uint = OpTypeVector %uint 3
4720 %_ptr_Output_v3uint = OpTypePointer Output %v3uint
4721 %_ptr_Output_int = OpTypePointer Output %int
4722 %_arr_int_int_1 = OpTypeArray %int %int_1
4723 %_ptr_Output__arr_int_int_1 = OpTypePointer Output %_arr_int_int_1
4724 %gl_PrimitiveID = OpVariable %_ptr_Output__arr_int_int_1 Output
4725 %MainMesh = OpFunction %void None %9
4726 %25 = OpLabel
4727 %ref_load = OpLoad %_arr_int_int_1 %gl_PrimitiveID
4728 OpSetMeshOutputsEXT %uint_3 %uint_1
4729 OpReturn
4730 OpFunctionEnd
4731 )";
4732
4733 CompileSuccessfully(text, SPV_ENV_VULKAN_1_2);
4734 EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_2));
4735 EXPECT_THAT(getDiagnosticString(),
4736 AnyVUID("VUID-PrimitiveId-PrimitiveId-07040"));
4737 }
4738
4739
4740 TEST_F(ValidateBuiltIns, BadVulkanBuiltinViewportIndexWithPerPrimitiveEXT) {
4741 const std::string text = R"(
4742 OpCapability MeshShadingEXT
4743 OpCapability Shader
4744 OpExtension "SPV_EXT_mesh_shader"
4745 OpMemoryModel Logical GLSL450
4746 OpEntryPoint MeshEXT %MainMesh "MainMesh" %gl_ViewportIndex
4747 OpExecutionMode %MainMesh OutputPrimitivesNV 1
4748 OpExecutionMode %MainMesh OutputVertices 3
4749 OpExecutionMode %MainMesh OutputTrianglesNV
4750 OpExecutionMode %MainMesh LocalSize 1 1 1
4751 OpSource Slang 1
4752 OpName %MainMesh "MainMesh"
4753 OpDecorate %gl_ViewportIndex BuiltIn ViewportIndex
4754 %void = OpTypeVoid
4755 %9 = OpTypeFunction %void
4756 %uint = OpTypeInt 32 0
4757 %uint_3 = OpConstant %uint 3
4758 %uint_1 = OpConstant %uint 1
4759 %float = OpTypeFloat 32
4760 %int = OpTypeInt 32 1
4761 %int_1 = OpConstant %int 1
4762 %int_3 = OpConstant %int 3
4763 %uint_0 = OpConstant %uint 0
4764 %v3float = OpTypeVector %float 3
4765 %_ptr_Output_v3float = OpTypePointer Output %v3float
4766 %v3uint = OpTypeVector %uint 3
4767 %_ptr_Output_v3uint = OpTypePointer Output %v3uint
4768 %_ptr_Output_int = OpTypePointer Output %int
4769 %_arr_int_int_1 = OpTypeArray %int %int_1
4770 %_ptr_Output__arr_int_int_1 = OpTypePointer Output %_arr_int_int_1
4771 %gl_ViewportIndex = OpVariable %_ptr_Output__arr_int_int_1 Output
4772 %MainMesh = OpFunction %void None %9
4773 %25 = OpLabel
4774 %ref_load = OpLoad %_arr_int_int_1 %gl_ViewportIndex
4775 OpSetMeshOutputsEXT %uint_3 %uint_1
4776 OpReturn
4777 OpFunctionEnd
4778 )";
4779
4780 CompileSuccessfully(text, SPV_ENV_VULKAN_1_2);
4781 EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_2));
4782 EXPECT_THAT(getDiagnosticString(),
4783 AnyVUID("VUID-ViewportIndex-ViewportIndex-07060"));
4784 }
4785
4786 TEST_F(ValidateBuiltIns, VulkanBuiltinPrimitivePointIndicesEXT) {
4787 const std::string text = R"(
4788 OpCapability MeshShadingEXT
4789 OpExtension "SPV_EXT_mesh_shader"
4790 %1 = OpExtInstImport "GLSL.std.450"
4791 OpMemoryModel Logical GLSL450
4792 OpEntryPoint MeshEXT %main "main" %gl_PrimitivePointIndicesEXT
4793 OpExecutionMode %main LocalSize 32 1 1
4794 OpExecutionMode %main OutputVertices 81
4795 OpExecutionMode %main OutputPrimitivesEXT 32
4796 OpExecutionMode %main OutputPoints
4797 OpSource GLSL 460
4798 OpSourceExtension "GL_EXT_mesh_shader"
4799 OpName %main "main"
4800 OpName %gl_PrimitivePointIndicesEXT "gl_PrimitivePointIndicesEXT"
4801 OpDecorate %gl_PrimitivePointIndicesEXT BuiltIn PrimitivePointIndicesEXT
4802 OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize
4803 %void = OpTypeVoid
4804 %3 = OpTypeFunction %void
4805 %uint = OpTypeInt 32 0
4806 %uint_32 = OpConstant %uint 32
4807 %_arr_uint_uint_32 = OpTypeArray %uint %uint_32
4808 %_ptr_Output__arr_uint_uint_32 = OpTypePointer Output %_arr_uint_uint_32
4809 %gl_PrimitivePointIndicesEXT = OpVariable %_ptr_Output__arr_uint_uint_32 Output
4810 %int = OpTypeInt 32 1
4811 %int_0 = OpConstant %int 0
4812 %uint_0 = OpConstant %uint 0
4813 %_ptr_Output_uint = OpTypePointer Output %uint
4814 %v3uint = OpTypeVector %uint 3
4815 %uint_1 = OpConstant %uint 1
4816 %gl_WorkGroupSize = OpConstantComposite %v3uint %uint_32 %uint_1 %uint_1
4817 %main = OpFunction %void None %3
4818 %5 = OpLabel
4819 %15 = OpAccessChain %_ptr_Output_uint %gl_PrimitivePointIndicesEXT %int_0
4820 OpStore %15 %uint_0
4821 OpReturn
4822 OpFunctionEnd
4823 )";
4824
4825 CompileSuccessfully(text, SPV_ENV_VULKAN_1_2);
4826 EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_2));
4827 }
4828
4829 TEST_F(ValidateBuiltIns, VulkanBuiltinPrimitiveLineIndicesEXT) {
4830 const std::string text = R"(
4831 OpCapability MeshShadingEXT
4832 OpExtension "SPV_EXT_mesh_shader"
4833 %1 = OpExtInstImport "GLSL.std.450"
4834 OpMemoryModel Logical GLSL450
4835 OpEntryPoint MeshEXT %main "main" %gl_PrimitiveLineIndicesEXT
4836 OpExecutionMode %main LocalSize 32 1 1
4837 OpExecutionMode %main OutputVertices 81
4838 OpExecutionMode %main OutputPrimitivesEXT 32
4839 OpExecutionMode %main OutputLinesEXT
4840 OpSource GLSL 460
4841 OpSourceExtension "GL_EXT_mesh_shader"
4842 OpName %main "main"
4843 OpName %gl_PrimitiveLineIndicesEXT "gl_PrimitiveLineIndicesEXT"
4844 OpDecorate %gl_PrimitiveLineIndicesEXT BuiltIn PrimitiveLineIndicesEXT
4845 OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize
4846 %void = OpTypeVoid
4847 %3 = OpTypeFunction %void
4848 %uint = OpTypeInt 32 0
4849 %v2uint = OpTypeVector %uint 2
4850 %uint_32 = OpConstant %uint 32
4851 %_arr_v2uint_uint_32 = OpTypeArray %v2uint %uint_32
4852 %_ptr_Output__arr_v2uint_uint_32 = OpTypePointer Output %_arr_v2uint_uint_32
4853 %gl_PrimitiveLineIndicesEXT = OpVariable %_ptr_Output__arr_v2uint_uint_32 Output
4854 %int = OpTypeInt 32 1
4855 %int_0 = OpConstant %int 0
4856 %uint_0 = OpConstant %uint 0
4857 %15 = OpConstantComposite %v2uint %uint_0 %uint_0
4858 %_ptr_Output_v2uint = OpTypePointer Output %v2uint
4859 %v3uint = OpTypeVector %uint 3
4860 %uint_1 = OpConstant %uint 1
4861 %gl_WorkGroupSize = OpConstantComposite %v3uint %uint_32 %uint_1 %uint_1
4862 %main = OpFunction %void None %3
4863 %5 = OpLabel
4864 %17 = OpAccessChain %_ptr_Output_v2uint %gl_PrimitiveLineIndicesEXT %int_0
4865 OpStore %17 %15
4866 OpReturn
4867 OpFunctionEnd
4868 )";
4869
4870 CompileSuccessfully(text, SPV_ENV_VULKAN_1_2);
4871 EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_2));
4872 }
4873
4874 TEST_F(ValidateBuiltIns, BadVulkanBuiltinPrimitiveLineIndicesEXT) {
4875 const std::string text = R"(
4876 OpCapability MeshShadingEXT
4877 OpExtension "SPV_EXT_mesh_shader"
4878 %1 = OpExtInstImport "GLSL.std.450"
4879 OpMemoryModel Logical GLSL450
4880 OpEntryPoint MeshEXT %main "main" %gl_PrimitiveLineIndicesEXT
4881 OpExecutionMode %main LocalSize 32 1 1
4882 OpExecutionMode %main OutputVertices 81
4883 OpExecutionMode %main OutputPrimitivesEXT 32
4884 OpExecutionMode %main OutputPoints
4885 OpSource GLSL 460
4886 OpSourceExtension "GL_EXT_mesh_shader"
4887 OpName %main "main"
4888 OpName %gl_PrimitiveLineIndicesEXT "gl_PrimitiveLineIndicesEXT"
4889 OpDecorate %gl_PrimitiveLineIndicesEXT BuiltIn PrimitiveLineIndicesEXT
4890 OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize
4891 %void = OpTypeVoid
4892 %3 = OpTypeFunction %void
4893 %uint = OpTypeInt 32 0
4894 %v2uint = OpTypeVector %uint 2
4895 %uint_32 = OpConstant %uint 32
4896 %_arr_v2uint_uint_32 = OpTypeArray %v2uint %uint_32
4897 %_ptr_Output__arr_v2uint_uint_32 = OpTypePointer Output %_arr_v2uint_uint_32
4898 %gl_PrimitiveLineIndicesEXT = OpVariable %_ptr_Output__arr_v2uint_uint_32 Output
4899 %int = OpTypeInt 32 1
4900 %int_0 = OpConstant %int 0
4901 %uint_0 = OpConstant %uint 0
4902 %15 = OpConstantComposite %v2uint %uint_0 %uint_0
4903 %_ptr_Output_v2uint = OpTypePointer Output %v2uint
4904 %v3uint = OpTypeVector %uint 3
4905 %uint_1 = OpConstant %uint 1
4906 %gl_WorkGroupSize = OpConstantComposite %v3uint %uint_32 %uint_1 %uint_1
4907 %main = OpFunction %void None %3
4908 %5 = OpLabel
4909 %17 = OpAccessChain %_ptr_Output_v2uint %gl_PrimitiveLineIndicesEXT %int_0
4910 OpStore %17 %15
4911 OpReturn
4912 OpFunctionEnd
4913 )";
4914
4915 CompileSuccessfully(text, SPV_ENV_VULKAN_1_2);
4916 EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_2));
4917 EXPECT_THAT(
4918 getDiagnosticString(),
4919 AnyVUID("VUID-PrimitiveLineIndicesEXT-PrimitiveLineIndicesEXT-07048"));
4920 }
4921
4922 TEST_F(ValidateBuiltIns, BadVulkanBuiltinPrimitivePointIndicesEXT) {
4923 const std::string text = R"(
4924 OpCapability MeshShadingEXT
4925 OpExtension "SPV_EXT_mesh_shader"
4926 %1 = OpExtInstImport "GLSL.std.450"
4927 OpMemoryModel Logical GLSL450
4928 OpEntryPoint MeshEXT %main "main" %gl_PrimitivePointIndicesEXT
4929 OpExecutionMode %main LocalSize 32 1 1
4930 OpExecutionMode %main OutputVertices 81
4931 OpExecutionMode %main OutputPrimitivesEXT 32
4932 OpExecutionMode %main OutputTrianglesEXT
4933 OpSource GLSL 460
4934 OpSourceExtension "GL_EXT_mesh_shader"
4935 OpName %main "main"
4936 OpName %gl_PrimitivePointIndicesEXT "gl_PrimitivePointIndicesEXT"
4937 OpDecorate %gl_PrimitivePointIndicesEXT BuiltIn PrimitivePointIndicesEXT
4938 OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize
4939 %void = OpTypeVoid
4940 %3 = OpTypeFunction %void
4941 %uint = OpTypeInt 32 0
4942 %uint_32 = OpConstant %uint 32
4943 %_arr_uint_uint_32 = OpTypeArray %uint %uint_32
4944 %_ptr_Output__arr_uint_uint_32 = OpTypePointer Output %_arr_uint_uint_32
4945 %gl_PrimitivePointIndicesEXT = OpVariable %_ptr_Output__arr_uint_uint_32 Output
4946 %int = OpTypeInt 32 1
4947 %int_0 = OpConstant %int 0
4948 %uint_0 = OpConstant %uint 0
4949 %_ptr_Output_uint = OpTypePointer Output %uint
4950 %v3uint = OpTypeVector %uint 3
4951 %uint_1 = OpConstant %uint 1
4952 %gl_WorkGroupSize = OpConstantComposite %v3uint %uint_32 %uint_1 %uint_1
4953 %main = OpFunction %void None %3
4954 %5 = OpLabel
4955 %15 = OpAccessChain %_ptr_Output_uint %gl_PrimitivePointIndicesEXT %int_0
4956 OpStore %15 %uint_0
4957 OpReturn
4958 OpFunctionEnd
4959 )";
4960
4961 CompileSuccessfully(text, SPV_ENV_VULKAN_1_2);
4962 EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_2));
4963 EXPECT_THAT(
4964 getDiagnosticString(),
4965 AnyVUID("VUID-PrimitivePointIndicesEXT-PrimitivePointIndicesEXT-07042"));
4966 }
4967
4968 TEST_F(ValidateBuiltIns, VulkanBuiltinPrimitiveTriangleIndicesEXT) {
4969 const std::string text = R"(
4970 OpCapability MeshShadingEXT
4971 OpExtension "SPV_EXT_mesh_shader"
4972 %1 = OpExtInstImport "GLSL.std.450"
4973 OpMemoryModel Logical GLSL450
4974 OpEntryPoint MeshEXT %main "main" %gl_PrimitiveTriangleIndicesEXT
4975 OpExecutionModeId %main LocalSizeId %uint_32 %uint_1 %uint_1
4976 OpExecutionMode %main OutputVertices 81
4977 OpExecutionMode %main OutputPrimitivesEXT 32
4978 OpExecutionMode %main OutputTrianglesEXT
4979 OpSource GLSL 460
4980 OpSourceExtension "GL_EXT_mesh_shader"
4981 OpName %main "main"
4982 OpName %gl_PrimitiveTriangleIndicesEXT "gl_PrimitiveTriangleIndicesEXT"
4983 OpDecorate %gl_PrimitiveTriangleIndicesEXT BuiltIn PrimitiveTriangleIndicesEXT
4984 %void = OpTypeVoid
4985 %7 = OpTypeFunction %void
4986 %uint = OpTypeInt 32 0
4987 %uint_32 = OpConstant %uint 32
4988 %uint_1 = OpConstant %uint 1
4989 %v3uint = OpTypeVector %uint 3
4990 %_arr_v3uint_uint_32 = OpTypeArray %v3uint %uint_32
4991 %_ptr_Output__arr_v3uint_uint_32 = OpTypePointer Output %_arr_v3uint_uint_32
4992 %gl_PrimitiveTriangleIndicesEXT = OpVariable %_ptr_Output__arr_v3uint_uint_32 Output
4993 %int = OpTypeInt 32 1
4994 %int_0 = OpConstant %int 0
4995 %uint_0 = OpConstant %uint 0
4996 %15 = OpConstantComposite %v3uint %uint_0 %uint_0 %uint_0
4997 %_ptr_Output_v3uint = OpTypePointer Output %v3uint
4998 %17 = OpConstantComposite %v3uint %uint_32 %uint_1 %uint_1
4999 %main = OpFunction %void None %7
5000 %18 = OpLabel
5001 %19 = OpAccessChain %_ptr_Output_v3uint %gl_PrimitiveTriangleIndicesEXT %int_0
5002 OpStore %19 %15
5003 OpReturn
5004 OpFunctionEnd
5005 )";
5006
5007 CompileSuccessfully(text, SPV_ENV_VULKAN_1_3);
5008 EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_3));
5009 }
5010
5011 TEST_F(ValidateBuiltIns, BadVulkanBuiltinPrimitiveTriangleIndicesEXT) {
5012 const std::string text = R"(
5013 OpCapability MeshShadingEXT
5014 OpExtension "SPV_EXT_mesh_shader"
5015 %1 = OpExtInstImport "GLSL.std.450"
5016 OpMemoryModel Logical GLSL450
5017 OpEntryPoint MeshEXT %main "main" %gl_PrimitiveTriangleIndicesEXT
5018 OpExecutionModeId %main LocalSizeId %uint_32 %uint_1 %uint_1
5019 OpExecutionMode %main OutputVertices 81
5020 OpExecutionMode %main OutputPrimitivesEXT 32
5021 OpExecutionMode %main OutputPoints
5022 OpSource GLSL 460
5023 OpSourceExtension "GL_EXT_mesh_shader"
5024 OpName %main "main"
5025 OpName %gl_PrimitiveTriangleIndicesEXT "gl_PrimitiveTriangleIndicesEXT"
5026 OpDecorate %gl_PrimitiveTriangleIndicesEXT BuiltIn PrimitiveTriangleIndicesEXT
5027 %void = OpTypeVoid
5028 %7 = OpTypeFunction %void
5029 %uint = OpTypeInt 32 0
5030 %uint_32 = OpConstant %uint 32
5031 %uint_1 = OpConstant %uint 1
5032 %v3uint = OpTypeVector %uint 3
5033 %_arr_v3uint_uint_32 = OpTypeArray %v3uint %uint_32
5034 %_ptr_Output__arr_v3uint_uint_32 = OpTypePointer Output %_arr_v3uint_uint_32
5035 %gl_PrimitiveTriangleIndicesEXT = OpVariable %_ptr_Output__arr_v3uint_uint_32 Output
5036 %int = OpTypeInt 32 1
5037 %int_0 = OpConstant %int 0
5038 %uint_0 = OpConstant %uint 0
5039 %15 = OpConstantComposite %v3uint %uint_0 %uint_0 %uint_0
5040 %_ptr_Output_v3uint = OpTypePointer Output %v3uint
5041 %17 = OpConstantComposite %v3uint %uint_32 %uint_1 %uint_1
5042 %main = OpFunction %void None %7
5043 %18 = OpLabel
5044 %19 = OpAccessChain %_ptr_Output_v3uint %gl_PrimitiveTriangleIndicesEXT %int_0
5045 OpStore %19 %15
5046 OpReturn
5047 OpFunctionEnd
5048 )";
5049
5050 CompileSuccessfully(text, SPV_ENV_VULKAN_1_3);
5051 EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_3));
5052 EXPECT_THAT(getDiagnosticString(),
5053 AnyVUID("VUID-PrimitiveTriangleIndicesEXT-"
5054 "PrimitiveTriangleIndicesEXT-07054"));
5055 }
5056
5057 // https://github.com/KhronosGroup/SPIRV-Tools/issues/6307
5058 TEST_F(ValidateBuiltIns, VulkanBuiltinPrimitiveTriangleIndicesMultiEntrypoint) {
5059 const std::string text = R"(
5060 OpCapability Shader
5061 OpCapability MeshShadingEXT
5062 OpCapability VulkanMemoryModel
5063 OpExtension "SPV_EXT_mesh_shader"
5064 OpMemoryModel Logical Vulkan
5065 OpEntryPoint MeshEXT %1 "mesh" %positions %indices
5066 OpEntryPoint Fragment %4 "frag" %color
5067 OpExecutionMode %1 LocalSize 1 1 1
5068 OpExecutionMode %1 OutputVertices 3
5069 OpExecutionMode %1 OutputPrimitivesEXT 1
5070 OpExecutionMode %1 OutputTrianglesEXT
5071 OpExecutionMode %4 OriginUpperLeft
5072 OpDecorate %_arr_v4float_uint_3 ArrayStride 16
5073 OpDecorate %_arr_v3uint_uint_1 ArrayStride 16
5074 OpDecorate %positions BuiltIn Position
5075 OpDecorate %indices BuiltIn PrimitiveTriangleIndicesEXT
5076 OpDecorate %color Location 0
5077 %float = OpTypeFloat 32
5078 %v4float = OpTypeVector %float 4
5079 %uint = OpTypeInt 32 0
5080 %uint_3 = OpConstant %uint 3
5081 %_arr_v4float_uint_3 = OpTypeArray %v4float %uint_3
5082 %_ptr_Output__arr_v4float_uint_3 = OpTypePointer Output %_arr_v4float_uint_3
5083 %v3uint = OpTypeVector %uint 3
5084 %uint_1 = OpConstant %uint 1
5085 %_arr_v3uint_uint_1 = OpTypeArray %v3uint %uint_1
5086 %_ptr_Output__arr_v3uint_uint_1 = OpTypePointer Output %_arr_v3uint_uint_1
5087 %void = OpTypeVoid
5088 %18 = OpTypeFunction %void
5089 %uint_0 = OpConstant %uint 0
5090 %_ptr_Output_v4float = OpTypePointer Output %v4float
5091 %positions = OpVariable %_ptr_Output__arr_v4float_uint_3 Output
5092 %indices = OpVariable %_ptr_Output__arr_v3uint_uint_1 Output
5093 %color = OpVariable %_ptr_Output_v4float Output
5094 %1 = OpFunction %void None %18
5095 %21 = OpLabel
5096 OpSetMeshOutputsEXT %uint_0 %uint_0
5097 OpNoLine
5098 OpReturn
5099 OpFunctionEnd
5100 %4 = OpFunction %void None %18
5101 %22 = OpLabel
5102 OpReturn
5103 OpFunctionEnd
5104 )";
5105
5106 CompileSuccessfully(text, SPV_ENV_VULKAN_1_3);
5107 EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_3));
5108 }
5109
5110 TEST_F(ValidateBuiltIns, BadVulkanPrimitivePointIndicesArraySizeMeshEXT) {
5111 const std::string text = R"(
5112 OpCapability MeshShadingEXT
5113 OpExtension "SPV_EXT_mesh_shader"
5114 %1 = OpExtInstImport "GLSL.std.450"
5115 OpMemoryModel Logical GLSL450
5116 OpEntryPoint MeshEXT %main "main" %gl_PrimitivePointIndicesEXT
5117 OpExecutionMode %main LocalSize 32 1 1
5118 OpExecutionMode %main OutputVertices 81
5119 OpExecutionMode %main OutputPrimitivesEXT 16
5120 OpExecutionMode %main OutputPoints
5121 OpSource GLSL 460
5122 OpSourceExtension "GL_EXT_mesh_shader"
5123 OpName %main "main"
5124 OpName %gl_PrimitivePointIndicesEXT "gl_PrimitivePointIndicesEXT"
5125 OpDecorate %gl_PrimitivePointIndicesEXT BuiltIn PrimitivePointIndicesEXT
5126 OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize
5127 %void = OpTypeVoid
5128 %3 = OpTypeFunction %void
5129 %uint = OpTypeInt 32 0
5130 %uint_32 = OpConstant %uint 32
5131 %_arr_uint_uint_32 = OpTypeArray %uint %uint_32
5132 %_ptr_Output__arr_uint_uint_32 = OpTypePointer Output %_arr_uint_uint_32
5133 %gl_PrimitivePointIndicesEXT = OpVariable %_ptr_Output__arr_uint_uint_32 Output
5134 %int = OpTypeInt 32 1
5135 %int_0 = OpConstant %int 0
5136 %uint_0 = OpConstant %uint 0
5137 %_ptr_Output_uint = OpTypePointer Output %uint
5138 %v3uint = OpTypeVector %uint 3
5139 %uint_1 = OpConstant %uint 1
5140 %gl_WorkGroupSize = OpConstantComposite %v3uint %uint_32 %uint_1 %uint_1
5141 %main = OpFunction %void None %3
5142 %5 = OpLabel
5143 %15 = OpAccessChain %_ptr_Output_uint %gl_PrimitivePointIndicesEXT %int_0
5144 OpStore %15 %uint_0
5145 OpReturn
5146 OpFunctionEnd
5147 )";
5148
5149 CompileSuccessfully(text, SPV_ENV_VULKAN_1_2);
5150 EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_2));
5151 EXPECT_THAT(
5152 getDiagnosticString(),
5153 AnyVUID("VUID-PrimitivePointIndicesEXT-PrimitivePointIndicesEXT-07046"));
5154 }
5155
5156 TEST_F(ValidateBuiltIns, BadVulkanPrimitiveLineIndicesArraySizeMeshEXT) {
5157 const std::string text = R"(
5158 OpCapability MeshShadingEXT
5159 OpExtension "SPV_EXT_mesh_shader"
5160 %1 = OpExtInstImport "GLSL.std.450"
5161 OpMemoryModel Logical GLSL450
5162 OpEntryPoint MeshEXT %main "main" %gl_PrimitiveLineIndicesEXT
5163 OpExecutionMode %main LocalSize 32 1 1
5164 OpExecutionMode %main OutputVertices 81
5165 OpExecutionMode %main OutputPrimitivesEXT 16
5166 OpExecutionMode %main OutputLinesEXT
5167 OpSource GLSL 460
5168 OpSourceExtension "GL_EXT_mesh_shader"
5169 OpName %main "main"
5170 OpName %gl_PrimitiveLineIndicesEXT "gl_PrimitiveLineIndicesEXT"
5171 OpDecorate %gl_PrimitiveLineIndicesEXT BuiltIn PrimitiveLineIndicesEXT
5172 OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize
5173 %void = OpTypeVoid
5174 %3 = OpTypeFunction %void
5175 %uint = OpTypeInt 32 0
5176 %v2uint = OpTypeVector %uint 2
5177 %uint_32 = OpConstant %uint 32
5178 %_arr_v2uint_uint_32 = OpTypeArray %v2uint %uint_32
5179 %_ptr_Output__arr_v2uint_uint_32 = OpTypePointer Output %_arr_v2uint_uint_32
5180 %gl_PrimitiveLineIndicesEXT = OpVariable %_ptr_Output__arr_v2uint_uint_32 Output
5181 %int = OpTypeInt 32 1
5182 %int_0 = OpConstant %int 0
5183 %uint_0 = OpConstant %uint 0
5184 %15 = OpConstantComposite %v2uint %uint_0 %uint_0
5185 %_ptr_Output_v2uint = OpTypePointer Output %v2uint
5186 %v3uint = OpTypeVector %uint 3
5187 %uint_1 = OpConstant %uint 1
5188 %gl_WorkGroupSize = OpConstantComposite %v3uint %uint_32 %uint_1 %uint_1
5189 %main = OpFunction %void None %3
5190 %5 = OpLabel
5191 %17 = OpAccessChain %_ptr_Output_v2uint %gl_PrimitiveLineIndicesEXT %int_0
5192 OpStore %17 %15
5193 OpReturn
5194 OpFunctionEnd
5195 )";
5196
5197 CompileSuccessfully(text, SPV_ENV_VULKAN_1_3);
5198 EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_3));
5199 EXPECT_THAT(
5200 getDiagnosticString(),
5201 AnyVUID("VUID-PrimitiveLineIndicesEXT-PrimitiveLineIndicesEXT-07052"));
5202 }
5203
5204 TEST_F(ValidateBuiltIns, BadVulkanPrimitiveTriangleIndicesArraySizeMeshEXT) {
5205 const std::string text = R"(
5206 OpCapability MeshShadingEXT
5207 OpExtension "SPV_EXT_mesh_shader"
5208 %1 = OpExtInstImport "GLSL.std.450"
5209 OpMemoryModel Logical GLSL450
5210 OpEntryPoint MeshEXT %main "main" %gl_PrimitiveTriangleIndicesEXT
5211 OpExecutionModeId %main LocalSizeId %uint_32 %uint_1 %uint_1
5212 OpExecutionMode %main OutputVertices 81
5213 OpExecutionMode %main OutputPrimitivesEXT 16
5214 OpExecutionMode %main OutputTrianglesEXT
5215 OpSource GLSL 460
5216 OpSourceExtension "GL_EXT_mesh_shader"
5217 OpName %main "main"
5218 OpName %gl_PrimitiveTriangleIndicesEXT "gl_PrimitiveTriangleIndicesEXT"
5219 OpDecorate %gl_PrimitiveTriangleIndicesEXT BuiltIn PrimitiveTriangleIndicesEXT
5220 %void = OpTypeVoid
5221 %7 = OpTypeFunction %void
5222 %uint = OpTypeInt 32 0
5223 %uint_32 = OpConstant %uint 32
5224 %uint_1 = OpConstant %uint 1
5225 %v3uint = OpTypeVector %uint 3
5226 %_arr_v3uint_uint_32 = OpTypeArray %v3uint %uint_32
5227 %_ptr_Output__arr_v3uint_uint_32 = OpTypePointer Output %_arr_v3uint_uint_32
5228 %gl_PrimitiveTriangleIndicesEXT = OpVariable %_ptr_Output__arr_v3uint_uint_32 Output
5229 %int = OpTypeInt 32 1
5230 %int_0 = OpConstant %int 0
5231 %uint_0 = OpConstant %uint 0
5232 %15 = OpConstantComposite %v3uint %uint_0 %uint_0 %uint_0
5233 %_ptr_Output_v3uint = OpTypePointer Output %v3uint
5234 %17 = OpConstantComposite %v3uint %uint_32 %uint_1 %uint_1
5235 %main = OpFunction %void None %7
5236 %18 = OpLabel
5237 %19 = OpAccessChain %_ptr_Output_v3uint %gl_PrimitiveTriangleIndicesEXT %int_0
5238 OpStore %19 %15
5239 OpReturn
5240 OpFunctionEnd
5241 )";
5242
5243 CompileSuccessfully(text, SPV_ENV_VULKAN_1_3);
5244 EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_3));
5245 EXPECT_THAT(getDiagnosticString(),
5246 AnyVUID("VUID-PrimitiveTriangleIndicesEXT-"
5247 "PrimitiveTriangleIndicesEXT-07058"));
5248 }
5249
5250 // https://godbolt.org/z/xqsMqqnxd
5251 TEST_F(ValidateBuiltIns, VulkanMeshMultipleTopology) {
5252 const std::string text = R"(
5253 OpCapability MeshShadingEXT
5254 OpCapability Shader
5255 OpExtension "SPV_EXT_mesh_shader"
5256 OpMemoryModel Logical GLSL450
5257 OpEntryPoint MeshEXT %main1 "main1" %26 %vertices_color
5258 OpEntryPoint MeshEXT %main2 "main2" %43 %vertices_color_0
5259 OpExecutionMode %main1 OutputVertices 3
5260 OpExecutionMode %main1 OutputPrimitivesEXT 1
5261 OpExecutionMode %main1 LocalSize 1 1 1
5262 OpExecutionMode %main1 OutputTrianglesEXT
5263 OpExecutionMode %main2 OutputVertices 3
5264 OpExecutionMode %main2 OutputPrimitivesEXT 1
5265 OpExecutionMode %main2 LocalSize 1 1 1
5266 OpExecutionMode %main2 OutputLinesEXT
5267 OpDecorate %vertices_color Location 0
5268 OpDecorate %26 BuiltIn PrimitiveTriangleIndicesEXT
5269 OpDecorate %vertices_color_0 Location 0
5270 OpDecorate %43 BuiltIn PrimitiveLineIndicesEXT
5271 %void = OpTypeVoid
5272 %3 = OpTypeFunction %void
5273 %uint = OpTypeInt 32 0
5274 %uint_3 = OpConstant %uint 3
5275 %uint_1 = OpConstant %uint 1
5276 %float = OpTypeFloat 32
5277 %v4float = OpTypeVector %float 4
5278 %int = OpTypeInt 32 1
5279 %int_3 = OpConstant %int 3
5280 %_arr_v4float_int_3 = OpTypeArray %v4float %int_3
5281 %_ptr_Output__arr_v4float_int_3 = OpTypePointer Output %_arr_v4float_int_3
5282 %_ptr_Output_v4float = OpTypePointer Output %v4float
5283 %uint_0 = OpConstant %uint 0
5284 %float_0 = OpConstant %float 0
5285 %19 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_0
5286 %v3uint = OpTypeVector %uint 3
5287 %int_1 = OpConstant %int 1
5288 %_arr_v3uint_int_1 = OpTypeArray %v3uint %int_1
5289 %_ptr_Output__arr_v3uint_int_1 = OpTypePointer Output %_arr_v3uint_int_1
5290 %_ptr_Output_v3uint = OpTypePointer Output %v3uint
5291 %uint_2 = OpConstant %uint 2
5292 %29 = OpConstantComposite %v3uint %uint_0 %uint_1 %uint_2
5293 %38 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_0
5294 %v2uint = OpTypeVector %uint 2
5295 %_arr_v2uint_int_1 = OpTypeArray %v2uint %int_1
5296 %_ptr_Output__arr_v2uint_int_1 = OpTypePointer Output %_arr_v2uint_int_1
5297 %_ptr_Output_v2uint = OpTypePointer Output %v2uint
5298 %46 = OpConstantComposite %v2uint %uint_0 %uint_1
5299 %vertices_color = OpVariable %_ptr_Output__arr_v4float_int_3 Output
5300 %26 = OpVariable %_ptr_Output__arr_v3uint_int_1 Output
5301 %vertices_color_0 = OpVariable %_ptr_Output__arr_v4float_int_3 Output
5302 %43 = OpVariable %_ptr_Output__arr_v2uint_int_1 Output
5303 %main1 = OpFunction %void None %3
5304 %4 = OpLabel
5305 OpSetMeshOutputsEXT %uint_3 %uint_1
5306 %17 = OpAccessChain %_ptr_Output_v4float %vertices_color %uint_0
5307 OpStore %17 %19
5308 %28 = OpAccessChain %_ptr_Output_v3uint %26 %uint_0
5309 OpStore %28 %29
5310 OpReturn
5311 OpFunctionEnd
5312 %main2 = OpFunction %void None %3
5313 %34 = OpLabel
5314 OpSetMeshOutputsEXT %uint_3 %uint_1
5315 %37 = OpAccessChain %_ptr_Output_v4float %vertices_color_0 %uint_0
5316 OpStore %37 %38
5317 %45 = OpAccessChain %_ptr_Output_v2uint %43 %uint_0
5318 OpStore %45 %46
5319 OpReturn
5320 OpFunctionEnd
5321 )";
5322
5323 CompileSuccessfully(text, SPV_ENV_VULKAN_1_3);
5324 EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_3));
5325 }
5326
5327 // https://godbolt.org/z/MeTadeYEr
5328 TEST_F(ValidateBuiltIns, VulkanMeshMultipleArraySizes) {
5329 const std::string text = R"(
5330 OpCapability MeshShadingEXT
5331 OpCapability Shader
5332 OpExtension "SPV_EXT_mesh_shader"
5333 OpMemoryModel Logical GLSL450
5334 OpEntryPoint MeshEXT %main1 "main1" %var1 %vertices_color
5335 OpEntryPoint MeshEXT %main2 "main2" %var2 %vertices_color_0
5336 OpExecutionMode %main1 OutputVertices 3
5337 OpExecutionMode %main1 OutputPrimitivesEXT 2
5338 OpExecutionMode %main1 LocalSize 1 1 1
5339 OpExecutionMode %main1 OutputTrianglesEXT
5340 OpExecutionMode %main2 OutputVertices 3
5341 OpExecutionMode %main2 OutputPrimitivesEXT 4
5342 OpExecutionMode %main2 LocalSize 1 1 1
5343 OpExecutionMode %main2 OutputTrianglesEXT
5344 OpSource Slang 1
5345 OpName %vertices_color "vertices.color"
5346 OpName %main1 "main1"
5347 OpName %vertices_color_0 "vertices.color"
5348 OpName %main2 "main2"
5349 OpDecorate %vertices_color Location 0
5350 OpDecorate %var1 BuiltIn PrimitiveTriangleIndicesEXT
5351 OpDecorate %var2 BuiltIn PrimitiveTriangleIndicesEXT
5352 OpDecorate %vertices_color_0 Location 0
5353 %void = OpTypeVoid
5354 %3 = OpTypeFunction %void
5355 %uint = OpTypeInt 32 0
5356 %uint_3 = OpConstant %uint 3
5357 %uint_1 = OpConstant %uint 1
5358 %float = OpTypeFloat 32
5359 %v4float = OpTypeVector %float 4
5360 %int = OpTypeInt 32 1
5361 %int_3 = OpConstant %int 3
5362 %_arr_v4float_int_3 = OpTypeArray %v4float %int_3
5363 %_ptr_Output__arr_v4float_int_3 = OpTypePointer Output %_arr_v4float_int_3
5364 %_ptr_Output_v4float = OpTypePointer Output %v4float
5365 %uint_0 = OpConstant %uint 0
5366 %float_0 = OpConstant %float 0
5367 %19 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_0
5368 %v3uint = OpTypeVector %uint 3
5369 %int_2 = OpConstant %int 2
5370 %int_4 = OpConstant %int 4
5371 %_arr_v3uint_int_2 = OpTypeArray %v3uint %int_2
5372 %_arr_v3uint_int_4 = OpTypeArray %v3uint %int_4
5373 %_ptr_Output__arr_v3uint_int_2 = OpTypePointer Output %_arr_v3uint_int_2
5374 %_ptr_Output__arr_v3uint_int_4 = OpTypePointer Output %_arr_v3uint_int_4
5375 %_ptr_Output_v3uint = OpTypePointer Output %v3uint
5376 %uint_2 = OpConstant %uint 2
5377 %29 = OpConstantComposite %v3uint %uint_0 %uint_1 %uint_2
5378 %38 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_0
5379 %41 = OpConstantComposite %v3uint %uint_0 %uint_1 %uint_2
5380 %vertices_color = OpVariable %_ptr_Output__arr_v4float_int_3 Output
5381 %var1 = OpVariable %_ptr_Output__arr_v3uint_int_2 Output
5382 %var2 = OpVariable %_ptr_Output__arr_v3uint_int_4 Output
5383 %vertices_color_0 = OpVariable %_ptr_Output__arr_v4float_int_3 Output
5384 %main1 = OpFunction %void None %3
5385 %4 = OpLabel
5386 OpSetMeshOutputsEXT %uint_3 %uint_1
5387 %17 = OpAccessChain %_ptr_Output_v4float %vertices_color %uint_0
5388 OpStore %17 %19
5389 %28 = OpAccessChain %_ptr_Output_v3uint %var1 %uint_0
5390 OpStore %28 %29
5391 OpReturn
5392 OpFunctionEnd
5393 %main2 = OpFunction %void None %3
5394 %34 = OpLabel
5395 OpSetMeshOutputsEXT %uint_3 %uint_1
5396 %37 = OpAccessChain %_ptr_Output_v4float %vertices_color_0 %uint_0
5397 OpStore %37 %38
5398 %40 = OpAccessChain %_ptr_Output_v3uint %var2 %uint_0
5399 OpStore %40 %41
5400 OpReturn
5401 OpFunctionEnd
5402 )";
5403
5404 CompileSuccessfully(text, SPV_ENV_VULKAN_1_3);
5405 EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_3));
5406 }
5407
5408 TEST_F(ValidateBuiltIns, BadVulkanMeshMultipleArraySizes) {
5409 const std::string text = R"(
5410 OpCapability MeshShadingEXT
5411 OpCapability Shader
5412 OpExtension "SPV_EXT_mesh_shader"
5413 OpMemoryModel Logical GLSL450
5414 OpEntryPoint MeshEXT %main1 "main1" %26 %vertices_color
5415 OpEntryPoint MeshEXT %main2 "main2" %26 %vertices_color_0
5416 OpExecutionMode %main1 OutputVertices 3
5417 OpExecutionMode %main1 OutputPrimitivesEXT 2
5418 OpExecutionMode %main1 LocalSize 1 1 1
5419 OpExecutionMode %main1 OutputTrianglesEXT
5420 OpExecutionMode %main2 OutputVertices 3
5421 OpExecutionMode %main2 OutputPrimitivesEXT 42
5422 OpExecutionMode %main2 LocalSize 1 1 1
5423 OpExecutionMode %main2 OutputTrianglesEXT
5424 OpSource Slang 1
5425 OpName %vertices_color "vertices.color"
5426 OpName %main1 "main1"
5427 OpName %vertices_color_0 "vertices.color"
5428 OpName %main2 "main2"
5429 OpDecorate %vertices_color Location 0
5430 OpDecorate %26 BuiltIn PrimitiveTriangleIndicesEXT
5431 OpDecorate %vertices_color_0 Location 0
5432 %void = OpTypeVoid
5433 %3 = OpTypeFunction %void
5434 %uint = OpTypeInt 32 0
5435 %uint_3 = OpConstant %uint 3
5436 %uint_1 = OpConstant %uint 1
5437 %float = OpTypeFloat 32
5438 %v4float = OpTypeVector %float 4
5439 %int = OpTypeInt 32 1
5440 %int_3 = OpConstant %int 3
5441 %_arr_v4float_int_3 = OpTypeArray %v4float %int_3
5442 %_ptr_Output__arr_v4float_int_3 = OpTypePointer Output %_arr_v4float_int_3
5443 %_ptr_Output_v4float = OpTypePointer Output %v4float
5444 %uint_0 = OpConstant %uint 0
5445 %float_0 = OpConstant %float 0
5446 %19 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_0
5447 %v3uint = OpTypeVector %uint 3
5448 %int_2 = OpConstant %int 2
5449 %_arr_v3uint_int_2 = OpTypeArray %v3uint %int_2
5450 %_ptr_Output__arr_v3uint_int_2 = OpTypePointer Output %_arr_v3uint_int_2
5451 %_ptr_Output_v3uint = OpTypePointer Output %v3uint
5452 %uint_2 = OpConstant %uint 2
5453 %29 = OpConstantComposite %v3uint %uint_0 %uint_1 %uint_2
5454 %38 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_0
5455 %41 = OpConstantComposite %v3uint %uint_0 %uint_1 %uint_2
5456 %vertices_color = OpVariable %_ptr_Output__arr_v4float_int_3 Output
5457 %26 = OpVariable %_ptr_Output__arr_v3uint_int_2 Output
5458 %vertices_color_0 = OpVariable %_ptr_Output__arr_v4float_int_3 Output
5459 %main1 = OpFunction %void None %3
5460 %4 = OpLabel
5461 OpSetMeshOutputsEXT %uint_3 %uint_1
5462 %17 = OpAccessChain %_ptr_Output_v4float %vertices_color %uint_0
5463 OpStore %17 %19
5464 %28 = OpAccessChain %_ptr_Output_v3uint %26 %uint_0
5465 OpStore %28 %29
5466 OpReturn
5467 OpFunctionEnd
5468 %main2 = OpFunction %void None %3
5469 %34 = OpLabel
5470 OpSetMeshOutputsEXT %uint_3 %uint_1
5471 %37 = OpAccessChain %_ptr_Output_v4float %vertices_color_0 %uint_0
5472 OpStore %37 %38
5473 %40 = OpAccessChain %_ptr_Output_v3uint %26 %uint_0
5474 OpStore %40 %41
5475 OpReturn
5476 OpFunctionEnd
5477 )";
5478
5479 CompileSuccessfully(text, SPV_ENV_VULKAN_1_3);
5480 EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_3));
5481 EXPECT_THAT(getDiagnosticString(),
5482 AnyVUID("VUID-PrimitiveTriangleIndicesEXT-"
5483 "PrimitiveTriangleIndicesEXT-07058"));
5484 }
5485
5486 TEST_F(ValidateBuiltIns, BadVulkanMeshMultipleArraySizesSharedVariable) {
5487 const std::string text = R"(
5488 OpCapability MeshShadingEXT
5489 OpCapability Shader
5490 OpExtension "SPV_EXT_mesh_shader"
5491 OpMemoryModel Logical GLSL450
5492 OpEntryPoint MeshEXT %main1 "main1" %26 %vertices_color
5493 OpEntryPoint MeshEXT %main2 "main2" %26 %vertices_color_0
5494 OpExecutionMode %main1 OutputVertices 3
5495 OpExecutionMode %main1 OutputPrimitivesEXT 2
5496 OpExecutionMode %main1 LocalSize 1 1 1
5497 OpExecutionMode %main1 OutputTrianglesEXT
5498 OpExecutionMode %main2 OutputVertices 3
5499 OpExecutionMode %main2 OutputPrimitivesEXT 4
5500 OpExecutionMode %main2 LocalSize 1 1 1
5501 OpExecutionMode %main2 OutputTrianglesEXT
5502 OpSource Slang 1
5503 OpName %vertices_color "vertices.color"
5504 OpName %main1 "main1"
5505 OpName %vertices_color_0 "vertices.color"
5506 OpName %main2 "main2"
5507 OpDecorate %vertices_color Location 0
5508 OpDecorate %26 BuiltIn PrimitiveTriangleIndicesEXT
5509 OpDecorate %vertices_color_0 Location 0
5510 %void = OpTypeVoid
5511 %3 = OpTypeFunction %void
5512 %uint = OpTypeInt 32 0
5513 %uint_3 = OpConstant %uint 3
5514 %uint_1 = OpConstant %uint 1
5515 %float = OpTypeFloat 32
5516 %v4float = OpTypeVector %float 4
5517 %int = OpTypeInt 32 1
5518 %int_3 = OpConstant %int 3
5519 %_arr_v4float_int_3 = OpTypeArray %v4float %int_3
5520 %_ptr_Output__arr_v4float_int_3 = OpTypePointer Output %_arr_v4float_int_3
5521 %_ptr_Output_v4float = OpTypePointer Output %v4float
5522 %uint_0 = OpConstant %uint 0
5523 %float_0 = OpConstant %float 0
5524 %19 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_0
5525 %v3uint = OpTypeVector %uint 3
5526 %int_2 = OpConstant %int 2
5527 %_arr_v3uint_int_2 = OpTypeArray %v3uint %int_2
5528 %_ptr_Output__arr_v3uint_int_2 = OpTypePointer Output %_arr_v3uint_int_2
5529 %_ptr_Output_v3uint = OpTypePointer Output %v3uint
5530 %uint_2 = OpConstant %uint 2
5531 %29 = OpConstantComposite %v3uint %uint_0 %uint_1 %uint_2
5532 %38 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_0
5533 %41 = OpConstantComposite %v3uint %uint_0 %uint_1 %uint_2
5534 %vertices_color = OpVariable %_ptr_Output__arr_v4float_int_3 Output
5535 %26 = OpVariable %_ptr_Output__arr_v3uint_int_2 Output
5536 %vertices_color_0 = OpVariable %_ptr_Output__arr_v4float_int_3 Output
5537 %main1 = OpFunction %void None %3
5538 %4 = OpLabel
5539 OpSetMeshOutputsEXT %uint_3 %uint_1
5540 %17 = OpAccessChain %_ptr_Output_v4float %vertices_color %uint_0
5541 OpStore %17 %19
5542 %28 = OpAccessChain %_ptr_Output_v3uint %26 %uint_0
5543 OpStore %28 %29
5544 OpReturn
5545 OpFunctionEnd
5546 %main2 = OpFunction %void None %3
5547 %34 = OpLabel
5548 OpSetMeshOutputsEXT %uint_3 %uint_1
5549 %37 = OpAccessChain %_ptr_Output_v4float %vertices_color_0 %uint_0
5550 OpStore %37 %38
5551 %40 = OpAccessChain %_ptr_Output_v3uint %26 %uint_0
5552 OpStore %40 %41
5553 OpReturn
5554 OpFunctionEnd
5555 )";
5556
5557 CompileSuccessfully(text, SPV_ENV_VULKAN_1_3);
5558 EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_3));
5559 EXPECT_THAT(getDiagnosticString(),
5560 AnyVUID("VUID-PrimitiveTriangleIndicesEXT-"
5561 "PrimitiveTriangleIndicesEXT-07058"));
5562 }
5563
5564 TEST_F(ValidateBuiltIns, BadExecModelVulkanPrimitivePointIndicesEXT) {
5565 const std::string text = R"(
5566 OpCapability MeshShadingNV
5567 OpCapability MeshShadingEXT
5568 OpExtension "SPV_NV_mesh_shader"
5569 OpExtension "SPV_EXT_mesh_shader"
5570 %1 = OpExtInstImport "GLSL.std.450"
5571 OpMemoryModel Logical GLSL450
5572 OpEntryPoint MeshNV %main "main" %gl_PrimitivePointIndicesEXT
5573 OpExecutionMode %main LocalSize 32 1 1
5574 OpExecutionMode %main OutputVertices 81
5575 OpExecutionMode %main OutputPrimitivesEXT 32
5576 OpExecutionMode %main OutputPoints
5577 OpSource GLSL 460
5578 OpSourceExtension "GL_EXT_mesh_shader"
5579 OpName %main "main"
5580 OpName %gl_PrimitivePointIndicesEXT "gl_PrimitivePointIndicesEXT"
5581 OpDecorate %gl_PrimitivePointIndicesEXT BuiltIn PrimitivePointIndicesEXT
5582 OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize
5583 %void = OpTypeVoid
5584 %3 = OpTypeFunction %void
5585 %uint = OpTypeInt 32 0
5586 %uint_32 = OpConstant %uint 32
5587 %_arr_uint_uint_32 = OpTypeArray %uint %uint_32
5588 %_ptr_Output__arr_uint_uint_32 = OpTypePointer Output %_arr_uint_uint_32
5589 %gl_PrimitivePointIndicesEXT = OpVariable %_ptr_Output__arr_uint_uint_32 Output
5590 %int = OpTypeInt 32 1
5591 %int_0 = OpConstant %int 0
5592 %uint_0 = OpConstant %uint 0
5593 %_ptr_Output_uint = OpTypePointer Output %uint
5594 %v3uint = OpTypeVector %uint 3
5595 %uint_1 = OpConstant %uint 1
5596 %gl_WorkGroupSize = OpConstantComposite %v3uint %uint_32 %uint_1 %uint_1
5597 %main = OpFunction %void None %3
5598 %5 = OpLabel
5599 %15 = OpAccessChain %_ptr_Output_uint %gl_PrimitivePointIndicesEXT %int_0
5600 OpStore %15 %uint_0
5601 OpReturn
5602 OpFunctionEnd
5603 )";
5604
5605 CompileSuccessfully(text, SPV_ENV_VULKAN_1_3);
5606 EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_3));
5607 EXPECT_THAT(
5608 getDiagnosticString(),
5609 AnyVUID("VUID-PrimitivePointIndicesEXT-PrimitivePointIndicesEXT-07041"));
5610 }
5611
5612 TEST_F(ValidateBuiltIns, VulkanBuiltinCullPrimitiveEXTInBlock) {
5613 const std::string text = R"(
5614 OpCapability MeshShadingEXT
5615 OpExtension "SPV_EXT_mesh_shader"
5616 %1 = OpExtInstImport "GLSL.std.450"
5617 OpMemoryModel Logical GLSL450
5618 OpEntryPoint MeshEXT %main "main" %gl_MeshPrimitivesEXT
5619 OpExecutionModeId %main LocalSizeId %uint_32 %uint_1 %uint_1
5620 OpExecutionMode %main OutputVertices 81
5621 OpExecutionMode %main OutputPrimitivesEXT 32
5622 OpExecutionMode %main OutputTrianglesEXT
5623 OpSource GLSL 450
5624 OpSourceExtension "GL_EXT_mesh_shader"
5625 OpName %main "main"
5626 OpName %gl_MeshPerPrimitiveEXT "gl_MeshPerPrimitiveEXT"
5627 OpMemberName %gl_MeshPerPrimitiveEXT 0 "gl_CullPrimitiveEXT"
5628 OpName %gl_MeshPrimitivesEXT "gl_MeshPrimitivesEXT"
5629 OpDecorate %gl_MeshPerPrimitiveEXT Block
5630 OpMemberDecorate %gl_MeshPerPrimitiveEXT 0 BuiltIn CullPrimitiveEXT
5631 OpMemberDecorate %gl_MeshPerPrimitiveEXT 0 PerPrimitiveEXT
5632 %void = OpTypeVoid
5633 %3 = OpTypeFunction %void
5634 %uint = OpTypeInt 32 0
5635 %uint_32 = OpConstant %uint 32
5636 %uint_1 = OpConstant %uint 1
5637 %int = OpTypeInt 32 1
5638 %bool = OpTypeBool
5639 %gl_MeshPerPrimitiveEXT = OpTypeStruct %bool
5640 %_arr_gl_MeshPerPrimitiveEXT_uint_32 = OpTypeArray %gl_MeshPerPrimitiveEXT %uint_32
5641 %_ptr_Output__arr_gl_MeshPerPrimitiveEXT_uint_32 = OpTypePointer Output %_arr_gl_MeshPerPrimitiveEXT_uint_32
5642 %gl_MeshPrimitivesEXT = OpVariable %_ptr_Output__arr_gl_MeshPerPrimitiveEXT_uint_32 Output
5643 %main = OpFunction %void None %3
5644 %5 = OpLabel
5645 OpReturn
5646 OpFunctionEnd
5647 )";
5648
5649 CompileSuccessfully(text, SPV_ENV_VULKAN_1_3);
5650 EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_3));
5651 }
5652
5653 TEST_F(ValidateBuiltIns, BadVulkanBuiltinCullPrimitiveEXTBlockArraySize) {
5654 const std::string text = R"(
5655 OpCapability MeshShadingEXT
5656 OpExtension "SPV_EXT_mesh_shader"
5657 %1 = OpExtInstImport "GLSL.std.450"
5658 OpMemoryModel Logical GLSL450
5659 OpEntryPoint MeshEXT %main "main" %gl_MeshPrimitivesEXT
5660 OpExecutionModeId %main LocalSizeId %uint_32 %uint_1 %uint_1
5661 OpExecutionMode %main OutputVertices 81
5662 OpExecutionMode %main OutputPrimitivesEXT 32
5663 OpExecutionMode %main OutputTrianglesEXT
5664 OpSource GLSL 450
5665 OpSourceExtension "GL_EXT_mesh_shader"
5666 OpName %main "main"
5667 OpName %gl_MeshPerPrimitiveEXT "gl_MeshPerPrimitiveEXT"
5668 OpMemberName %gl_MeshPerPrimitiveEXT 0 "gl_CullPrimitiveEXT"
5669 OpName %gl_MeshPrimitivesEXT "gl_MeshPrimitivesEXT"
5670 OpDecorate %gl_MeshPerPrimitiveEXT Block
5671 OpMemberDecorate %gl_MeshPerPrimitiveEXT 0 BuiltIn CullPrimitiveEXT
5672 OpMemberDecorate %gl_MeshPerPrimitiveEXT 0 PerPrimitiveEXT
5673 %void = OpTypeVoid
5674 %3 = OpTypeFunction %void
5675 %uint = OpTypeInt 32 0
5676 %uint_32 = OpConstant %uint 32
5677 %uint_16 = OpConstant %uint 16
5678 %uint_1 = OpConstant %uint 1
5679 %int = OpTypeInt 32 1
5680 %bool = OpTypeBool
5681 %gl_MeshPerPrimitiveEXT = OpTypeStruct %bool
5682 %_arr_gl_MeshPerPrimitiveEXT_uint_16 = OpTypeArray %gl_MeshPerPrimitiveEXT %uint_16
5683 %_ptr_Output__arr_gl_MeshPerPrimitiveEXT_uint_16 = OpTypePointer Output %_arr_gl_MeshPerPrimitiveEXT_uint_16
5684 %gl_MeshPrimitivesEXT = OpVariable %_ptr_Output__arr_gl_MeshPerPrimitiveEXT_uint_16 Output
5685 %main = OpFunction %void None %3
5686 %5 = OpLabel
5687 %ref_load = OpLoad %_arr_gl_MeshPerPrimitiveEXT_uint_16 %gl_MeshPrimitivesEXT
5688 OpReturn
5689 OpFunctionEnd
5690 )";
5691
5692 CompileSuccessfully(text, SPV_ENV_VULKAN_1_3);
5693 EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_3));
5694 EXPECT_THAT(getDiagnosticString(),
5695 AnyVUID("VUID-CullPrimitiveEXT-CullPrimitiveEXT-10590"));
5696 }
5697
5698 TEST_F(ValidateBuiltIns, VulkanBuiltinCullPrimitiveEXTMissingBlock) {
5699 const std::string text = R"(
5700 OpCapability MeshShadingEXT
5701 OpExtension "SPV_EXT_mesh_shader"
5702 %1 = OpExtInstImport "GLSL.std.450"
5703 OpMemoryModel Logical GLSL450
5704 OpEntryPoint MeshEXT %main "main" %gl_MeshPrimitivesEXT
5705 OpExecutionModeId %main LocalSizeId %uint_32 %uint_1 %uint_1
5706 OpExecutionMode %main OutputVertices 81
5707 OpExecutionMode %main OutputPrimitivesEXT 32
5708 OpExecutionMode %main OutputTrianglesEXT
5709 OpSource GLSL 450
5710 OpSourceExtension "GL_EXT_mesh_shader"
5711 OpName %main "main"
5712 OpName %gl_MeshPerPrimitiveEXT "gl_MeshPerPrimitiveEXT"
5713 OpMemberName %gl_MeshPerPrimitiveEXT 0 "gl_CullPrimitiveEXT"
5714 OpName %gl_MeshPrimitivesEXT "gl_MeshPrimitivesEXT"
5715 OpMemberDecorate %gl_MeshPerPrimitiveEXT 0 BuiltIn CullPrimitiveEXT
5716 OpMemberDecorate %gl_MeshPerPrimitiveEXT 0 PerPrimitiveEXT
5717 %void = OpTypeVoid
5718 %3 = OpTypeFunction %void
5719 %uint = OpTypeInt 32 0
5720 %uint_32 = OpConstant %uint 32
5721 %uint_1 = OpConstant %uint 1
5722 %int = OpTypeInt 32 1
5723 %bool = OpTypeBool
5724 %gl_MeshPerPrimitiveEXT = OpTypeStruct %bool
5725 %_arr_gl_MeshPerPrimitiveEXT_uint_32 = OpTypeArray %gl_MeshPerPrimitiveEXT %uint_32
5726 %_ptr_Output__arr_gl_MeshPerPrimitiveEXT_uint_32 = OpTypePointer Output %_arr_gl_MeshPerPrimitiveEXT_uint_32
5727 %gl_MeshPrimitivesEXT = OpVariable %_ptr_Output__arr_gl_MeshPerPrimitiveEXT_uint_32 Output
5728 %main = OpFunction %void None %3
5729 %5 = OpLabel
5730 %ref_load = OpLoad %_arr_gl_MeshPerPrimitiveEXT_uint_32 %gl_MeshPrimitivesEXT
5731 OpReturn
5732 OpFunctionEnd
5733 )";
5734
5735 CompileSuccessfully(text, SPV_ENV_VULKAN_1_3);
5736 EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_3));
5737 EXPECT_THAT(getDiagnosticString(),
5738 AnyVUID("VUID-CullPrimitiveEXT-CullPrimitiveEXT-07036"));
5739 EXPECT_THAT(getDiagnosticString(),
5740 AnyVUID("Scalar boolean must be in a Block"));
5741 }
5742
5743 TEST_F(ValidateBuiltIns, BadVulkanBuiltinCullPrimitiveEXTType) {
5744 const std::string text = R"(
5745 OpCapability MeshShadingEXT
5746 OpExtension "SPV_EXT_mesh_shader"
5747 %1 = OpExtInstImport "GLSL.std.450"
5748 OpMemoryModel Logical GLSL450
5749 OpEntryPoint MeshEXT %main "main" %gl_MeshPrimitivesEXT
5750 OpExecutionModeId %main LocalSizeId %uint_32 %uint_1 %uint_1
5751 OpExecutionMode %main OutputVertices 81
5752 OpExecutionMode %main OutputPrimitivesEXT 32
5753 OpExecutionMode %main OutputTrianglesEXT
5754 OpSource GLSL 450
5755 OpSourceExtension "GL_EXT_mesh_shader"
5756 OpName %main "main"
5757 OpName %gl_MeshPerPrimitiveEXT "gl_MeshPerPrimitiveEXT"
5758 OpMemberName %gl_MeshPerPrimitiveEXT 0 "gl_CullPrimitiveEXT"
5759 OpName %gl_MeshPrimitivesEXT "gl_MeshPrimitivesEXT"
5760 OpDecorate %gl_MeshPerPrimitiveEXT Block
5761 OpMemberDecorate %gl_MeshPerPrimitiveEXT 0 BuiltIn CullPrimitiveEXT
5762 OpMemberDecorate %gl_MeshPerPrimitiveEXT 0 PerPrimitiveEXT
5763 %void = OpTypeVoid
5764 %3 = OpTypeFunction %void
5765 %uint = OpTypeInt 32 0
5766 %uint_32 = OpConstant %uint 32
5767 %uint_1 = OpConstant %uint 1
5768 %int = OpTypeInt 32 1
5769 %bool = OpTypeBool
5770 %gl_MeshPerPrimitiveEXT = OpTypeStruct %int
5771 %_arr_gl_MeshPerPrimitiveEXT_uint_32 = OpTypeArray %gl_MeshPerPrimitiveEXT %uint_32
5772 %_ptr_Output__arr_gl_MeshPerPrimitiveEXT_uint_32 = OpTypePointer Output %_arr_gl_MeshPerPrimitiveEXT_uint_32
5773 %gl_MeshPrimitivesEXT = OpVariable %_ptr_Output__arr_gl_MeshPerPrimitiveEXT_uint_32 Output
5774 %main = OpFunction %void None %3
5775 %5 = OpLabel
5776 %ref_load = OpLoad %_arr_gl_MeshPerPrimitiveEXT_uint_32 %gl_MeshPrimitivesEXT
5777 OpReturn
5778 OpFunctionEnd
5779 )";
5780
5781 CompileSuccessfully(text, SPV_ENV_VULKAN_1_3);
5782 EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_3));
5783 EXPECT_THAT(getDiagnosticString(),
5784 AnyVUID("VUID-CullPrimitiveEXT-CullPrimitiveEXT-07036"));
5785 }
5786
5787 // from https://github.com/KhronosGroup/SPIRV-Tools/issues/5980
5788 TEST_F(ValidateBuiltIns, VulkanBuiltinCullPrimitiveEXTArrayOfBool) {
5789 const std::string text = R"(
5790 OpCapability MeshShadingEXT
5791 OpExtension "SPV_EXT_mesh_shader"
5792 OpMemoryModel Logical GLSL450
5793 OpEntryPoint MeshEXT %main "main" %gl_LocalInvocationIndex %gl_Position %4 %5
5794 OpExecutionMode %main LocalSize 2 1 1
5795 OpExecutionMode %main OutputTrianglesEXT
5796 OpExecutionMode %main OutputVertices 2
5797 OpExecutionMode %main OutputPrimitivesEXT 2
5798 OpDecorate %gl_LocalInvocationIndex BuiltIn LocalInvocationIndex
5799 OpDecorate %gl_Position BuiltIn Position
5800 OpDecorate %4 BuiltIn PrimitiveTriangleIndicesEXT
5801 OpDecorate %5 BuiltIn CullPrimitiveEXT
5802 OpDecorate %5 PerPrimitiveEXT
5803 %uint = OpTypeInt 32 0
5804 %uint_2 = OpConstant %uint 2
5805 %bool = OpTypeBool
5806 %false = OpConstantFalse %bool
5807 %_ptr_Input_uint = OpTypePointer Input %uint
5808 %float = OpTypeFloat 32
5809 %v4float = OpTypeVector %float 4
5810 %_arr_v4float_uint_2 = OpTypeArray %v4float %uint_2
5811 %_ptr_Output__arr_v4float_uint_2 = OpTypePointer Output %_arr_v4float_uint_2
5812 %v3uint = OpTypeVector %uint 3
5813 %_arr_v3uint_uint_2 = OpTypeArray %v3uint %uint_2
5814 %_ptr_Output__arr_v3uint_uint_2 = OpTypePointer Output %_arr_v3uint_uint_2
5815 %_arr_bool_uint_2 = OpTypeArray %bool %uint_2
5816 %_ptr_Output__arr_bool_uint_2 = OpTypePointer Output %_arr_bool_uint_2
5817 %void = OpTypeVoid
5818 %21 = OpTypeFunction %void
5819 %_ptr_Output_bool = OpTypePointer Output %bool
5820 %gl_LocalInvocationIndex = OpVariable %_ptr_Input_uint Input
5821 %gl_Position = OpVariable %_ptr_Output__arr_v4float_uint_2 Output
5822 %4 = OpVariable %_ptr_Output__arr_v3uint_uint_2 Output
5823 %5 = OpVariable %_ptr_Output__arr_bool_uint_2 Output
5824 %main = OpFunction %void None %21
5825 %23 = OpLabel
5826 %24 = OpLoad %uint %gl_LocalInvocationIndex
5827 OpSetMeshOutputsEXT %uint_2 %uint_2
5828 %25 = OpAccessChain %_ptr_Output_bool %5 %24
5829 OpStore %25 %false
5830 OpReturn
5831 OpFunctionEnd
5832 )";
5833
5834 CompileSuccessfully(text, SPV_ENV_VULKAN_1_3);
5835 EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_3));
5836 }
5837
5838 TEST_F(ValidateBuiltIns, BadVulkanBuiltinCullPrimitiveEXTArrayType) {
5839 const std::string text = R"(
5840 OpCapability MeshShadingEXT
5841 OpExtension "SPV_EXT_mesh_shader"
5842 OpMemoryModel Logical GLSL450
5843 OpEntryPoint MeshEXT %main "main" %gl_LocalInvocationIndex %gl_Position %4 %5
5844 OpExecutionMode %main LocalSize 2 1 1
5845 OpExecutionMode %main OutputTrianglesEXT
5846 OpExecutionMode %main OutputVertices 2
5847 OpExecutionMode %main OutputPrimitivesEXT 2
5848 OpDecorate %gl_LocalInvocationIndex BuiltIn LocalInvocationIndex
5849 OpDecorate %gl_Position BuiltIn Position
5850 OpDecorate %4 BuiltIn PrimitiveTriangleIndicesEXT
5851 OpDecorate %5 BuiltIn CullPrimitiveEXT
5852 OpDecorate %5 PerPrimitiveEXT
5853 %uint = OpTypeInt 32 0
5854 %uint_2 = OpConstant %uint 2
5855 %bool = OpTypeBool
5856 %false = OpConstantFalse %bool
5857 %_ptr_Input_uint = OpTypePointer Input %uint
5858 %float = OpTypeFloat 32
5859 %v4float = OpTypeVector %float 4
5860 %_arr_v4float_uint_2 = OpTypeArray %v4float %uint_2
5861 %_ptr_Output__arr_v4float_uint_2 = OpTypePointer Output %_arr_v4float_uint_2
5862 %v3uint = OpTypeVector %uint 3
5863 %_arr_v3uint_uint_2 = OpTypeArray %v3uint %uint_2
5864 %_ptr_Output__arr_v3uint_uint_2 = OpTypePointer Output %_arr_v3uint_uint_2
5865 %_arr_uint_uint_2 = OpTypeArray %uint %uint_2
5866 %_ptr_Output__arr_uint_uint_2 = OpTypePointer Output %_arr_uint_uint_2
5867 %void = OpTypeVoid
5868 %21 = OpTypeFunction %void
5869 %_ptr_Output_uint = OpTypePointer Output %uint
5870 %gl_LocalInvocationIndex = OpVariable %_ptr_Input_uint Input
5871 %gl_Position = OpVariable %_ptr_Output__arr_v4float_uint_2 Output
5872 %4 = OpVariable %_ptr_Output__arr_v3uint_uint_2 Output
5873 %5 = OpVariable %_ptr_Output__arr_uint_uint_2 Output
5874 %main = OpFunction %void None %21
5875 %23 = OpLabel
5876 %24 = OpLoad %uint %gl_LocalInvocationIndex
5877 OpSetMeshOutputsEXT %uint_2 %uint_2
5878 %25 = OpAccessChain %_ptr_Output_uint %5 %24
5879 OpReturn
5880 OpFunctionEnd
5881 )";
5882
5883 CompileSuccessfully(text, SPV_ENV_VULKAN_1_3);
5884 EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_3));
5885 EXPECT_THAT(getDiagnosticString(),
5886 AnyVUID("VUID-CullPrimitiveEXT-CullPrimitiveEXT-07036"));
5887 }
5888
5889 TEST_F(ValidateBuiltIns, BadVulkanBuiltinCullPrimitiveEXTArrayOfBoolSize) {
5890 const std::string text = R"(
5891 OpCapability MeshShadingEXT
5892 OpExtension "SPV_EXT_mesh_shader"
5893 OpMemoryModel Logical GLSL450
5894 OpEntryPoint MeshEXT %main "main" %gl_LocalInvocationIndex %gl_Position %4 %5
5895 OpExecutionMode %main LocalSize 2 1 1
5896 OpExecutionMode %main OutputTrianglesEXT
5897 OpExecutionMode %main OutputVertices 2
5898 OpExecutionMode %main OutputPrimitivesEXT 2
5899 OpDecorate %gl_LocalInvocationIndex BuiltIn LocalInvocationIndex
5900 OpDecorate %gl_Position BuiltIn Position
5901 OpDecorate %4 BuiltIn PrimitiveTriangleIndicesEXT
5902 OpDecorate %5 BuiltIn CullPrimitiveEXT
5903 OpDecorate %5 PerPrimitiveEXT
5904 %uint = OpTypeInt 32 0
5905 %uint_2 = OpConstant %uint 2
5906 %uint_4 = OpConstant %uint 4
5907 %bool = OpTypeBool
5908 %false = OpConstantFalse %bool
5909 %_ptr_Input_uint = OpTypePointer Input %uint
5910 %float = OpTypeFloat 32
5911 %v4float = OpTypeVector %float 4
5912 %_arr_v4float_uint_2 = OpTypeArray %v4float %uint_2
5913 %_ptr_Output__arr_v4float_uint_2 = OpTypePointer Output %_arr_v4float_uint_2
5914 %v3uint = OpTypeVector %uint 3
5915 %_arr_v3uint_uint_2 = OpTypeArray %v3uint %uint_2
5916 %_ptr_Output__arr_v3uint_uint_2 = OpTypePointer Output %_arr_v3uint_uint_2
5917 %_arr_bool_uint_4 = OpTypeArray %bool %uint_4
5918 %_ptr_Output__arr_bool_uint_4 = OpTypePointer Output %_arr_bool_uint_4
5919 %void = OpTypeVoid
5920 %21 = OpTypeFunction %void
5921 %_ptr_Output_bool = OpTypePointer Output %bool
5922 %gl_LocalInvocationIndex = OpVariable %_ptr_Input_uint Input
5923 %gl_Position = OpVariable %_ptr_Output__arr_v4float_uint_2 Output
5924 %4 = OpVariable %_ptr_Output__arr_v3uint_uint_2 Output
5925 %5 = OpVariable %_ptr_Output__arr_bool_uint_4 Output
5926 %main = OpFunction %void None %21
5927 %23 = OpLabel
5928 %24 = OpLoad %uint %gl_LocalInvocationIndex
5929 OpSetMeshOutputsEXT %uint_2 %uint_2
5930 %25 = OpAccessChain %_ptr_Output_bool %5 %24
5931 OpStore %25 %false
5932 OpReturn
5933 OpFunctionEnd
5934 )";
5935
5936 CompileSuccessfully(text, SPV_ENV_VULKAN_1_3);
5937 EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_3));
5938 EXPECT_THAT(getDiagnosticString(),
5939 AnyVUID("VUID-CullPrimitiveEXT-CullPrimitiveEXT-10589"));
5940 }
5941
5942 TEST_F(ValidateBuiltIns, BadVulkanBuiltinCullPrimitiveEXTInterfaceVariable) {
5943 const std::string text = R"(
5944 OpCapability MeshShadingEXT
5945 OpExtension "SPV_EXT_mesh_shader"
5946 OpMemoryModel Logical GLSL450
5947 OpEntryPoint MeshEXT %main "main" %gl_LocalInvocationIndex %gl_Position %4 %5 %gl_MeshPrimitivesEXT
5948 OpExecutionMode %main LocalSize 2 1 1
5949 OpExecutionMode %main OutputTrianglesEXT
5950 OpExecutionMode %main OutputVertices 2
5951 OpExecutionMode %main OutputPrimitivesEXT 2
5952 OpDecorate %gl_LocalInvocationIndex BuiltIn LocalInvocationIndex
5953 OpDecorate %gl_Position BuiltIn Position
5954 OpDecorate %4 BuiltIn PrimitiveTriangleIndicesEXT
5955 OpDecorate %5 BuiltIn CullPrimitiveEXT
5956 OpDecorate %5 PerPrimitiveEXT
5957 OpDecorate %gl_MeshPerPrimitiveEXT Block
5958 OpMemberDecorate %gl_MeshPerPrimitiveEXT 0 BuiltIn CullPrimitiveEXT
5959 OpMemberDecorate %gl_MeshPerPrimitiveEXT 0 PerPrimitiveEXT
5960 %uint = OpTypeInt 32 0
5961 %uint_2 = OpConstant %uint 2
5962 %bool = OpTypeBool
5963 %false = OpConstantFalse %bool
5964 %_ptr_Input_uint = OpTypePointer Input %uint
5965 %float = OpTypeFloat 32
5966 %v4float = OpTypeVector %float 4
5967 %_arr_v4float_uint_2 = OpTypeArray %v4float %uint_2
5968 %_ptr_Output__arr_v4float_uint_2 = OpTypePointer Output %_arr_v4float_uint_2
5969 %v3uint = OpTypeVector %uint 3
5970 %_arr_v3uint_uint_2 = OpTypeArray %v3uint %uint_2
5971 %_ptr_Output__arr_v3uint_uint_2 = OpTypePointer Output %_arr_v3uint_uint_2
5972 %_arr_bool_uint_2 = OpTypeArray %bool %uint_2
5973 %_ptr_Output__arr_bool_uint_2 = OpTypePointer Output %_arr_bool_uint_2
5974 %void = OpTypeVoid
5975 %21 = OpTypeFunction %void
5976 %_ptr_Output_bool = OpTypePointer Output %bool
5977 %gl_LocalInvocationIndex = OpVariable %_ptr_Input_uint Input
5978 %gl_Position = OpVariable %_ptr_Output__arr_v4float_uint_2 Output
5979 %4 = OpVariable %_ptr_Output__arr_v3uint_uint_2 Output
5980 %5 = OpVariable %_ptr_Output__arr_bool_uint_2 Output
5981 %gl_MeshPerPrimitiveEXT = OpTypeStruct %bool
5982 %_arr_gl_MeshPerPrimitiveEXT_uint_2 = OpTypeArray %gl_MeshPerPrimitiveEXT %uint_2
5983 %_ptr_Output__arr_gl_MeshPerPrimitiveEXT_uint_2 = OpTypePointer Output %_arr_gl_MeshPerPrimitiveEXT_uint_2
5984 %gl_MeshPrimitivesEXT = OpVariable %_ptr_Output__arr_gl_MeshPerPrimitiveEXT_uint_2 Output
5985 %main = OpFunction %void None %21
5986 %23 = OpLabel
5987 %ref_load = OpLoad %_arr_gl_MeshPerPrimitiveEXT_uint_2 %gl_MeshPrimitivesEXT
5988 %24 = OpLoad %uint %gl_LocalInvocationIndex
5989 OpSetMeshOutputsEXT %uint_2 %uint_2
5990 %25 = OpAccessChain %_ptr_Output_bool %5 %24
5991 OpStore %25 %false
5992 OpReturn
5993 OpFunctionEnd
5994 )";
5995
5996 CompileSuccessfully(text, SPV_ENV_VULKAN_1_3);
5997 EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_3));
5998 EXPECT_THAT(getDiagnosticString(),
5999 AnyVUID("VUID-CullPrimitiveEXT-CullPrimitiveEXT-10591"));
6000 }
6001
6002 TEST_F(ValidateBuiltIns, BadVulkanBuiltinCullPrimitiveEXTStorageClass) {
6003 const std::string text = R"(
6004 OpCapability MeshShadingEXT
6005 OpExtension "SPV_EXT_mesh_shader"
6006 %1 = OpExtInstImport "GLSL.std.450"
6007 OpMemoryModel Logical GLSL450
6008 OpEntryPoint MeshEXT %main "main" %gl_MeshPrimitivesEXT
6009 OpExecutionModeId %main LocalSizeId %uint_32 %uint_1 %uint_1
6010 OpExecutionMode %main OutputVertices 81
6011 OpExecutionMode %main OutputPrimitivesEXT 32
6012 OpExecutionMode %main OutputTrianglesEXT
6013 OpSource GLSL 450
6014 OpSourceExtension "GL_EXT_mesh_shader"
6015 OpName %main "main"
6016 OpName %gl_MeshPerPrimitiveEXT "gl_MeshPerPrimitiveEXT"
6017 OpMemberName %gl_MeshPerPrimitiveEXT 0 "gl_CullPrimitiveEXT"
6018 OpName %gl_MeshPrimitivesEXT "gl_MeshPrimitivesEXT"
6019 OpDecorate %gl_MeshPerPrimitiveEXT Block
6020 OpMemberDecorate %gl_MeshPerPrimitiveEXT 0 BuiltIn CullPrimitiveEXT
6021 OpMemberDecorate %gl_MeshPerPrimitiveEXT 0 PerPrimitiveEXT
6022 %void = OpTypeVoid
6023 %3 = OpTypeFunction %void
6024 %uint = OpTypeInt 32 0
6025 %uint_32 = OpConstant %uint 32
6026 %uint_1 = OpConstant %uint 1
6027 %int = OpTypeInt 32 1
6028 %bool = OpTypeBool
6029 %gl_MeshPerPrimitiveEXT = OpTypeStruct %bool
6030 %_arr_gl_MeshPerPrimitiveEXT_uint_32 = OpTypeArray %gl_MeshPerPrimitiveEXT %uint_32
6031 %_ptr_Output__arr_gl_MeshPerPrimitiveEXT_uint_32 = OpTypePointer Input %_arr_gl_MeshPerPrimitiveEXT_uint_32
6032 %gl_MeshPrimitivesEXT = OpVariable %_ptr_Output__arr_gl_MeshPerPrimitiveEXT_uint_32 Input
6033 %main = OpFunction %void None %3
6034 %5 = OpLabel
6035 OpReturn
6036 OpFunctionEnd
6037 )";
6038
6039 CompileSuccessfully(text, SPV_ENV_VULKAN_1_3);
6040 EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_3));
6041 EXPECT_THAT(getDiagnosticString(),
6042 AnyVUID("VUID-CullPrimitiveEXT-CullPrimitiveEXT-07035"));
6043 }
6044
6045 TEST_F(ValidateBuiltIns, BadBuiltinCullPrimitiveEXTWithPerPrimitiveEXT) {
6046 const std::string text = R"(
6047 OpCapability MeshShadingEXT
6048 OpExtension "SPV_EXT_mesh_shader"
6049 %1 = OpExtInstImport "GLSL.std.450"
6050 OpMemoryModel Logical GLSL450
6051 OpEntryPoint MeshEXT %main "main" %gl_MeshPrimitivesEXT
6052 OpExecutionModeId %main LocalSizeId %uint_32 %uint_1 %uint_1
6053 OpExecutionMode %main OutputVertices 81
6054 OpExecutionMode %main OutputPrimitivesEXT 32
6055 OpExecutionMode %main OutputTrianglesEXT
6056 OpSource GLSL 450
6057 OpSourceExtension "GL_EXT_mesh_shader"
6058 OpName %main "main"
6059 OpName %gl_MeshPerPrimitiveEXT "gl_MeshPerPrimitiveEXT"
6060 OpMemberName %gl_MeshPerPrimitiveEXT 0 "gl_CullPrimitiveEXT"
6061 OpName %gl_MeshPrimitivesEXT "gl_MeshPrimitivesEXT"
6062 OpDecorate %gl_MeshPerPrimitiveEXT Block
6063 OpMemberDecorate %gl_MeshPerPrimitiveEXT 0 BuiltIn CullPrimitiveEXT
6064 %void = OpTypeVoid
6065 %3 = OpTypeFunction %void
6066 %uint = OpTypeInt 32 0
6067 %uint_32 = OpConstant %uint 32
6068 %uint_1 = OpConstant %uint 1
6069 %int = OpTypeInt 32 1
6070 %bool = OpTypeBool
6071 %gl_MeshPerPrimitiveEXT = OpTypeStruct %bool
6072 %_arr_gl_MeshPerPrimitiveEXT_uint_32 = OpTypeArray %gl_MeshPerPrimitiveEXT %uint_32
6073 %_ptr_Output__arr_gl_MeshPerPrimitiveEXT_uint_32 = OpTypePointer Output %_arr_gl_MeshPerPrimitiveEXT_uint_32
6074 %gl_MeshPrimitivesEXT = OpVariable %_ptr_Output__arr_gl_MeshPerPrimitiveEXT_uint_32 Output
6075 %main = OpFunction %void None %3
6076 %5 = OpLabel
6077 %ref_load = OpLoad %_arr_gl_MeshPerPrimitiveEXT_uint_32 %gl_MeshPrimitivesEXT
6078 OpReturn
6079 OpFunctionEnd
6080 )";
6081
6082 CompileSuccessfully(text, SPV_ENV_VULKAN_1_3);
6083 EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_3));
6084 EXPECT_THAT(getDiagnosticString(),
6085 AnyVUID("VUID-CullPrimitiveEXT-CullPrimitiveEXT-07038"));
6086 }
6087
6088 TEST_F(ValidateBuiltIns, BadBuiltinPrimitiveShadingRateWithPerPrimitiveEXT) {
6089 const std::string text = R"(
6090 OpCapability FragmentShadingRateKHR
6091 OpCapability MeshShadingEXT
6092 OpExtension "SPV_EXT_mesh_shader"
6093 OpExtension "SPV_KHR_fragment_shading_rate"
6094 %1 = OpExtInstImport "GLSL.std.450"
6095 OpMemoryModel Logical GLSL450
6096 OpEntryPoint MeshEXT %main "main" %gl_MeshPrimitivesEXT
6097 OpExecutionModeId %main LocalSizeId %uint_32 %uint_1 %uint_1
6098 OpExecutionMode %main OutputVertices 81
6099 OpExecutionMode %main OutputPrimitivesEXT 32
6100 OpExecutionMode %main OutputTrianglesEXT
6101 OpSource GLSL 450
6102 OpSourceExtension "GL_EXT_mesh_shader"
6103 OpName %main "main"
6104 OpName %gl_MeshPerPrimitiveEXT "gl_MeshPerPrimitiveEXT"
6105 OpMemberName %gl_MeshPerPrimitiveEXT 0 "gl_PrimitiveShadingRateKHR"
6106 OpName %gl_MeshPrimitivesEXT "gl_MeshPrimitivesEXT"
6107 OpDecorate %gl_MeshPerPrimitiveEXT Block
6108 OpMemberDecorate %gl_MeshPerPrimitiveEXT 0 BuiltIn PrimitiveShadingRateKHR
6109 %void = OpTypeVoid
6110 %3 = OpTypeFunction %void
6111 %uint = OpTypeInt 32 0
6112 %uint_32 = OpConstant %uint 32
6113 %uint_1 = OpConstant %uint 1
6114 %int = OpTypeInt 32 1
6115 %bool = OpTypeBool
6116 %gl_MeshPerPrimitiveEXT = OpTypeStruct %int
6117 %_arr_gl_MeshPerPrimitiveEXT_uint_32 = OpTypeArray %gl_MeshPerPrimitiveEXT %uint_32
6118 %_ptr_Output__arr_gl_MeshPerPrimitiveEXT_uint_32 = OpTypePointer Output %_arr_gl_MeshPerPrimitiveEXT_uint_32
6119 %gl_MeshPrimitivesEXT = OpVariable %_ptr_Output__arr_gl_MeshPerPrimitiveEXT_uint_32 Output
6120 %main = OpFunction %void None %3
6121 %5 = OpLabel
6122 %ref_load = OpLoad %_arr_gl_MeshPerPrimitiveEXT_uint_32 %gl_MeshPrimitivesEXT
6123 OpReturn
6124 OpFunctionEnd
6125 )";
6126
6127 CompileSuccessfully(text, SPV_ENV_VULKAN_1_3);
6128 EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_3));
6129 EXPECT_THAT(
6130 getDiagnosticString(),
6131 AnyVUID("VUID-PrimitiveShadingRateKHR-PrimitiveShadingRateKHR-07059"));
6132 }
6133
6134 TEST_F(ValidateBuiltIns, BadExecModelVulkanCullPrimitiveEXT) {
6135 const std::string text = R"(
6136 OpCapability MeshShadingNV
6137 OpCapability MeshShadingEXT
6138 OpExtension "SPV_NV_mesh_shader"
6139 OpExtension "SPV_EXT_mesh_shader"
6140 %1 = OpExtInstImport "GLSL.std.450"
6141 OpMemoryModel Logical GLSL450
6142 OpEntryPoint MeshNV %main "main" %gl_MeshPrimitivesEXT
6143 OpExecutionModeId %main LocalSizeId %uint_32 %uint_1 %uint_1
6144 OpExecutionMode %main OutputVertices 81
6145 OpExecutionMode %main OutputPrimitivesNV 32
6146 OpExecutionMode %main OutputTrianglesNV
6147 OpSource GLSL 450
6148 OpSourceExtension "GL_EXT_mesh_shader"
6149 OpMemberDecorate %gl_MeshPerPrimitiveEXT 0 PerPrimitiveEXT
6150 OpMemberDecorate %gl_MeshPerPrimitiveEXT 0 BuiltIn CullPrimitiveEXT
6151 OpDecorate %gl_MeshPerPrimitiveEXT Block
6152 %void = OpTypeVoid
6153 %3 = OpTypeFunction %void
6154 %uint = OpTypeInt 32 0
6155 %uint_32 = OpConstant %uint 32
6156 %uint_1 = OpConstant %uint 1
6157 %v3uint = OpTypeVector %uint 3
6158 %bool = OpTypeBool
6159 %int = OpTypeInt 32 1
6160 %int_0 = OpConstant %int 0
6161 %gl_MeshPerPrimitiveEXT = OpTypeStruct %bool
6162 %_ptr_Output_bool = OpTypePointer Output %bool
6163 %_arr_gl_MeshPerPrimitiveEXT_uint_32 = OpTypeArray %gl_MeshPerPrimitiveEXT %uint_32
6164 %_ptr_Output__arr_gl_MeshPerPrimitiveEXT_uint_32 = OpTypePointer Output %_arr_gl_MeshPerPrimitiveEXT_uint_32
6165 %gl_MeshPrimitivesEXT = OpVariable %_ptr_Output__arr_gl_MeshPerPrimitiveEXT_uint_32 Output
6166 %main = OpFunction %void None %3
6167 %5 = OpLabel
6168 %18 = OpAccessChain %_ptr_Output_bool %gl_MeshPrimitivesEXT %int_0 %int_0
6169 OpReturn
6170 OpFunctionEnd
6171 )";
6172
6173 CompileSuccessfully(text, SPV_ENV_VULKAN_1_3);
6174 EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_3));
6175 EXPECT_THAT(getDiagnosticString(),
6176 AnyVUID("VUID-CullPrimitiveEXT-CullPrimitiveEXT-07034"));
6177 }
6178
6179 TEST_F(ValidateBuiltIns, VulkanBuiltinLayerInBlockMeshEXT) {
6180 const std::string text = R"(
6181 OpCapability MeshShadingEXT
6182 OpExtension "SPV_EXT_mesh_shader"
6183 %1 = OpExtInstImport "GLSL.std.450"
6184 OpMemoryModel Logical GLSL450
6185 OpEntryPoint MeshEXT %main "main" %gl_MeshPrimitivesEXT
6186 OpExecutionModeId %main LocalSizeId %uint_32 %uint_1 %uint_1
6187 OpExecutionMode %main OutputVertices 81
6188 OpExecutionMode %main OutputPrimitivesEXT 32
6189 OpExecutionMode %main OutputTrianglesEXT
6190 OpSource GLSL 450
6191 OpSourceExtension "GL_EXT_mesh_shader"
6192 OpName %main "main"
6193 OpName %gl_MeshPerPrimitiveEXT "gl_MeshPerPrimitiveEXT"
6194 OpMemberName %gl_MeshPerPrimitiveEXT 0 "gl_Layer"
6195 OpName %gl_MeshPrimitivesEXT "gl_MeshPrimitivesEXT"
6196 OpDecorate %gl_MeshPerPrimitiveEXT Block
6197 OpMemberDecorate %gl_MeshPerPrimitiveEXT 0 BuiltIn Layer
6198 OpMemberDecorate %gl_MeshPerPrimitiveEXT 0 PerPrimitiveEXT
6199 %void = OpTypeVoid
6200 %3 = OpTypeFunction %void
6201 %uint = OpTypeInt 32 0
6202 %uint_32 = OpConstant %uint 32
6203 %uint_1 = OpConstant %uint 1
6204 %int = OpTypeInt 32 1
6205 %bool = OpTypeBool
6206 %gl_MeshPerPrimitiveEXT = OpTypeStruct %int
6207 %_arr_gl_MeshPerPrimitiveEXT_uint_32 = OpTypeArray %gl_MeshPerPrimitiveEXT %uint_32
6208 %_ptr_Output__arr_gl_MeshPerPrimitiveEXT_uint_32 = OpTypePointer Output %_arr_gl_MeshPerPrimitiveEXT_uint_32
6209 %gl_MeshPrimitivesEXT = OpVariable %_ptr_Output__arr_gl_MeshPerPrimitiveEXT_uint_32 Output
6210 %main = OpFunction %void None %3
6211 %5 = OpLabel
6212 OpReturn
6213 OpFunctionEnd
6214 )";
6215
6216 CompileSuccessfully(text, SPV_ENV_VULKAN_1_3);
6217 EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_3));
6218 }
6219
6220 TEST_F(ValidateBuiltIns, VulkanBuiltinLayerAsArrayOfIntMeshEXT) {
6221 const std::string text = R"(
6222 OpCapability MeshShadingEXT
6223 OpExtension "SPV_EXT_mesh_shader"
6224 %1 = OpExtInstImport "GLSL.std.450"
6225 OpMemoryModel Logical GLSL450
6226 OpEntryPoint MeshEXT %main "main" %gl_Layer
6227 OpExecutionModeId %main LocalSizeId %uint_32 %uint_1 %uint_1
6228 OpExecutionMode %main OutputVertices 81
6229 OpExecutionMode %main OutputPrimitivesEXT 32
6230 OpExecutionMode %main OutputTrianglesEXT
6231 OpSource GLSL 450
6232 OpSourceExtension "GL_EXT_mesh_shader"
6233 OpName %main "main"
6234 OpDecorate %gl_Layer BuiltIn Layer
6235 OpDecorate %gl_Layer PerPrimitiveEXT
6236 %void = OpTypeVoid
6237 %3 = OpTypeFunction %void
6238 %uint = OpTypeInt 32 0
6239 %uint_32 = OpConstant %uint 32
6240 %uint_1 = OpConstant %uint 1
6241 %int = OpTypeInt 32 1
6242 %bool = OpTypeBool
6243 %_arr_gl_Layer_uint_32 = OpTypeArray %int %uint_32
6244 %_ptr_Output__arr_gl_Layer_uint_32 = OpTypePointer Output %_arr_gl_Layer_uint_32
6245 %gl_Layer = OpVariable %_ptr_Output__arr_gl_Layer_uint_32 Output
6246 %main = OpFunction %void None %3
6247 %5 = OpLabel
6248 OpReturn
6249 OpFunctionEnd
6250 )";
6251
6252 CompileSuccessfully(text, SPV_ENV_VULKAN_1_3);
6253 EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_3));
6254 }
6255
6256 TEST_F(ValidateBuiltIns, BadVulkanBuiltinLayerArrayTypeMeshEXT) {
6257 const std::string text = R"(
6258 OpCapability MeshShadingEXT
6259 OpExtension "SPV_EXT_mesh_shader"
6260 %1 = OpExtInstImport "GLSL.std.450"
6261 OpMemoryModel Logical GLSL450
6262 OpEntryPoint MeshEXT %main "main" %gl_Layer
6263 OpExecutionModeId %main LocalSizeId %uint_32 %uint_1 %uint_1
6264 OpExecutionMode %main OutputVertices 81
6265 OpExecutionMode %main OutputPrimitivesEXT 32
6266 OpExecutionMode %main OutputTrianglesEXT
6267 OpSource GLSL 450
6268 OpSourceExtension "GL_EXT_mesh_shader"
6269 OpName %main "main"
6270 OpDecorate %gl_Layer BuiltIn Layer
6271 OpDecorate %gl_Layer PerPrimitiveEXT
6272 %void = OpTypeVoid
6273 %3 = OpTypeFunction %void
6274 %uint = OpTypeInt 32 0
6275 %uint_32 = OpConstant %uint 32
6276 %uint_1 = OpConstant %uint 1
6277 %int = OpTypeInt 32 1
6278 %bool = OpTypeBool
6279 %_arr_gl_Layer_uint_32 = OpTypeArray %bool %uint_32
6280 %_ptr_Output__arr_gl_Layer_uint_32 = OpTypePointer Output %_arr_gl_Layer_uint_32
6281 %gl_Layer = OpVariable %_ptr_Output__arr_gl_Layer_uint_32 Output
6282 %main = OpFunction %void None %3
6283 %5 = OpLabel
6284 %ref_load = OpLoad %_arr_gl_Layer_uint_32 %gl_Layer
6285 OpReturn
6286 OpFunctionEnd
6287 )";
6288
6289 CompileSuccessfully(text, SPV_ENV_VULKAN_1_3);
6290 EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_3));
6291 EXPECT_THAT(getDiagnosticString(), AnyVUID("VUID-Layer-Layer-10592"));
6292 }
6293
6294 TEST_F(ValidateBuiltIns, BadVulkanBuiltinLayerInBlockMeshEXTType) {
6295 const std::string text = R"(
6296 OpCapability MeshShadingEXT
6297 OpExtension "SPV_EXT_mesh_shader"
6298 %1 = OpExtInstImport "GLSL.std.450"
6299 OpMemoryModel Logical GLSL450
6300 OpEntryPoint MeshEXT %main "main" %gl_MeshPrimitivesEXT
6301 OpExecutionModeId %main LocalSizeId %uint_32 %uint_1 %uint_1
6302 OpExecutionMode %main OutputVertices 81
6303 OpExecutionMode %main OutputPrimitivesEXT 32
6304 OpExecutionMode %main OutputTrianglesEXT
6305 OpSource GLSL 450
6306 OpSourceExtension "GL_EXT_mesh_shader"
6307 OpName %main "main"
6308 OpName %gl_MeshPerPrimitiveEXT "gl_MeshPerPrimitiveEXT"
6309 OpMemberName %gl_MeshPerPrimitiveEXT 0 "gl_Layer"
6310 OpName %gl_MeshPrimitivesEXT "gl_MeshPrimitivesEXT"
6311 OpDecorate %gl_MeshPerPrimitiveEXT Block
6312 OpMemberDecorate %gl_MeshPerPrimitiveEXT 0 BuiltIn Layer
6313 OpMemberDecorate %gl_MeshPerPrimitiveEXT 0 PerPrimitiveEXT
6314 %void = OpTypeVoid
6315 %3 = OpTypeFunction %void
6316 %uint = OpTypeInt 32 0
6317 %uint_32 = OpConstant %uint 32
6318 %uint_1 = OpConstant %uint 1
6319 %int = OpTypeInt 32 1
6320 %bool = OpTypeBool
6321 %gl_MeshPerPrimitiveEXT = OpTypeStruct %bool
6322 %_arr_gl_MeshPerPrimitiveEXT_uint_32 = OpTypeArray %gl_MeshPerPrimitiveEXT %uint_32
6323 %_ptr_Output__arr_gl_MeshPerPrimitiveEXT_uint_32 = OpTypePointer Output %_arr_gl_MeshPerPrimitiveEXT_uint_32
6324 %gl_MeshPrimitivesEXT = OpVariable %_ptr_Output__arr_gl_MeshPerPrimitiveEXT_uint_32 Output
6325 %main = OpFunction %void None %3
6326 %5 = OpLabel
6327 %ref_load = OpLoad %_arr_gl_MeshPerPrimitiveEXT_uint_32 %gl_MeshPrimitivesEXT
6328 OpReturn
6329 OpFunctionEnd
6330 )";
6331
6332 CompileSuccessfully(text, SPV_ENV_VULKAN_1_3);
6333 EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_3));
6334 EXPECT_THAT(getDiagnosticString(), AnyVUID("VUID-Layer-Layer-10592"));
6335 }
6336
6337 TEST_F(ValidateBuiltIns, BadVulkanBuiltinLayerArrayOfIntSizeMeshEXT) {
6338 const std::string text = R"(
6339 OpCapability MeshShadingEXT
6340 OpExtension "SPV_EXT_mesh_shader"
6341 %1 = OpExtInstImport "GLSL.std.450"
6342 OpMemoryModel Logical GLSL450
6343 OpEntryPoint MeshEXT %main "main" %gl_Layer
6344 OpExecutionModeId %main LocalSizeId %uint_32 %uint_1 %uint_1
6345 OpExecutionMode %main OutputVertices 81
6346 OpExecutionMode %main OutputPrimitivesEXT 16
6347 OpExecutionMode %main OutputTrianglesEXT
6348 OpSource GLSL 450
6349 OpSourceExtension "GL_EXT_mesh_shader"
6350 OpName %main "main"
6351 OpDecorate %gl_Layer BuiltIn Layer
6352 OpDecorate %gl_Layer PerPrimitiveEXT
6353 %void = OpTypeVoid
6354 %3 = OpTypeFunction %void
6355 %uint = OpTypeInt 32 0
6356 %uint_32 = OpConstant %uint 32
6357 %uint_1 = OpConstant %uint 1
6358 %int = OpTypeInt 32 1
6359 %bool = OpTypeBool
6360 %_arr_gl_Layer_uint_32 = OpTypeArray %int %uint_32
6361 %_ptr_Output__arr_gl_Layer_uint_32 = OpTypePointer Output %_arr_gl_Layer_uint_32
6362 %gl_Layer = OpVariable %_ptr_Output__arr_gl_Layer_uint_32 Output
6363 %main = OpFunction %void None %3
6364 %5 = OpLabel
6365 %ref_load = OpLoad %_arr_gl_Layer_uint_32 %gl_Layer
6366 OpReturn
6367 OpFunctionEnd
6368 )";
6369
6370 CompileSuccessfully(text, SPV_ENV_VULKAN_1_3);
6371 EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_3));
6372 EXPECT_THAT(getDiagnosticString(), AnyVUID("VUID-Layer-Layer-10593"));
6373 }
6374
6375 TEST_F(ValidateBuiltIns, BadVulkanBuiltinLayerInBlockArraySizeMeshEXT) {
6376 const std::string text = R"(
6377 OpCapability MeshShadingEXT
6378 OpExtension "SPV_EXT_mesh_shader"
6379 %1 = OpExtInstImport "GLSL.std.450"
6380 OpMemoryModel Logical GLSL450
6381 OpEntryPoint MeshEXT %main "main" %gl_MeshPrimitivesEXT
6382 OpExecutionModeId %main LocalSizeId %uint_32 %uint_1 %uint_1
6383 OpExecutionMode %main OutputVertices 81
6384 OpExecutionMode %main OutputPrimitivesEXT 16
6385 OpExecutionMode %main OutputTrianglesEXT
6386 OpSource GLSL 450
6387 OpSourceExtension "GL_EXT_mesh_shader"
6388 OpName %main "main"
6389 OpName %gl_MeshPerPrimitiveEXT "gl_MeshPerPrimitiveEXT"
6390 OpMemberName %gl_MeshPerPrimitiveEXT 0 "gl_Layer"
6391 OpName %gl_MeshPrimitivesEXT "gl_MeshPrimitivesEXT"
6392 OpDecorate %gl_MeshPerPrimitiveEXT Block
6393 OpMemberDecorate %gl_MeshPerPrimitiveEXT 0 BuiltIn Layer
6394 OpMemberDecorate %gl_MeshPerPrimitiveEXT 0 PerPrimitiveEXT
6395 %void = OpTypeVoid
6396 %3 = OpTypeFunction %void
6397 %uint = OpTypeInt 32 0
6398 %uint_32 = OpConstant %uint 32
6399 %uint_1 = OpConstant %uint 1
6400 %int = OpTypeInt 32 1
6401 %bool = OpTypeBool
6402 %gl_MeshPerPrimitiveEXT = OpTypeStruct %int
6403 %_arr_gl_MeshPerPrimitiveEXT_uint_32 = OpTypeArray %gl_MeshPerPrimitiveEXT %uint_32
6404 %_ptr_Output__arr_gl_MeshPerPrimitiveEXT_uint_32 = OpTypePointer Output %_arr_gl_MeshPerPrimitiveEXT_uint_32
6405 %gl_MeshPrimitivesEXT = OpVariable %_ptr_Output__arr_gl_MeshPerPrimitiveEXT_uint_32 Output
6406 %main = OpFunction %void None %3
6407 %5 = OpLabel
6408 %ref_load = OpLoad %_arr_gl_MeshPerPrimitiveEXT_uint_32 %gl_MeshPrimitivesEXT
6409 OpReturn
6410 OpFunctionEnd
6411 )";
6412
6413 CompileSuccessfully(text, SPV_ENV_VULKAN_1_3);
6414 EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_3));
6415 EXPECT_THAT(getDiagnosticString(), AnyVUID("VUID-Layer-Layer-10594"));
6416 }
6417
6418 TEST_F(ValidateBuiltIns, BadVulkanBuiltinLayerWithPerPrimitiveEXT) {
6419 const std::string text = R"(
6420 OpCapability MeshShadingEXT
6421 OpCapability Shader
6422 OpExtension "SPV_EXT_mesh_shader"
6423 OpMemoryModel Logical GLSL450
6424 OpEntryPoint MeshEXT %MainMesh "MainMesh" %gl_Layer
6425 OpExecutionMode %MainMesh OutputPrimitivesNV 1
6426 OpExecutionMode %MainMesh OutputVertices 3
6427 OpExecutionMode %MainMesh OutputTrianglesNV
6428 OpExecutionMode %MainMesh LocalSize 1 1 1
6429 OpSource Slang 1
6430 OpName %MainMesh "MainMesh"
6431 OpDecorate %gl_Layer BuiltIn Layer
6432 %void = OpTypeVoid
6433 %9 = OpTypeFunction %void
6434 %uint = OpTypeInt 32 0
6435 %uint_3 = OpConstant %uint 3
6436 %uint_1 = OpConstant %uint 1
6437 %float = OpTypeFloat 32
6438 %int = OpTypeInt 32 1
6439 %int_1 = OpConstant %int 1
6440 %int_3 = OpConstant %int 3
6441 %uint_0 = OpConstant %uint 0
6442 %v3float = OpTypeVector %float 3
6443 %_ptr_Output_v3float = OpTypePointer Output %v3float
6444 %v3uint = OpTypeVector %uint 3
6445 %_ptr_Output_v3uint = OpTypePointer Output %v3uint
6446 %_ptr_Output_int = OpTypePointer Output %int
6447 %_arr_int_int_1 = OpTypeArray %int %int_1
6448 %_ptr_Output__arr_int_int_1 = OpTypePointer Output %_arr_int_int_1
6449 %gl_Layer = OpVariable %_ptr_Output__arr_int_int_1 Output
6450 %MainMesh = OpFunction %void None %9
6451 %25 = OpLabel
6452 %ref_load = OpLoad %_arr_int_int_1 %gl_Layer
6453 OpSetMeshOutputsEXT %uint_3 %uint_1
6454 OpReturn
6455 OpFunctionEnd
6456 )";
6457
6458 CompileSuccessfully(text, SPV_ENV_VULKAN_1_3);
6459 EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_3));
6460 EXPECT_THAT(getDiagnosticString(), AnyVUID("VUID-Layer-Layer-07039"));
6461 }
6462
6463 TEST_F(ValidateBuiltIns, VulkanBuiltinPrimitiveShadingRateKHRInBlockMeshEXT) {
6464 const std::string text = R"(
6465 OpCapability FragmentShadingRateKHR
6466 OpCapability MeshShadingEXT
6467 OpExtension "SPV_EXT_mesh_shader"
6468 OpExtension "SPV_KHR_fragment_shading_rate"
6469 %1 = OpExtInstImport "GLSL.std.450"
6470 OpMemoryModel Logical GLSL450
6471 OpEntryPoint MeshEXT %main "main" %gl_MeshPrimitivesEXT
6472 OpExecutionModeId %main LocalSizeId %uint_32 %uint_1 %uint_1
6473 OpExecutionMode %main OutputVertices 81
6474 OpExecutionMode %main OutputPrimitivesEXT 32
6475 OpExecutionMode %main OutputTrianglesEXT
6476 OpSource GLSL 450
6477 OpSourceExtension "GL_EXT_mesh_shader"
6478 OpName %main "main"
6479 OpName %gl_MeshPerPrimitiveEXT "gl_MeshPerPrimitiveEXT"
6480 OpMemberName %gl_MeshPerPrimitiveEXT 0 "gl_PrimitiveShadingRateEXT"
6481 OpName %gl_MeshPrimitivesEXT "gl_MeshPrimitivesEXT"
6482 OpDecorate %gl_MeshPerPrimitiveEXT Block
6483 OpMemberDecorate %gl_MeshPerPrimitiveEXT 0 BuiltIn PrimitiveShadingRateKHR
6484 OpMemberDecorate %gl_MeshPerPrimitiveEXT 0 PerPrimitiveEXT
6485 %void = OpTypeVoid
6486 %3 = OpTypeFunction %void
6487 %uint = OpTypeInt 32 0
6488 %uint_32 = OpConstant %uint 32
6489 %uint_1 = OpConstant %uint 1
6490 %int = OpTypeInt 32 1
6491 %bool = OpTypeBool
6492 %gl_MeshPerPrimitiveEXT = OpTypeStruct %int
6493 %_arr_gl_MeshPerPrimitiveEXT_uint_32 = OpTypeArray %gl_MeshPerPrimitiveEXT %uint_32
6494 %_ptr_Output__arr_gl_MeshPerPrimitiveEXT_uint_32 = OpTypePointer Output %_arr_gl_MeshPerPrimitiveEXT_uint_32
6495 %gl_MeshPrimitivesEXT = OpVariable %_ptr_Output__arr_gl_MeshPerPrimitiveEXT_uint_32 Output
6496 %main = OpFunction %void None %3
6497 %5 = OpLabel
6498 OpReturn
6499 OpFunctionEnd
6500 )";
6501
6502 CompileSuccessfully(text, SPV_ENV_VULKAN_1_3);
6503 EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_3));
6504 }
6505
6506 TEST_F(ValidateBuiltIns,
6507 VulkanBuiltinPrimitiveShadingRateKHRInArrayOfIntMeshEXT) {
6508 const std::string text = R"(
6509 OpCapability FragmentShadingRateKHR
6510 OpCapability MeshShadingEXT
6511 OpExtension "SPV_EXT_mesh_shader"
6512 OpExtension "SPV_KHR_fragment_shading_rate"
6513 %1 = OpExtInstImport "GLSL.std.450"
6514 OpMemoryModel Logical GLSL450
6515 OpEntryPoint MeshEXT %main "main" %gl_PrimitiveShadingRateEXT
6516 OpExecutionModeId %main LocalSizeId %uint_32 %uint_1 %uint_1
6517 OpExecutionMode %main OutputVertices 81
6518 OpExecutionMode %main OutputPrimitivesEXT 32
6519 OpExecutionMode %main OutputTrianglesEXT
6520 OpSource GLSL 450
6521 OpSourceExtension "GL_EXT_mesh_shader"
6522 OpName %main "main"
6523 OpName %gl_PrimitiveShadingRateEXT "gl_PrimitiveShadingRateEXT"
6524 OpDecorate %gl_PrimitiveShadingRateEXT BuiltIn PrimitiveShadingRateKHR
6525 OpDecorate %gl_PrimitiveShadingRateEXT PerPrimitiveEXT
6526 %void = OpTypeVoid
6527 %3 = OpTypeFunction %void
6528 %uint = OpTypeInt 32 0
6529 %int = OpTypeInt 32 1
6530 %uint_32 = OpConstant %uint 32
6531 %uint_1 = OpConstant %uint 1
6532 %uint_0 = OpConstant %uint 0
6533 %int_0 = OpConstant %int 0
6534 %bool = OpTypeBool
6535 %_arr_gl_PrimitiveShadingRateEXT_uint_32 = OpTypeArray %int %uint_32
6536 %_ptr_Output__arr_gl_PrimitiveShadingRateEXT_uint_32 = OpTypePointer Output %_arr_gl_PrimitiveShadingRateEXT_uint_32
6537 %gl_PrimitiveShadingRateEXT = OpVariable %_ptr_Output__arr_gl_PrimitiveShadingRateEXT_uint_32 Output
6538 %uint_ptr = OpTypePointer Output %int
6539 %main = OpFunction %void None %3
6540 %5 = OpLabel
6541 %21 = OpAccessChain %uint_ptr %gl_PrimitiveShadingRateEXT %uint_0
6542 OpStore %21 %int_0
6543 OpReturn
6544 OpFunctionEnd
6545 )";
6546
6547 CompileSuccessfully(text, SPV_ENV_VULKAN_1_3);
6548 EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_3));
6549 }
6550
6551 TEST_F(ValidateBuiltIns,
6552 BadVulkanBuiltinPrimitiveShadingRateKHRInArrayTypeMeshEXT) {
6553 const std::string text = R"(
6554 OpCapability FragmentShadingRateKHR
6555 OpCapability MeshShadingEXT
6556 OpExtension "SPV_EXT_mesh_shader"
6557 OpExtension "SPV_KHR_fragment_shading_rate"
6558 %1 = OpExtInstImport "GLSL.std.450"
6559 OpMemoryModel Logical GLSL450
6560 OpEntryPoint MeshEXT %main "main" %gl_PrimitiveShadingRateEXT
6561 OpExecutionModeId %main LocalSizeId %uint_32 %uint_1 %uint_1
6562 OpExecutionMode %main OutputVertices 81
6563 OpExecutionMode %main OutputPrimitivesEXT 32
6564 OpExecutionMode %main OutputTrianglesEXT
6565 OpSource GLSL 450
6566 OpSourceExtension "GL_EXT_mesh_shader"
6567 OpName %main "main"
6568 OpName %gl_PrimitiveShadingRateEXT "gl_PrimitiveShadingRateEXT"
6569 OpDecorate %gl_PrimitiveShadingRateEXT BuiltIn PrimitiveShadingRateKHR
6570 OpDecorate %gl_PrimitiveShadingRateEXT PerPrimitiveEXT
6571 %void = OpTypeVoid
6572 %3 = OpTypeFunction %void
6573 %uint = OpTypeInt 32 0
6574 %uint_32 = OpConstant %uint 32
6575 %uint_1 = OpConstant %uint 1
6576 %int = OpTypeInt 32 1
6577 %bool = OpTypeBool
6578 %_arr_gl_PrimitiveShadingRateEXT_uint_32 = OpTypeArray %bool %uint_32
6579 %_ptr_Output__arr_gl_PrimitiveShadingRateEXT_uint_32 = OpTypePointer Output %_arr_gl_PrimitiveShadingRateEXT_uint_32
6580 %gl_PrimitiveShadingRateEXT = OpVariable %_ptr_Output__arr_gl_PrimitiveShadingRateEXT_uint_32 Output
6581 %main = OpFunction %void None %3
6582 %5 = OpLabel
6583 %ref_load = OpLoad %_arr_gl_PrimitiveShadingRateEXT_uint_32 %gl_PrimitiveShadingRateEXT
6584 OpReturn
6585 OpFunctionEnd
6586 )";
6587
6588 CompileSuccessfully(text, SPV_ENV_VULKAN_1_3);
6589 EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_3));
6590 EXPECT_THAT(
6591 getDiagnosticString(),
6592 AnyVUID("VUID-PrimitiveShadingRateKHR-PrimitiveShadingRateKHR-10598"));
6593 }
6594
6595 TEST_F(ValidateBuiltIns,
6596 BadVulkanBuiltinPrimitiveShadingRateKHRInBlockTypeMeshEXT) {
6597 const std::string text = R"(
6598 OpCapability FragmentShadingRateKHR
6599 OpCapability MeshShadingEXT
6600 OpExtension "SPV_EXT_mesh_shader"
6601 OpExtension "SPV_KHR_fragment_shading_rate"
6602 %1 = OpExtInstImport "GLSL.std.450"
6603 OpMemoryModel Logical GLSL450
6604 OpEntryPoint MeshEXT %main "main" %gl_MeshPrimitivesEXT
6605 OpExecutionModeId %main LocalSizeId %uint_32 %uint_1 %uint_1
6606 OpExecutionMode %main OutputVertices 81
6607 OpExecutionMode %main OutputPrimitivesEXT 32
6608 OpExecutionMode %main OutputTrianglesEXT
6609 OpSource GLSL 450
6610 OpSourceExtension "GL_EXT_mesh_shader"
6611 OpName %main "main"
6612 OpName %gl_MeshPerPrimitiveEXT "gl_MeshPerPrimitiveEXT"
6613 OpMemberName %gl_MeshPerPrimitiveEXT 0 "gl_PrimitiveShadingRateEXT"
6614 OpName %gl_MeshPrimitivesEXT "gl_MeshPrimitivesEXT"
6615 OpDecorate %gl_MeshPerPrimitiveEXT Block
6616 OpMemberDecorate %gl_MeshPerPrimitiveEXT 0 BuiltIn PrimitiveShadingRateKHR
6617 OpMemberDecorate %gl_MeshPerPrimitiveEXT 0 PerPrimitiveEXT
6618 %void = OpTypeVoid
6619 %3 = OpTypeFunction %void
6620 %uint = OpTypeInt 32 0
6621 %uint_32 = OpConstant %uint 32
6622 %uint_1 = OpConstant %uint 1
6623 %int = OpTypeInt 32 1
6624 %bool = OpTypeBool
6625 %gl_MeshPerPrimitiveEXT = OpTypeStruct %bool
6626 %_arr_gl_MeshPerPrimitiveEXT_uint_32 = OpTypeArray %gl_MeshPerPrimitiveEXT %uint_32
6627 %_ptr_Output__arr_gl_MeshPerPrimitiveEXT_uint_32 = OpTypePointer Output %_arr_gl_MeshPerPrimitiveEXT_uint_32
6628 %gl_MeshPrimitivesEXT = OpVariable %_ptr_Output__arr_gl_MeshPerPrimitiveEXT_uint_32 Output
6629 %main = OpFunction %void None %3
6630 %5 = OpLabel
6631 %ref_load = OpLoad %_arr_gl_MeshPerPrimitiveEXT_uint_32 %gl_MeshPrimitivesEXT
6632 OpReturn
6633 OpFunctionEnd
6634 )";
6635
6636 CompileSuccessfully(text, SPV_ENV_VULKAN_1_3);
6637 EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_3));
6638 EXPECT_THAT(
6639 getDiagnosticString(),
6640 AnyVUID("VUID-PrimitiveShadingRateKHR-PrimitiveShadingRateKHR-10598"));
6641 }
6642
6643 TEST_F(ValidateBuiltIns,
6644 BadVulkanBuiltinPrimitiveShadingRateKHRInBlockSizeMeshEXT) {
6645 const std::string text = R"(
6646 OpCapability FragmentShadingRateKHR
6647 OpCapability MeshShadingEXT
6648 OpExtension "SPV_EXT_mesh_shader"
6649 OpExtension "SPV_KHR_fragment_shading_rate"
6650 %1 = OpExtInstImport "GLSL.std.450"
6651 OpMemoryModel Logical GLSL450
6652 OpEntryPoint MeshEXT %main "main" %gl_MeshPrimitivesEXT
6653 OpExecutionModeId %main LocalSizeId %uint_32 %uint_1 %uint_1
6654 OpExecutionMode %main OutputVertices 81
6655 OpExecutionMode %main OutputPrimitivesEXT 16
6656 OpExecutionMode %main OutputTrianglesEXT
6657 OpSource GLSL 450
6658 OpSourceExtension "GL_EXT_mesh_shader"
6659 OpName %main "main"
6660 OpName %gl_MeshPerPrimitiveEXT "gl_MeshPerPrimitiveEXT"
6661 OpMemberName %gl_MeshPerPrimitiveEXT 0 "gl_PrimitiveShadingRateEXT"
6662 OpName %gl_MeshPrimitivesEXT "gl_MeshPrimitivesEXT"
6663 OpDecorate %gl_MeshPerPrimitiveEXT Block
6664 OpMemberDecorate %gl_MeshPerPrimitiveEXT 0 BuiltIn PrimitiveShadingRateKHR
6665 OpMemberDecorate %gl_MeshPerPrimitiveEXT 0 PerPrimitiveEXT
6666 %void = OpTypeVoid
6667 %3 = OpTypeFunction %void
6668 %uint = OpTypeInt 32 0
6669 %uint_32 = OpConstant %uint 32
6670 %uint_1 = OpConstant %uint 1
6671 %int = OpTypeInt 32 1
6672 %bool = OpTypeBool
6673 %gl_MeshPerPrimitiveEXT = OpTypeStruct %int
6674 %_arr_gl_MeshPerPrimitiveEXT_uint_32 = OpTypeArray %gl_MeshPerPrimitiveEXT %uint_32
6675 %_ptr_Output__arr_gl_MeshPerPrimitiveEXT_uint_32 = OpTypePointer Output %_arr_gl_MeshPerPrimitiveEXT_uint_32
6676 %gl_MeshPrimitivesEXT = OpVariable %_ptr_Output__arr_gl_MeshPerPrimitiveEXT_uint_32 Output
6677 %main = OpFunction %void None %3
6678 %5 = OpLabel
6679 %ref_load = OpLoad %_arr_gl_MeshPerPrimitiveEXT_uint_32 %gl_MeshPrimitivesEXT
6680 OpReturn
6681 OpFunctionEnd
6682 )";
6683
6684 CompileSuccessfully(text, SPV_ENV_VULKAN_1_3);
6685 EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_3));
6686 EXPECT_THAT(
6687 getDiagnosticString(),
6688 AnyVUID("VUID-PrimitiveShadingRateKHR-PrimitiveShadingRateKHR-10600"));
6689 }
6690
6691 TEST_F(ValidateBuiltIns,
6692 BadVulkanBuiltinPrimitiveShadingRateKHRInArraySizeMeshEXT) {
6693 const std::string text = R"(
6694 OpCapability FragmentShadingRateKHR
6695 OpCapability MeshShadingEXT
6696 OpExtension "SPV_EXT_mesh_shader"
6697 OpExtension "SPV_KHR_fragment_shading_rate"
6698 %1 = OpExtInstImport "GLSL.std.450"
6699 OpMemoryModel Logical GLSL450
6700 OpEntryPoint MeshEXT %main "main" %gl_PrimitiveShadingRateEXT
6701 OpExecutionModeId %main LocalSizeId %uint_32 %uint_1 %uint_1
6702 OpExecutionMode %main OutputVertices 81
6703 OpExecutionMode %main OutputPrimitivesEXT 16
6704 OpExecutionMode %main OutputTrianglesEXT
6705 OpSource GLSL 450
6706 OpSourceExtension "GL_EXT_mesh_shader"
6707 OpName %main "main"
6708 OpName %gl_PrimitiveShadingRateEXT "gl_PrimitiveShadingRateEXT"
6709 OpDecorate %gl_PrimitiveShadingRateEXT BuiltIn PrimitiveShadingRateKHR
6710 OpDecorate %gl_PrimitiveShadingRateEXT PerPrimitiveEXT
6711 %void = OpTypeVoid
6712 %3 = OpTypeFunction %void
6713 %uint = OpTypeInt 32 0
6714 %uint_32 = OpConstant %uint 32
6715 %uint_1 = OpConstant %uint 1
6716 %int = OpTypeInt 32 1
6717 %bool = OpTypeBool
6718 %_arr_gl_PrimitiveShadingRateEXT_uint_32 = OpTypeArray %int %uint_32
6719 %_ptr_Output__arr_gl_PrimitiveShadingRateEXT_uint_32 = OpTypePointer Output %_arr_gl_PrimitiveShadingRateEXT_uint_32
6720 %gl_PrimitiveShadingRateEXT = OpVariable %_ptr_Output__arr_gl_PrimitiveShadingRateEXT_uint_32 Output
6721 %main = OpFunction %void None %3
6722 %5 = OpLabel
6723 %ref_load = OpLoad %_arr_gl_PrimitiveShadingRateEXT_uint_32 %gl_PrimitiveShadingRateEXT
6724 OpReturn
6725 OpFunctionEnd
6726 )";
6727
6728 CompileSuccessfully(text, SPV_ENV_VULKAN_1_3);
6729 EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_3));
6730 EXPECT_THAT(
6731 getDiagnosticString(),
6732 AnyVUID("VUID-PrimitiveShadingRateKHR-PrimitiveShadingRateKHR-10599"));
6733 }
6734
6735 TEST_F(ValidateBuiltIns, VulkanBuiltinViewportIndexInBlockMeshEXT) {
6736 const std::string text = R"(
6737 OpCapability MeshShadingEXT
6738 OpExtension "SPV_EXT_mesh_shader"
6739 %1 = OpExtInstImport "GLSL.std.450"
6740 OpMemoryModel Logical GLSL450
6741 OpEntryPoint MeshEXT %main "main" %gl_MeshPrimitivesEXT
6742 OpExecutionModeId %main LocalSizeId %uint_32 %uint_1 %uint_1
6743 OpExecutionMode %main OutputVertices 81
6744 OpExecutionMode %main OutputPrimitivesEXT 32
6745 OpExecutionMode %main OutputTrianglesEXT
6746 OpSource GLSL 450
6747 OpSourceExtension "GL_EXT_mesh_shader"
6748 OpName %main "main"
6749 OpName %gl_MeshPerPrimitiveEXT "gl_MeshPerPrimitiveEXT"
6750 OpMemberName %gl_MeshPerPrimitiveEXT 0 "gl_ViewportIndex"
6751 OpName %gl_MeshPrimitivesEXT "gl_MeshPrimitivesEXT"
6752 OpDecorate %gl_MeshPerPrimitiveEXT Block
6753 OpMemberDecorate %gl_MeshPerPrimitiveEXT 0 BuiltIn ViewportIndex
6754 OpMemberDecorate %gl_MeshPerPrimitiveEXT 0 PerPrimitiveEXT
6755 %void = OpTypeVoid
6756 %3 = OpTypeFunction %void
6757 %uint = OpTypeInt 32 0
6758 %uint_32 = OpConstant %uint 32
6759 %uint_1 = OpConstant %uint 1
6760 %int = OpTypeInt 32 1
6761 %bool = OpTypeBool
6762 %gl_MeshPerPrimitiveEXT = OpTypeStruct %int
6763 %_arr_gl_MeshPerPrimitiveEXT_uint_32 = OpTypeArray %gl_MeshPerPrimitiveEXT %uint_32
6764 %_ptr_Output__arr_gl_MeshPerPrimitiveEXT_uint_32 = OpTypePointer Output %_arr_gl_MeshPerPrimitiveEXT_uint_32
6765 %gl_MeshPrimitivesEXT = OpVariable %_ptr_Output__arr_gl_MeshPerPrimitiveEXT_uint_32 Output
6766 %main = OpFunction %void None %3
6767 %5 = OpLabel
6768 OpReturn
6769 OpFunctionEnd
6770 )";
6771
6772 CompileSuccessfully(text, SPV_ENV_VULKAN_1_3);
6773 EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_3));
6774 }
6775
6776 TEST_F(ValidateBuiltIns, VulkanBuiltinViewportIndexAsArrayOfIntMeshEXT) {
6777 const std::string text = R"(
6778 OpCapability MeshShadingEXT
6779 OpExtension "SPV_EXT_mesh_shader"
6780 %1 = OpExtInstImport "GLSL.std.450"
6781 OpMemoryModel Logical GLSL450
6782 OpEntryPoint MeshEXT %main "main" %gl_ViewportIndex
6783 OpExecutionModeId %main LocalSizeId %uint_32 %uint_1 %uint_1
6784 OpExecutionMode %main OutputVertices 81
6785 OpExecutionMode %main OutputPrimitivesEXT 32
6786 OpExecutionMode %main OutputTrianglesEXT
6787 OpSource GLSL 450
6788 OpSourceExtension "GL_EXT_mesh_shader"
6789 OpName %main "main"
6790 OpName %gl_ViewportIndex "gl_ViewportIndex"
6791 OpDecorate %gl_ViewportIndex BuiltIn ViewportIndex
6792 OpDecorate %gl_ViewportIndex PerPrimitiveEXT
6793 %void = OpTypeVoid
6794 %3 = OpTypeFunction %void
6795 %uint = OpTypeInt 32 0
6796 %uint_32 = OpConstant %uint 32
6797 %uint_1 = OpConstant %uint 1
6798 %int = OpTypeInt 32 1
6799 %bool = OpTypeBool
6800 %_arr_gl_ViewportIndex_uint_32 = OpTypeArray %int %uint_32
6801 %_ptr_Output__arr_gl_ViewportIndex_uint_32 = OpTypePointer Output %_arr_gl_ViewportIndex_uint_32
6802 %gl_ViewportIndex = OpVariable %_ptr_Output__arr_gl_ViewportIndex_uint_32 Output
6803 %main = OpFunction %void None %3
6804 %5 = OpLabel
6805 OpReturn
6806 OpFunctionEnd
6807 )";
6808
6809 CompileSuccessfully(text, SPV_ENV_VULKAN_1_3);
6810 EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_3));
6811 }
6812
6813 TEST_F(ValidateBuiltIns, BadVulkanBuiltinViewportIndexInBlockTypeMeshEXT) {
6814 const std::string text = R"(
6815 OpCapability MeshShadingEXT
6816 OpExtension "SPV_EXT_mesh_shader"
6817 %1 = OpExtInstImport "GLSL.std.450"
6818 OpMemoryModel Logical GLSL450
6819 OpEntryPoint MeshEXT %main "main" %gl_MeshPrimitivesEXT
6820 OpExecutionModeId %main LocalSizeId %uint_32 %uint_1 %uint_1
6821 OpExecutionMode %main OutputVertices 81
6822 OpExecutionMode %main OutputPrimitivesEXT 32
6823 OpExecutionMode %main OutputTrianglesEXT
6824 OpSource GLSL 450
6825 OpSourceExtension "GL_EXT_mesh_shader"
6826 OpName %main "main"
6827 OpName %gl_MeshPerPrimitiveEXT "gl_MeshPerPrimitiveEXT"
6828 OpMemberName %gl_MeshPerPrimitiveEXT 0 "gl_ViewportIndex"
6829 OpName %gl_MeshPrimitivesEXT "gl_MeshPrimitivesEXT"
6830 OpDecorate %gl_MeshPerPrimitiveEXT Block
6831 OpMemberDecorate %gl_MeshPerPrimitiveEXT 0 BuiltIn ViewportIndex
6832 OpMemberDecorate %gl_MeshPerPrimitiveEXT 0 PerPrimitiveEXT
6833 %void = OpTypeVoid
6834 %3 = OpTypeFunction %void
6835 %uint = OpTypeInt 32 0
6836 %uint_32 = OpConstant %uint 32
6837 %uint_1 = OpConstant %uint 1
6838 %int = OpTypeInt 32 1
6839 %bool = OpTypeBool
6840 %gl_MeshPerPrimitiveEXT = OpTypeStruct %bool
6841 %_arr_gl_MeshPerPrimitiveEXT_uint_32 = OpTypeArray %gl_MeshPerPrimitiveEXT %uint_32
6842 %_ptr_Output__arr_gl_MeshPerPrimitiveEXT_uint_32 = OpTypePointer Output %_arr_gl_MeshPerPrimitiveEXT_uint_32
6843 %gl_MeshPrimitivesEXT = OpVariable %_ptr_Output__arr_gl_MeshPerPrimitiveEXT_uint_32 Output
6844 %main = OpFunction %void None %3
6845 %5 = OpLabel
6846 %ref_load = OpLoad %_arr_gl_MeshPerPrimitiveEXT_uint_32 %gl_MeshPrimitivesEXT
6847 OpReturn
6848 OpFunctionEnd
6849 )";
6850
6851 CompileSuccessfully(text, SPV_ENV_VULKAN_1_3);
6852 EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_3));
6853 EXPECT_THAT(getDiagnosticString(),
6854 AnyVUID("VUID-ViewportIndex-ViewportIndex-10601"));
6855 }
6856
6857 TEST_F(ValidateBuiltIns, BadVulkanBuiltinViewportIndexAsArrayTypeMeshEXT) {
6858 const std::string text = R"(
6859 OpCapability MeshShadingEXT
6860 OpExtension "SPV_EXT_mesh_shader"
6861 %1 = OpExtInstImport "GLSL.std.450"
6862 OpMemoryModel Logical GLSL450
6863 OpEntryPoint MeshEXT %main "main" %gl_ViewportIndex
6864 OpExecutionModeId %main LocalSizeId %uint_32 %uint_1 %uint_1
6865 OpExecutionMode %main OutputVertices 81
6866 OpExecutionMode %main OutputPrimitivesEXT 32
6867 OpExecutionMode %main OutputTrianglesEXT
6868 OpSource GLSL 450
6869 OpSourceExtension "GL_EXT_mesh_shader"
6870 OpName %main "main"
6871 OpName %gl_ViewportIndex "gl_ViewportIndex"
6872 OpDecorate %gl_ViewportIndex BuiltIn ViewportIndex
6873 OpDecorate %gl_ViewportIndex PerPrimitiveEXT
6874 %void = OpTypeVoid
6875 %3 = OpTypeFunction %void
6876 %uint = OpTypeInt 32 0
6877 %uint_32 = OpConstant %uint 32
6878 %uint_1 = OpConstant %uint 1
6879 %int = OpTypeInt 32 1
6880 %bool = OpTypeBool
6881 %_arr_gl_ViewportIndex_uint_32 = OpTypeArray %bool %uint_32
6882 %_ptr_Output__arr_gl_ViewportIndex_uint_32 = OpTypePointer Output %_arr_gl_ViewportIndex_uint_32
6883 %gl_ViewportIndex = OpVariable %_ptr_Output__arr_gl_ViewportIndex_uint_32 Output
6884 %main = OpFunction %void None %3
6885 %5 = OpLabel
6886 %ref_load = OpLoad %_arr_gl_ViewportIndex_uint_32 %gl_ViewportIndex
6887 OpReturn
6888 OpFunctionEnd
6889 )";
6890
6891 CompileSuccessfully(text, SPV_ENV_VULKAN_1_3);
6892 EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_3));
6893 EXPECT_THAT(getDiagnosticString(),
6894 AnyVUID("VUID-ViewportIndex-ViewportIndex-10601"));
6895 }
6896
6897 TEST_F(ValidateBuiltIns, BadVulkanBuiltinViewportIndexInBlockArraySizeMeshEXT) {
6898 const std::string text = R"(
6899 OpCapability MeshShadingEXT
6900 OpExtension "SPV_EXT_mesh_shader"
6901 %1 = OpExtInstImport "GLSL.std.450"
6902 OpMemoryModel Logical GLSL450
6903 OpEntryPoint MeshEXT %main "main" %gl_MeshPrimitivesEXT
6904 OpExecutionModeId %main LocalSizeId %uint_32 %uint_1 %uint_1
6905 OpExecutionMode %main OutputVertices 81
6906 OpExecutionMode %main OutputPrimitivesEXT 16
6907 OpExecutionMode %main OutputTrianglesEXT
6908 OpSource GLSL 450
6909 OpSourceExtension "GL_EXT_mesh_shader"
6910 OpName %main "main"
6911 OpName %gl_MeshPerPrimitiveEXT "gl_MeshPerPrimitiveEXT"
6912 OpMemberName %gl_MeshPerPrimitiveEXT 0 "gl_ViewportIndex"
6913 OpName %gl_MeshPrimitivesEXT "gl_MeshPrimitivesEXT"
6914 OpDecorate %gl_MeshPerPrimitiveEXT Block
6915 OpMemberDecorate %gl_MeshPerPrimitiveEXT 0 BuiltIn ViewportIndex
6916 OpMemberDecorate %gl_MeshPerPrimitiveEXT 0 PerPrimitiveEXT
6917 %void = OpTypeVoid
6918 %3 = OpTypeFunction %void
6919 %uint = OpTypeInt 32 0
6920 %uint_32 = OpConstant %uint 32
6921 %uint_1 = OpConstant %uint 1
6922 %int = OpTypeInt 32 1
6923 %bool = OpTypeBool
6924 %gl_MeshPerPrimitiveEXT = OpTypeStruct %int
6925 %_arr_gl_MeshPerPrimitiveEXT_uint_32 = OpTypeArray %gl_MeshPerPrimitiveEXT %uint_32
6926 %_ptr_Output__arr_gl_MeshPerPrimitiveEXT_uint_32 = OpTypePointer Output %_arr_gl_MeshPerPrimitiveEXT_uint_32
6927 %gl_MeshPrimitivesEXT = OpVariable %_ptr_Output__arr_gl_MeshPerPrimitiveEXT_uint_32 Output
6928 %main = OpFunction %void None %3
6929 %5 = OpLabel
6930 %ref_load = OpLoad %_arr_gl_MeshPerPrimitiveEXT_uint_32 %gl_MeshPrimitivesEXT
6931 OpReturn
6932 OpFunctionEnd
6933 )";
6934
6935 CompileSuccessfully(text, SPV_ENV_VULKAN_1_3);
6936 EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_3));
6937 EXPECT_THAT(getDiagnosticString(),
6938 AnyVUID("VUID-ViewportIndex-ViewportIndex-10603"));
6939 }
6940
6941 TEST_F(ValidateBuiltIns, BadVulkanBuiltinViewportIndexAsArrayOfIntSizeMeshEXT) {
6942 const std::string text = R"(
6943 OpCapability MeshShadingEXT
6944 OpExtension "SPV_EXT_mesh_shader"
6945 %1 = OpExtInstImport "GLSL.std.450"
6946 OpMemoryModel Logical GLSL450
6947 OpEntryPoint MeshEXT %main "main" %gl_ViewportIndex
6948 OpExecutionModeId %main LocalSizeId %uint_32 %uint_1 %uint_1
6949 OpExecutionMode %main OutputVertices 81
6950 OpExecutionMode %main OutputPrimitivesEXT 16
6951 OpExecutionMode %main OutputTrianglesEXT
6952 OpSource GLSL 450
6953 OpSourceExtension "GL_EXT_mesh_shader"
6954 OpName %main "main"
6955 OpName %gl_ViewportIndex "gl_ViewportIndex"
6956 OpDecorate %gl_ViewportIndex BuiltIn ViewportIndex
6957 OpDecorate %gl_ViewportIndex PerPrimitiveEXT
6958 %void = OpTypeVoid
6959 %3 = OpTypeFunction %void
6960 %uint = OpTypeInt 32 0
6961 %uint_32 = OpConstant %uint 32
6962 %uint_1 = OpConstant %uint 1
6963 %int = OpTypeInt 32 1
6964 %bool = OpTypeBool
6965 %_arr_gl_ViewportIndex_uint_32 = OpTypeArray %int %uint_32
6966 %_ptr_Output__arr_gl_ViewportIndex_uint_32 = OpTypePointer Output %_arr_gl_ViewportIndex_uint_32
6967 %gl_ViewportIndex = OpVariable %_ptr_Output__arr_gl_ViewportIndex_uint_32 Output
6968 %main = OpFunction %void None %3
6969 %5 = OpLabel
6970 %ref_load = OpLoad %_arr_gl_ViewportIndex_uint_32 %gl_ViewportIndex
6971 OpReturn
6972 OpFunctionEnd
6973 )";
6974
6975 CompileSuccessfully(text, SPV_ENV_VULKAN_1_3);
6976 EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_3));
6977 EXPECT_THAT(getDiagnosticString(),
6978 AnyVUID("VUID-ViewportIndex-ViewportIndex-10602"));
6979 }
6980
6981 TEST_F(ValidateBuiltIns, BadVulkanBuiltinPrimitiveIdFragmentWithRayTracing) {
6982 const std::string text = R"(
6983 OpCapability Shader
6984 OpCapability RayTracingKHR
6985 OpExtension "SPV_KHR_ray_tracing"
6986 OpMemoryModel Logical GLSL450
6987 OpEntryPoint Fragment %main "main" %outVar %gl_PrimitiveID
6988 OpExecutionMode %main OriginUpperLeft
6989 OpDecorate %outVar Location 0
6990 OpDecorate %gl_PrimitiveID BuiltIn PrimitiveId
6991 OpDecorate %gl_PrimitiveID Flat
6992 %void = OpTypeVoid
6993 %4 = OpTypeFunction %void
6994 %int = OpTypeInt 32 1
6995 %v4int = OpTypeVector %int 4
6996 %ptrOut = OpTypePointer Output %v4int
6997 %outVar = OpVariable %ptrOut Output
6998 %ptrIn = OpTypePointer Input %int
6999 %gl_PrimitiveID = OpVariable %ptrIn Input
7000 %main = OpFunction %void None %4
7001 %6 = OpLabel
7002 %13 = OpLoad %int %gl_PrimitiveID
7003 %14 = OpCompositeConstruct %v4int %13 %13 %13 %13
7004 OpStore %outVar %14
7005 OpReturn
7006 OpFunctionEnd
7007 )";
7008
7009 CompileSuccessfully(text, SPV_ENV_VULKAN_1_3);
7010 EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_3));
7011 EXPECT_THAT(getDiagnosticString(),
7012 AnyVUID("VUID-PrimitiveId-Fragment-04333"));
7013 }
7014
7015 TEST_F(ValidateBuiltIns, TessellationMissingPatch) {
7016 const std::string spirv = R"(
7017 OpCapability Tessellation
7018 OpMemoryModel Logical GLSL450
7019 OpEntryPoint TessellationControl %main "main" %gl_TessLevelInner %gl_TessLevelOuter
7020 OpExecutionMode %main OutputVertices 3
7021 OpDecorate %gl_TessLevelInner BuiltIn TessLevelInner
7022 OpDecorate %gl_TessLevelOuter BuiltIn TessLevelOuter
7023 OpDecorate %gl_TessLevelOuter Patch
7024 %void = OpTypeVoid
7025 %4 = OpTypeFunction %void
7026 %float = OpTypeFloat 32
7027 %uint = OpTypeInt 32 0
7028 %uint_2 = OpConstant %uint 2
7029 %_arr_float_uint_2 = OpTypeArray %float %uint_2
7030 %_ptr_Output__arr_float_uint_2 = OpTypePointer Output %_arr_float_uint_2
7031 %gl_TessLevelInner = OpVariable %_ptr_Output__arr_float_uint_2 Output
7032 %int = OpTypeInt 32 1
7033 %int_0 = OpConstant %int 0
7034 %float_1 = OpConstant %float 1
7035 %_ptr_Output_float = OpTypePointer Output %float
7036 %uint_4 = OpConstant %uint 4
7037 %_arr_float_uint_4 = OpTypeArray %float %uint_4
7038 %_ptr_Output__arr_float_uint_4 = OpTypePointer Output %_arr_float_uint_4
7039 %gl_TessLevelOuter = OpVariable %_ptr_Output__arr_float_uint_4 Output
7040 %main = OpFunction %void None %4
7041 %6 = OpLabel
7042 %17 = OpAccessChain %_ptr_Output_float %gl_TessLevelInner %int_0
7043 OpStore %17 %float_1
7044 %22 = OpAccessChain %_ptr_Output_float %gl_TessLevelOuter %int_0
7045 OpStore %22 %float_1
7046 OpReturn
7047 OpFunctionEnd
7048 )";
7049
7050 CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_0);
7051 EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0));
7052 EXPECT_THAT(getDiagnosticString(),
7053 HasSubstr("BuiltIn TessLevelInner variable needs to also have a "
7054 "Patch decoration"));
7055 EXPECT_THAT(getDiagnosticString(),
7056 AnyVUID("VUID-StandaloneSpirv-TessLevelInner-10880"));
7057 }
7058
7059 // From dEQP-VK.mesh_shader.ext.builtin.primitive_id_spirv
7060 TEST_F(ValidateBuiltIns, PrimitiveIdInFragmentWithMeshCapability) {
7061 const std::string spirv = R"(
7062 OpCapability Shader
7063 OpCapability MeshShadingEXT
7064 OpExtension "SPV_EXT_mesh_shader"
7065 %1 = OpExtInstImport "GLSL.std.450"
7066 OpMemoryModel Logical GLSL450
7067 OpEntryPoint Fragment %4 "main" %9 %gl_PrimitiveID
7068 OpExecutionMode %4 OriginUpperLeft
7069 OpDecorate %9 Location 0
7070 OpDecorate %gl_PrimitiveID Flat
7071 OpDecorate %gl_PrimitiveID BuiltIn PrimitiveId
7072 %void = OpTypeVoid
7073 %3 = OpTypeFunction %void
7074 %float = OpTypeFloat 32
7075 %v4float = OpTypeVector %float 4
7076 %_ptr_Output_v4float = OpTypePointer Output %v4float
7077 %9 = OpVariable %_ptr_Output_v4float Output
7078 %int = OpTypeInt 32 1
7079 %_ptr_Input_int = OpTypePointer Input %int
7080 %gl_PrimitiveID = OpVariable %_ptr_Input_int Input
7081 %int_1629198956 = OpConstant %int 1629198956
7082 %bool = OpTypeBool
7083 %float_0 = OpConstant %float 0
7084 %float_1 = OpConstant %float 1
7085 %19 = OpConstantComposite %v4float %float_0 %float_0 %float_1 %float_1
7086 %20 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_1
7087 %v4bool = OpTypeVector %bool 4
7088 %4 = OpFunction %void None %3
7089 %5 = OpLabel
7090 %13 = OpLoad %int %gl_PrimitiveID
7091 %16 = OpIEqual %bool %13 %int_1629198956
7092 %22 = OpCompositeConstruct %v4bool %16 %16 %16 %16
7093 %23 = OpSelect %v4float %22 %19 %20
7094 OpStore %9 %23
7095 OpReturn
7096 OpFunctionEnd
7097 )";
7098
7099 CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_3);
7100 EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_3));
7101 }
7102
7103 // https://github.com/KhronosGroup/SPIRV-Tools/issues/6237
7104 TEST_F(ValidateBuiltIns, MeshBuiltinUnsignedInt) {
7105 const std::string spirv = R"(
7106 OpCapability FragmentShadingRateKHR
7107 OpCapability MeshShadingEXT
7108 OpExtension "SPV_EXT_mesh_shader"
7109 OpExtension "SPV_KHR_fragment_shading_rate"
7110 OpMemoryModel Logical GLSL450
7111 OpEntryPoint MeshEXT %main "main" %gl_MeshPrimitivesEXT
7112 OpExecutionModeId %main LocalSizeId %uint_1 %uint_1 %uint_1
7113 OpExecutionMode %main OutputVertices 81
7114 OpExecutionMode %main OutputPrimitivesEXT 32
7115 OpExecutionMode %main OutputTrianglesEXT
7116 OpDecorate %gl_MeshPerPrimitiveEXT Block
7117 OpMemberDecorate %gl_MeshPerPrimitiveEXT 0 BuiltIn PrimitiveId
7118 OpMemberDecorate %gl_MeshPerPrimitiveEXT 0 PerPrimitiveEXT
7119 OpMemberDecorate %gl_MeshPerPrimitiveEXT 1 BuiltIn Layer
7120 OpMemberDecorate %gl_MeshPerPrimitiveEXT 1 PerPrimitiveEXT
7121 OpMemberDecorate %gl_MeshPerPrimitiveEXT 2 BuiltIn ViewportIndex
7122 OpMemberDecorate %gl_MeshPerPrimitiveEXT 2 PerPrimitiveEXT
7123 OpMemberDecorate %gl_MeshPerPrimitiveEXT 3 BuiltIn CullPrimitiveEXT
7124 OpMemberDecorate %gl_MeshPerPrimitiveEXT 3 PerPrimitiveEXT
7125 OpMemberDecorate %gl_MeshPerPrimitiveEXT 4 BuiltIn PrimitiveShadingRateKHR
7126 OpMemberDecorate %gl_MeshPerPrimitiveEXT 4 PerPrimitiveEXT
7127 %void = OpTypeVoid
7128 %4 = OpTypeFunction %void
7129 %uint = OpTypeInt 32 0
7130 %int = OpTypeInt 32 1
7131 %bool = OpTypeBool
7132 %int_0 = OpConstant %int 0
7133 %uint_0 = OpConstant %uint 0
7134 %uint_1 = OpConstant %uint 1
7135 %uint_2 = OpConstant %uint 2
7136 %uint_3 = OpConstant %uint 3
7137 %uint_4 = OpConstant %uint 4
7138 %uint_81 = OpConstant %uint 81
7139 %uint_32 = OpConstant %uint 32
7140 %gl_MeshPerPrimitiveEXT = OpTypeStruct %uint %uint %uint %bool %uint
7141 %_arr_gl_MeshPerPrimitiveEXT_uint_32 = OpTypeArray %gl_MeshPerPrimitiveEXT %uint_32
7142 %_ptr_Output__arr_gl_MeshPerPrimitiveEXT_uint_32 = OpTypePointer Output %_arr_gl_MeshPerPrimitiveEXT_uint_32
7143 %gl_MeshPrimitivesEXT = OpVariable %_ptr_Output__arr_gl_MeshPerPrimitiveEXT_uint_32 Output
7144 %_ptr_Output_uint = OpTypePointer Output %uint
7145 %main = OpFunction %void None %4
7146 %6 = OpLabel
7147 OpSetMeshOutputsEXT %uint_81 %uint_32
7148 %20 = OpAccessChain %_ptr_Output_uint %gl_MeshPrimitivesEXT %int_0 %uint_0
7149 OpStore %20 %uint_1
7150 %22 = OpAccessChain %_ptr_Output_uint %gl_MeshPrimitivesEXT %int_0 %uint_1
7151 OpStore %22 %uint_2
7152 %24 = OpAccessChain %_ptr_Output_uint %gl_MeshPrimitivesEXT %int_0 %uint_2
7153 OpStore %24 %uint_3
7154 %26 = OpAccessChain %_ptr_Output_uint %gl_MeshPrimitivesEXT %int_0 %uint_4
7155 OpStore %26 %uint_4
7156 OpReturn
7157 OpFunctionEnd
7158 )";
7159
7160 CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_3);
7161 EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_3));
7162 }
7163
7164 } // namespace
7165 } // namespace val
7166 } // namespace spvtools