Skip to content

Commit 58dc0b3

Browse files
authored
Add the VUID-StandaloneSpirv-OpControlBarrierArriveEXT-13553 check (KhronosGroup#6782)
Add the VUID-StandaloneSpirv-OpControlBarrierArriveEXT-13553 check (KhronosGroup#6771)
1 parent 6ab70dc commit 58dc0b3

3 files changed

Lines changed: 73 additions & 0 deletions

File tree

source/val/validate_scopes.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,15 @@ spv_result_t ValidateExecutionScope(ValidationState_t& _,
139139
});
140140
}
141141

142+
if (opcode == spv::Op::OpControlBarrierArriveEXT ||
143+
opcode == spv::Op::OpControlBarrierWaitEXT) {
144+
if (value != spv::Scope::Workgroup && value != spv::Scope::Subgroup) {
145+
return _.diag(SPV_ERROR_INVALID_DATA, inst)
146+
<< _.VkErrorID(13553)
147+
<< "The execution Scope for OpControlBarrierArriveEXT and "
148+
"OpControlBarrierWaitEXT must be Workgroup or Subgroup";
149+
}
150+
}
142151
// Only subset of execution models support Workgroup.
143152
if (value == spv::Scope::Workgroup) {
144153
std::string errorVUID = _.VkErrorID(4637);

source/val/validation_state.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3515,6 +3515,8 @@ std::string ValidationState_t::VkErrorID(uint32_t id,
35153515
return VUID_WRAP(VUID-StandaloneSpirv-MemorySemantics-13551);
35163516
case 13552:
35173517
return VUID_WRAP(VUID-StandaloneSpirv-SplitBarrierEXT-13552);
3518+
case 13553:
3519+
return VUID_WRAP(VUID-StandaloneSpirv-OpControlBarrierArriveEXT-13553);
35183520
case 13556:
35193521
return VUID_WRAP(VUID-StandaloneSpirv-MemorySemantics-13556);
35203522
case 13557:

test/val/val_barriers_test.cpp

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,6 +1365,68 @@ OpControlBarrierWaitEXT %workgroup %workgroup %acquire_workgroup_memory
13651365
"any stage other than GLCompute or Kernel."));
13661366
}
13671367

1368+
TEST_F(ValidateBarriers, OpControlBarrierArriveExecutionScope) {
1369+
const std::string body = R"(
1370+
OpControlBarrierArriveEXT %device %workgroup %release_workgroup_memory
1371+
OpControlBarrierWaitEXT %workgroup %workgroup %acquire_workgroup_memory
1372+
)";
1373+
1374+
CompileSuccessfully(GenerateShaderCodeImpl(body,
1375+
// capabilities_and_extensions
1376+
R"(
1377+
OpCapability VulkanMemoryModelKHR
1378+
OpCapability SplitBarrierEXT
1379+
OpExtension "SPV_KHR_vulkan_memory_model"
1380+
OpExtension "SPV_EXT_split_barrier"
1381+
)",
1382+
// definitions
1383+
"",
1384+
// execution_model
1385+
"GLCompute",
1386+
// memory_model
1387+
"OpMemoryModel Logical VulkanKHR"),
1388+
SPV_ENV_VULKAN_1_1);
1389+
1390+
ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_1));
1391+
EXPECT_THAT(getDiagnosticString(),
1392+
AnyVUID("VUID-StandaloneSpirv-OpControlBarrierArriveEXT-13553"));
1393+
EXPECT_THAT(
1394+
getDiagnosticString(),
1395+
HasSubstr("The execution Scope for OpControlBarrierArriveEXT and "
1396+
"OpControlBarrierWaitEXT must be Workgroup or Subgroup"));
1397+
}
1398+
1399+
TEST_F(ValidateBarriers, OpControlBarrierWaitExecutionScope) {
1400+
const std::string body = R"(
1401+
OpControlBarrierArriveEXT %workgroup %workgroup %release_workgroup_memory
1402+
OpControlBarrierWaitEXT %invocation %workgroup %acquire_workgroup_memory
1403+
)";
1404+
1405+
CompileSuccessfully(GenerateShaderCodeImpl(body,
1406+
// capabilities_and_extensions
1407+
R"(
1408+
OpCapability VulkanMemoryModelKHR
1409+
OpCapability SplitBarrierEXT
1410+
OpExtension "SPV_KHR_vulkan_memory_model"
1411+
OpExtension "SPV_EXT_split_barrier"
1412+
)",
1413+
// definitions
1414+
"",
1415+
// execution_model
1416+
"GLCompute",
1417+
// memory_model
1418+
"OpMemoryModel Logical VulkanKHR"),
1419+
SPV_ENV_VULKAN_1_1);
1420+
1421+
ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_1));
1422+
EXPECT_THAT(getDiagnosticString(),
1423+
AnyVUID("VUID-StandaloneSpirv-OpControlBarrierArriveEXT-13553"));
1424+
EXPECT_THAT(
1425+
getDiagnosticString(),
1426+
HasSubstr("The execution Scope for OpControlBarrierArriveEXT and "
1427+
"OpControlBarrierWaitEXT must be Workgroup or Subgroup"));
1428+
}
1429+
13681430
TEST_F(ValidateBarriers, OpControlBarrierArriveInvalidMemorySemantics) {
13691431
const std::string body = R"(
13701432
OpControlBarrierArriveEXT %workgroup %workgroup %acquire_release_workgroup

0 commit comments

Comments
 (0)