|
1 | 1 | export const description = ` |
2 | 2 | Tests for capability checking for features enabling optional texture formats. |
3 | 3 |
|
4 | | -TODO(#902): test GPUTextureViewDescriptor.format |
5 | 4 | TODO(#902): test GPUCanvasConfiguration.format (it doesn't allow any optional formats today but the |
6 | 5 | error might still be different - exception instead of validation. |
7 | 6 |
|
@@ -49,6 +48,46 @@ g.test('texture_descriptor') |
49 | 48 | }); |
50 | 49 | }); |
51 | 50 |
|
| 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 | + |
52 | 91 | g.test('storage_texture_binding_layout') |
53 | 92 | .desc( |
54 | 93 | ` |
|
0 commit comments