From 01831137f7aa194508f1c1a9ad3c4c9fe2caf80d Mon Sep 17 00:00:00 2001 From: Gregg Tavares Date: Mon, 23 Dec 2024 15:20:39 +0900 Subject: [PATCH] Compat: refactor createBindGroup tests Note: Several tests just switched from FRAGMENT to COMPUTE as nothing about the test seemed dependent on using the FRAGMENT stage. We could add a stage parameter if we want to test in all stages. For now I just switched those tests that didn't need FRAGMENT to use COMPUTE. For those that were testing all stages I added a parameter to test all vs only compute with the appropriate skipIf if the resources are not available. --- .../api/validation/createBindGroup.spec.ts | 34 +++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/webgpu/api/validation/createBindGroup.spec.ts b/src/webgpu/api/validation/createBindGroup.spec.ts index 3724acb93c1..23b1354d738 100644 --- a/src/webgpu/api/validation/createBindGroup.spec.ts +++ b/src/webgpu/api/validation/createBindGroup.spec.ts @@ -25,7 +25,7 @@ import { } from '../../capability_info.js'; import { GPUConst } from '../../constants.js'; import { kAllTextureFormats, kTextureFormatInfo } from '../../format_info.js'; -import { kResourceStates } from '../../gpu_test.js'; +import { kResourceStates, MaxLimitsTestMixin } from '../../gpu_test.js'; import { getTextureDimensionFromView } from '../../util/texture/base.js'; import { ValidationTest } from './validation_test.js'; @@ -43,8 +43,8 @@ function skipIfResourceNotSupportedInStages( t.skipIf( (visibility & GPUShaderStage.FRAGMENT) !== 0 && (entry.buffer?.type === 'storage' || entry.buffer?.type === 'read-only-storage') && - !(t.device.limits.maxStorageBuffersInFragmentStage! >= 1), - `maxStorageBuffersInFragmentStage(${t.device.limits.maxStorageBuffersInFragmentStage}) < 1` + !(t.device.limits.maxStorageBuffersInFragmentStage! >= 2), + `maxStorageBuffersInFragmentStage(${t.device.limits.maxStorageBuffersInFragmentStage}) < 2` ); t.skipIf( (visibility & GPUShaderStage.FRAGMENT) !== 0 && @@ -55,8 +55,8 @@ function skipIfResourceNotSupportedInStages( t.skipIf( (visibility & GPUShaderStage.VERTEX) !== 0 && (entry.buffer?.type === 'storage' || entry.buffer?.type === 'read-only-storage') && - !(t.device.limits.maxStorageBuffersInVertexStage! >= 1), - `maxStorageBuffersInVertexStage(${t.device.limits.maxStorageBuffersInVertexStage}) < 1` + !(t.device.limits.maxStorageBuffersInVertexStage! >= 2), + `maxStorageBuffersInVertexStage(${t.device.limits.maxStorageBuffersInVertexStage}) < 2` ); t.skipIf( (visibility & GPUShaderStage.VERTEX) !== 0 && @@ -67,7 +67,7 @@ function skipIfResourceNotSupportedInStages( } } -export const g = makeTestGroup(ValidationTest); +export const g = makeTestGroup(MaxLimitsTestMixin(ValidationTest)); const kStorageTextureFormats = kAllTextureFormats.filter(f => kTextureFormatInfo[f].color?.storage); @@ -546,7 +546,8 @@ g.test('minBindingSize') ); }); -const kAllShaderStages = GPUShaderStage.COMPUTE | GPUShaderStage.FRAGMENT | GPUShaderStage.VERTEX; +const kAllShaderStages = + GPUConst.ShaderStage.COMPUTE | GPUConst.ShaderStage.FRAGMENT | GPUConst.ShaderStage.VERTEX; g.test('buffer,resource_state') .desc('Test bind group creation with various buffer resource states') @@ -554,7 +555,7 @@ g.test('buffer,resource_state') u .combine('state', kResourceStates) .combine('entry', bufferBindingEntries(true)) - .combine('visibilityMask', [kAllShaderStages, GPUShaderStage.COMPUTE] as const) + .combine('visibilityMask', [kAllShaderStages, GPUConst.ShaderStage.COMPUTE] as const) ) .fn(t => { const { state, entry, visibilityMask } = t.params; @@ -598,18 +599,24 @@ g.test('buffer,resource_state') g.test('texture,resource_state') .desc('Test bind group creation with various texture resource states') .paramsSubcasesOnly(u => - u.combine('state', kResourceStates).combine('entry', sampledAndStorageBindingEntries(true)) + u + .combine('state', kResourceStates) + .combine('entry', sampledAndStorageBindingEntries(true)) + .combine('visibilityMask', [kAllShaderStages, GPUConst.ShaderStage.COMPUTE] as const) ) .fn(t => { - const { state, entry } = t.params; + const { state, entry, visibilityMask } = t.params; const info = texBindingTypeInfo(entry); + const visibility = info.validStages & visibilityMask; + skipIfResourceNotSupportedInStages(t, entry, visibility); + const bgl = t.device.createBindGroupLayout({ entries: [ { ...entry, binding: 0, - visibility: info.validStages, + visibility, }, ], }); @@ -707,7 +714,7 @@ g.test('binding_resources,device_mismatch') { resource0Mismatched: true, resource1Mismatched: false }, { resource0Mismatched: false, resource1Mismatched: true }, ]) - .combine('visibilityMask', [kAllShaderStages, GPUShaderStage.COMPUTE] as const) + .combine('visibilityMask', [kAllShaderStages, GPUConst.ShaderStage.COMPUTE] as const) ) .beforeAllSubcases(t => { t.selectMismatchedDeviceOrSkipTestCase(undefined); @@ -717,8 +724,7 @@ g.test('binding_resources,device_mismatch') const info = bindingTypeInfo(entry); const visibility = info.validStages & visibilityMask; -// ======> Other unrelated tests pass if this is commented out -// skipIfResourceNotSupportedInStages(t, entry, visibility); + skipIfResourceNotSupportedInStages(t, entry, visibility); const resource0 = resource0Mismatched ? t.getDeviceMismatchedBindingResource(info.resource)