1export const description = ` 2fences validation tests. 3`; 4 5import { makeTestGroup } from '../../../common/framework/test_group.js'; 6import { assert } from '../../../common/framework/util/util.js'; 7 8import { ValidationTest } from './validation_test.js'; 9 10export const g = makeTestGroup(ValidationTest); 11 12// TODO: Remove if https://github.com/gpuweb/gpuweb/issues/377 is decided 13g.test('wait_on_a_fence_without_signaling_the_value_is_invalid').fn(async t => { 14 const fence = t.queue.createFence(); 15 16 t.expectValidationError(() => { 17 const promise = fence.onCompletion(2); 18 t.shouldReject('OperationError', promise); 19 }); 20}); 21 22// TODO: Remove if https://github.com/gpuweb/gpuweb/issues/377 is decided 23g.test('wait_on_a_fence_with_a_value_greater_than_signaled_value_is_invalid').fn(async t => { 24 const fence = t.queue.createFence(); 25 t.queue.signal(fence, 2); 26 27 t.expectValidationError(() => { 28 const promise = fence.onCompletion(3); 29 t.shouldReject('OperationError', promise); 30 }); 31}); 32 33g.test('signal_a_value_lower_than_signaled_value_is_invalid').fn(async t => { 34 const fence = t.queue.createFence({ initialValue: 1 }); 35 36 t.expectValidationError(() => { 37 t.queue.signal(fence, 0); 38 }); 39}); 40 41g.test('signal_a_value_equal_to_signaled_value_is_invalid').fn(async t => { 42 const fence = t.queue.createFence({ initialValue: 1 }); 43 44 t.expectValidationError(() => { 45 t.queue.signal(fence, 1); 46 }); 47}); 48 49g.test('increasing_fence_value_by_more_than_1_succeeds').fn(async t => { 50 const fence = t.queue.createFence(); 51 52 t.queue.signal(fence, 2); 53 await fence.onCompletion(2); 54 55 t.queue.signal(fence, 6); 56 await fence.onCompletion(6); 57}); 58 59g.test('signal_a_fence_on_a_different_device_than_it_was_created_on_is_invalid').fn(async t => { 60 const anotherDevice = await t.device.adapter.requestDevice(); 61 assert(anotherDevice !== null); 62 const fence = anotherDevice.defaultQueue.createFence(); 63 64 t.expectValidationError(() => { 65 t.queue.signal(fence, 2); 66 }); 67}); 68 69g.test('signal_a_fence_on_a_different_device_does_not_update_fence_signaled_value').fn(async t => { 70 const anotherDevice = await t.device.adapter.requestDevice(); 71 assert(anotherDevice !== null); 72 const fence = anotherDevice.defaultQueue.createFence({ initialValue: 1 }); 73 74 t.expectValidationError(() => { 75 t.queue.signal(fence, 2); 76 }); 77 78 t.expect(fence.getCompletedValue() === 1); 79 80 anotherDevice.pushErrorScope('validation'); 81 82 anotherDevice.defaultQueue.signal(fence, 2); 83 await fence.onCompletion(2); 84 t.expect(fence.getCompletedValue() === 2); 85 86 const gpuValidationError = await anotherDevice.popErrorScope(); 87 if (gpuValidationError instanceof GPUValidationError) { 88 t.fail(`Captured validation error - ${gpuValidationError.message}`); 89 } 90}); 91