Skip to content

Commit b40dc47

Browse files
authored
Refactor api/validation/(encoding|query_set|render_pass|shader_module) (gpuweb#4276)
Issue gpuweb#4178 Issue gpuweb#4181
1 parent 1a34648 commit b40dc47

File tree

7 files changed

+34
-50
lines changed

7 files changed

+34
-50
lines changed

src/webgpu/api/validation/encoding/createRenderBundleEncoder.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
isTextureFormatColorRenderable,
1515
kAllTextureFormats,
1616
kDepthStencilFormats,
17-
kRenderableColorTextureFormats,
17+
kPossibleColorRenderableTextureFormats,
1818
} from '../../../format_info.js';
1919
import { AllFeaturesMaxLimitsValidationTest } from '../validation_test.js';
2020

@@ -56,7 +56,7 @@ g.test('attachment_state,limits,maxColorAttachmentBytesPerSample,aligned')
5656
)
5757
.params(u =>
5858
u
59-
.combine('format', kRenderableColorTextureFormats)
59+
.combine('format', kPossibleColorRenderableTextureFormats)
6060
.beginSubcases()
6161
.combine(
6262
'colorFormatCount',

src/webgpu/api/validation/query_set/create.spec.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ Tests for validation in createQuerySet.
44

55
import { makeTestGroup } from '../../../../common/framework/test_group.js';
66
import { kQueryTypes, kMaxQueryCount } from '../../../capability_info.js';
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('count')
1212
.desc(
@@ -22,11 +22,9 @@ Tests that create query set with the count for all query types:
2222
.beginSubcases()
2323
.combine('count', [0, kMaxQueryCount, kMaxQueryCount + 1])
2424
)
25-
.beforeAllSubcases(t => {
26-
t.selectDeviceForQueryTypeOrSkipTestCase(t.params.type);
27-
})
2825
.fn(t => {
2926
const { type, count } = t.params;
27+
t.skipIfDeviceDoesNotSupportQueryType(type);
3028

3129
t.expectValidationError(() => {
3230
t.createQuerySetTracked({ type, count });

src/webgpu/api/validation/query_set/destroy.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ Destroying a query set more than once is allowed.
33
`;
44

55
import { makeTestGroup } from '../../../../common/framework/test_group.js';
6-
import { ValidationTest } from '../validation_test.js';
6+
import { AllFeaturesMaxLimitsValidationTest } from '../validation_test.js';
77

8-
export const g = makeTestGroup(ValidationTest);
8+
export const g = makeTestGroup(AllFeaturesMaxLimitsValidationTest);
99

1010
g.test('twice').fn(t => {
1111
const qset = t.createQuerySetTracked({ type: 'occlusion', count: 1 });

src/webgpu/api/validation/render_pass/attachment_compatibility.spec.ts

Lines changed: 21 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@ import { makeTestGroup } from '../../../../common/framework/test_group.js';
88
import { range } from '../../../../common/util/util.js';
99
import { getDefaultLimits, kTextureSampleCounts } from '../../../capability_info.js';
1010
import {
11-
kRegularTextureFormats,
1211
kSizedDepthStencilFormats,
1312
kUnsizedDepthStencilFormats,
14-
kTextureFormatInfo,
1513
filterFormatsByFeature,
1614
getFeaturesForFormats,
15+
isDepthTextureFormat,
16+
isStencilTextureFormat,
17+
kPossibleColorRenderableTextureFormats,
1718
} from '../../../format_info.js';
18-
import { ValidationTest } from '../validation_test.js';
19+
import { AllFeaturesMaxLimitsValidationTest } from '../validation_test.js';
1920

2021
// MAINTENANCE_TODO: This should be changed to kMaxColorAttachmentsToTest
2122
// when this is made a MaxLimitTest (see above).
@@ -89,7 +90,7 @@ const kFeaturesForDepthStencilAttachmentFormats = getFeaturesForFormats([
8990
...kUnsizedDepthStencilFormats,
9091
]);
9192

92-
class F extends ValidationTest {
93+
class F extends AllFeaturesMaxLimitsValidationTest {
9394
createAttachmentTextureView(format: GPUTextureFormat, sampleCount?: number) {
9495
return this.createTextureTracked({
9596
// Size matching the "arbitrary" size used by ValidationTest helpers.
@@ -121,12 +122,12 @@ class F extends ValidationTest {
121122
const attachment: GPURenderPassDepthStencilAttachment = {
122123
view: this.createAttachmentTextureView(format, sampleCount),
123124
};
124-
if (kTextureFormatInfo[format].depth) {
125+
if (isDepthTextureFormat(format)) {
125126
attachment.depthClearValue = 0;
126127
attachment.depthLoadOp = 'clear';
127128
attachment.depthStoreOp = 'discard';
128129
}
129-
if (kTextureFormatInfo[format].stencil) {
130+
if (isStencilTextureFormat(format)) {
130131
attachment.stencilClearValue = 1;
131132
attachment.stencilLoadOp = 'clear';
132133
attachment.stencilStoreOp = 'discard';
@@ -167,21 +168,17 @@ class F extends ValidationTest {
167168

168169
export const g = makeTestGroup(F);
169170

170-
const kColorAttachmentFormats = kRegularTextureFormats.filter(
171-
format => !!kTextureFormatInfo[format].colorRender
172-
);
173-
174171
g.test('render_pass_and_bundle,color_format')
175172
.desc('Test that color attachment formats in render passes and bundles must match.')
176173
.paramsSubcasesOnly(u =>
177174
u //
178-
.combine('passFormat', kColorAttachmentFormats)
179-
.combine('bundleFormat', kColorAttachmentFormats)
175+
.combine('passFormat', kPossibleColorRenderableTextureFormats)
176+
.combine('bundleFormat', kPossibleColorRenderableTextureFormats)
180177
)
181178
.fn(t => {
182179
const { passFormat, bundleFormat } = t.params;
183-
184-
t.skipIfTextureFormatNotSupportedDeprecated(passFormat, bundleFormat);
180+
t.skipIfTextureFormatNotSupported(passFormat, bundleFormat);
181+
t.skipIfTextureFormatNotUsableAsRenderAttachment(passFormat, bundleFormat);
185182

186183
const bundleEncoder = t.device.createRenderBundleEncoder({
187184
colorFormats: [bundleFormat],
@@ -301,12 +298,9 @@ g.test('render_pass_and_bundle,depth_format')
301298
filterFormatsByFeature(bundleFeature, kDepthStencilAttachmentFormats)
302299
)
303300
)
304-
.beforeAllSubcases(t => {
305-
const { passFeature, bundleFeature } = t.params;
306-
t.selectDeviceOrSkipTestCase([passFeature, bundleFeature]);
307-
})
308301
.fn(t => {
309302
const { passFormat, bundleFormat } = t.params;
303+
t.skipIfTextureFormatNotSupported(passFormat, bundleFormat);
310304

311305
const bundleEncoder = t.device.createRenderBundleEncoder({
312306
colorFormats: ['rgba8unorm'],
@@ -351,9 +345,7 @@ g.test('render_pass_and_bundle,sample_count')
351345
g.test('render_pass_and_bundle,device_mismatch')
352346
.desc('Test that render passes cannot be called with bundles created from another device.')
353347
.paramsSubcasesOnly(u => u.combine('mismatched', [true, false]))
354-
.beforeAllSubcases(t => {
355-
t.selectMismatchedDeviceOrSkipTestCase(undefined);
356-
})
348+
.beforeAllSubcases(t => t.usesMismatchedDevice())
357349
.fn(t => {
358350
const { mismatched } = t.params;
359351
const sourceDevice = mismatched ? t.mismatchedDevice : t.device;
@@ -383,13 +375,13 @@ Test that color attachment formats in render passes or bundles match the pipelin
383375
u
384376
.combine('encoderType', ['render pass', 'render bundle'] as const)
385377
.beginSubcases()
386-
.combine('encoderFormat', kColorAttachmentFormats)
387-
.combine('pipelineFormat', kColorAttachmentFormats)
378+
.combine('encoderFormat', kPossibleColorRenderableTextureFormats)
379+
.combine('pipelineFormat', kPossibleColorRenderableTextureFormats)
388380
)
389381
.fn(t => {
390382
const { encoderType, encoderFormat, pipelineFormat } = t.params;
391-
392-
t.skipIfTextureFormatNotSupportedDeprecated(encoderFormat, pipelineFormat);
383+
t.skipIfTextureFormatNotSupported(encoderFormat, pipelineFormat);
384+
t.skipIfTextureFormatNotUsableAsRenderAttachment(encoderFormat, pipelineFormat);
393385

394386
const pipeline = t.createRenderPipeline([{ format: pipelineFormat, writeMask: 0 }]);
395387

@@ -506,12 +498,9 @@ Test that the depth attachment format in render passes or bundles match the pipe
506498
filterFormatsByFeature(pipelineFormatFeature, kDepthStencilAttachmentFormats)
507499
)
508500
)
509-
.beforeAllSubcases(t => {
510-
const { encoderFormatFeature, pipelineFormatFeature } = t.params;
511-
t.selectDeviceOrSkipTestCase([encoderFormatFeature, pipelineFormatFeature]);
512-
})
513501
.fn(t => {
514502
const { encoderType, encoderFormat, pipelineFormat } = t.params;
503+
t.skipIfTextureFormatNotSupported(encoderFormat, pipelineFormat);
515504

516505
const pipeline = t.createRenderPipeline(
517506
[{ format: 'rgba8unorm', writeMask: 0 }],
@@ -554,16 +543,15 @@ Test that the depth stencil read only state in render passes or bundles is compa
554543
.combine('cullMode', ['none', 'front', 'back'] as const)
555544
.filter(p => {
556545
if (p.format) {
557-
const depthStencilInfo = kTextureFormatInfo[p.format];
558546
// If the format has no depth aspect, the depthReadOnly, depthWriteEnabled of the pipeline must not be true
559547
// in order to create a valid render pipeline.
560-
if (!depthStencilInfo.depth && p.depthWriteEnabled) {
548+
if (!isDepthTextureFormat(p.format) && p.depthWriteEnabled) {
561549
return false;
562550
}
563551
// If the format has no stencil aspect, the stencil state operation must be 'keep'
564552
// in order to create a valid render pipeline.
565553
if (
566-
!depthStencilInfo.stencil &&
554+
!isStencilTextureFormat(p.format) &&
567555
(p.stencilFront.failOp !== 'keep' || p.stencilBack.failOp !== 'keep')
568556
) {
569557
return false;
@@ -573,9 +561,6 @@ Test that the depth stencil read only state in render passes or bundles is compa
573561
return true;
574562
})
575563
)
576-
.beforeAllSubcases(t => {
577-
t.selectDeviceForTextureFormatOrSkipTestCase(t.params.format);
578-
})
579564
.fn(t => {
580565
const {
581566
encoderType,
@@ -588,6 +573,7 @@ Test that the depth stencil read only state in render passes or bundles is compa
588573
stencilFront,
589574
stencilBack,
590575
} = t.params;
576+
t.skipIfTextureFormatNotSupported(format);
591577

592578
const pipeline = t.createRenderPipeline(
593579
[{ format: 'rgba8unorm', writeMask: 0 }],

src/webgpu/api/validation/render_pass/resolve.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ Validation tests for render pass resolve.
44

55
import { makeTestGroup } from '../../../../common/framework/test_group.js';
66
import { GPUConst } from '../../../constants.js';
7-
import { ValidationTest } from '../validation_test.js';
7+
import { AllFeaturesMaxLimitsValidationTest } from '../validation_test.js';
88

99
const kNumColorAttachments = 4;
1010

11-
export const g = makeTestGroup(ValidationTest);
11+
export const g = makeTestGroup(AllFeaturesMaxLimitsValidationTest);
1212

1313
g.test('resolve_attachment')
1414
.desc(

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ TODO:
1616

1717
import { makeTestGroup } from '../../../../common/framework/test_group.js';
1818
import { kDefaultVertexShaderCode, getShaderWithEntryPoint } from '../../../util/shader.js';
19-
import { ValidationTest } from '../validation_test.js';
19+
import { AllFeaturesMaxLimitsValidationTest } from '../validation_test.js';
2020

21-
export const g = makeTestGroup(ValidationTest);
21+
export const g = makeTestGroup(AllFeaturesMaxLimitsValidationTest);
2222

2323
const kEntryPointTestCases = [
2424
{ shaderModuleEntryPoint: 'main', stageEntryPoint: 'main' },

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ This tests overrides numeric identifiers should not conflict.
33
`;
44

55
import { makeTestGroup } from '../../../../common/framework/test_group.js';
6-
import { ValidationTest } from '../validation_test.js';
6+
import { AllFeaturesMaxLimitsValidationTest } from '../validation_test.js';
77

8-
export const g = makeTestGroup(ValidationTest);
8+
export const g = makeTestGroup(AllFeaturesMaxLimitsValidationTest);
99

1010
g.test('id_conflict')
1111
.desc(

0 commit comments

Comments
 (0)