Phones: sideways only; back from the background the Vulkan surface is made again (it was lost), the work saved on the way out and carried on with on the next start if the phone closed it

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Nexoniarz 2026-10-21 00:16:22 +02:00
commit a79a6c9020
9 changed files with 87 additions and 2 deletions

View file

@ -50,6 +50,8 @@ public:
void setVsync(bool vsync) { vsync_ = vsync; swapchainDirty_ = true; }
void markResized() { swapchainDirty_ = true; }
// The window's surface went away (a phone: the app was in the background): made again.
void markSurfaceLost() { surfaceLost_ = true; }
void waitIdle() { vkDeviceWaitIdle(device_); }
VkInstance instance() const { return instance_; }
@ -81,6 +83,7 @@ private:
};
bool createSwapchain();
bool recreateSurface();
void destroySwapchainViews();
const Window* window_ = nullptr;
@ -102,7 +105,7 @@ private:
std::vector<VkImageView> views_;
std::vector<VkSemaphore> renderDone_; // per swapchain image, so present never reuses one in flight
bool vsync_ = true;
bool swapchainDirty_ = false;
bool swapchainDirty_ = false, surfaceLost_ = false;
Frame frames_[kFramesInFlight];
VkCommandPool immPool_ = VK_NULL_HANDLE;