playcanvas
Version:
Open-source WebGL/WebGPU 3D engine for the web
26 lines (23 loc) • 720 B
JavaScript
import { DeviceCache } from '../../platform/graphics/device-cache.js';
class GSplatResourceCleanup {
static queueDestroy(device, resource) {
this._cache.get(device, ()=>new GSplatResourceCleanup())._pendingDestroy.add(resource);
}
static process(device) {
const pending = this._cache.get(device, ()=>new GSplatResourceCleanup())._pendingDestroy;
for (const resource of pending){
if (resource.refCount === 0) {
resource._actualDestroy();
pending.delete(resource);
}
}
}
destroy() {
this._pendingDestroy.clear();
}
constructor(){
this._pendingDestroy = new Set();
}
}
GSplatResourceCleanup._cache = new DeviceCache();
export { GSplatResourceCleanup };