Skip to content

Commit

Permalink
Add a 'sampler,device_mismatch' test to createBindGroup.spec.ts
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 27, 2022
1 parent deb4ba9 commit 2fb7dfc
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 @@ -992,3 +992,33 @@ 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);
});

0 comments on commit 2fb7dfc

Please sign in to comment.