Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions src/platform/graphics/storage-buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Comment thread
slimbuck marked this conversation as resolved.

this.adjustVramSizeTracking(graphicsDevice._vram, this.byteSize);
}
Expand All @@ -47,13 +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);
this.adjustVramSizeTracking(this.device._vram, -this.byteSize);
this.impl.destroy(this.device);
}

adjustVramSizeTracking(vram, size) {
Expand Down