Skip to content

Commit f4cda20

Browse files
authored
Update mapping tests to be in line with the spec (#4575)
1 parent ded0ae3 commit f4cda20

1 file changed

Lines changed: 14 additions & 17 deletions

File tree

src/webgpu/api/validation/buffer/mapping.spec.ts

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ g.test('mapAsync,state,mappedAtCreation')
201201
mappedAtCreation: true,
202202
});
203203
await t.testMapAsyncCall(
204-
{ validationError: true, earlyRejection: false, rejectName: 'OperationError' },
204+
{ validationError: true, earlyRejection: true, rejectName: 'OperationError' },
205205
buffer,
206206
mapMode
207207
);
@@ -222,7 +222,7 @@ g.test('mapAsync,state,mapped')
222222
const buffer = t.createMappableBuffer(mapMode, 16);
223223
await t.testMapAsyncCall('success', buffer, mapMode);
224224
await t.testMapAsyncCall(
225-
{ validationError: true, earlyRejection: false, rejectName: 'OperationError' },
225+
{ validationError: true, earlyRejection: true, rejectName: 'OperationError' },
226226
buffer,
227227
mapMode
228228
);
@@ -254,7 +254,7 @@ g.test('mapAsync,state,mappingPending')
254254
// that we can unmap the previous mapping in the same stack frame and testing this one doesn't
255255
// get canceled, but instead is rejected.
256256
const pending1 = t.testMapAsyncCall(
257-
{ validationError: false, earlyRejection: true, rejectName: 'OperationError' },
257+
{ validationError: true, earlyRejection: true, rejectName: 'OperationError' },
258258
buffer,
259259
mapMode
260260
);
@@ -392,7 +392,7 @@ g.test('mapAsync,earlyRejection')
392392
const p1 = buffer.mapAsync(mapMode, offset1, mapSize); // succeeds
393393
await t.testMapAsyncCall(
394394
{
395-
validationError: false,
395+
validationError: true,
396396
earlyRejection: true,
397397
rejectName: 'OperationError',
398398
},
@@ -405,20 +405,17 @@ g.test('mapAsync,earlyRejection')
405405
});
406406

407407
g.test('mapAsync,abort_over_invalid_error')
408-
.desc(
409-
`Test that unmap abort error should have precedence over validation error
410-
TODO
411-
- Add other validation error test (eg. offset is not a multiple of 8)
412-
`
413-
)
408+
.desc('Test that unmap abort error should have precedence over validation error')
414409
.paramsSubcasesOnly(u =>
415410
u.combine('mapMode', kMapModeOptions).combine('unmapBeforeResolve', [true, false])
416411
)
417412
.fn(async t => {
418413
const { mapMode, unmapBeforeResolve } = t.params;
419414
const bufferSize = 8;
420-
const buffer = t.createMappableBuffer(mapMode, bufferSize);
421-
await buffer.mapAsync(mapMode);
415+
const buffer = t.createBufferTracked({
416+
usage: 0,
417+
size: bufferSize,
418+
});
422419

423420
if (unmapBeforeResolve) {
424421
// unmap abort error should have precedence over validation error
@@ -430,7 +427,7 @@ TODO
430427
buffer.unmap();
431428
await pending;
432429
} else {
433-
// map on already mapped buffer should cause validation error
430+
// invalid map call should cause validation error
434431
await t.testMapAsyncCall(
435432
{ validationError: true, earlyRejection: false, rejectName: 'OperationError' },
436433
buffer,
@@ -455,7 +452,7 @@ g.test('getMappedRange,state,mapped')
455452

456453
// map on already mapped buffer should be rejected
457454
const pending = t.testMapAsyncCall(
458-
{ validationError: true, earlyRejection: false, rejectName: 'OperationError' },
455+
{ validationError: true, earlyRejection: true, rejectName: 'OperationError' },
459456
buffer,
460457
mapMode
461458
);
@@ -490,7 +487,7 @@ g.test('getMappedRange,state,mappedAtCreation')
490487

491488
// map on already mapped buffer should be rejected
492489
const pending = t.testMapAsyncCall(
493-
{ validationError: true, earlyRejection: false, rejectName: 'OperationError' },
490+
{ validationError: true, earlyRejection: true, rejectName: 'OperationError' },
494491
buffer,
495492
mapMode
496493
);
@@ -533,7 +530,7 @@ g.test('getMappedRange,state,mappedAgain')
533530

534531
// call mapAsync again on already mapped buffer should fail
535532
await t.testMapAsyncCall(
536-
{ validationError: true, earlyRejection: false, rejectName: 'OperationError' },
533+
{ validationError: true, earlyRejection: true, rejectName: 'OperationError' },
537534
buffer,
538535
mapMode
539536
);
@@ -674,7 +671,7 @@ g.test('getMappedRange,state,mappingPending')
674671
/* noawait */ const mapping0 = buffer.mapAsync(mapMode);
675672
// seconding mapping should be rejected
676673
const mapping1 = t.testMapAsyncCall(
677-
{ validationError: false, earlyRejection: true, rejectName: 'OperationError' },
674+
{ validationError: true, earlyRejection: true, rejectName: 'OperationError' },
678675
buffer,
679676
mapMode
680677
);

0 commit comments

Comments
 (0)