Skip to content

Commit 30454b0

Browse files
Fix more validation tests for transient attachment usage (#4519)
* Fix more validation tests for transient attachment usage * Skip tests if TRANSIENT_ATTACHMENT is not supported * Address greggman's feedback * Added missing skip * Use IsValidTextureUsageCombination
1 parent 9ad7259 commit 30454b0

File tree

12 files changed

+124
-31
lines changed

12 files changed

+124
-31
lines changed

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

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {
2323
kTextureViewDimensions,
2424
sampledAndStorageBindingEntries,
2525
texBindingTypeInfo,
26-
IsValidTransientAttachmentUsage,
26+
IsValidTextureUsageCombination,
2727
} from '../../capability_info.js';
2828
import { GPUConst } from '../../constants.js';
2929
import { kPossibleStorageTextureFormats, kRegularTextureFormats } from '../../format_info.js';
@@ -220,6 +220,11 @@ g.test('texture_binding_must_have_correct_usage')
220220
"The test requires 'r32float' multisampled support which compat mode doesn't guarantee."
221221
);
222222

223+
// MAINTENANCE_TODO(#4509): Remove this when TRANSIENT_ATTACHMENT is added to the WebGPU spec.
224+
if ((usage & GPUConst.TextureUsage.TRANSIENT_ATTACHMENT) !== 0) {
225+
t.skipIfTransientAttachmentNotSupported();
226+
}
227+
223228
const bindGroupLayout = t.device.createBindGroupLayout({
224229
entries: [{ binding: 0, visibility: GPUShaderStage.COMPUTE, ...entry }],
225230
});
@@ -790,18 +795,19 @@ g.test('storage_texture,usage')
790795
.combine('usage0', kTextureUsages)
791796
.combine('usage1', kTextureUsages)
792797
.unless(({ usage0, usage1 }) => {
793-
const usage = usage0 | usage1;
794-
return (
795-
(usage & GPUConst.TextureUsage.TRANSIENT_ATTACHMENT) !== 0 &&
796-
!IsValidTransientAttachmentUsage(usage)
797-
);
798+
return !IsValidTextureUsageCombination(usage0 | usage1);
798799
})
799800
)
800801
.fn(t => {
801802
const { usage0, usage1 } = t.params;
802803

803804
const usage = usage0 | usage1;
804805

806+
// MAINTENANCE_TODO(#4509): Remove this when TRANSIENT_ATTACHMENT is added to the WebGPU spec.
807+
if ((usage & GPUConst.TextureUsage.TRANSIENT_ATTACHMENT) !== 0) {
808+
t.skipIfTransientAttachmentNotSupported();
809+
}
810+
805811
const bindGroupLayout = t.device.createBindGroupLayout({
806812
entries: [
807813
{
@@ -1228,18 +1234,19 @@ g.test('external_texture,texture_view,usage')
12281234
.combine('usage0', kTextureUsages)
12291235
.combine('usage1', kTextureUsages)
12301236
.unless(({ usage0, usage1 }) => {
1231-
const usage = usage0 | usage1;
1232-
return (
1233-
(usage & GPUConst.TextureUsage.TRANSIENT_ATTACHMENT) !== 0 &&
1234-
!IsValidTransientAttachmentUsage(usage)
1235-
);
1237+
return !IsValidTextureUsageCombination(usage0 | usage1);
12361238
})
12371239
)
12381240
.fn(t => {
12391241
const { usage0, usage1 } = t.params;
12401242

12411243
const usage = usage0 | usage1;
12421244

1245+
// MAINTENANCE_TODO(#4509): Remove this when TRANSIENT_ATTACHMENT is added to the WebGPU spec.
1246+
if ((usage & GPUConst.TextureUsage.TRANSIENT_ATTACHMENT) !== 0) {
1247+
t.skipIfTransientAttachmentNotSupported();
1248+
}
1249+
12431250
const bindGroupLayout = t.device.createBindGroupLayout({
12441251
entries: [
12451252
{

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { assert, makeValueTestVariant } from '../../../common/util/util.js';
66
import {
77
kTextureDimensions,
88
kTextureUsages,
9-
IsValidTransientAttachmentUsage,
9+
IsValidTextureUsageCombination,
1010
} from '../../capability_info.js';
1111
import { GPUConst } from '../../constants.js';
1212
import {
@@ -362,6 +362,10 @@ g.test('sampleCount,valid_sampleCount_with_other_parameter_varies')
362362
if ((usage & GPUConst.TextureUsage.RENDER_ATTACHMENT) !== 0) {
363363
t.skipIfTextureFormatNotUsableAsRenderAttachment(format);
364364
}
365+
// MAINTENANCE_TODO(#4509): Remove this when TRANSIENT_ATTACHMENT is added to the WebGPU spec.
366+
if ((usage & GPUConst.TextureUsage.TRANSIENT_ATTACHMENT) !== 0) {
367+
t.skipIfTransientAttachmentNotSupported();
368+
}
365369
const { blockWidth, blockHeight } = getBlockInfoForTextureFormat(format);
366370

367371
const size =
@@ -1017,11 +1021,7 @@ g.test('texture_usage')
10171021
textureFormatAndDimensionPossiblyCompatible(dimension, format)
10181022
)
10191023
.unless(({ usage0, usage1 }) => {
1020-
const usage = usage0 | usage1;
1021-
return (
1022-
(usage & GPUConst.TextureUsage.TRANSIENT_ATTACHMENT) !== 0 &&
1023-
!IsValidTransientAttachmentUsage(usage)
1024-
);
1024+
return !IsValidTextureUsageCombination(usage0 | usage1);
10251025
})
10261026
)
10271027
.fn(t => {
@@ -1039,6 +1039,11 @@ g.test('texture_usage')
10391039
usage,
10401040
};
10411041

1042+
// MAINTENANCE_TODO(#4509): Remove this when TRANSIENT_ATTACHMENT is added to the WebGPU spec.
1043+
if ((usage & GPUConst.TextureUsage.TRANSIENT_ATTACHMENT) !== 0) {
1044+
t.skipIfTransientAttachmentNotSupported();
1045+
}
1046+
10421047
let success = true;
10431048
const appliedDimension = dimension ?? '2d';
10441049
// Note that we unconditionally test copy usages for all formats and
@@ -1052,11 +1057,6 @@ g.test('texture_usage')
10521057
if (isColorTextureFormat(format) && !isTextureFormatColorRenderable(t.device, format))
10531058
success = false;
10541059
}
1055-
if (usage & GPUTextureUsage.TRANSIENT_ATTACHMENT) {
1056-
if (usage !== (GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TRANSIENT_ATTACHMENT)) {
1057-
success = false;
1058-
}
1059-
}
10601060

10611061
t.expectValidationError(() => {
10621062
t.createTextureTracked(descriptor);

src/webgpu/api/validation/encoding/cmds/copyTextureToTexture.spec.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ copyTextureToTexture tests.
44

55
import { makeTestGroup } from '../../../../../common/framework/test_group.js';
66
import { kTextureUsages, kTextureDimensions } from '../../../../capability_info.js';
7+
import { GPUConst } from '../../../../constants.js';
78
import {
89
kAllTextureFormats,
910
kCompressedTextureFormats,
@@ -216,6 +217,13 @@ Test that copyTextureToTexture source/destination need COPY_SRC/COPY_DST usages.
216217
u //
217218
.combine('srcUsage', kTextureUsages)
218219
.combine('dstUsage', kTextureUsages)
220+
.unless(({ srcUsage, dstUsage }) => {
221+
// TRANSIENT_ATTACHMENT is only valid when combined with RENDER_ATTACHMENT.
222+
return (
223+
srcUsage === GPUConst.TextureUsage.TRANSIENT_ATTACHMENT ||
224+
dstUsage === GPUConst.TextureUsage.TRANSIENT_ATTACHMENT
225+
);
226+
})
219227
)
220228
.fn(t => {
221229
const { srcUsage, dstUsage } = t.params;

src/webgpu/api/validation/image_copy/buffer_texture_copies.spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,10 @@ g.test('texture_buffer_usages')
371371
.combine('copyType', ['CopyB2T', 'CopyT2B'] as const)
372372
.beginSubcases()
373373
.combine('textureUsage', kTextureUsages)
374+
.unless(({ textureUsage }) => {
375+
// TRANSIENT_ATTACHMENT is only valid when combined with RENDER_ATTACHMENT.
376+
return textureUsage === GPUConst.TextureUsage.TRANSIENT_ATTACHMENT;
377+
})
374378
.expand('_textureUsageValid', p => [p.textureUsage === kRequiredTextureUsage[p.copyType]])
375379
.combine('bufferUsage', kBufferUsages)
376380
.expand('_bufferUsageValid', p => [p.bufferUsage === kRequiredBufferUsage[p.copyType]])

src/webgpu/api/validation/image_copy/texture_related.spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,13 @@ The texture must have the appropriate COPY_SRC/COPY_DST usage.
124124
((usage0 | usage1) & GPUConst.TextureUsage.RENDER_ATTACHMENT) !== 0 &&
125125
(dimension === '1d' || dimension === '3d')
126126
)
127+
.unless(({ usage0, usage1 }) => {
128+
// TRANSIENT_ATTACHMENT is only valid when combined with RENDER_ATTACHMENT.
129+
return (
130+
usage0 === GPUConst.TextureUsage.TRANSIENT_ATTACHMENT ||
131+
usage1 === GPUConst.TextureUsage.TRANSIENT_ATTACHMENT
132+
);
133+
})
127134
)
128135
.fn(t => {
129136
const { usage0, usage1, method, size, dimension } = t.params;

src/webgpu/api/validation/queue/copyToTexture/CopyExternalImageToTexture.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
import { makeTestGroup } from '../../../../../common/framework/test_group.js';
1313
import { raceWithRejectOnTimeout, unreachable, assert } from '../../../../../common/util/util.js';
1414
import { kTextureUsages } from '../../../../capability_info.js';
15+
import { GPUConst } from '../../../../constants.js';
1516
import {
1617
kAllTextureFormats,
1718
isTextureFormatUsableWithCopyExternalImageToTexture,
@@ -570,6 +571,10 @@ g.test('destination_texture,usage')
570571
.params(u =>
571572
u //
572573
.combine('usage', kTextureUsages)
574+
.unless(({ usage }) => {
575+
// TRANSIENT_ATTACHMENT is only valid when combined with RENDER_ATTACHMENT.
576+
return usage === GPUConst.TextureUsage.TRANSIENT_ATTACHMENT;
577+
})
573578
.beginSubcases()
574579
.combine('copySize', [
575580
{ width: 0, height: 0, depthOrArrayLayers: 0 },

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

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -741,9 +741,14 @@ g.test('color_attachments,loadOp_storeOp')
741741
t.skipIfTextureFormatNotSupported(format);
742742
t.skipIfTextureFormatNotUsableAsRenderAttachment(format);
743743

744+
// MAINTENANCE_TODO(#4509): Remove this when TRANSIENT_ATTACHMENT is added to the WebGPU spec.
745+
if (transientTexture) {
746+
t.skipIfTransientAttachmentNotSupported();
747+
}
748+
744749
const usage = transientTexture
745-
? GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TRANSIENT_ATTACHMENT
746-
: GPUTextureUsage.RENDER_ATTACHMENT;
750+
? GPUConst.TextureUsage.RENDER_ATTACHMENT | GPUConst.TextureUsage.TRANSIENT_ATTACHMENT
751+
: GPUConst.TextureUsage.RENDER_ATTACHMENT;
747752

748753
const texture = t.createTestTexture({ usage });
749754

@@ -1124,9 +1129,14 @@ g.test('depth_stencil_attachment,loadOp_storeOp_match_depthReadOnly_stencilReadO
11241129

11251130
t.skipIfTextureFormatNotSupported(format);
11261131

1132+
// MAINTENANCE_TODO(#4509): Remove this when TRANSIENT_ATTACHMENT is added to the WebGPU spec.
1133+
if (transientTexture) {
1134+
t.skipIfTransientAttachmentNotSupported();
1135+
}
1136+
11271137
const usage = transientTexture
1128-
? GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TRANSIENT_ATTACHMENT
1129-
: GPUTextureUsage.RENDER_ATTACHMENT;
1138+
? GPUConst.TextureUsage.RENDER_ATTACHMENT | GPUConst.TextureUsage.TRANSIENT_ATTACHMENT
1139+
: GPUConst.TextureUsage.RENDER_ATTACHMENT;
11301140
const depthAttachment = t.createTextureTracked({
11311141
format,
11321142
size: { width: 1, height: 1, depthOrArrayLayers: 1 },

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ 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 { GPUConst } from '../../../../constants.js';
89
import { AllFeaturesMaxLimitsGPUTest } from '../../../../gpu_test.js';
910
import * as vtu from '../../validation_test_utils.js';
1011
import {
@@ -614,6 +615,10 @@ g.test('subresources,texture_view_usages')
614615
u
615616
.combine('bindingType', ['color-attachment', ...kTextureBindingTypes] as const)
616617
.combine('viewUsage', [0, ...kTextureUsages])
618+
.unless(({ viewUsage }) => {
619+
// TRANSIENT_ATTACHMENT is only valid when combined with RENDER_ATTACHMENT.
620+
return viewUsage === GPUConst.TextureUsage.TRANSIENT_ATTACHMENT;
621+
})
617622
)
618623
.fn(t => {
619624
const { bindingType, viewUsage } = t.params;

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

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Tests for capabilities added by bgra8unorm-storage flag.
44

55
import { makeTestGroup } from '../../../../common/framework/test_group.js';
66
import { assert } from '../../../../common/util/util.js';
7-
import { kTextureUsages } from '../../../capability_info.js';
7+
import { kTextureUsages, IsValidTextureUsageCombination } from '../../../capability_info.js';
88
import { GPUConst } from '../../../constants.js';
99
import { UniqueFeaturesOrLimitsGPUTest } from '../../../gpu_test.js';
1010
import { kAllCanvasTypes, createCanvas } from '../../../util/create_elements.js';
@@ -101,9 +101,18 @@ Test that it is invalid to configure a GPUCanvasContext to 'GPUStorageBinding' u
101101
}
102102
return usageSet;
103103
})
104+
.unless(({ usage }) => {
105+
return !IsValidTextureUsageCombination(usage);
106+
})
104107
)
105108
.fn(t => {
106109
const { canvasType, usage } = t.params;
110+
111+
// MAINTENANCE_TODO(#4509): Remove this when TRANSIENT_ATTACHMENT is added to the WebGPU spec.
112+
if ((usage & GPUConst.TextureUsage.TRANSIENT_ATTACHMENT) !== 0) {
113+
t.skipIfTransientAttachmentNotSupported();
114+
}
115+
107116
const canvas = createCanvas(t, canvasType, 1, 1);
108117
const ctx = canvas.getContext('webgpu');
109118
assert(ctx instanceof GPUCanvasContext, 'Failed to get WebGPU context from canvas');
@@ -144,9 +153,18 @@ with 'bgra8unorm-storage' enabled.
144153
}
145154
return usageSet;
146155
})
156+
.unless(({ usage }) => {
157+
return !IsValidTextureUsageCombination(usage);
158+
})
147159
)
148160
.fn(t => {
149161
const { canvasType, usage } = t.params;
162+
163+
// MAINTENANCE_TODO(#4509): Remove this when TRANSIENT_ATTACHMENT is added to the WebGPU spec.
164+
if ((usage & GPUConst.TextureUsage.TRANSIENT_ATTACHMENT) !== 0) {
165+
t.skipIfTransientAttachmentNotSupported();
166+
}
167+
150168
const canvas = createCanvas(t, canvasType, 1, 1);
151169
const ctx = canvas.getContext('webgpu');
152170
assert(ctx instanceof GPUCanvasContext, 'Failed to get WebGPU context from canvas');

src/webgpu/capability_info.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,10 @@ export const kTextureUsageInfo: {
215215
/** List of all GPUTextureUsage values. */
216216
export const kTextureUsages = numericKeysOf<GPUTextureUsageFlags>(kTextureUsageInfo);
217217

218-
/** Check if `usage` is TRANSIENT_ATTACHMENT | RENDER_ATTACHMENT. */
219-
export function IsValidTransientAttachmentUsage(usage: GPUTextureUsageFlags): boolean {
218+
/** Check if `usage` does not contain TRANSIENT_ATTACHMENT or is TRANSIENT_ATTACHMENT | RENDER_ATTACHMENT. */
219+
export function IsValidTextureUsageCombination(usage: GPUTextureUsageFlags): boolean {
220220
return (
221+
(usage & GPUConst.TextureUsage.TRANSIENT_ATTACHMENT) === 0 ||
221222
usage === (GPUConst.TextureUsage.TRANSIENT_ATTACHMENT | GPUConst.TextureUsage.RENDER_ATTACHMENT)
222223
);
223224
}

0 commit comments

Comments
 (0)