Skip to content

Commit 49e659b

Browse files
authored
Implement api,validation,capability_checks,features,texture_formats:texture_view_descriptor (gpuweb#902) (gpuweb#1523)
This patch adds the texture_view_descriptor in 'api,validation,capability_checks,features,texture_formats:*' in order to check if createView throws an exception when the required feature is not enabled.
1 parent aa6069d commit 49e659b

1 file changed

Lines changed: 40 additions & 1 deletion

File tree

src/webgpu/api/validation/capability_checks/features/texture_formats.spec.ts

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
export const description = `
22
Tests for capability checking for features enabling optional texture formats.
33
4-
TODO(#902): test GPUTextureViewDescriptor.format
54
TODO(#902): test GPUCanvasConfiguration.format (it doesn't allow any optional formats today but the
65
error might still be different - exception instead of validation.
76
@@ -49,6 +48,46 @@ g.test('texture_descriptor')
4948
});
5049
});
5150

51+
g.test('texture_view_descriptor')
52+
.desc(
53+
`
54+
Test creating a texture view with all texture formats will fail if the required optional feature is not enabled.
55+
`
56+
)
57+
.params(u =>
58+
u.combine('format', kOptionalTextureFormats).combine('enable_required_feature', [true, false])
59+
)
60+
.beforeAllSubcases(t => {
61+
const { format, enable_required_feature } = t.params;
62+
63+
const formatInfo = kTextureFormatInfo[format];
64+
if (enable_required_feature) {
65+
t.selectDeviceOrSkipTestCase(formatInfo.feature);
66+
}
67+
})
68+
.fn(async t => {
69+
const { format, enable_required_feature } = t.params;
70+
71+
const formatInfo = kTextureFormatInfo[format];
72+
const testTexture = t.device.createTexture({
73+
format,
74+
size: [formatInfo.blockWidth, formatInfo.blockHeight, 1] as const,
75+
usage: GPUTextureUsage.TEXTURE_BINDING,
76+
});
77+
const testViewDesc: GPUTextureViewDescriptor = {
78+
format,
79+
dimension: '2d',
80+
aspect: 'all',
81+
arrayLayerCount: 1,
82+
baseMipLevel: 0,
83+
mipLevelCount: 1,
84+
baseArrayLayer: 0,
85+
};
86+
t.shouldThrow(enable_required_feature ? false : 'TypeError', () => {
87+
testTexture.createView(testViewDesc);
88+
});
89+
});
90+
5291
g.test('storage_texture_binding_layout')
5392
.desc(
5493
`

0 commit comments

Comments
 (0)