From 2c53b58e18348a435ebeeb6bdd8acc15a2926a95 Mon Sep 17 00:00:00 2001 From: Gyuyoung Kim Date: Wed, 28 Sep 2022 11:34:51 +0900 Subject: [PATCH] Add a 'sampler,device_mismatch' test to createBindGroup.spec.ts (#1867) This PR adds a new test to ensure that a validation error happens if createBindGroup is called with a sampler created from another device. Issue: 884, 912 --- .../api/validation/createBindGroup.spec.ts | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/webgpu/api/validation/createBindGroup.spec.ts b/src/webgpu/api/validation/createBindGroup.spec.ts index 0cfd2a1197b1..c4948c615e88 100644 --- a/src/webgpu/api/validation/createBindGroup.spec.ts +++ b/src/webgpu/api/validation/createBindGroup.spec.ts @@ -995,6 +995,36 @@ g.test('buffer,resource_binding_size') }, !isValid); }); +g.test('sampler,device_mismatch') + .desc(`Tests createBindGroup cannot be called with a sampler created from another device.`) + .params(u => u.combine('mismatched', [true, false])) + .beforeAllSubcases(t => { + t.selectMismatchedDeviceOrSkipTestCase(undefined); + }) + .fn(async t => { + const { mismatched } = t.params; + + const device = mismatched ? t.mismatchedDevice : t.device; + + const bindGroupLayout = t.device.createBindGroupLayout({ + entries: [ + { + binding: 0, + visibility: GPUShaderStage.FRAGMENT, + sampler: { type: 'filtering' as const }, + }, + ], + }); + + const sampler = device.createSampler(); + t.expectValidationError(() => { + t.device.createBindGroup({ + entries: [{ binding: 0, resource: sampler }], + layout: bindGroupLayout, + }); + }, mismatched); + }); + g.test('sampler,compare_function_with_binding_type') .desc( `