[PR #489] VK-PRESENTER-SURFACE: recover a lost presentation surface #539

Open
opened 2026-11-26 20:18:13 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/489
Author: @bobcatchris
Created: 11/24/2026
Status: 🔄 Open

Base: main ← Head: presenter-surface-recovery


📝 Commits (1)

  • c0d7bd3 present: recover a lost presentation surface

📊 Changes

2 files changed (+103 additions, -28 deletions)

View changed files

📝 runtime/src/vulkan_present.h (+45 -27)
📝 runtime/test/vk_presenter_sync_test.cpp (+58 -1)

📄 Description

Claimed in the coordination issue as: VK-PRESENTER-SURFACE

What and why

The Xbox Vulkan presenter could lose its WSI surface during format enumeration, swapchain creation, or swapchain replacement. The old code only handled surface loss during acquire; a lost surface found during setup left the presenter unusable, and a replacement could leave later presents aimed at the old handle.

This checks the result of every surface query and swapchain creation, marks the surface lost on VK_ERROR_SURFACE_LOST_KHR, and defers presentation until the retained recreate callback supplies a fresh surface. The presenter test injects lost startup and replacement surfaces and verifies that presentation resumes with matching pixels.

Carried from the source patch and measurements by @Sigtryggur-Mani-Gudmundsson:
github.com/Sigtryggur-Mani-Gudmundsson/graphics-runtime-patches@33ab48d3ea/README.md (recovering-a-lost-presentation-surface)

No game data, keys, or decryption are included.

Tested

  • Built vk_presenter_sync_test with CMake/Ninja, RelWithDebInfo.
  • Patched source + patched test: passes, including recovered lost startup and replacement surfaces, 128x96 pixels matched.
  • Unpatched main source + patched test: fails at presenter.ok(), proving the regression test catches the bug.
  • Unpatched main source + old test: passes, so the new failure comes from the added lost-surface cases.
  • A full runtime build in this shell hits an unrelated toolchain issue (clang++ receiving MSVC flags such as /utf-8 and /W4); the targeted presenter target builds and runs cleanly.
  • git diff --check clean.
  • Security sweep of the diff: 0 hits.

Source report measured the same fix on an RTX 4070 Ti under Wine/XWayland with 12,288 of 12,288 pixels matching after recovery.

GPUs tested: AMD Radeon RX 7900 XTX, driver 32.0.32029.2010, Windows 11; source report used NVIDIA GeForce RTX 4070 Ti under Wine/XWayland

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly.
  • One topic.
  • No game data, keys or decryption.
  • Regression test added for the lost-surface cases.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/489 **Author:** [@bobcatchris](https://github.com/bobcatchris) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `presenter-surface-recovery` --- ### 📝 Commits (1) - [`c0d7bd3`](https://github.com/ubiquitarianism/leonida/commit/c0d7bd396686c61d308ae1583a6e65c15d876fc2) present: recover a lost presentation surface ### 📊 Changes **2 files changed** (+103 additions, -28 deletions) <details> <summary>View changed files</summary> 📝 `runtime/src/vulkan_present.h` (+45 -27) 📝 `runtime/test/vk_presenter_sync_test.cpp` (+58 -1) </details> ### 📄 Description Claimed in the coordination issue as: VK-PRESENTER-SURFACE ### What and why The Xbox Vulkan presenter could lose its WSI surface during format enumeration, swapchain creation, or swapchain replacement. The old code only handled surface loss during acquire; a lost surface found during setup left the presenter unusable, and a replacement could leave later presents aimed at the old handle. This checks the result of every surface query and swapchain creation, marks the surface lost on `VK_ERROR_SURFACE_LOST_KHR`, and defers presentation until the retained recreate callback supplies a fresh surface. The presenter test injects lost startup and replacement surfaces and verifies that presentation resumes with matching pixels. Carried from the source patch and measurements by @Sigtryggur-Mani-Gudmundsson: https://github.com/Sigtryggur-Mani-Gudmundsson/graphics-runtime-patches/blob/33ab48d3ea90f9925351aeee8708181a71fb9634/README.md#recovering-a-lost-presentation-surface No game data, keys, or decryption are included. ### Tested - Built `vk_presenter_sync_test` with CMake/Ninja, RelWithDebInfo. - Patched source + patched test: passes, including `recovered lost startup and replacement surfaces, 128x96 pixels matched`. - Unpatched `main` source + patched test: fails at `presenter.ok()`, proving the regression test catches the bug. - Unpatched `main` source + old test: passes, so the new failure comes from the added lost-surface cases. - A full runtime build in this shell hits an unrelated toolchain issue (`clang++` receiving MSVC flags such as `/utf-8` and `/W4`); the targeted presenter target builds and runs cleanly. - `git diff --check` clean. - Security sweep of the diff: 0 hits. Source report measured the same fix on an RTX 4070 Ti under Wine/XWayland with 12,288 of 12,288 pixels matching after recovery. GPUs tested: AMD Radeon RX 7900 XTX, driver 32.0.32029.2010, Windows 11; source report used NVIDIA GeForce RTX 4070 Ti under Wine/XWayland AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly. - [x] One topic. - [x] No game data, keys or decryption. - [x] Regression test added for the lost-surface cases. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#539
No description provided.