diff --git a/src/webgpu/listing_meta.json b/src/webgpu/listing_meta.json index 2e9dba95dc75..75e615cf4c7d 100644 --- a/src/webgpu/listing_meta.json +++ b/src/webgpu/listing_meta.json @@ -2122,6 +2122,7 @@ "webgpu:shader,validation,expression,call,builtin,inverseSqrt:values:*": { "subcaseMS": 0.315 }, "webgpu:shader,validation,expression,call,builtin,ldexp:args:*": { "subcaseMS": 86.955 }, "webgpu:shader,validation,expression,call,builtin,ldexp:must_use:*": { "subcaseMS": 6.088 }, + "webgpu:shader,validation,expression,call,builtin,ldexp:partial_values:*": { "subcaseMS": 102.253 }, "webgpu:shader,validation,expression,call,builtin,ldexp:values:*": { "subcaseMS": 7707.260 }, "webgpu:shader,validation,expression,call,builtin,length:args:*": { "subcaseMS": 5.046 }, "webgpu:shader,validation,expression,call,builtin,length:integer_argument:*": { "subcaseMS": 2.011 }, diff --git a/src/webgpu/shader/validation/expression/call/builtin/ldexp.spec.ts b/src/webgpu/shader/validation/expression/call/builtin/ldexp.spec.ts index b928c68a1d78..826354d1ff08 100644 --- a/src/webgpu/shader/validation/expression/call/builtin/ldexp.spec.ts +++ b/src/webgpu/shader/validation/expression/call/builtin/ldexp.spec.ts @@ -115,6 +115,84 @@ Validates that constant evaluation and override evaluation of ${builtin}() never ); }); +g.test('partial_values') + .desc('Validates e2 <= bias + 1 when e1 is a runtime value') + .params(u => + u + .combine('stage', ['constant', 'override', 'runtime'] as const) + .combine('typeA', keysOf(kValidArgumentTypesA)) + .filter(t => { + const ty = kValidArgumentTypesA[t.typeA]; + const scalar = scalarTypeOf(ty); + return scalar !== Type.abstractInt && scalar !== Type.abstractFloat; + }) + .expand('typeB', u => keysOf(supportedSecondArgTypes(u.typeA))) + .filter(t => { + const ty = kValidArgumentTypesB[t.typeB]; + const scalar = scalarTypeOf(ty); + return scalar !== Type.abstractInt && scalar !== Type.abstractFloat; + }) + .beginSubcases() + .expandWithParams(p => { + const ty = kValidArgumentTypesA[p.typeA]; + const scalar = scalarTypeOf(ty); + const cases = []; + const bias = biasForType(scalar); + cases.push({ value: bias }); + cases.push({ value: bias + 1 }); + cases.push({ value: bias + 2 }); + return cases; + }) + ) + .beforeAllSubcases(t => { + const ty = kValidArgumentTypesA[t.params.typeA]; + if (ty.requiresF16()) { + t.selectDeviceOrSkipTestCase('shader-f16'); + } + }) + .fn(t => { + const tyA = kValidArgumentTypesA[t.params.typeA]; + const tyB = kValidArgumentTypesB[t.params.typeB]; + const scalarB = scalarTypeOf(tyB); + const enable = `${tyA.requiresF16() ? 'enable f16;' : ''}`; + let bArg = ''; + switch (t.params.stage) { + case 'constant': + bArg = `${tyB.create(t.params.value).wgsl()}`; + break; + case 'override': + bArg = `${tyB.toString()}(o_b)`; + break; + case 'runtime': + bArg = 'v_b'; + break; + } + const wgsl = ` +${enable} +override o_b : ${scalarB.toString()}; +fn foo() { + var v_b : ${tyB.toString()}; + var v : ${tyA.toString()}; + let tmp = ldexp(v, ${bArg}); +}`; + + const bias = biasForType(scalarTypeOf(tyA)); + const error = t.params.value > bias + 1; + const shader_error = error && t.params.stage === 'constant'; + const pipeline_error = error && t.params.stage === 'override'; + t.expectCompileResult(!shader_error, wgsl); + if (!shader_error) { + const constants: Record = {}; + constants['o_b'] = t.params.value; + t.expectPipelineResult({ + expectedResult: !pipeline_error, + code: wgsl, + constants, + reference: ['o_b'], + }); + } + }); + const kArgCases = { good: '(vec3(0), vec3(1))', bad_no_parens: '',