Skip to content

Commit

Permalink
Compat: refactor createBindGroup tests
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
greggman committed Dec 23, 2024
1 parent b1996f5 commit 0183113
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions src/webgpu/api/validation/createBindGroup.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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 &&
Expand All @@ -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 &&
Expand All @@ -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);

Expand Down Expand Up @@ -546,15 +546,16 @@ 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')
.paramsSubcasesOnly(u =>
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;
Expand Down Expand Up @@ -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,
},
],
});
Expand Down Expand Up @@ -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);
Expand All @@ -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)
Expand Down

0 comments on commit 0183113

Please sign in to comment.