Skip to content

Commit c400867

Browse files
committed
Refactor api/validation/resource_usages/*
Issue #4178 Issue #4181
1 parent 1a34648 commit c400867

File tree

5 files changed

+33
-40
lines changed

5 files changed

+33
-40
lines changed

src/webgpu/api/validation/resource_usages/buffer/in_pass_encoder.spec.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ Buffer Usages Validation Tests in Render Pass and Compute Pass.
44

55
import { makeTestGroup } from '../../../../../common/framework/test_group.js';
66
import { assert, unreachable } from '../../../../../common/util/util.js';
7-
import { GPUTestBase, MaxLimitsTestMixin } from '../../../../gpu_test.js';
8-
import { ValidationTest } from '../../validation_test.js';
7+
import { GPUTestBase } from '../../../../gpu_test.js';
8+
import { AllFeaturesMaxLimitsValidationTest } from '../../validation_test.js';
99

1010
const kBoundBufferSize = 256;
1111

@@ -32,7 +32,7 @@ function resourceVisibilityToVisibility(resourceVisibility: 'compute' | 'fragmen
3232
return resourceVisibility === 'compute' ? GPUShaderStage.COMPUTE : GPUShaderStage.FRAGMENT;
3333
}
3434

35-
export class BufferResourceUsageTest extends ValidationTest {
35+
export class BufferResourceUsageTest extends AllFeaturesMaxLimitsValidationTest {
3636
createBindGroupLayoutForTest(
3737
type: 'uniform' | 'storage' | 'read-only-storage',
3838
resourceVisibility: 'compute' | 'fragment'
@@ -180,7 +180,7 @@ export function skipIfStorageBuffersUsedAndNotAvailableInStages(
180180
}
181181
}
182182

183-
export const g = makeTestGroup(MaxLimitsTestMixin(BufferResourceUsageTest));
183+
export const g = makeTestGroup(BufferResourceUsageTest);
184184

185185
g.test('subresources,buffer_usage_in_one_compute_pass_with_no_dispatch')
186186
.desc(

src/webgpu/api/validation/resource_usages/buffer/in_pass_misc.spec.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ Test other buffer usage validation rules that are not tests in ./in_pass_encoder
44

55
import { makeTestGroup } from '../../../../../common/framework/test_group.js';
66
import { unreachable } from '../../../../../common/util/util.js';
7-
import { MaxLimitsTestMixin } from '../../../../gpu_test.js';
87

98
import {
109
BufferUsage,
@@ -13,7 +12,7 @@ import {
1312
skipIfStorageBuffersUsedAndNotAvailableInStages,
1413
} from './in_pass_encoder.spec.js';
1514

16-
export const g = makeTestGroup(MaxLimitsTestMixin(BufferResourceUsageTest));
15+
export const g = makeTestGroup(BufferResourceUsageTest);
1716

1817
const kBufferSize = 256;
1918

src/webgpu/api/validation/resource_usages/texture/in_pass_encoder.spec.ts

+21-25
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@ import { GPUConst } from '../../../../constants.js';
99
import {
1010
kDepthStencilFormats,
1111
kDepthStencilFormatResolvedAspect,
12-
kTextureFormatInfo,
13-
isMultisampledTextureFormatDeprecated,
12+
isStencilTextureFormat,
13+
isDepthTextureFormat,
1414
} from '../../../../format_info.js';
15-
import { MaxLimitsTestMixin } from '../../../../gpu_test.js';
16-
import { ValidationTest } from '../../validation_test.js';
15+
import { AllFeaturesMaxLimitsValidationTest } from '../../validation_test.js';
1716

1817
type TextureBindingType =
1918
| 'sampled-texture'
@@ -30,7 +29,7 @@ const kTextureBindingTypes = [
3029
] as const;
3130

3231
const SIZE = 32;
33-
class TextureUsageTracking extends ValidationTest {
32+
class TextureUsageTracking extends AllFeaturesMaxLimitsValidationTest {
3433
createTestTexture(
3534
options: {
3635
width?: number;
@@ -268,7 +267,7 @@ class TextureUsageTracking extends ValidationTest {
268267
}
269268
}
270269

271-
export const g = makeTestGroup(MaxLimitsTestMixin(TextureUsageTracking));
270+
export const g = makeTestGroup(TextureUsageTracking);
272271

273272
const BASE_LEVEL = 1;
274273
const TOTAL_LEVELS = 6;
@@ -680,13 +679,13 @@ g.test('subresources_and_binding_types_combination_for_aspect')
680679
.combine('aspect1', ['all', 'depth-only', 'stencil-only'] as const)
681680
.unless(
682681
p =>
683-
(p.aspect0 === 'stencil-only' && !kTextureFormatInfo[p.format].stencil) ||
684-
(p.aspect1 === 'stencil-only' && !kTextureFormatInfo[p.format].stencil)
682+
(p.aspect0 === 'stencil-only' && !isStencilTextureFormat(p.format)) ||
683+
(p.aspect1 === 'stencil-only' && !isStencilTextureFormat(p.format))
685684
)
686685
.unless(
687686
p =>
688-
(p.aspect0 === 'depth-only' && !kTextureFormatInfo[p.format].depth) ||
689-
(p.aspect1 === 'depth-only' && !kTextureFormatInfo[p.format].depth)
687+
(p.aspect0 === 'depth-only' && !isDepthTextureFormat(p.format)) ||
688+
(p.aspect1 === 'depth-only' && !isDepthTextureFormat(p.format))
690689
)
691690
.combineWithParams([
692691
{
@@ -703,8 +702,8 @@ g.test('subresources_and_binding_types_combination_for_aspect')
703702
.unless(
704703
// Can't sample a multiplanar texture without selecting an aspect.
705704
p =>
706-
!!kTextureFormatInfo[p.format].depth &&
707-
!!kTextureFormatInfo[p.format].stencil &&
705+
isDepthTextureFormat(p.format) &&
706+
isStencilTextureFormat(p.format) &&
708707
((p.aspect0 === 'all' && p.type0 === 'sampled-texture') ||
709708
(p.aspect1 === 'all' && p.type1 === 'sampled-texture'))
710709
)
@@ -724,15 +723,11 @@ g.test('subresources_and_binding_types_combination_for_aspect')
724723
// Depth-stencil attachment views must encompass all aspects of the texture. Invalid
725724
// cases are for depth-stencil textures when the aspect is not 'all'.
726725
p.type1 === 'render-target' &&
727-
!!kTextureFormatInfo[p.format].depth &&
728-
!!kTextureFormatInfo[p.format].stencil &&
726+
isDepthTextureFormat(p.format) &&
727+
isStencilTextureFormat(p.format) &&
729728
p.aspect1 !== 'all'
730729
)
731730
)
732-
.beforeAllSubcases(t => {
733-
const { format } = t.params;
734-
t.selectDeviceOrSkipTestCase(kTextureFormatInfo[format].feature);
735-
})
736731
.fn(t => {
737732
const {
738733
compute,
@@ -749,6 +744,7 @@ g.test('subresources_and_binding_types_combination_for_aspect')
749744
_usageSuccess,
750745
} = t.params;
751746

747+
t.skipIfTextureFormatNotSupported(format);
752748
t.skipIf(t.isCompatibility, 'sub ranges of layers are not supported in compat mode');
753749

754750
const texture = t.createTestTexture({
@@ -775,8 +771,8 @@ g.test('subresources_and_binding_types_combination_for_aspect')
775771
aspect: aspect1,
776772
});
777773
const view1ResolvedFormat = kDepthStencilFormatResolvedAspect[format][aspect1]!;
778-
const view1HasDepth = kTextureFormatInfo[view1ResolvedFormat].depth;
779-
const view1HasStencil = kTextureFormatInfo[view1ResolvedFormat].stencil;
774+
const view1HasDepth = isDepthTextureFormat(view1ResolvedFormat);
775+
const view1HasStencil = isStencilTextureFormat(view1ResolvedFormat);
780776

781777
const encoder = t.device.createCommandEncoder();
782778
// Color attachment's size should match depth/stencil attachment's size. Note that if
@@ -813,8 +809,8 @@ g.test('subresources_and_binding_types_combination_for_aspect')
813809
case 'stencil-only':
814810
return 'uint';
815811
case 'all':
816-
assert(kTextureFormatInfo[format].depth !== kTextureFormatInfo[format].stencil);
817-
if (kTextureFormatInfo[format].stencil) {
812+
assert(isDepthTextureFormat(format) !== isStencilTextureFormat(format));
813+
if (isStencilTextureFormat(format)) {
818814
return 'uint';
819815
}
820816
return 'depth';
@@ -1157,9 +1153,9 @@ g.test('bindings_in_bundle')
11571153

11581154
t.skipIfNeedStorageTexturesByResourceTypeAndNoStorageTextures(type0, GPUShaderStage.FRAGMENT);
11591155
t.skipIfNeedStorageTexturesByResourceTypeAndNoStorageTextures(type1, GPUShaderStage.FRAGMENT);
1160-
t.skipIf(
1161-
_sampleCount! > 1 && !isMultisampledTextureFormatDeprecated('r32float', t.isCompatibility)
1162-
);
1156+
if (_sampleCount! > 1) {
1157+
t.skipIfTextureFormatNotMultisampled('r32float');
1158+
}
11631159

11641160
// Two bindings are attached to the same texture view.
11651161
const usage =

src/webgpu/api/validation/resource_usages/texture/in_render_common.spec.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ Texture Usages Validation Tests in Same or Different Render Pass Encoders.
44

55
import { makeTestGroup } from '../../../../../common/framework/test_group.js';
66
import { assert, unreachable } from '../../../../../common/util/util.js';
7-
import { MaxLimitsTestMixin } from '../../../../gpu_test.js';
8-
import { ValidationTest } from '../../validation_test.js';
7+
import { AllFeaturesMaxLimitsValidationTest } from '../../validation_test.js';
98

109
export type TextureBindingType =
1110
| 'sampled-texture'
@@ -22,7 +21,7 @@ export function IsReadOnlyTextureBindingType(t: TextureBindingType): boolean {
2221
return t === 'sampled-texture' || t === 'readonly-storage-texture';
2322
}
2423

25-
class F extends ValidationTest {
24+
class F extends AllFeaturesMaxLimitsValidationTest {
2625
getColorAttachment(
2726
texture: GPUTexture,
2827
textureViewDescriptor?: GPUTextureViewDescriptor
@@ -93,7 +92,7 @@ class F extends ValidationTest {
9392
}
9493
}
9594

96-
export const g = makeTestGroup(MaxLimitsTestMixin(F));
95+
export const g = makeTestGroup(F);
9796

9897
const kTextureSize = 16;
9998
const kTextureLevels = 3;

src/webgpu/api/validation/resource_usages/texture/in_render_misc.spec.ts

+4-5
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,15 @@ Texture Usages Validation Tests on All Kinds of WebGPU Subresource Usage Scopes.
55
import { makeTestGroup } from '../../../../../common/framework/test_group.js';
66
import { unreachable } from '../../../../../common/util/util.js';
77
import { kTextureUsages } from '../../../../capability_info.js';
8-
import { MaxLimitsTestMixin } from '../../../../gpu_test.js';
9-
import { ValidationTest } from '../../validation_test.js';
8+
import { AllFeaturesMaxLimitsValidationTest } from '../../validation_test.js';
109
import {
1110
TextureBindingType,
1211
kTextureBindingTypes,
1312
IsReadOnlyTextureBindingType,
1413
} from '../texture/in_render_common.spec.js';
1514

1615
function skipIfStorageTexturesUsedAndNotAvailableInFragmentStage(
17-
t: ValidationTest,
16+
t: AllFeaturesMaxLimitsValidationTest,
1817
usage: (typeof kTextureBindingTypes)[number] | 'copy-src' | 'copy-dst' | 'color-attachment',
1918
numRequired: number
2019
) {
@@ -28,7 +27,7 @@ function skipIfStorageTexturesUsedAndNotAvailableInFragmentStage(
2827
);
2928
}
3029

31-
class F extends ValidationTest {
30+
class F extends AllFeaturesMaxLimitsValidationTest {
3231
createBindGroupLayoutForTest(
3332
textureUsage: TextureBindingType,
3433
sampleType: 'unfilterable-float' | 'depth' | 'uint',
@@ -86,7 +85,7 @@ class F extends ValidationTest {
8685
}
8786
}
8887

89-
export const g = makeTestGroup(MaxLimitsTestMixin(F));
88+
export const g = makeTestGroup(F);
9089

9190
const kTextureSize = 16;
9291
const kTextureLayers = 3;

0 commit comments

Comments
 (0)