Error on unknown workgroup_size instruction.
If the workgroup size instruction is not a Constant or InstructionResult
add an error.
Fixed: 446986761
Change-Id: I05e4cc69ab20080caa0232d58ed750c31ac67b7f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/263334
Reviewed-by: James Price <jrprice@google.com>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Commit-Queue: James Price <jrprice@google.com>
diff --git a/src/tint/lang/core/ir/validator.cc b/src/tint/lang/core/ir/validator.cc
index 949cc55..dc1ceec 100644
--- a/src/tint/lang/core/ir/validator.cc
+++ b/src/tint/lang/core/ir/validator.cc
@@ -2683,7 +2683,11 @@
// if not constant expression && not override expression:
// fail
// pass
+
+ continue;
}
+
+ AddError(func) << "@workgroup_size must be an InstructionResult or a Constant";
}
constexpr uint64_t kMaxGridSize = 0xffffffff;
diff --git a/src/tint/lang/core/ir/validator_function_test.cc b/src/tint/lang/core/ir/validator_function_test.cc
index 81891e4..6faeed4 100644
--- a/src/tint/lang/core/ir/validator_function_test.cc
+++ b/src/tint/lang/core/ir/validator_function_test.cc
@@ -1227,6 +1227,22 @@
)")) << res.Failure();
}
+TEST_F(IR_ValidatorTest, Function_WorkgroupSize_InvalidValueKind) {
+ auto* f = ComputeEntryPoint();
+ f->SetWorkgroupSize({b.Constant(1_u), b.FunctionParam("p", ty.u32()), b.Constant(3_u)});
+
+ b.Append(f->Block(), [&] { b.Unreachable(); });
+
+ auto res = ir::Validate(mod, Capabilities{Capability::kAllowOverrides});
+ ASSERT_NE(res, Success);
+ EXPECT_THAT(
+ res.Failure().reason,
+ testing::HasSubstr(R"(:1:1 error: @workgroup_size must be an InstructionResult or a Constant
+%f = @compute @workgroup_size(1u, %p, 3u) func():void {
+^^
+)")) << res.Failure();
+}
+
TEST_F(IR_ValidatorTest, Function_WorkgroupSize_ParamsTooSmall) {
auto* f = ComputeEntryPoint();
f->SetWorkgroupSize({b.Constant(-1_i), b.Constant(2_i), b.Constant(3_i)});