[ir][fuzz] Handle invalid workgroup sizes in fuzzer. Then wokgroup size is checked by Dawn and Tint exe outside of the tint backend. Add a similar check into the WGSL fuzzer so we don't fail with a validation error. This is not checked in the const-eval code for SubstituteOverrides because Dawn needs the result of the const-eval to do it's own checks, and shouldn't fail before it does so. Bug: 408370947 Change-Id: I7ae3011c314e0d1abac068e2b34bdd95031271d5 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/235334 Auto-Submit: dan sinclair <dsinclair@chromium.org> Reviewed-by: James Price <jrprice@google.com> Commit-Queue: James Price <jrprice@google.com>
diff --git a/src/tint/cmd/fuzz/ir/fuzz.cc b/src/tint/cmd/fuzz/ir/fuzz.cc index 7925cc8..f01c25c 100644 --- a/src/tint/cmd/fuzz/ir/fuzz.cc +++ b/src/tint/cmd/fuzz/ir/fuzz.cc
@@ -88,6 +88,25 @@ return; } + // Workgroup sizes < 1 are checked by Dawn and the Tint binary, + // should be skipped by the fuzzer. + for (auto func : ir->functions) { + if (func->Stage() != tint::core::ir::Function::PipelineStage::kCompute) { + continue; + } + + auto wg = func->WorkgroupSize().value(); + for (auto value : wg) { + auto* cnst = value->As<core::ir::Constant>(); + TINT_ASSERT(cnst); + + auto val = cnst->Value()->ValueAs<int32_t>(); + if (val < 1) { + return; + } + } + } + if (auto val = core::ir::Validate(ir.Get()); val != Success) { TINT_ICE() << val.Failure(); }