Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions src/webgpu/api/validation/buffer/mapping.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,37 @@ g.test('mapAsync,invalidBuffer')
);
});

g.test('mapAsync,destroyedDevice')
.desc('Test that mapAsync is an error when called on a destroyed device.')
.params(u =>
u.combine('bufferState', ['valid', 'invalid'] as const).combine('awaitLost', [true, false])
)
.fn(async t => {
const { awaitLost, bufferState } = t.params;
const buffer =
bufferState === 'valid' ? t.createMappableBuffer(GPUMapMode.READ, 4) : vtu.getErrorBuffer(t);
t.expectDeviceLost('destroyed');

await t.testMapAsyncCall(
bufferState === 'valid'
? 'success'
: { validationError: true, earlyRejection: false, rejectName: 'OperationError' },
buffer,
GPUMapMode.READ
);
buffer.unmap();
t.device.destroy();
if (awaitLost) {
const lostInfo = await t.device.lost;
t.expect(lostInfo.reason === 'destroyed');
}
await t.testMapAsyncCall(
{ validationError: false, earlyRejection: false, rejectName: 'AbortError' },
buffer,
GPUMapMode.READ
);
});

g.test('mapAsync,state,destroyed')
.desc('Test that mapAsync is an error when called on a destroyed buffer.')
.paramsSubcasesOnly(u => u.combine('mapMode', kMapModeOptions))
Expand Down
Loading