diff --git a/src/common/runtime/cmdline.ts b/src/common/runtime/cmdline.ts index 635c30eb141..c071cd54aa8 100644 --- a/src/common/runtime/cmdline.ts +++ b/src/common/runtime/cmdline.ts @@ -123,7 +123,7 @@ for (let i = 0; i < sys.args.length; ++i) { let codeCoverage: CodeCoverageProvider | undefined = undefined; if (globalTestConfig.compatibility || globalTestConfig.forceFallbackAdapter) { - // MAINTENANCE_TODO: remove the cast once compatibilityMode is officially added + // MAINTENANCE_TODO: remove compatibilityMode (and the typecast) once no longer needed. setDefaultRequestAdapterOptions({ compatibilityMode: globalTestConfig.compatibility, featureLevel: globalTestConfig.compatibility ? 'compatibility' : 'core', diff --git a/src/common/runtime/helper/utils_worker.ts b/src/common/runtime/helper/utils_worker.ts index 7054be317c1..4210db20f08 100644 --- a/src/common/runtime/helper/utils_worker.ts +++ b/src/common/runtime/helper/utils_worker.ts @@ -27,7 +27,7 @@ export function setupWorkerEnvironment(ctsOptions: CTSOptions): Logger { if (powerPreference || compatibility) { setDefaultRequestAdapterOptions({ ...(powerPreference && { powerPreference }), - // MAINTENANCE_TODO: Change this to whatever the option ends up being + // MAINTENANCE_TODO: remove compatibilityMode once no longer needed. ...(compatibility && { compatibilityMode: true, featureLevel: 'compatibility' }), }); } diff --git a/src/common/runtime/server.ts b/src/common/runtime/server.ts index bb68b041335..783d7244d4f 100644 --- a/src/common/runtime/server.ts +++ b/src/common/runtime/server.ts @@ -122,7 +122,7 @@ for (let i = 0; i < sys.args.length; ++i) { let codeCoverage: CodeCoverageProvider | undefined = undefined; if (globalTestConfig.compatibility || globalTestConfig.forceFallbackAdapter) { - // MAINTENANCE_TODO: remove the cast once compatibilityMode is officially added + // MAINTENANCE_TODO: remove compatibilityMode (and the typecast) once no longer needed. setDefaultRequestAdapterOptions({ compatibilityMode: globalTestConfig.compatibility, featureLevel: globalTestConfig.compatibility ? 'compatibility' : 'core', diff --git a/src/common/runtime/standalone.ts b/src/common/runtime/standalone.ts index d5b51b11c6f..3f7333c1eb3 100644 --- a/src/common/runtime/standalone.ts +++ b/src/common/runtime/standalone.ts @@ -85,7 +85,7 @@ stopButtonElem.addEventListener('click', () => { if (powerPreference || compatibility || forceFallbackAdapter) { setDefaultRequestAdapterOptions({ ...(powerPreference && { powerPreference }), - // MAINTENANCE_TODO: Change this to whatever the option ends up being + // MAINTENANCE_TODO: remove compatibilityMode once no longer needed. ...(compatibility && { compatibilityMode: true, featureLevel: 'compatibility' }), ...(forceFallbackAdapter && { forceFallbackAdapter: true }), }); diff --git a/src/webgpu/api/operation/adapter/requestDevice.spec.ts b/src/webgpu/api/operation/adapter/requestDevice.spec.ts index 42701660386..421fc991f40 100644 --- a/src/webgpu/api/operation/adapter/requestDevice.spec.ts +++ b/src/webgpu/api/operation/adapter/requestDevice.spec.ts @@ -491,7 +491,7 @@ g.test('always_returns_device') Note: This is a regression test for a Chrome bug crbug.com/349062459 Checking that a requestDevice always return a device is checked in other tests above - but those tests have 'compatibilityMode: true' set for them by the API that getGPU + but those tests have 'featureLevel: "compatibility"' set for them by the API that getGPU returns when the test suite is run in compatibility mode. This test tries to force both compat and core separately so both code paths are @@ -502,19 +502,34 @@ g.test('always_returns_device') .fn(async t => { const { compatibilityMode } = t.params; const gpu = getGPU(t.rec); - // MAINTENANCE_TODO: Remove this cast compatibilityMode is added. - const adapter = await gpu.requestAdapter({ compatibilityMode } as GPURequestAdapterOptions); + // MAINTENANCE_TODO: Remove compatibilityMode and the cast once compatibilityMode is no longer + // used (mainly in `setDefaultRequestAdapterOptions`). + const adapter = await gpu.requestAdapter({ + compatibilityMode, + featureLevel: compatibilityMode ? 'compatibility' : 'core', + } as GPURequestAdapterOptions); if (adapter) { + const device = await t.requestDeviceTracked(adapter); + assert(device instanceof GPUDevice, 'requestDevice must return a device or throw'); + if (!compatibilityMode) { - // This check is to make sure something lower-level is not forcing compatibility mode - // MAINTENANCE_TODO: Remove this cast compatibilityMode is added. + // This check is to make sure something lower-level is not forcing compatibility mode. + + // MAINTENANCE_TODO: Simplify this check (and typecast) once we standardize how to do this. + const adapterExtensions = adapter as unknown as { + isCompatibilityMode?: boolean; + featureLevel?: string; + }; t.expect( - !(adapter as unknown as { isCompatibilityMode?: boolean }).isCompatibilityMode, - 'must not be compatibility mode' + // Old version of Compat design. + !adapterExtensions.isCompatibilityMode && + // Current version of Compat design, as of this writing. + adapterExtensions.featureLevel !== 'compatibility' && + // An as-yet-unlanded proposed change to the Compat design, but for now it doesn't hurt + // to just check. Unlanded PR: https://github.com/gpuweb/gpuweb/pull/5036 + !device.features.has('webgpu-core'), + 'must not get a Compatibility adapter if not requested' ); } - const device = await t.requestDeviceTracked(adapter); - t.expect(device instanceof GPUDevice, 'requestDevice must return a device or throw'); - device.destroy(); } }); diff --git a/src/webgpu/capability_info.ts b/src/webgpu/capability_info.ts index 661812cd4be..4da99bad66e 100644 --- a/src/webgpu/capability_info.ts +++ b/src/webgpu/capability_info.ts @@ -801,12 +801,17 @@ export function getDefaultLimits(featureLevel: FeatureLevel) { } export function getDefaultLimitsForAdapter(adapter: GPUAdapter) { - // MAINTENANCE_TODO: Remove casts when GPUAdapter IDL has isCompatibilityMode. - return getDefaultLimits( - (adapter as unknown as { isCompatibilityMode: boolean }).isCompatibilityMode + // MAINTENANCE_TODO: Remove casts once we have a standardized way to do this + // (see https://github.com/gpuweb/gpuweb/pull/5037#issuecomment-2576110161). + const adapterExtensions = adapter as unknown as { + isCompatibilityMode?: boolean; + featureLevel?: string; + }; + const featureLevel = + adapterExtensions.featureLevel === 'compatibility' || adapterExtensions.isCompatibilityMode ? 'compatibility' - : 'core' - ); + : 'core'; + return getDefaultLimits(featureLevel); } const kEachStage = [