GPU: Don't keep state from before a device loss

- Metal: Load the shader cache again in DeviceRestore, like Vulkan. DeviceLost
  saves it and throws everything away, so the next save (the next app switch,
  or quitting) overwrote it with only what had been drawn since.
- Software renderer: Bring the post-shader back after a device loss.
  DestroyDeviceObjects asks for it with restorePostShader_, but
  CreateDeviceObjects cleared the flag again before BeginFrame could act on
  it. The hardware backends recover through renderResized_.
- Forget pointers into the old device's objects in DeviceLost, rather than
  relying on BeginFrame to come before the next flush: Vulkan's last pipeline
  and bound views, Metal's UBO allocations, the GLES last linked shader and
  bound texture.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Henrik RydgårdandClaude Opus 5.5 committed 2026-10-26 15:16:33 +01:00
1 parent 247e764b97
commit b43e119ea1
6 files changed
+17 -2

No files matched your search

+4
View File
@@ -133,6 +133,10 @@ void DrawEngineVulkan::DestroyDeviceObjects() {
void DrawEngineVulkan::DeviceLost() {
DestroyDeviceObjects();
DirtyAllUBOs();
// The pipelines and views these point to are gone (BeginFrame resets them too, but a flush could come first).
lastPipeline_ = nullptr;
boundDepal_ = VK_NULL_HANDLE;
boundSecondary_ = VK_NULL_HANDLE;
draw_ = nullptr;
}