Skip to content

Commit 73b1c97

Browse files
authored
Refactor api/validation/create* (#4275)
Issue #4178 Issue #4181
1 parent b40dc47 commit 73b1c97

6 files changed

+76
-150
lines changed

src/webgpu/api/validation/createBindGroup.spec.ts

+4-10
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ g.test('texture_must_have_correct_dimension')
368368
dimension: getTextureDimensionFromView(dimension),
369369
});
370370

371-
t.skipIfTextureViewDimensionNotSupportedDeprecated(viewDimension, dimension);
371+
t.skipIfTextureViewDimensionNotSupported(viewDimension, dimension);
372372
if (t.isCompatibility && texture.dimension === '2d') {
373373
if (depthOrArrayLayers === 1) {
374374
t.skipIf(
@@ -661,9 +661,7 @@ g.test('bind_group_layout,device_mismatch')
661661
'Tests createBindGroup cannot be called with a bind group layout created from another device'
662662
)
663663
.paramsSubcasesOnly(u => u.combine('mismatched', [true, false]))
664-
.beforeAllSubcases(t => {
665-
t.usesMismatchedDevice();
666-
})
664+
.beforeAllSubcases(t => t.usesMismatchedDevice())
667665
.fn(t => {
668666
const mismatched = t.params.mismatched;
669667

@@ -721,9 +719,7 @@ g.test('binding_resources,device_mismatch')
721719
])
722720
.combine('visibilityMask', [kAllShaderStages, GPUConst.ShaderStage.COMPUTE] as const)
723721
)
724-
.beforeAllSubcases(t => {
725-
t.usesMismatchedDevice();
726-
})
722+
.beforeAllSubcases(t => t.usesMismatchedDevice())
727723
.fn(t => {
728724
const { entry, resource0Mismatched, resource1Mismatched, visibilityMask } = t.params;
729725

@@ -1131,9 +1127,7 @@ g.test('buffer,effective_buffer_binding_size')
11311127
g.test('sampler,device_mismatch')
11321128
.desc(`Tests createBindGroup cannot be called with a sampler created from another device.`)
11331129
.paramsSubcasesOnly(u => u.combine('mismatched', [true, false]))
1134-
.beforeAllSubcases(t => {
1135-
t.usesMismatchedDevice();
1136-
})
1130+
.beforeAllSubcases(t => t.usesMismatchedDevice())
11371131
.fn(t => {
11381132
const { mismatched } = t.params;
11391133

src/webgpu/api/validation/createBindGroupLayout.spec.ts

+13-10
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,13 @@ import {
1919
BGLEntry,
2020
getBindingLimitForBindingType,
2121
} from '../../capability_info.js';
22-
import { kAllTextureFormats, kTextureFormatInfo } from '../../format_info.js';
23-
import { MaxLimitsTestMixin } from '../../gpu_test.js';
22+
import {
23+
isTextureFormatUsableAsReadWriteStorageTexture,
24+
isTextureFormatUsableAsStorageFormat,
25+
kAllTextureFormats,
26+
} from '../../format_info.js';
2427

25-
import { ValidationTest } from './validation_test.js';
28+
import { AllFeaturesMaxLimitsValidationTest } from './validation_test.js';
2629

2730
function clone<T extends GPUBindGroupLayoutDescriptor>(descriptor: T): T {
2831
return JSON.parse(JSON.stringify(descriptor));
@@ -74,7 +77,7 @@ function isValidBGLEntryForStages(device: GPUDevice, visibility: number, entry:
7477
: true;
7578
}
7679

77-
export const g = makeTestGroup(MaxLimitsTestMixin(ValidationTest));
80+
export const g = makeTestGroup(AllFeaturesMaxLimitsValidationTest);
7881

7982
g.test('duplicate_bindings')
8083
.desc('Test that uniqueness of binding numbers across entries is enforced.')
@@ -505,16 +508,16 @@ g.test('storage_texture,formats')
505508
.combine('format', kAllTextureFormats) //
506509
.combine('access', kStorageTextureAccessValues)
507510
)
508-
.beforeAllSubcases(t => {
509-
t.selectDeviceForTextureFormatOrSkipTestCase(t.params.format);
510-
t.skipIfTextureFormatNotUsableAsStorageTextureDeprecated(t.params.format);
511-
})
512511
.fn(t => {
513512
const { format, access } = t.params;
514-
const info = kTextureFormatInfo[format];
513+
t.skipIfTextureFormatNotSupported(format);
514+
t.skipIfTextureFormatNotUsableAsStorageTexture(format);
515515

516516
const success =
517-
info.color?.storage && !(access === 'read-write' && !info.color?.readWriteStorage);
517+
isTextureFormatUsableAsStorageFormat(t.device, format) &&
518+
!(
519+
access === 'read-write' && !isTextureFormatUsableAsReadWriteStorageTexture(t.device, format)
520+
);
518521

519522
t.expectValidationError(() => {
520523
t.device.createBindGroupLayout({

src/webgpu/api/validation/createPipelineLayout.spec.ts

+3-6
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,14 @@ import {
1212
kBufferBindingTypes,
1313
} from '../../capability_info.js';
1414
import { GPUConst } from '../../constants.js';
15-
import { MaxLimitsTestMixin } from '../../gpu_test.js';
1615

17-
import { ValidationTest } from './validation_test.js';
16+
import { AllFeaturesMaxLimitsValidationTest } from './validation_test.js';
1817

1918
function clone<T extends GPUBindGroupLayoutDescriptor>(descriptor: T): T {
2019
return JSON.parse(JSON.stringify(descriptor));
2120
}
2221

23-
export const g = makeTestGroup(MaxLimitsTestMixin(ValidationTest));
22+
export const g = makeTestGroup(AllFeaturesMaxLimitsValidationTest);
2423

2524
g.test('number_of_dynamic_buffers_exceeds_the_maximum_value')
2625
.desc(
@@ -145,9 +144,7 @@ g.test('bind_group_layouts,device_mismatch')
145144
{ layout0Mismatched: true, layout1Mismatched: false },
146145
{ layout0Mismatched: false, layout1Mismatched: true },
147146
])
148-
.beforeAllSubcases(t => {
149-
t.selectMismatchedDeviceOrSkipTestCase(undefined);
150-
})
147+
.beforeAllSubcases(t => t.usesMismatchedDevice())
151148
.fn(t => {
152149
const { layout0Mismatched, layout1Mismatched } = t.params;
153150

src/webgpu/api/validation/createSampler.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ createSampler validation tests.
44

55
import { makeTestGroup } from '../../../common/framework/test_group.js';
66

7-
import { ValidationTest } from './validation_test.js';
7+
import { AllFeaturesMaxLimitsValidationTest } from './validation_test.js';
88

9-
export const g = makeTestGroup(ValidationTest);
9+
export const g = makeTestGroup(AllFeaturesMaxLimitsValidationTest);
1010

1111
g.test('lodMinAndMaxClamp')
1212
.desc('test different combinations of min and max clamp values')

0 commit comments

Comments
 (0)