Skip to content

Commit

Permalink
Add a 'sampler,device_mismatch' test to createBindGroup.spec.ts (#1867)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Gyuyoung committed Sep 28, 2022
1 parent 291ce4c commit 2c53b58
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/webgpu/api/validation/createBindGroup.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
`
Expand Down

0 comments on commit 2c53b58

Please sign in to comment.