Skip to content

Commit 42ec18a

Browse files
authored
Refactor api/validation/* (gpuweb#4278)
Issue gpuweb#4178 Issue gpuweb#4181
1 parent 73b1c97 commit 42ec18a

File tree

7 files changed

+27
-37
lines changed

7 files changed

+27
-37
lines changed

src/webgpu/api/validation/capability_checks/features/texture_formats.spec.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { assert } from '../../../../../common/util/util.js';
88
import { kCanvasTextureFormats } from '../../../../capability_info.js';
99
import {
1010
getBlockInfoForTextureFormat,
11-
getRequiredFeatureForTextureFormat,
1211
isDepthOrStencilTextureFormat,
1312
isTextureFormatPossiblyStorageReadable,
1413
isTextureFormatPossiblyUsableAsColorRenderAttachment,
@@ -33,7 +32,7 @@ g.test('texture_descriptor')
3332
const { format, enable_required_feature } = t.params;
3433

3534
if (enable_required_feature) {
36-
t.selectDeviceOrSkipTestCase(getRequiredFeatureForTextureFormat(format));
35+
t.selectDeviceForTextureFormatOrSkipTestCase(format);
3736
}
3837
})
3938
.fn(t => {
@@ -63,7 +62,7 @@ g.test('texture_descriptor_view_formats')
6362
const { format, enable_required_feature } = t.params;
6463

6564
if (enable_required_feature) {
66-
t.selectDeviceOrSkipTestCase(getRequiredFeatureForTextureFormat(format));
65+
t.selectDeviceForTextureFormatOrSkipTestCase(format);
6766
}
6867
})
6968
.fn(t => {
@@ -94,7 +93,7 @@ g.test('texture_view_descriptor')
9493
const { format, enable_required_feature } = t.params;
9594

9695
if (enable_required_feature) {
97-
t.selectDeviceOrSkipTestCase(getRequiredFeatureForTextureFormat(format));
96+
t.selectDeviceForTextureFormatOrSkipTestCase(format);
9897
}
9998
})
10099
.fn(t => {
@@ -145,7 +144,7 @@ g.test('canvas_configuration')
145144
const { format, enable_required_feature } = t.params;
146145

147146
if (enable_required_feature) {
148-
t.selectDeviceOrSkipTestCase(getRequiredFeatureForTextureFormat(format));
147+
t.selectDeviceForTextureFormatOrSkipTestCase(format);
149148
}
150149
})
151150
.fn(t => {
@@ -241,7 +240,7 @@ g.test('storage_texture_binding_layout')
241240
const { format, enable_required_feature } = t.params;
242241

243242
if (enable_required_feature) {
244-
t.selectDeviceOrSkipTestCase(getRequiredFeatureForTextureFormat(format));
243+
t.selectDeviceForTextureFormatOrSkipTestCase(format);
245244
}
246245
})
247246
.fn(t => {
@@ -283,7 +282,7 @@ g.test('color_target_state')
283282
const { format, enable_required_feature } = t.params;
284283

285284
if (enable_required_feature) {
286-
t.selectDeviceOrSkipTestCase(getRequiredFeatureForTextureFormat(format));
285+
t.selectDeviceForTextureFormatOrSkipTestCase(format);
287286
}
288287
})
289288
.fn(t => {
@@ -339,7 +338,7 @@ g.test('depth_stencil_state')
339338
const { format, enable_required_feature } = t.params;
340339

341340
if (enable_required_feature) {
342-
t.selectDeviceOrSkipTestCase(getRequiredFeatureForTextureFormat(format));
341+
t.selectDeviceForTextureFormatOrSkipTestCase(format);
343342
}
344343
})
345344
.fn(t => {
@@ -400,7 +399,7 @@ g.test('render_bundle_encoder_descriptor_color_format')
400399
const { format, enable_required_feature } = t.params;
401400

402401
if (enable_required_feature) {
403-
t.selectDeviceOrSkipTestCase(getRequiredFeatureForTextureFormat(format));
402+
t.selectDeviceForTextureFormatOrSkipTestCase(format);
404403
}
405404
})
406405
.fn(t => {
@@ -431,7 +430,7 @@ g.test('render_bundle_encoder_descriptor_depth_stencil_format')
431430
const { format, enable_required_feature } = t.params;
432431

433432
if (enable_required_feature) {
434-
t.selectDeviceOrSkipTestCase(getRequiredFeatureForTextureFormat(format));
433+
t.selectDeviceForTextureFormatOrSkipTestCase(format);
435434
}
436435
})
437436
.fn(t => {

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

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ import {
1515
getAPIBindGroupLayoutForResource,
1616
doResourcesMatch,
1717
} from './utils.js';
18-
import { ValidationTest } from './validation_test.js';
18+
import { AllFeaturesMaxLimitsValidationTest } from './validation_test.js';
1919

20-
class F extends ValidationTest {
20+
class F extends AllFeaturesMaxLimitsValidationTest {
2121
getShaderModule(
2222
shaderStage: TShaderStage = 'compute',
2323
entryPoint: string = 'main'
@@ -93,9 +93,7 @@ g.test('shader_module,device_mismatch')
9393
'Tests createComputePipeline(Async) cannot be called with a shader module created from another device'
9494
)
9595
.paramsSubcasesOnly(u => u.combine('isAsync', [true, false]).combine('mismatched', [true, false]))
96-
.beforeAllSubcases(t => {
97-
t.selectMismatchedDeviceOrSkipTestCase(undefined);
98-
})
96+
.beforeAllSubcases(t => t.usesMismatchedDevice())
9997
.fn(t => {
10098
const { isAsync, mismatched } = t.params;
10199

@@ -121,9 +119,7 @@ g.test('pipeline_layout,device_mismatch')
121119
'Tests createComputePipeline(Async) cannot be called with a pipeline layout created from another device'
122120
)
123121
.paramsSubcasesOnly(u => u.combine('isAsync', [true, false]).combine('mismatched', [true, false]))
124-
.beforeAllSubcases(t => {
125-
t.selectMismatchedDeviceOrSkipTestCase(undefined);
126-
})
122+
.beforeAllSubcases(t => t.usesMismatchedDevice())
127123
.fn(t => {
128124
const { isAsync, mismatched } = t.params;
129125
const sourceDevice = mismatched ? t.mismatchedDevice : t.device;
@@ -515,10 +511,8 @@ clarity on whether values like f16.positive.last_castable_pipeline_override woul
515511
},
516512
] as const)
517513
)
518-
.beforeAllSubcases(t => {
519-
t.selectDeviceOrSkipTestCase({ requiredFeatures: ['shader-f16'] });
520-
})
521514
.fn(t => {
515+
t.skipIfDeviceDoesNotHaveFeature('shader-f16');
522516
const { isAsync, constants, _success } = t.params;
523517

524518
const descriptor = {
@@ -718,7 +712,7 @@ g.test('resource_compatibility')
718712
!t.hasLanguageFeature('readonly_and_readwrite_storage_textures'),
719713
'Storage textures require language feature'
720714
);
721-
t.skipIfTextureViewDimensionNotSupportedDeprecated(wgslResource.texture?.viewDimension);
715+
t.skipIfTextureViewDimensionNotSupported(wgslResource.texture?.viewDimension);
722716

723717
const layout = t.device.createPipelineLayout({
724718
bindGroupLayouts: [

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ Test validation of pushDebugGroup, popDebugGroup, and insertDebugMarker.
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-
class F extends ValidationTest {
9+
class F extends AllFeaturesMaxLimitsValidationTest {
1010
beginRenderPass(commandEncoder: GPUCommandEncoder): GPURenderPassEncoder {
1111
const attachmentTexture = this.createTextureTracked({
1212
format: 'rgba8unorm',

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ export const description = `
55
import { makeTestGroup } from '../../../common/framework/test_group.js';
66
import { assert } from '../../../common/util/util.js';
77

8-
import { ValidationTest } from './validation_test.js';
8+
import { AllFeaturesMaxLimitsValidationTest } from './validation_test.js';
99

10-
export const g = makeTestGroup(ValidationTest);
10+
export const g = makeTestGroup(AllFeaturesMaxLimitsValidationTest);
1111

1212
g.test('index_range,explicit_layout')
1313
.desc(

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import {
1212
waitForNextTask,
1313
} from '../../web_platform/util.js';
1414

15-
import { ValidationTest } from './validation_test.js';
15+
import { AllFeaturesMaxLimitsValidationTest } from './validation_test.js';
1616

17-
class GPUExternalTextureExpireTest extends ValidationTest {
17+
class GPUExternalTextureExpireTest extends AllFeaturesMaxLimitsValidationTest {
1818
submitCommandBuffer(bindGroup: GPUBindGroup, success: boolean): void {
1919
const kHeight = 16;
2020
const kWidth = 16;

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ import {
1212
ValidBindableResource,
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
type BindableResourceType = ValidBindableResource | 'readonlyStorageBuf';
2019
const kBindableResources = [
@@ -93,7 +92,7 @@ const bindGroupLayoutEntryContents = {
9392
},
9493
} as const;
9594

96-
class F extends ValidationTest {
95+
class F extends AllFeaturesMaxLimitsValidationTest {
9796
createPipelineLayout(
9897
bindingInPipelineLayout: BindableResourceType,
9998
visibility: number
@@ -157,7 +156,7 @@ const BindingResourceCompatibleWithShaderStages = function (
157156
return true;
158157
};
159158

160-
export const g = makeTestGroup(MaxLimitsTestMixin(F));
159+
export const g = makeTestGroup(F);
161160

162161
g.test('pipeline_layout_shader_exact_match')
163162
.desc(

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Tests that non-filterable textures used with filtering samplers generate a valid
55
import { makeTestGroup } from '../../../common/framework/test_group.js';
66
import { keysOf } from '../../../common/util/data_tables.js';
77

8-
import { ValidationTest } from './validation_test.js';
8+
import { AllFeaturesMaxLimitsValidationTest } from './validation_test.js';
99

1010
const kNonFilterableCaseInfo: Record<GPUTextureSampleType, { type: string; component: string }> = {
1111
sint: { type: 'i32', component: '0,' },
@@ -16,7 +16,7 @@ const kNonFilterableCaseInfo: Record<GPUTextureSampleType, { type: string; compo
1616
};
1717
const kNonFilterableCases = keysOf(kNonFilterableCaseInfo);
1818

19-
export const g = makeTestGroup(ValidationTest);
19+
export const g = makeTestGroup(AllFeaturesMaxLimitsValidationTest);
2020

2121
g.test('non_filterable_texture_with_filtering_sampler')
2222
.desc(
@@ -30,13 +30,11 @@ g.test('non_filterable_texture_with_filtering_sampler')
3030
.combine('viewDimension', ['2d', '2d-array', 'cube', 'cube-array'] as const)
3131
.combine('sameGroup', [true, false] as const)
3232
)
33-
.beforeAllSubcases(t =>
34-
t.skipIfTextureViewDimensionNotSupportedDeprecated(t.params.viewDimension)
35-
)
3633
.fn(t => {
3734
const { device } = t;
3835
const { pipeline, async, sampleType, viewDimension, sameGroup } = t.params;
3936
const { type, component } = kNonFilterableCaseInfo[sampleType];
37+
t.skipIfTextureViewDimensionNotSupported(viewDimension);
4038

4139
const coord = viewDimension.startsWith('2d') ? 'vec2f(0)' : 'vec3f(0)';
4240
const dimensionSuffix = viewDimension.replace('-', '_');

0 commit comments

Comments
 (0)