[PR #2032] d3d12: copy shader writes in a title window back to the title's pages (TITLE-GPU-WRITE-BACK) #2036

Open
opened 2026-11-26 21:19:49 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/2032
Author: @BubsMcgee
Created: 11/25/2026
Status: 🔄 Open

Base: main ← Head: fix/title-gpu-write-back


📝 Commits (2)

  • 9f9486e d3d12: copy shader writes in a title window back to the title's pages
  • f3c6c18 d3d12: copy title-window writes back after the submission that made them

📊 Changes

4 files changed (+386 additions, -0 deletions)

View changed files

📝 runtime/CMakeLists.txt (+4 -0)
📝 runtime/shims/d3d12_vulkan_device.cpp (+91 -0)
➕ runtime/src/title_write_back.h (+170 -0)
➕ runtime/test/title_write_back_test.cpp (+121 -0)

📄 Description

Ports the first gap from DexNom/VIctory (GPL-3.0-or-later), commits
cd94d35 and 940d32f, reworked for this layer.

The gap

Our title-memory copies are one way: ShadowPages copies the title's pages into the GPU copies before every
submission, and nothing copies a shader's writes back. A UAV/raw-address store into a title window landed in the copy
and was invisible to the title (and could be overwritten by the next refresh).

What this does

  • runtime/src/title_write_back.h: a registry of title windows (their title range and host copy) and the ranges a
    shader wrote, split at window edges, merged when adjacent, taken once for copy-back.
  • make_title_window registers the window; write_buffer_uav marks the buffer's range when a view that names the
    title's pages is made.
  • After the refresh in set_before_execute, flush_title_write_backs copies each marked range back. The refresh
    has just put every page the title wrote into the same copies, so a page copied back cannot lose a title write; the
    copy-back waits for the device first, and skips pages the title has no readable mapping for.

Limits and gating

  • LEONIDA_TITLE_WRITE_BACK=1 enables it; default off until a retail A/B.
  • Title windows only. A slot-133 shadow copy is not a window and is not registered yet (next stage).
  • The copy-back waits for the device instead of using the queue's timeline; that is the safe first form, not the
    fast one. Shader-side page marks (VIctory's view_marks) are the optimization once this is proven.

Tests

  • New title_write_back_test (9 checks): marks split at window edges, merge when adjacent, respect the window end,
    are taken once, and ignore addresses outside every window. title_write_back: OK.
  • The shim target builds; no behaviour changes with the switch unset.

Renamed to this repository's conventions (no VIctory file names). Attribution is in the header comment. AI-assisted.

Claimed as TITLE-GPU-WRITE-BACK in the coordination issue.


🔄 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/2032 **Author:** [@BubsMcgee](https://github.com/BubsMcgee) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/title-gpu-write-back` --- ### 📝 Commits (2) - [`9f9486e`](https://github.com/ubiquitarianism/leonida/commit/9f9486e63625a095370c6ecc1a2d3f00199c666e) d3d12: copy shader writes in a title window back to the title's pages - [`f3c6c18`](https://github.com/ubiquitarianism/leonida/commit/f3c6c18b777cee12b561cc6e34637e2b94b049e7) d3d12: copy title-window writes back after the submission that made them ### 📊 Changes **4 files changed** (+386 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `runtime/CMakeLists.txt` (+4 -0) 📝 `runtime/shims/d3d12_vulkan_device.cpp` (+91 -0) ➕ `runtime/src/title_write_back.h` (+170 -0) ➕ `runtime/test/title_write_back_test.cpp` (+121 -0) </details> ### 📄 Description Ports the first gap from [DexNom/VIctory](https://github.com/DexNom/VIctory) (GPL-3.0-or-later), commits `cd94d35` and `940d32f`, reworked for this layer. ## The gap Our title-memory copies are one way: `ShadowPages` copies the title's pages into the GPU copies before every submission, and nothing copies a shader's writes back. A UAV/raw-address store into a title window landed in the copy and was invisible to the title (and could be overwritten by the next refresh). ## What this does - `runtime/src/title_write_back.h`: a registry of title windows (their title range and host copy) and the ranges a shader wrote, split at window edges, merged when adjacent, taken once for copy-back. - `make_title_window` registers the window; `write_buffer_uav` marks the buffer's range when a view that names the title's pages is made. - After the refresh in `set_before_execute`, `flush_title_write_backs` copies each marked range back. The refresh has just put every page the title wrote into the same copies, so a page copied back cannot lose a title write; the copy-back waits for the device first, and skips pages the title has no readable mapping for. ## Limits and gating - `LEONIDA_TITLE_WRITE_BACK=1` enables it; default off until a retail A/B. - Title windows only. A slot-133 shadow copy is not a window and is not registered yet (next stage). - The copy-back waits for the device instead of using the queue's timeline; that is the safe first form, not the fast one. Shader-side page marks (VIctory's `view_marks`) are the optimization once this is proven. ## Tests - New `title_write_back_test` (9 checks): marks split at window edges, merge when adjacent, respect the window end, are taken once, and ignore addresses outside every window. `title_write_back: OK`. - The shim target builds; no behaviour changes with the switch unset. Renamed to this repository's conventions (no VIctory file names). Attribution is in the header comment. AI-assisted. Claimed as `TITLE-GPU-WRITE-BACK` in the coordination issue. --- <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#2036
No description provided.