From 7047ffc56aa67a7a09e7773bb7febf6c00ad6294 Mon Sep 17 00:00:00 2001 From: Donovan Hutchence Date: Wed, 6 May 2026 13:34:47 +0100 Subject: [PATCH 1/2] latest --- src/platform/graphics/storage-buffer.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/platform/graphics/storage-buffer.js b/src/platform/graphics/storage-buffer.js index c414fac05b1..fc86e8018bc 100644 --- a/src/platform/graphics/storage-buffer.js +++ b/src/platform/graphics/storage-buffer.js @@ -56,6 +56,15 @@ class StorageBuffer { this.impl.destroy(device); } + /** + * Called when the device context was lost. Releases the underlying GPU buffer. + * + * @ignore + */ + loseContext() { + this.impl.loseContext(); + } + adjustVramSizeTracking(vram, size) { Debug.trace(TRACEID_VRAM_SB, `${this.id} size: ${size} vram.sb: ${vram.sb} => ${vram.sb + size}`); vram.sb += size; From bf9b1bde573964e04faab94789617970b098faba Mon Sep 17 00:00:00 2001 From: Donovan Hutchence Date: Wed, 6 May 2026 14:25:52 +0100 Subject: [PATCH 2/2] latest --- src/platform/graphics/storage-buffer.js | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/src/platform/graphics/storage-buffer.js b/src/platform/graphics/storage-buffer.js index fc86e8018bc..8e4e10546dc 100644 --- a/src/platform/graphics/storage-buffer.js +++ b/src/platform/graphics/storage-buffer.js @@ -38,7 +38,11 @@ class StorageBuffer { const usage = addStorageUsage ? (BUFFERUSAGE_STORAGE | bufferUsage) : bufferUsage; this.impl = graphicsDevice.createBufferImpl(usage); this.impl.allocate(graphicsDevice, byteSize); - this.device.buffers.add(this); + + // Note: not registered in device.buffers — storage buffer contents are not + // recoverable on device-lost (no CPU-side shadow, may be GPU-written), so + // they don't participate in the engine's auto lose/restore iteration. + // Consumers handling device-lost must destroy() and recreate storage buffers. this.adjustVramSizeTracking(graphicsDevice._vram, this.byteSize); } @@ -47,22 +51,8 @@ class StorageBuffer { * Frees resources associated with this storage buffer. */ destroy() { - - // stop tracking the buffer - const device = this.device; - device.buffers.delete(this); - - this.adjustVramSizeTracking(device._vram, -this.byteSize); - this.impl.destroy(device); - } - - /** - * Called when the device context was lost. Releases the underlying GPU buffer. - * - * @ignore - */ - loseContext() { - this.impl.loseContext(); + this.adjustVramSizeTracking(this.device._vram, -this.byteSize); + this.impl.destroy(this.device); } adjustVramSizeTracking(vram, size) {