From 5e6fa3bfd366648b507774d40148b4ed073b6ef4 Mon Sep 17 00:00:00 2001 From: Gregg Tavares Date: Fri, 27 Dec 2024 15:15:29 -0800 Subject: [PATCH] Compat: refactor maxStorageTexturesPerShaderStage test Refactor to handle maxStorageTexturesInFragmentStage being less than maxStorageTexturesPerShaderStage --- .../maxStorageTexturesPerShaderStage.spec.ts | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/webgpu/api/validation/capability_checks/limits/maxStorageTexturesPerShaderStage.spec.ts b/src/webgpu/api/validation/capability_checks/limits/maxStorageTexturesPerShaderStage.spec.ts index 8af61f51fc7a..2d28ff852842 100644 --- a/src/webgpu/api/validation/capability_checks/limits/maxStorageTexturesPerShaderStage.spec.ts +++ b/src/webgpu/api/validation/capability_checks/limits/maxStorageTexturesPerShaderStage.spec.ts @@ -15,11 +15,13 @@ import { getPipelineTypeForBindingCombination, BindingCombination, LimitsRequest, + LimitTestsImpl, } from './limit_utils.js'; const kExtraLimits: LimitsRequest = { maxBindingsPerBindGroup: 'adapterLimit', maxBindGroups: 'adapterLimit', + maxStorageTexturesInFragmentStage: 'adapterLimit', }; const limit = 'maxStorageTexturesPerShaderStage'; @@ -43,6 +45,25 @@ function createBindGroupLayout( }); } +function skipIfNotEnoughStorageTexturesInStage( + t: LimitTestsImpl, + visibility: GPUShaderStageFlags, + testValue: number +) { + t.skipIf( + t.isCompatibility && + // If we're using the fragment stage + (visibility & GPUConst.ShaderStage.FRAGMENT) !== 0 && + // If perShaderStage and inFragment stage are equal we want to + // allow the test to run as otherwise we can't test overMaximum and overLimit + t.device.limits.maxStorageTexturesPerShaderStage > + t.device.limits.maxStorageTexturesInFragmentStage! && + // They aren't equal so if there aren't enough supported in the fragment then skip + !(t.device.limits.maxStorageTexturesInFragmentStage! >= testValue), + `maxStorageTexturesInVertexShader = ${t.adapter.limits.maxStorageTexturesInVertexStage} which is less than ${testValue}` + ); +} + g.test('createBindGroupLayout,at_over') .desc( ` @@ -71,7 +92,7 @@ g.test('createBindGroupLayout,at_over') t.adapter.limits.maxBindingsPerBindGroup < testValue, `maxBindingsPerBindGroup = ${t.adapter.limits.maxBindingsPerBindGroup} which is less than ${testValue}` ); - + skipIfNotEnoughStorageTexturesInStage(t, visibility, testValue); await t.expectValidationError( () => createBindGroupLayout(device, visibility, order, testValue), shouldError @@ -105,6 +126,8 @@ g.test('createPipelineLayout,at_over') limitTest, testValueName, async ({ device, testValue, shouldError, actualLimit }) => { + skipIfNotEnoughStorageTexturesInStage(t, visibility, testValue); + const maxBindingsPerBindGroup = Math.min( t.device.limits.maxBindingsPerBindGroup, actualLimit