Skip to content

Commit 5c24db5

Browse files
Require depthOrArrayLayers=1 and mipLevelCount=1 for transient textures (#4533)
* Require depthOrArrayLayers=1 and mipLevelCount=1 for transient textures * Add dedicated test * Do not test all texture formats
1 parent 18183dc commit 5c24db5

File tree

1 file changed

+38
-3
lines changed

1 file changed

+38
-3
lines changed

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

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ g.test('sampleCount,valid_sampleCount_with_other_parameter_varies')
333333
.filter(({ dimension, format }) =>
334334
textureFormatAndDimensionPossiblyCompatible(dimension, format)
335335
)
336-
.unless(({ usage, format, mipLevelCount, dimension }) => {
336+
.unless(({ usage, format, arrayLayerCount, mipLevelCount, dimension }) => {
337337
return (
338338
((usage & GPUConst.TextureUsage.RENDER_ATTACHMENT) !== 0 &&
339339
(!isTextureFormatPossiblyUsableAsColorRenderAttachment(format) ||
@@ -342,9 +342,11 @@ g.test('sampleCount,valid_sampleCount_with_other_parameter_varies')
342342
!isTextureFormatPossiblyStorageReadable(format)) ||
343343
(mipLevelCount !== 1 && dimension === '1d') ||
344344
((usage & GPUConst.TextureUsage.TRANSIENT_ATTACHMENT) !== 0 &&
345-
usage !==
345+
(usage !==
346346
(GPUConst.TextureUsage.RENDER_ATTACHMENT |
347-
GPUConst.TextureUsage.TRANSIENT_ATTACHMENT))
347+
GPUConst.TextureUsage.TRANSIENT_ATTACHMENT) ||
348+
mipLevelCount !== 1 ||
349+
arrayLayerCount !== 1))
348350
);
349351
})
350352
)
@@ -1059,6 +1061,39 @@ g.test('texture_usage')
10591061
}, !success);
10601062
});
10611063

1064+
g.test('depthOrArrayLayers_and_mipLevelCount_for_transient_attachments')
1065+
.desc(`Test depthOrArrayLayers and mipLevelCount must be 1 for transient attachments`)
1066+
.params(u =>
1067+
u
1068+
.combine('format', ['rgba8unorm', 'depth24plus'] as const)
1069+
.beginSubcases()
1070+
.combine('depthOrArrayLayers', [1, 2])
1071+
.combine('mipLevelCount', [1, 2])
1072+
)
1073+
.fn(t => {
1074+
// MAINTENANCE_TODO(#4509): Remove this when TRANSIENT_ATTACHMENT is added to the WebGPU spec.
1075+
t.skipIfTransientAttachmentNotSupported();
1076+
1077+
const { format, depthOrArrayLayers, mipLevelCount } = t.params;
1078+
1079+
const info = getBlockInfoForTextureFormat(format);
1080+
const size = [info.blockWidth, info.blockHeight, depthOrArrayLayers];
1081+
const descriptor = {
1082+
size,
1083+
mipLevelCount,
1084+
format,
1085+
usage: GPUConst.TextureUsage.RENDER_ATTACHMENT | GPUConst.TextureUsage.TRANSIENT_ATTACHMENT,
1086+
};
1087+
1088+
let success = true;
1089+
if (depthOrArrayLayers !== 1) success = false;
1090+
if (mipLevelCount !== 1) success = false;
1091+
1092+
t.expectValidationError(() => {
1093+
t.createTextureTracked(descriptor);
1094+
}, !success);
1095+
});
1096+
10621097
g.test('viewFormats')
10631098
.desc(
10641099
`Test creating a texture with viewFormats list for all {texture format}x{view format}. Only compatible view formats should be valid.`

0 commit comments

Comments
 (0)