From 416346165b71cb54d54a3b57b5845b2fd111db89 Mon Sep 17 00:00:00 2001 From: alan-baker Date: Mon, 24 Jun 2024 12:01:39 -0400 Subject: [PATCH] Fix div/rem early eval error cases (#3787) Contributes to #3778 * scalar_vector_out_of_range already covers the const and override cases generally * modified scalar_vector tests to 0 and 1 rhs values * this test set covers compound assignments * previously the tests had invalid constant cases for 0 / 0 variants --- .../validation/expression/binary/div_rem.spec.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/webgpu/shader/validation/expression/binary/div_rem.spec.ts b/src/webgpu/shader/validation/expression/binary/div_rem.spec.ts index 02922ef2d909..4169786cb69b 100644 --- a/src/webgpu/shader/validation/expression/binary/div_rem.spec.ts +++ b/src/webgpu/shader/validation/expression/binary/div_rem.spec.ts @@ -58,6 +58,7 @@ g.test('scalar_vector') .combine('compound_assignment', [false, true] as const) .beginSubcases() .combine('op', keysOf(kOperators)) + .combine('rhs_value', [0, 1] as const) ) .beforeAllSubcases(t => { if ( @@ -82,19 +83,26 @@ g.test('scalar_vector') ${hasF16 ? 'enable f16;' : ''} fn f() { var v = ${lhs.create(0).wgsl()}; - v ${op.op}= ${rhs.create(0).wgsl()}; + v ${op.op}= ${rhs.create(t.params.rhs_value).wgsl()}; } ` : ` ${hasF16 ? 'enable f16;' : ''} const lhs = ${lhs.create(1).wgsl()}; -const rhs = ${rhs.create(1).wgsl()}; +const rhs = ${rhs.create(t.params.rhs_value).wgsl()}; const foo ${resTypeIsTypeable ? `: ${resType}` : ''} = lhs ${op.op} rhs; `; + const scalarLHS = scalarTypeOf(concreteTypeOf(lhs)); + const integral = scalarLHS === Type.u32 || scalarLHS === Type.i32; let valid = !hasBool && resType !== null; if (valid && t.params.compound_assignment) { - valid = valid && isConvertible(resType!, concreteTypeOf(lhs)); + valid = + valid && + isConvertible(resType!, concreteTypeOf(lhs)) && + (!integral || t.params.rhs_value === 1); + } else { + valid = valid && t.params.rhs_value === 1; } t.expectCompileResult(valid, code); });