diff --git a/src/webgpu/compat/api/validation/createBindGroupLayout_limits.spec.ts b/src/webgpu/compat/api/validation/createBindGroupLayout_limits.spec.ts index 7f8fabc5ec6..d5bf7a063aa 100644 --- a/src/webgpu/compat/api/validation/createBindGroupLayout_limits.spec.ts +++ b/src/webgpu/compat/api/validation/createBindGroupLayout_limits.spec.ts @@ -62,12 +62,12 @@ g.test('maxStorageBuffersTexturesInVertexFragmentStage') : 'maxStorageTexturesPerShaderStage'; const perStageLimit = device.limits[perStageLimitName]; - t.debug(`{${limit}(${inStageLimit}), ${perStageLimitName}(${perStageLimit}})`); + t.debug(`${limit}(${inStageLimit}), ${perStageLimitName}(${perStageLimit})`); t.skipIf(inStageLimit === 0, `${limit} is 0`); t.skipIf( !(inStageLimit < perStageLimit), - `{${limit}(${inStageLimit}) is not less than ${perStageLimitName}(${perStageLimit}})` + `${limit}(${inStageLimit}) is not less than ${perStageLimitName}(${perStageLimit})` ); const visibility = limit.includes('Fragment') ? GPUShaderStage.FRAGMENT : GPUShaderStage.VERTEX; diff --git a/src/webgpu/compat/api/validation/render_pipeline/in_stage_limits.spec.ts b/src/webgpu/compat/api/validation/render_pipeline/in_stage_limits.spec.ts index d7fc4408849..5e07c274958 100644 --- a/src/webgpu/compat/api/validation/render_pipeline/in_stage_limits.spec.ts +++ b/src/webgpu/compat/api/validation/render_pipeline/in_stage_limits.spec.ts @@ -63,12 +63,12 @@ g.test('maxStorageBuffersTexturesInVertexFragmentStage') : 'maxStorageTexturesPerShaderStage'; const perStageLimit = device.limits[perStageLimitName]; - t.debug(`{${limit}(${inStageLimit}), ${perStageLimitName}(${perStageLimit}})`); + t.debug(`${limit}(${inStageLimit}), ${perStageLimitName}(${perStageLimit})`); t.skipIf(inStageLimit === 0, `${limit} is 0`); t.skipIf( !(inStageLimit < perStageLimit), - `{${limit}(${inStageLimit}) is not less than ${perStageLimitName}(${perStageLimit}})` + `${limit}(${inStageLimit}) is not less than ${perStageLimitName}(${perStageLimit})` ); const typeWGSLFn = isBuffer diff --git a/src/webgpu/gpu_test.ts b/src/webgpu/gpu_test.ts index a7d8cef19c8..1e7fac4a984 100644 --- a/src/webgpu/gpu_test.ts +++ b/src/webgpu/gpu_test.ts @@ -1298,6 +1298,27 @@ function getAdapterLimitsAsDeviceRequiredLimits(adapter: GPUAdapter) { return requiredLimits; } +/** + * Removes limits that don't exist on the adapter. + * A test might request a new limit that not all implementions support. The test itself + * should check the requested limit using code that expects undefined. + * + * ```ts + * t.skipIf(limit < 2); // BAD! Doesn't skip if unsupported beause undefined is never less than 2. + * t.skipIf(!(limit >= 2)); // Good. Skips if limits is not >= 2. undefined is not >= 2. + * ``` + */ +function removeNonExistantLimits(adapter: GPUAdapter, limits: Record) { + const filteredLimits: Record = {}; + const adapterLimits = adapter.limits as unknown as Record; + for (const [limit, value] of Object.entries(limits)) { + if (adapterLimits[limit] !== undefined) { + filteredLimits[limit] = value; + } + } + return filteredLimits; +} + function applyLimitsToDescriptor( adapter: GPUAdapter, desc: CanonicalDeviceDescriptor | undefined, @@ -1307,7 +1328,7 @@ function applyLimitsToDescriptor( requiredFeatures: [], defaultQueue: {}, ...desc, - requiredLimits: getRequiredLimits(adapter), + requiredLimits: removeNonExistantLimits(adapter, getRequiredLimits(adapter)), }; return descWithMaxLimits; }