Skip to content

Commit ae99c53

Browse files
committed
Refactor api/validation/render_pipeline/*
Issue #4178 Issue #4181
1 parent f555996 commit ae99c53

File tree

6 files changed

+45
-80
lines changed

6 files changed

+45
-80
lines changed

src/webgpu/api/validation/render_pipeline/depth_stencil_state.spec.ts

+37-63
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ import {
1111
} from '../../../capability_info.js';
1212
import {
1313
kAllTextureFormats,
14-
kTextureFormatInfo,
1514
kDepthStencilFormats,
15+
isDepthOrStencilTextureFormat,
16+
isDepthTextureFormat,
17+
isStencilTextureFormat,
1618
} from '../../../format_info.js';
1719
import { getFragmentShaderCodeWithOutput } from '../../../util/shader.js';
1820

@@ -27,21 +29,15 @@ g.test('format')
2729
.combine('isAsync', [false, true])
2830
.combine('format', kAllTextureFormats)
2931
)
30-
.beforeAllSubcases(t => {
31-
const { format } = t.params;
32-
const info = kTextureFormatInfo[format];
33-
t.skipIfTextureFormatNotSupportedDeprecated(format);
34-
t.selectDeviceOrSkipTestCase(info.feature);
35-
})
3632
.fn(t => {
3733
const { isAsync, format } = t.params;
38-
const info = kTextureFormatInfo[format];
34+
t.skipIfTextureFormatNotSupported(format);
3935

4036
const descriptor = t.getDescriptor({
4137
depthStencil: { format, depthWriteEnabled: false, depthCompare: 'always' },
4238
});
4339

44-
t.doCreateRenderPipelineTest(isAsync, !!info.depth || !!info.stencil, descriptor);
40+
t.doCreateRenderPipelineTest(isAsync, isDepthOrStencilTextureFormat(format), descriptor);
4541
});
4642

4743
g.test('depthCompare_optional')
@@ -59,12 +55,6 @@ g.test('depthCompare_optional')
5955
.combine('stencilFrontDepthFailOp', ['keep', 'zero'] as const)
6056
.combine('stencilBackDepthFailOp', ['keep', 'zero'] as const)
6157
)
62-
.beforeAllSubcases(t => {
63-
const { format } = t.params;
64-
const info = kTextureFormatInfo[format];
65-
t.skipIfTextureFormatNotSupportedDeprecated(format);
66-
t.selectDeviceOrSkipTestCase(info.feature);
67-
})
6858
.fn(t => {
6959
const {
7060
isAsync,
@@ -74,7 +64,7 @@ g.test('depthCompare_optional')
7464
stencilFrontDepthFailOp,
7565
stencilBackDepthFailOp,
7666
} = t.params;
77-
const info = kTextureFormatInfo[format];
67+
t.skipIfTextureFormatNotSupported(format);
7868
const descriptor = t.getDescriptor({
7969
depthStencil: {
8070
format,
@@ -90,12 +80,12 @@ g.test('depthCompare_optional')
9080
const stencilStateIsDefault = depthFailOpsAreKeep;
9181
let success = true;
9282
if (depthWriteEnabled || (depthCompare && depthCompare !== 'always')) {
93-
if (!info.depth) success = false;
83+
if (!isDepthTextureFormat(format)) success = false;
9484
}
9585
if (!stencilStateIsDefault) {
96-
if (!info.stencil) success = false;
86+
if (!isStencilTextureFormat(format)) success = false;
9787
}
98-
if (info.depth) {
88+
if (isDepthTextureFormat(format)) {
9989
if (depthWriteEnabled === undefined) success = false;
10090
if (depthWriteEnabled || !depthFailOpsAreKeep) {
10191
if (depthCompare === undefined) success = false;
@@ -110,20 +100,14 @@ g.test('depthWriteEnabled_optional')
110100
`The depthWriteEnabled in depthStencilState is optional for stencil-only formats but required for formats with a depth.`
111101
)
112102
.params(u => u.combine('isAsync', [false, true]).combine('format', kDepthStencilFormats))
113-
.beforeAllSubcases(t => {
114-
const { format } = t.params;
115-
const info = kTextureFormatInfo[format];
116-
t.skipIfTextureFormatNotSupportedDeprecated(format);
117-
t.selectDeviceOrSkipTestCase(info.feature);
118-
})
119103
.fn(t => {
120104
const { isAsync, format } = t.params;
121-
const info = kTextureFormatInfo[format];
105+
t.skipIfTextureFormatNotSupported(format);
122106
const descriptor = t.getDescriptor({
123107
depthStencil: { format, depthCompare: 'always', depthWriteEnabled: undefined },
124108
});
125109

126-
t.doCreateRenderPipelineTest(isAsync, !info.depth, descriptor);
110+
t.doCreateRenderPipelineTest(isAsync, !isDepthTextureFormat(format), descriptor);
127111
});
128112

129113
g.test('depth_test')
@@ -136,21 +120,20 @@ g.test('depth_test')
136120
.combine('format', kDepthStencilFormats)
137121
.combine('depthCompare', kCompareFunctions)
138122
)
139-
.beforeAllSubcases(t => {
140-
const { format } = t.params;
141-
const info = kTextureFormatInfo[format];
142-
t.selectDeviceOrSkipTestCase(info.feature);
143-
})
144123
.fn(t => {
145124
const { isAsync, format, depthCompare } = t.params;
146-
const info = kTextureFormatInfo[format];
125+
t.skipIfTextureFormatNotSupported(format);
147126

148127
const descriptor = t.getDescriptor({
149128
depthStencil: { format, depthCompare, depthWriteEnabled: false },
150129
});
151130

152131
const depthTestEnabled = depthCompare !== undefined && depthCompare !== 'always';
153-
t.doCreateRenderPipelineTest(isAsync, !depthTestEnabled || !!info.depth, descriptor);
132+
t.doCreateRenderPipelineTest(
133+
isAsync,
134+
!depthTestEnabled || isDepthTextureFormat(format),
135+
descriptor
136+
);
154137
});
155138

156139
g.test('depth_write')
@@ -163,35 +146,28 @@ g.test('depth_write')
163146
.combine('format', kDepthStencilFormats)
164147
.combine('depthWriteEnabled', [false, true])
165148
)
166-
.beforeAllSubcases(t => {
167-
const { format } = t.params;
168-
const info = kTextureFormatInfo[format];
169-
t.selectDeviceOrSkipTestCase(info.feature);
170-
})
171149
.fn(t => {
172150
const { isAsync, format, depthWriteEnabled } = t.params;
173-
const info = kTextureFormatInfo[format];
151+
t.skipIfTextureFormatNotSupported(format);
174152

175153
const descriptor = t.getDescriptor({
176154
depthStencil: { format, depthWriteEnabled, depthCompare: 'always' },
177155
});
178-
t.doCreateRenderPipelineTest(isAsync, !depthWriteEnabled || !!info.depth, descriptor);
156+
t.doCreateRenderPipelineTest(
157+
isAsync,
158+
!depthWriteEnabled || isDepthTextureFormat(format),
159+
descriptor
160+
);
179161
});
180162

181163
g.test('depth_write,frag_depth')
182164
.desc(`Depth aspect must be contained in the format if frag_depth is written in fragment stage.`)
183165
.params(u =>
184166
u.combine('isAsync', [false, true]).combine('format', [undefined, ...kDepthStencilFormats])
185167
)
186-
.beforeAllSubcases(t => {
187-
const { format } = t.params;
188-
if (format !== undefined) {
189-
const info = kTextureFormatInfo[format];
190-
t.selectDeviceOrSkipTestCase(info.feature);
191-
}
192-
})
193168
.fn(t => {
194169
const { isAsync, format } = t.params;
170+
t.skipIfTextureFormatNotSupported(format);
195171

196172
const descriptor = t.getDescriptor({
197173
// Keep one color target so that the pipeline is still valid with no depth stencil target.
@@ -205,7 +181,7 @@ g.test('depth_write,frag_depth')
205181
),
206182
});
207183

208-
const hasDepth = format ? !!kTextureFormatInfo[format].depth : false;
184+
const hasDepth = format ? isDepthTextureFormat(format) : false;
209185
t.doCreateRenderPipelineTest(isAsync, hasDepth, descriptor);
210186
});
211187

@@ -265,14 +241,9 @@ g.test('stencil_test')
265241
.combine('face', ['front', 'back'] as const)
266242
.combine('compare', [undefined, ...kCompareFunctions])
267243
)
268-
.beforeAllSubcases(t => {
269-
const { format } = t.params;
270-
const info = kTextureFormatInfo[format];
271-
t.selectDeviceOrSkipTestCase(info.feature);
272-
})
273244
.fn(t => {
274245
const { isAsync, format, face, compare } = t.params;
275-
const info = kTextureFormatInfo[format];
246+
t.skipIfTextureFormatNotSupported(format);
276247

277248
let descriptor: GPURenderPipelineDescriptor;
278249
if (face === 'front') {
@@ -296,7 +267,11 @@ g.test('stencil_test')
296267
}
297268

298269
const stencilTestEnabled = compare !== undefined && compare !== 'always';
299-
t.doCreateRenderPipelineTest(isAsync, !stencilTestEnabled || !!info.stencil, descriptor);
270+
t.doCreateRenderPipelineTest(
271+
isAsync,
272+
!stencilTestEnabled || isStencilTextureFormat(format),
273+
descriptor
274+
);
300275
});
301276

302277
g.test('stencil_write')
@@ -317,14 +292,9 @@ g.test('stencil_write')
317292
] as const)
318293
.combine('op', [undefined, ...kStencilOperations])
319294
)
320-
.beforeAllSubcases(t => {
321-
const { format } = t.params;
322-
const info = kTextureFormatInfo[format];
323-
t.selectDeviceOrSkipTestCase(info.feature);
324-
})
325295
.fn(t => {
326296
const { isAsync, format, faceAndOpType, op } = t.params;
327-
const info = kTextureFormatInfo[format];
297+
t.skipIfTextureFormatNotSupported(format);
328298

329299
const common = {
330300
format,
@@ -357,5 +327,9 @@ g.test('stencil_write')
357327
const descriptor = t.getDescriptor({ depthStencil });
358328

359329
const stencilWriteEnabled = op !== undefined && op !== 'keep';
360-
t.doCreateRenderPipelineTest(isAsync, !stencilWriteEnabled || !!info.stencil, descriptor);
330+
t.doCreateRenderPipelineTest(
331+
isAsync,
332+
!stencilWriteEnabled || isStencilTextureFormat(format),
333+
descriptor
334+
);
361335
});

src/webgpu/api/validation/render_pipeline/misc.spec.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,7 @@ g.test('pipeline_layout,device_mismatch')
8484
'Tests createRenderPipeline(Async) cannot be called with a pipeline layout created from another device'
8585
)
8686
.paramsSubcasesOnly(u => u.combine('isAsync', [true, false]).combine('mismatched', [true, false]))
87-
.beforeAllSubcases(t => {
88-
t.selectMismatchedDeviceOrSkipTestCase(undefined);
89-
})
87+
.beforeAllSubcases(t => t.usesMismatchedDevice())
9088
.fn(t => {
9189
const { isAsync, mismatched } = t.params;
9290

src/webgpu/api/validation/render_pipeline/overrides.spec.ts

+2-6
Original file line numberDiff line numberDiff line change
@@ -442,10 +442,8 @@ clarity on whether values like f16.positive.last_f64_castable would be valid. Se
442442
},
443443
] as const)
444444
)
445-
.beforeAllSubcases(t => {
446-
t.selectDeviceOrSkipTestCase({ requiredFeatures: ['shader-f16'] });
447-
})
448445
.fn(t => {
446+
t.skipIfDeviceDoesNotHaveFeature('shader-f16');
449447
const { isAsync, vertexConstants, _success } = t.params;
450448

451449
t.doCreateRenderPipelineTest(isAsync, _success, {
@@ -485,9 +483,6 @@ TODO(#2060): Tighten the cases around the valid/invalid boundary once we have WG
485483
clarity on whether values like f16.positive.last_f64_castable would be valid. See issue.
486484
`
487485
)
488-
.beforeAllSubcases(t => {
489-
t.selectDeviceOrSkipTestCase({ requiredFeatures: ['shader-f16'] });
490-
})
491486
.params(u =>
492487
u //
493488
.combine('isAsync', [true, false])
@@ -515,6 +510,7 @@ clarity on whether values like f16.positive.last_f64_castable would be valid. Se
515510
] as const)
516511
)
517512
.fn(t => {
513+
t.skipIfDeviceDoesNotHaveFeature('shader-f16');
518514
const { isAsync, fragmentConstants, _success } = t.params;
519515

520516
const descriptor = t.getDescriptor({

src/webgpu/api/validation/render_pipeline/resource_compatibility.spec.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ Tests for resource compatibility between pipeline layout and shader modules
44

55
import { makeTestGroup } from '../../../../common/framework/test_group.js';
66
import { keysOf } from '../../../../common/util/data_tables.js';
7-
import { MaxLimitsTestMixin } from '../../../gpu_test.js';
87
import {
98
kAPIResources,
109
getWGSLShaderForResource,
@@ -14,7 +13,7 @@ import {
1413

1514
import { CreateRenderPipelineValidationTest } from './common.js';
1615

17-
export const g = makeTestGroup(MaxLimitsTestMixin(CreateRenderPipelineValidationTest));
16+
export const g = makeTestGroup(CreateRenderPipelineValidationTest);
1817

1918
g.test('resource_compatibility')
2019
.desc(
@@ -84,7 +83,7 @@ g.test('resource_compatibility')
8483
'Storage textures can not be used in fragment shaders because maxStorageTexturesInFragmentStage === 0'
8584
);
8685
}
87-
t.skipIfTextureViewDimensionNotSupportedDeprecated(wgslResource.texture?.viewDimension);
86+
t.skipIfTextureViewDimensionNotSupported(wgslResource.texture?.viewDimension);
8887
const emptyVS = `
8988
@vertex
9089
fn main() -> @builtin(position) vec4f {

src/webgpu/api/validation/render_pipeline/shader_module.spec.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ g.test('device_mismatch')
2828
{ vertex_mismatched: false, fragment_mismatched: true, _success: false },
2929
])
3030
)
31-
.beforeAllSubcases(t => {
32-
t.selectMismatchedDeviceOrSkipTestCase(undefined);
33-
})
31+
.beforeAllSubcases(t => t.usesMismatchedDevice())
3432
.fn(t => {
3533
const { isAsync, vertex_mismatched, fragment_mismatched, _success } = t.params;
3634

src/webgpu/api/validation/render_pipeline/vertex_state.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
makeValueTestVariant,
99
} from '../../../../common/util/util.js';
1010
import { kVertexFormats, kVertexFormatInfo } from '../../../capability_info.js';
11-
import { ValidationTest } from '../validation_test.js';
11+
import { AllFeaturesMaxLimitsValidationTest } from '../validation_test.js';
1212

1313
const VERTEX_SHADER_CODE_WITH_NO_INPUT = `
1414
@vertex fn main() -> @builtin(position) vec4<f32> {
@@ -55,7 +55,7 @@ function addTestAttributes(
5555
}
5656
}
5757

58-
class F extends ValidationTest {
58+
class F extends AllFeaturesMaxLimitsValidationTest {
5959
getDescriptor(
6060
buffers: Iterable<GPUVertexBufferLayout>,
6161
vertexShaderCode: string

0 commit comments

Comments
 (0)