Skip to content

Commit

Permalink
Compat: test depthOrArrayLayers vs textureBindingViewFormat
Browse files Browse the repository at this point in the history
A texture with textureBindingViewFormat = '2d' should generate
a validation error if depthOrArrayLayers is not 1

A texture with textureBindingViewFormat = 'cube' should generate
a validation error if depthOrArrayLayers is not 6
  • Loading branch information
greggman committed Nov 30, 2023
1 parent 90b8a3e commit 1647569
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/webgpu/compat/api/validation/texture/createTexture.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable prettier/prettier */
export const description = `
Tests that you can not use bgra8unorm-srgb in compat mode.
Tests that textureBindingViewDimension must compatible with texture dimension
Expand Down Expand Up @@ -70,3 +71,36 @@ g.test('invalidTextureBindingViewDimension')
shouldError
);
});

g.test('depthOrArrayLayers_incompatible_with_textureBindingViewDimension')
.desc(
`Tests
* if textureBindingViewDimension is '2d' then depthOrArrayLayers must be 1
* if textureBindingViewDimension is 'cube' then depthOrArrayLayers must be 6
`
)
.params(u =>
u //
.combine('textureBindingViewDimension', ['2d', 'cube'])
.combine('depthOrArrayLayers', [1, 3, 6, 12])
)
.fn(t => {
const { textureBindingViewDimension, depthOrArrayLayers } = t.params;
const shouldError =
(textureBindingViewDimension === '2d' && depthOrArrayLayers !== 1) ||
(textureBindingViewDimension === 'cube' && depthOrArrayLayers !== 6);
t.expectGPUError(
'validation',
() => {
const texture = t.device.createTexture({
size: [1, 1, depthOrArrayLayers],
format: 'rgba8unorm',
usage: GPUTextureUsage.TEXTURE_BINDING,
textureBindingViewDimension,
} as GPUTextureDescriptor); // MAINTENANCE_TODO: remove cast once textureBindingViewDimension is added to IDL
t.trackForCleanup(texture);
},
shouldError
);
});

1 change: 1 addition & 0 deletions src/webgpu/listing_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,7 @@
"webgpu:compat,api,validation,render_pipeline,fragment_state:colorState:*": { "subcaseMS": 32.604 },
"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: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 1647569

Please sign in to comment.