Update execution scope rules for WebGPU (#2730)
Fixes #2722
diff --git a/source/val/validate_scopes.cpp b/source/val/validate_scopes.cpp
index 791ada7..c607984 100644
--- a/source/val/validate_scopes.cpp
+++ b/source/val/validate_scopes.cpp
@@ -123,11 +123,11 @@
// WebGPU Specific rules
if (spvIsWebGPUEnv(_.context()->target_env)) {
// Scope for execution must be limited to Workgroup or Subgroup
- if (value != SpvScopeWorkgroup && value != SpvScopeSubgroup) {
+ if (value != SpvScopeWorkgroup) {
return _.diag(SPV_ERROR_INVALID_DATA, inst)
<< spvOpcodeString(opcode)
<< ": in WebGPU environment Execution Scope is limited to "
- << "Workgroup and Subgroup";
+ << "Workgroup";
}
}
diff --git a/test/val/val_barriers_test.cpp b/test/val/val_barriers_test.cpp
index b28e51a..2214197 100644
--- a/test/val/val_barriers_test.cpp
+++ b/test/val/val_barriers_test.cpp
@@ -403,7 +403,7 @@
"is limited to Workgroup and Subgroup"));
}
-TEST_F(ValidateBarriers, OpControlBarrierWebGPUExecutionScopeDevice) {
+TEST_F(ValidateBarriers, OpControlBarrierWebGPUExecutionScopeDeviceBad) {
const std::string body = R"(
OpControlBarrier %device %workgroup %none
)";
@@ -412,7 +412,19 @@
ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_WEBGPU_0));
EXPECT_THAT(getDiagnosticString(),
HasSubstr("ControlBarrier: in WebGPU environment Execution Scope "
- "is limited to Workgroup and Subgroup"));
+ "is limited to Workgroup"));
+}
+
+TEST_F(ValidateBarriers, OpControlBarrierWebGPUExecutionScopeSubgroupBad) {
+ const std::string body = R"(
+OpControlBarrier %subgroup %workgroup %none
+)";
+
+ CompileSuccessfully(GenerateWebGPUShaderCode(body), SPV_ENV_WEBGPU_0);
+ ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_WEBGPU_0));
+ EXPECT_THAT(getDiagnosticString(),
+ HasSubstr("ControlBarrier: in WebGPU environment Execution Scope "
+ "is limited to Workgroup"));
}
TEST_F(ValidateBarriers, OpControlBarrierVulkanMemoryScopeSubgroup) {