Skip to content

Commit 5265eae

Browse files
authored
Refactor api/validation/texture/* (#4282)
Issue #4178 Issue #4181
1 parent 02d3423 commit 5265eae

File tree

4 files changed

+22
-27
lines changed

4 files changed

+22
-27
lines changed

src/webgpu/api/validation/texture/bgra8unorm_storage.spec.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import { assert } from '../../../../common/util/util.js';
77
import { kTextureUsages } from '../../../capability_info.js';
88
import { GPUConst } from '../../../constants.js';
99
import { kAllCanvasTypes, createCanvas } from '../../../util/create_elements.js';
10-
import { ValidationTest } from '../validation_test.js';
10+
import { UniqueFeaturesAndLimitsValidationTest } from '../validation_test.js';
1111

12-
class BGRA8UnormStorageValidationTests extends ValidationTest {
12+
class BGRA8UnormStorageValidationTests extends UniqueFeaturesAndLimitsValidationTest {
1313
testCreateShaderModuleWithBGRA8UnormStorage(
1414
shaderType: 'fragment' | 'compute',
1515
success: boolean
@@ -126,7 +126,12 @@ with 'bgra8unorm-storage' enabled.
126126
`
127127
)
128128
.beforeAllSubcases(t => {
129-
t.selectDeviceOrSkipTestCase('bgra8unorm-storage');
129+
t.selectDeviceOrSkipTestCase({
130+
requiredFeatures: ['bgra8unorm-storage'],
131+
requiredLimits: {
132+
maxStorageTexturesInFragmentStage: 1,
133+
},
134+
});
130135
})
131136
.params(u =>
132137
u

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ Destroying a texture more than once is allowed.
44

55
import { makeTestGroup } from '../../../../common/framework/test_group.js';
66
import { kTextureAspects } from '../../../capability_info.js';
7-
import { kTextureFormatInfo } from '../../../format_info.js';
8-
import { ValidationTest } from '../validation_test.js';
7+
import { isDepthTextureFormat, isStencilTextureFormat } from '../../../format_info.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('base')
1313
.desc(`Test that it is valid to destroy a texture.`)
@@ -104,12 +104,12 @@ that was destroyed {before, after} encoding finishes.
104104
const depthStencilAttachment: GPURenderPassDepthStencilAttachment = {
105105
view: depthStencilTexture.createView({ aspect: depthStencilTextureAspect }),
106106
};
107-
if (kTextureFormatInfo[depthStencilTextureFormat].depth) {
107+
if (isDepthTextureFormat(depthStencilTextureFormat)) {
108108
depthStencilAttachment.depthClearValue = 0;
109109
depthStencilAttachment.depthLoadOp = 'clear';
110110
depthStencilAttachment.depthStoreOp = 'discard';
111111
}
112-
if (kTextureFormatInfo[depthStencilTextureFormat].stencil) {
112+
if (isStencilTextureFormat(depthStencilTextureFormat)) {
113113
depthStencilAttachment.stencilClearValue = 0;
114114
depthStencilAttachment.stencilLoadOp = 'clear';
115115
depthStencilAttachment.stencilStoreOp = 'discard';

src/webgpu/api/validation/texture/float32_filterable.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ Tests for capabilities added by float32-filterable flag.
44

55
import { makeTestGroup } from '../../../../common/framework/test_group.js';
66
import { kTextureSampleTypes } from '../../../capability_info.js';
7-
import { ValidationTest } from '../validation_test.js';
7+
import { UniqueFeaturesAndLimitsValidationTest } from '../validation_test.js';
88

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

1111
const kFloat32Formats: GPUTextureFormat[] = ['r32float', 'rg32float', 'rgba32float'];
1212

src/webgpu/api/validation/texture/rg11b10ufloat_renderable.spec.ts

+7-17
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ Tests for capabilities added by rg11b10ufloat-renderable flag.
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

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

1111
g.test('create_texture')
1212
.desc(
@@ -17,10 +17,8 @@ Note, the createTexture tests cover these validation cases where this feature is
1717
`
1818
)
1919
.params(u => u.combine('sampleCount', [1, 4]))
20-
.beforeAllSubcases(t => {
21-
t.selectDeviceOrSkipTestCase('rg11b10ufloat-renderable');
22-
})
2320
.fn(t => {
21+
t.skipIfDeviceDoesNotHaveFeature('rg11b10ufloat-renderable');
2422
const { sampleCount } = t.params;
2523
const descriptor = {
2624
size: [1, 1, 1],
@@ -38,10 +36,8 @@ Test that it is valid to begin render pass with rg11b10ufloat texture format
3836
iff rg11b10ufloat-renderable feature is enabled. Single sampled case.
3937
`
4038
)
41-
.beforeAllSubcases(t => {
42-
t.selectDeviceOrSkipTestCase('rg11b10ufloat-renderable');
43-
})
4439
.fn(t => {
40+
t.skipIfDeviceDoesNotHaveFeature('rg11b10ufloat-renderable');
4541
const texture = t.createTextureTracked({
4642
size: [1, 1, 1],
4743
format: 'rg11b10ufloat',
@@ -70,10 +66,8 @@ Test that it is valid to begin render pass with rg11b10ufloat texture format
7066
iff rg11b10ufloat-renderable feature is enabled. MSAA and resolve case.
7167
`
7268
)
73-
.beforeAllSubcases(t => {
74-
t.selectDeviceOrSkipTestCase('rg11b10ufloat-renderable');
75-
})
7669
.fn(t => {
70+
t.skipIfDeviceDoesNotHaveFeature('rg11b10ufloat-renderable');
7771
const renderTexture = t.createTextureTracked({
7872
size: [1, 1, 1],
7973
format: 'rg11b10ufloat',
@@ -109,10 +103,8 @@ Test that it is valid to begin render bundle encoder with rg11b10ufloat texture
109103
format iff rg11b10ufloat-renderable feature is enabled.
110104
`
111105
)
112-
.beforeAllSubcases(t => {
113-
t.selectDeviceOrSkipTestCase('rg11b10ufloat-renderable');
114-
})
115106
.fn(t => {
107+
t.skipIfDeviceDoesNotHaveFeature('rg11b10ufloat-renderable');
116108
t.device.createRenderBundleEncoder({
117109
colorFormats: ['rg11b10ufloat'],
118110
});
@@ -125,10 +117,8 @@ Test that it is valid to create render pipeline with rg11b10ufloat texture forma
125117
in descriptor.fragment.targets iff rg11b10ufloat-renderable feature is enabled.
126118
`
127119
)
128-
.beforeAllSubcases(t => {
129-
t.selectDeviceOrSkipTestCase('rg11b10ufloat-renderable');
130-
})
131120
.fn(t => {
121+
t.skipIfDeviceDoesNotHaveFeature('rg11b10ufloat-renderable');
132122
t.device.createRenderPipeline({
133123
layout: 'auto',
134124
vertex: {

0 commit comments

Comments
 (0)