Skip to content

Commit

Permalink
Compat: Check viewFormats match format
Browse files Browse the repository at this point in the history
WIP: Note, spec has not finalized on whether
viewFormats is even allowed in compat
  • Loading branch information
greggman committed Dec 6, 2023
1 parent 5787eeb commit 63b0072
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
48 changes: 48 additions & 0 deletions src/webgpu/compat/api/validation/texture/createTexture.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Tests that textureBindingViewDimension must compatible with texture dimension

import { makeTestGroup } from '../../../../../common/framework/test_group.js';
import { kTextureDimensions, kTextureViewDimensions } from '../../../../capability_info.js';
import { kColorTextureFormats, kTextureFormatInfo } from '../../../../format_info.js';
import { getTextureDimensionFromView } from '../../../../util/texture/base.js';
import { CompatibilityTest } from '../../../compatibility_test.js';

Expand Down Expand Up @@ -105,3 +106,50 @@ g.test('depthOrArrayLayers_incompatible_with_textureBindingViewDimension')
);
});

g.test('format_reinterpretation')
.desc(
`
Tests that you can not request different view formats when creating a texture.
For example, rgba8unorm can not be viewed as rgba8unorm-srgb
`
)
.params(u =>
u //
.combine('format', kColorTextureFormats as GPUTextureFormat[])
.filter(
({ format }) =>
!!kTextureFormatInfo[format].baseFormat &&
kTextureFormatInfo[format].baseFormat !== format
)
)
.beforeAllSubcases(t => {
const info = kTextureFormatInfo[t.params.format];
t.skipIfTextureFormatNotSupported(t.params.format);
t.selectDeviceOrSkipTestCase(info.feature);
})
.fn(t => {
const { format } = t.params;
const info = kTextureFormatInfo[t.params.format];

const formatPairs = [
{ format, viewFormats: [info.baseFormat!] },
{ format: info.baseFormat!, viewFormats: [format] },
{ format, viewFormats: [format, info.baseFormat!] },
{ format: info.baseFormat!, viewFormats: [format, info.baseFormat!] },
];
for (const { format, viewFormats } of formatPairs) {
t.expectGPUError(
'validation',
() => {
const texture = t.device.createTexture({
size: [info.blockWidth, info.blockHeight],
format,
viewFormats,
usage: GPUTextureUsage.TEXTURE_BINDING,
});
t.trackForCleanup(texture);
},
true
);
}
});
1 change: 1 addition & 0 deletions src/webgpu/listing_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,7 @@
"webgpu:compat,api,validation,render_pipeline,shader_module:sample_mask:*": { "subcaseMS": 14.801 },
"webgpu:compat,api,validation,render_pipeline,vertex_state:maxVertexAttributesVertexIndexInstanceIndex:*": { "subcaseMS": 3.700 },
"webgpu:compat,api,validation,texture,createTexture:depthOrArrayLayers_incompatible_with_textureBindingViewDimension:*": { "subcaseMS": 12.712 },
"webgpu:compat,api,validation,texture,createTexture:format_reinterpretation:*": { "subcaseMS": 7.012 },
"webgpu:compat,api,validation,texture,createTexture:invalidTextureBindingViewDimension:*": { "subcaseMS": 6.022 },
"webgpu:compat,api,validation,texture,createTexture:unsupportedTextureFormats:*": { "subcaseMS": 0.700 },
"webgpu:compat,api,validation,texture,createTexture:unsupportedTextureViewFormats:*": { "subcaseMS": 0.601 },
Expand Down

0 comments on commit 63b0072

Please sign in to comment.