Skip to content

Commit f71a834

Browse files
authored
Fix device_pool refactor (#3469)
The old version made one device with no descriptor. If that fail then it stopped creating any devices period. The previous refactor was bad in that if the any device failed it would just stop making devices. This one is simplified. It just used the pool as a pool. There is no special handling for failed devices.
1 parent 8a03f77 commit f71a834

File tree

1 file changed

+2
-23
lines changed

1 file changed

+2
-23
lines changed

src/webgpu/util/device_pool.ts

+2-23
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class FeaturesNotSupported extends Error {}
2222
export class TestOOMedShouldAttemptGC extends Error {}
2323

2424
export class DevicePool {
25-
private holders: 'uninitialized' | 'failed' | DescriptorToHolderMap = 'uninitialized';
25+
private holders = new DescriptorToHolderMap();
2626

2727
async requestAdapter(recorder: TestCaseRecorder) {
2828
const gpu = getGPU(recorder);
@@ -36,28 +36,7 @@ export class DevicePool {
3636
adapter: GPUAdapter,
3737
descriptor?: UncanonicalizedDeviceDescriptor
3838
): Promise<DeviceProvider> {
39-
let holder;
40-
if (this.holders === 'uninitialized') {
41-
this.holders = new DescriptorToHolderMap();
42-
}
43-
44-
let errorMessage = '';
45-
if (this.holders !== 'failed') {
46-
try {
47-
holder = await this.holders.getOrCreate(adapter, descriptor);
48-
} catch (ex) {
49-
this.holders = 'failed';
50-
if (ex instanceof Error) {
51-
errorMessage = ` with ${ex.name} "${ex.message}"`;
52-
}
53-
}
54-
}
55-
56-
assert(
57-
this.holders !== 'failed',
58-
`WebGPU device failed to initialize${errorMessage}; not retrying`
59-
);
60-
assert(!!holder);
39+
const holder = await this.holders.getOrCreate(adapter, descriptor);
6140
assert(holder.state === 'free', 'Device was in use on DevicePool.acquire');
6241
holder.state = 'acquired';
6342
holder.beginTestScope();

0 commit comments

Comments
 (0)