diff --git a/src/common/runtime/helper/options.ts b/src/common/runtime/helper/options.ts index 5ec7140d3ae..2bea817d44a 100644 --- a/src/common/runtime/helper/options.ts +++ b/src/common/runtime/helper/options.ts @@ -102,7 +102,10 @@ export const kCTSOptionsInfo: OptionsInfos = { debug: { description: 'show more info' }, compatibility: { description: 'run in compatibility mode' }, forceFallbackAdapter: { description: 'pass forceFallbackAdapter: true to requestAdapter' }, - enforceDefaultLimits: { description: 'force the adapter limits to the default limits' }, + enforceDefaultLimits: { + description: `force the adapter limits to the default limits. +Note: May fail on tests for low-power/high-performance`, + }, unrollConstEvalLoops: { description: 'unroll const eval loops in WGSL' }, powerPreference: { description: 'set default powerPreference for some tests', diff --git a/src/common/util/navigator_gpu.ts b/src/common/util/navigator_gpu.ts index 9f137dd933c..728b8cdadf5 100644 --- a/src/common/util/navigator_gpu.ts +++ b/src/common/util/navigator_gpu.ts @@ -1,5 +1,4 @@ // eslint-disable-next-line import/no-restricted-paths -import { getDefaultLimitsForAdapter } from '../../webgpu/capability_info.js'; import { TestCaseRecorder } from '../framework/fixture.js'; import { globalTestConfig } from '../framework/test_config.js'; @@ -34,6 +33,7 @@ export function setGPUProvider(provider: GPUProvider) { } let impl: GPU | undefined = undefined; +let s_defaultLimits: Record | undefined = undefined; let defaultRequestAdapterOptions: GPURequestAdapterOptions | undefined; @@ -52,6 +52,14 @@ export function getDefaultRequestAdapterOptions() { return defaultRequestAdapterOptions; } +function copyLimits(objLike: GPUSupportedLimits) { + const obj: Record = {}; + for (const key in objLike) { + obj[key] = (objLike as unknown as Record)[key]; + } + return obj; +} + /** * Finds and returns the `navigator.gpu` object (or equivalent, for non-browser implementations). * Throws an exception if not found. @@ -65,15 +73,28 @@ export function getGPU(recorder: TestCaseRecorder | null): GPU { if (globalTestConfig.enforceDefaultLimits) { // eslint-disable-next-line @typescript-eslint/unbound-method - const oldFn = impl.requestAdapter; + const origRequestAdapterFn = impl.requestAdapter; + // eslint-disable-next-line @typescript-eslint/unbound-method + const origRequestDeviceFn = GPUAdapter.prototype.requestDevice; + impl.requestAdapter = async function (options?: GPURequestAdapterOptions) { - const adapter = await oldFn.call(this, { ...defaultRequestAdapterOptions, ...options }); + if (!s_defaultLimits) { + const tempAdapter = await origRequestAdapterFn.call(this, { + ...defaultRequestAdapterOptions, + ...options, + }); + // eslint-disable-next-line no-restricted-syntax + const tempDevice = await tempAdapter?.requestDevice(); + s_defaultLimits = copyLimits(tempDevice!.limits); + tempDevice?.destroy(); + } + const adapter = await origRequestAdapterFn.call(this, { + ...defaultRequestAdapterOptions, + ...options, + }); if (adapter) { const limits = Object.fromEntries( - Object.entries(getDefaultLimitsForAdapter(adapter)).map(([key, { default: v }]) => [ - key, - v, - ]) + Object.entries(s_defaultLimits).map(([key, v]) => [key, v]) ); Object.defineProperty(adapter, 'limits', { @@ -87,17 +108,15 @@ export function getGPU(recorder: TestCaseRecorder | null): GPU { const enforceDefaultLimits = (adapter: GPUAdapter, desc: GPUDeviceDescriptor | undefined) => { if (desc?.requiredLimits) { - const limits = getDefaultLimitsForAdapter(adapter); for (const [key, value] of Object.entries(desc.requiredLimits)) { - const info = limits[key as keyof ReturnType]; - if (info && value !== undefined) { - const [beyondLimit, condition] = - info.class === 'maximum' - ? [value > info.default, 'greater'] - : [value < info.default, 'less']; + const limit = s_defaultLimits![key]; + if (limit !== undefined && value !== undefined) { + const [beyondLimit, condition] = key.startsWith('max') + ? [value > limit, 'greater'] + : [value < limit, 'less']; if (beyondLimit) { throw new DOMException( - `requestedLimit ${value} for ${key} is ${condition} than adapter limit ${info.default}`, + `requestedLimit ${value} for ${key} is ${condition} than adapter limit ${limit}`, 'OperationError' ); } @@ -106,14 +125,22 @@ export function getGPU(recorder: TestCaseRecorder | null): GPU { } }; - // eslint-disable-next-line @typescript-eslint/unbound-method - const origFn = GPUAdapter.prototype.requestDevice; GPUAdapter.prototype.requestDevice = async function ( this: GPUAdapter, desc?: GPUDeviceDescriptor | undefined ) { + // We need to enforce the default limits because even though we patched the adapter to + // show defaults for adapter.limits, there are tests that test we throw when we request more than the max. + // In other words. + // + // adapter.requestDevice({ requiredLimits: { + // maxXXX: addapter.limits.maxXXX + 1, // should throw + // }); + // + // But unless we enforce this manually, it won't actual through if the adapter's + // true limits are higher than we patched above. enforceDefaultLimits(this, desc); - return await origFn.call(this, desc); + return await origRequestDeviceFn.call(this, desc); }; } diff --git a/src/resources/cache/hashes.json b/src/resources/cache/hashes.json index abf50ddcf2c..7f214ed4d33 100644 --- a/src/resources/cache/hashes.json +++ b/src/resources/cache/hashes.json @@ -1,112 +1,112 @@ { - "webgpu/shader/execution/binary/af_addition.bin": "5408a94a", - "webgpu/shader/execution/binary/af_logical.bin": "1d33464b", - "webgpu/shader/execution/binary/af_division.bin": "65b73bb6", - "webgpu/shader/execution/binary/af_matrix_addition.bin": "35487ff5", - "webgpu/shader/execution/binary/af_matrix_subtraction.bin": "3289a7a2", - "webgpu/shader/execution/binary/af_multiplication.bin": "30ecda2d", - "webgpu/shader/execution/binary/af_remainder.bin": "ee1b68bd", - "webgpu/shader/execution/binary/af_subtraction.bin": "66966082", - "webgpu/shader/execution/binary/f16_addition.bin": "f6c2622f", - "webgpu/shader/execution/binary/f16_logical.bin": "93930f71", - "webgpu/shader/execution/binary/f16_division.bin": "271933e8", - "webgpu/shader/execution/binary/f16_matrix_addition.bin": "f7a9b40a", - "webgpu/shader/execution/binary/f16_matrix_matrix_multiplication.bin": "db7072c9", - "webgpu/shader/execution/binary/f16_matrix_scalar_multiplication.bin": "b0303b76", - "webgpu/shader/execution/binary/f16_matrix_subtraction.bin": "edd3ccf", - "webgpu/shader/execution/binary/f16_matrix_vector_multiplication.bin": "6b6aab4f", - "webgpu/shader/execution/binary/f16_multiplication.bin": "df977744", - "webgpu/shader/execution/binary/f16_remainder.bin": "54eaaa18", - "webgpu/shader/execution/binary/f16_subtraction.bin": "ccb413fc", - "webgpu/shader/execution/binary/f32_addition.bin": "77eded0d", - "webgpu/shader/execution/binary/f32_logical.bin": "8fe5762b", - "webgpu/shader/execution/binary/f32_division.bin": "3bd88eb1", - "webgpu/shader/execution/binary/f32_matrix_addition.bin": "6978f1b0", - "webgpu/shader/execution/binary/f32_matrix_matrix_multiplication.bin": "3884d7de", - "webgpu/shader/execution/binary/f32_matrix_scalar_multiplication.bin": "7696009e", - "webgpu/shader/execution/binary/f32_matrix_subtraction.bin": "ddc14abb", - "webgpu/shader/execution/binary/f32_matrix_vector_multiplication.bin": "73de6c8e", - "webgpu/shader/execution/binary/f32_multiplication.bin": "2e8c2ac9", - "webgpu/shader/execution/binary/f32_remainder.bin": "e3177f52", - "webgpu/shader/execution/binary/f32_subtraction.bin": "caaadf56", - "webgpu/shader/execution/binary/i32_arithmetic.bin": "bd8e9f33", - "webgpu/shader/execution/binary/i32_comparison.bin": "76a32f73", - "webgpu/shader/execution/binary/u32_arithmetic.bin": "7f23f1ed", - "webgpu/shader/execution/binary/u32_comparison.bin": "af2a5678", - "webgpu/shader/execution/abs.bin": "e8e1ea83", - "webgpu/shader/execution/acos.bin": "31f1ed7c", - "webgpu/shader/execution/acosh.bin": "a7cb33a1", - "webgpu/shader/execution/asin.bin": "8ba86fc4", - "webgpu/shader/execution/asinh.bin": "2e2bf668", - "webgpu/shader/execution/atan.bin": "430514c3", - "webgpu/shader/execution/atan2.bin": "ae6817b5", - "webgpu/shader/execution/atanh.bin": "1a0b7d8f", - "webgpu/shader/execution/bitcast.bin": "4ae03bc0", - "webgpu/shader/execution/ceil.bin": "56fe5677", - "webgpu/shader/execution/clamp.bin": "5d094bf4", - "webgpu/shader/execution/cos.bin": "b7ad204e", - "webgpu/shader/execution/cosh.bin": "fa2f83cb", - "webgpu/shader/execution/cross.bin": "3e1af337", - "webgpu/shader/execution/degrees.bin": "2f19b33b", - "webgpu/shader/execution/determinant.bin": "f76c17f4", - "webgpu/shader/execution/distance.bin": "6969e44a", - "webgpu/shader/execution/dot.bin": "30da82e", - "webgpu/shader/execution/exp.bin": "a4732d12", - "webgpu/shader/execution/exp2.bin": "84801f38", - "webgpu/shader/execution/faceForward.bin": "83a06f41", - "webgpu/shader/execution/floor.bin": "2128b59f", - "webgpu/shader/execution/fma.bin": "c89a9b44", - "webgpu/shader/execution/fract.bin": "e9abda08", - "webgpu/shader/execution/frexp.bin": "77a177df", - "webgpu/shader/execution/inverseSqrt.bin": "3436ce23", - "webgpu/shader/execution/ldexp.bin": "990e3515", - "webgpu/shader/execution/length.bin": "bdd3557d", - "webgpu/shader/execution/log.bin": "3f875472", - "webgpu/shader/execution/log2.bin": "2a5deabe", - "webgpu/shader/execution/max.bin": "4d651b8c", - "webgpu/shader/execution/min.bin": "d04ec399", - "webgpu/shader/execution/mix.bin": "21317ca4", - "webgpu/shader/execution/modf.bin": "2ccbf20b", - "webgpu/shader/execution/normalize.bin": "b40908b4", - "webgpu/shader/execution/pack2x16float.bin": "6081f086", - "webgpu/shader/execution/pow.bin": "3b43ebfd", - "webgpu/shader/execution/quantizeToF16.bin": "7b730228", - "webgpu/shader/execution/radians.bin": "53b98108", - "webgpu/shader/execution/reflect.bin": "48554589", - "webgpu/shader/execution/refract.bin": "7b87b0bf", - "webgpu/shader/execution/round.bin": "f1902f69", - "webgpu/shader/execution/saturate.bin": "d1b03abc", - "webgpu/shader/execution/sign.bin": "11274a63", - "webgpu/shader/execution/sin.bin": "29a57158", - "webgpu/shader/execution/sinh.bin": "c9a446b4", - "webgpu/shader/execution/smoothstep.bin": "e169b991", - "webgpu/shader/execution/sqrt.bin": "d52c7e6c", - "webgpu/shader/execution/step.bin": "5e7ec97a", - "webgpu/shader/execution/tan.bin": "d4d2c708", - "webgpu/shader/execution/tanh.bin": "c4885953", - "webgpu/shader/execution/transpose.bin": "b46b7447", - "webgpu/shader/execution/trunc.bin": "6b54eb50", - "webgpu/shader/execution/unpack2x16float.bin": "60acf1b0", - "webgpu/shader/execution/unpack2x16snorm.bin": "3953f12b", - "webgpu/shader/execution/unpack2x16unorm.bin": "b31090b1", - "webgpu/shader/execution/unpack4x8snorm.bin": "de8990eb", - "webgpu/shader/execution/unpack4x8unorm.bin": "d6ee5b49", - "webgpu/shader/execution/unary/af_arithmetic.bin": "7f09aa85", - "webgpu/shader/execution/unary/af_assignment.bin": "6a7f0f82", - "webgpu/shader/execution/unary/bool_conversion.bin": "8fcb14ff", - "webgpu/shader/execution/unary/f16_arithmetic.bin": "84b2e3e", - "webgpu/shader/execution/unary/f16_conversion.bin": "f30cb12c", - "webgpu/shader/execution/unary/f32_arithmetic.bin": "d7d69b4f", - "webgpu/shader/execution/unary/f32_conversion.bin": "7081e848", - "webgpu/shader/execution/unary/i32_arithmetic.bin": "af3f3824", - "webgpu/shader/execution/unary/i32_conversion.bin": "2753cd5f", - "webgpu/shader/execution/unary/u32_conversion.bin": "37d1d643", - "webgpu/shader/execution/unary/ai_assignment.bin": "25777c", - "webgpu/shader/execution/binary/ai_arithmetic.bin": "88cad0b3", - "webgpu/shader/execution/unary/ai_arithmetic.bin": "27145100", - "webgpu/shader/execution/binary/af_matrix_matrix_multiplication.bin": "ef8c71c4", - "webgpu/shader/execution/binary/af_matrix_scalar_multiplication.bin": "b193fd0d", - "webgpu/shader/execution/binary/af_matrix_vector_multiplication.bin": "e69afbcf", - "webgpu/shader/execution/derivatives.bin": "ae627673", - "webgpu/shader/execution/fwidth.bin": "ecd0c359" + "webgpu/shader/execution/binary/af_addition.bin": "a076fefd", + "webgpu/shader/execution/binary/af_logical.bin": "5ef95b51", + "webgpu/shader/execution/binary/af_division.bin": "2ee1f517", + "webgpu/shader/execution/binary/af_matrix_addition.bin": "46d1c536", + "webgpu/shader/execution/binary/af_matrix_subtraction.bin": "1ba9140b", + "webgpu/shader/execution/binary/af_multiplication.bin": "f55ec87f", + "webgpu/shader/execution/binary/af_remainder.bin": "39607546", + "webgpu/shader/execution/binary/af_subtraction.bin": "a1e1671b", + "webgpu/shader/execution/binary/f16_addition.bin": "98ec8cbb", + "webgpu/shader/execution/binary/f16_logical.bin": "e1b101aa", + "webgpu/shader/execution/binary/f16_division.bin": "f24f41e6", + "webgpu/shader/execution/binary/f16_matrix_addition.bin": "a6c126ba", + "webgpu/shader/execution/binary/f16_matrix_matrix_multiplication.bin": "4810437f", + "webgpu/shader/execution/binary/f16_matrix_scalar_multiplication.bin": "33bd4e0b", + "webgpu/shader/execution/binary/f16_matrix_subtraction.bin": "2a42a145", + "webgpu/shader/execution/binary/f16_matrix_vector_multiplication.bin": "17eeecc2", + "webgpu/shader/execution/binary/f16_multiplication.bin": "5ee924d2", + "webgpu/shader/execution/binary/f16_remainder.bin": "a371e824", + "webgpu/shader/execution/binary/f16_subtraction.bin": "c5e6d455", + "webgpu/shader/execution/binary/f32_addition.bin": "371675d2", + "webgpu/shader/execution/binary/f32_logical.bin": "6c691798", + "webgpu/shader/execution/binary/f32_division.bin": "11ed1f8d", + "webgpu/shader/execution/binary/f32_matrix_addition.bin": "662a8c2a", + "webgpu/shader/execution/binary/f32_matrix_matrix_multiplication.bin": "3bef3e82", + "webgpu/shader/execution/binary/f32_matrix_scalar_multiplication.bin": "4b0d7b28", + "webgpu/shader/execution/binary/f32_matrix_subtraction.bin": "c1b78a5f", + "webgpu/shader/execution/binary/f32_matrix_vector_multiplication.bin": "3ae5663c", + "webgpu/shader/execution/binary/f32_multiplication.bin": "7c887b3c", + "webgpu/shader/execution/binary/f32_remainder.bin": "955b27f7", + "webgpu/shader/execution/binary/f32_subtraction.bin": "10a5d990", + "webgpu/shader/execution/binary/i32_arithmetic.bin": "d8d24c51", + "webgpu/shader/execution/binary/i32_comparison.bin": "97a65e83", + "webgpu/shader/execution/binary/u32_arithmetic.bin": "76af97a5", + "webgpu/shader/execution/binary/u32_comparison.bin": "107ae7dd", + "webgpu/shader/execution/abs.bin": "8702bbde", + "webgpu/shader/execution/acos.bin": "505d4e5c", + "webgpu/shader/execution/acosh.bin": "6d849181", + "webgpu/shader/execution/asin.bin": "3739abaa", + "webgpu/shader/execution/asinh.bin": "5f912ea9", + "webgpu/shader/execution/atan.bin": "d15dc231", + "webgpu/shader/execution/atan2.bin": "60eb6015", + "webgpu/shader/execution/atanh.bin": "f8b2fb79", + "webgpu/shader/execution/bitcast.bin": "af41ce05", + "webgpu/shader/execution/ceil.bin": "8da53d8b", + "webgpu/shader/execution/clamp.bin": "a02c15b", + "webgpu/shader/execution/cos.bin": "4f444ab6", + "webgpu/shader/execution/cosh.bin": "aaa40c4b", + "webgpu/shader/execution/cross.bin": "534a949c", + "webgpu/shader/execution/degrees.bin": "2d55f678", + "webgpu/shader/execution/determinant.bin": "5b49ee94", + "webgpu/shader/execution/distance.bin": "d6963680", + "webgpu/shader/execution/dot.bin": "e03347d6", + "webgpu/shader/execution/exp.bin": "a5affb43", + "webgpu/shader/execution/exp2.bin": "21d376a0", + "webgpu/shader/execution/faceForward.bin": "e0e2ad0e", + "webgpu/shader/execution/floor.bin": "3658073", + "webgpu/shader/execution/fma.bin": "a7cc5707", + "webgpu/shader/execution/fract.bin": "44a3775d", + "webgpu/shader/execution/frexp.bin": "241abedb", + "webgpu/shader/execution/inverseSqrt.bin": "766974b5", + "webgpu/shader/execution/ldexp.bin": "db0c0fcf", + "webgpu/shader/execution/length.bin": "c1240c03", + "webgpu/shader/execution/log.bin": "98aceda7", + "webgpu/shader/execution/log2.bin": "ffdc85d7", + "webgpu/shader/execution/max.bin": "a2c6c4b1", + "webgpu/shader/execution/min.bin": "344390ef", + "webgpu/shader/execution/mix.bin": "367c1ff3", + "webgpu/shader/execution/modf.bin": "7be6faa3", + "webgpu/shader/execution/normalize.bin": "b2b9eb0c", + "webgpu/shader/execution/pack2x16float.bin": "a66da753", + "webgpu/shader/execution/pow.bin": "a9858b9", + "webgpu/shader/execution/quantizeToF16.bin": "bf80d34e", + "webgpu/shader/execution/radians.bin": "cc7b8d0c", + "webgpu/shader/execution/reflect.bin": "cb0be6ee", + "webgpu/shader/execution/refract.bin": "501ac731", + "webgpu/shader/execution/round.bin": "b4ea1e61", + "webgpu/shader/execution/saturate.bin": "2783de66", + "webgpu/shader/execution/sign.bin": "30ad6ecf", + "webgpu/shader/execution/sin.bin": "9f8b5d9e", + "webgpu/shader/execution/sinh.bin": "d988cc09", + "webgpu/shader/execution/smoothstep.bin": "2e89af8e", + "webgpu/shader/execution/sqrt.bin": "55dd81cf", + "webgpu/shader/execution/step.bin": "f1bced79", + "webgpu/shader/execution/tan.bin": "a8354079", + "webgpu/shader/execution/tanh.bin": "fd1c38ee", + "webgpu/shader/execution/transpose.bin": "e8bdca54", + "webgpu/shader/execution/trunc.bin": "ffedffa", + "webgpu/shader/execution/unpack2x16float.bin": "9251ad61", + "webgpu/shader/execution/unpack2x16snorm.bin": "6133b78b", + "webgpu/shader/execution/unpack2x16unorm.bin": "291b47bd", + "webgpu/shader/execution/unpack4x8snorm.bin": "93230ee1", + "webgpu/shader/execution/unpack4x8unorm.bin": "99fd9a23", + "webgpu/shader/execution/unary/af_arithmetic.bin": "dc1de35b", + "webgpu/shader/execution/unary/af_assignment.bin": "6a907068", + "webgpu/shader/execution/unary/bool_conversion.bin": "4fb09ad6", + "webgpu/shader/execution/unary/f16_arithmetic.bin": "5443808d", + "webgpu/shader/execution/unary/f16_conversion.bin": "e6f6743", + "webgpu/shader/execution/unary/f32_arithmetic.bin": "980abd9d", + "webgpu/shader/execution/unary/f32_conversion.bin": "c666a6e8", + "webgpu/shader/execution/unary/i32_arithmetic.bin": "4c1bf2ef", + "webgpu/shader/execution/unary/i32_conversion.bin": "9d2e1411", + "webgpu/shader/execution/unary/u32_conversion.bin": "962b68ac", + "webgpu/shader/execution/unary/ai_assignment.bin": "d34f3811", + "webgpu/shader/execution/binary/ai_arithmetic.bin": "b4811a5c", + "webgpu/shader/execution/unary/ai_arithmetic.bin": "d203a070", + "webgpu/shader/execution/binary/af_matrix_matrix_multiplication.bin": "1405c422", + "webgpu/shader/execution/binary/af_matrix_scalar_multiplication.bin": "c24e7f75", + "webgpu/shader/execution/binary/af_matrix_vector_multiplication.bin": "e36fcfd", + "webgpu/shader/execution/derivatives.bin": "e8c5ea73", + "webgpu/shader/execution/fwidth.bin": "cb050a6f" } \ No newline at end of file