Skip to content

Commit 797458c

Browse files
authored
Test layout auto/storage texture formats/access modes (#4415)
I'm not sure if this is tested elsewhere. I didn't see it. This is testing that bindGroupLayouts that are invalid when calling createBindGroupLayout are also invalid if the bindgroup layout is auto-generated, specifically for storage texture formats and access modes.
1 parent 6185b7a commit 797458c

2 files changed

Lines changed: 84 additions & 0 deletions

File tree

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

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ Note: entry point matching tests are in shader_module/entry_point.spec.ts
77
import { AllFeaturesMaxLimitsGPUTest } from '../.././gpu_test.js';
88
import { makeTestGroup } from '../../../common/framework/test_group.js';
99
import { keysOf } from '../../../common/util/data_tables.js';
10+
import {
11+
isTextureFormatUsableWithStorageAccessMode,
12+
kPossibleStorageTextureFormats,
13+
} from '../../format_info.js';
1014
import { kValue } from '../../util/constants.js';
1115
import { TShaderStage, getShaderWithEntryPoint } from '../../util/shader.js';
1216

@@ -772,3 +776,38 @@ g.test('resource_compatibility')
772776
descriptor
773777
);
774778
});
779+
780+
g.test('storage_texture,format')
781+
.desc(
782+
`
783+
Test that a pipeline with auto layout and storage texture access combo that is not supported
784+
generates a validation error at createComputePipeline(Async)
785+
`
786+
)
787+
.params(u =>
788+
u //
789+
.combine('format', kPossibleStorageTextureFormats)
790+
.beginSubcases()
791+
.combine('isAsync', [true, false] as const)
792+
.combine('access', ['read', 'write', 'read_write'] as const)
793+
.combine('dimension', ['1d', '2d', '3d'] as const)
794+
)
795+
.fn(t => {
796+
const { format, isAsync, access, dimension } = t.params;
797+
t.skipIfTextureFormatNotSupported(format);
798+
799+
const code = `
800+
@group(0) @binding(0) var tex: texture_storage_${dimension}<${format}, ${access}>;
801+
@compute @workgroup_size(1) fn main() {
802+
_ = tex;
803+
}
804+
`;
805+
const module = t.device.createShaderModule({ code });
806+
807+
const success = isTextureFormatUsableWithStorageAccessMode(t.device, format, access);
808+
const descriptor: GPUComputePipelineDescriptor = {
809+
layout: 'auto',
810+
compute: { module },
811+
};
812+
vtu.doCreateComputePipelineTest(t, isAsync, success, descriptor);
813+
});

src/webgpu/api/validation/render_pipeline/misc.spec.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ misc createRenderPipeline and createRenderPipelineAsync validation tests.
33
`;
44

55
import { makeTestGroup } from '../../../../common/framework/test_group.js';
6+
import {
7+
isTextureFormatUsableWithStorageAccessMode,
8+
kPossibleStorageTextureFormats,
9+
} from '../../../format_info.js';
610
import { kDefaultVertexShaderCode, kDefaultFragmentShaderCode } from '../../../util/shader.js';
711
import * as vtu from '../validation_test_utils.js';
812

@@ -147,3 +151,44 @@ g.test('external_texture')
147151

148152
vtu.doCreateRenderPipelineTest(t, false, true, descriptor);
149153
});
154+
155+
g.test('storage_texture,format')
156+
.desc(
157+
`
158+
Test that a pipeline with auto layout and storage texture access combo that is not supported
159+
generates a validation error at createComputePipeline(Async)
160+
`
161+
)
162+
.params(u =>
163+
u //
164+
.combine('format', kPossibleStorageTextureFormats)
165+
.beginSubcases()
166+
.combine('isAsync', [true, false] as const)
167+
.combine('access', ['read', 'write', 'read_write'] as const)
168+
.combine('dimension', ['1d', '2d', '3d'] as const)
169+
)
170+
.fn(t => {
171+
const { format, isAsync, access, dimension } = t.params;
172+
t.skipIfTextureFormatNotSupported(format);
173+
174+
const code = `
175+
@group(0) @binding(0) var tex: texture_storage_${dimension}<${format}, ${access}>;
176+
@vertex fn vs() -> @builtin(position) vec4f {
177+
return vec4f(0);
178+
}
179+
180+
@fragment fn fs() -> @location(0) vec4f {
181+
_ = tex;
182+
return vec4f(0);
183+
}
184+
`;
185+
const module = t.device.createShaderModule({ code });
186+
187+
const success = isTextureFormatUsableWithStorageAccessMode(t.device, format, access);
188+
const descriptor: GPURenderPipelineDescriptor = {
189+
layout: 'auto',
190+
vertex: { module },
191+
fragment: { module, targets: [{ format: 'rgba8unorm' }] },
192+
};
193+
vtu.doCreateRenderPipelineTest(t, isAsync, success, descriptor);
194+
});

0 commit comments

Comments
 (0)