d3d12: every title write-back range on one guarded page goes back (RT-TITLE-WRITEBACK-SAME-PAGE-RANGES) #2470

Merged
Tyrannys merged 3 commits from upstream-pr/2470 into main 2026-11-29 01:55:44 +00:00
Tyrannys commented 2026-11-27 14:43:03 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Tyrannys on 2026-11-27T14:43:03Z.


Claimed in the coordination issue as: RT-TITLE-WRITEBACK-SAME-PAGE-RANGES (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7219907123). Found by @73N1X (their finding in #1608, 2026-11-27 11:40).

Depends on: none (builds on #2468, now merged; upstream/main merged in)

What and why

DeviceState::write_back_titles handed each finished range to ShadowPages::write_back on its own. When the first range that differs is on a guarded page, write_back reopens that page, and reopen_locked clears kProtected. Every later disjoint range on that page then fails the held() check (not protected, not clean) and is dropped as if the title had written the page. But only the write-back itself wrote there, so the GPU's later words on that page never reach the title, and the next forward copy writes the title's older bytes over them in the shadow. CPU code that reads GPU results back (the write-back case) sees stale words.

Fix:

  • ShadowPages::write_back takes all of one tracker's finished ranges in one call (const std::pair<uintptr_t, uintptr_t>*, count, optional reached count). It decides which pages are held once for every page the ranges cover, after the journal, pin and write-watch checks and before the first copy. Then it copies range by range as before.
  • write_back_titles sorts the finished ranges (batches can overlap) and gives each shadow the ranges over it in one call. The log line's range count now comes from reached.
  • The per-page decisions are allocated before lock_ is taken. A thread that faults on a guarded page waits on lock_ in reopen(), and it may hold the heap lock while it waits.

How it relates to the other work on this path:

  • #2468 (OreoFR, RT-WRITEBACK-TILE-REOPEN, merged) took held once per page before the copies of one range. This PR now builds on it: the same snapshot, in #2468's held_pages_ member, covers all of a tracker's ranges, and #2468's tile test stays.
  • #2352 merges touching ranges in note_title_write. This PR does not touch that function and is about disjoint ranges.
  • #2461 changes the batch-draining loop in write_back_titles. This PR changes only the loop after it (the per-range calls). The two edit neighbouring lines, so a textual conflict is possible, but no logic is shared.
  • RT-WRITEBACK-FAULT-RELOCK (OreoFR, #2418 is merged): the writer_ handling is unchanged.

Known limit, unchanged by this PR: a page opened by the write-back stays writable by the title until the next refresh guards it again. Before this PR that was already true for the pieces of a single range after the first.

Tested

New test d3d12_title_window_write_back_ranges (d3d12_title_va_test --window-writeback-ranges). It makes a title window and lets a submission that does not reach the ring guard the pages. Then the GPU writes new words into the window through its arena address, so nothing is noted for that write. Before that submission, the test notes 16 four-byte ranges 16 bytes apart on the first page. The next refresh copies them back.

  • base ec91d695c: fails 3/3. 1/16 four-byte ranges on one guarded page reached it, 48/48 words between them kept the title's
  • with the fix: passes 3/3. 16/16 ranges reach the page, the 48 words between them keep the title's, and no word has any other value.

Write-back, shadow and title-memory tests (-R "write_back|writeback|shadow|title_memory|title_va|title_window|placed"): 19/19 pass, including d3d12_title_window_write_back_fault (#2418), d3d12_placed_write_back and d3d12_shadow_keep_refill(_off).

Full suite (ctest -C Release -j 4): 498/502. The four failures:

  • big_compile_gate timed out under -j 4 and passes alone.
  • xs_proxy_mock failed under -j 4 and passes alone.
  • xbox_present (present_planes) and d3d12_set_descriptor_heaps (recorded_commands) also fail on the base with the original d3d12_vulkan_device.cpp, so they are not from this change.

No game files or shaders were needed.

GPUs tested: profile M: NVIDIA GeForce RTX 4070 SUPER, 12 GB, desktop, driver 621.01, Windows 11

AI-assisted: yes (Claude Code)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a)

🤖 Generated with Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5528487799 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2470). Originally posted by [Tyrannys](https://github.com/Tyrannys) on 2026-11-27T14:43:03Z. --- Claimed in the coordination issue as: RT-TITLE-WRITEBACK-SAME-PAGE-RANGES (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7219907123). Found by @73N1X (their finding in #1608, 2026-11-27 11:40). Depends on: none (builds on #2468, now merged; `upstream/main` merged in) ### What and why `DeviceState::write_back_titles` handed each finished range to `ShadowPages::write_back` on its own. When the first range that differs is on a guarded page, `write_back` reopens that page, and `reopen_locked` clears `kProtected`. Every later disjoint range on that page then fails the `held()` check (not protected, not clean) and is dropped as if the title had written the page. But only the write-back itself wrote there, so the GPU's later words on that page never reach the title, and the next forward copy writes the title's older bytes over them in the shadow. CPU code that reads GPU results back (the write-back case) sees stale words. Fix: - `ShadowPages::write_back` takes all of one tracker's finished ranges in one call (`const std::pair<uintptr_t, uintptr_t>*`, count, optional `reached` count). It decides which pages are held once for every page the ranges cover, after the journal, pin and write-watch checks and before the first copy. Then it copies range by range as before. - `write_back_titles` sorts the finished ranges (batches can overlap) and gives each shadow the ranges over it in one call. The log line's range count now comes from `reached`. - The per-page decisions are allocated before `lock_` is taken. A thread that faults on a guarded page waits on `lock_` in `reopen()`, and it may hold the heap lock while it waits. How it relates to the other work on this path: - **#2468** (OreoFR, RT-WRITEBACK-TILE-REOPEN, merged) took `held` once per page before the copies of one range. This PR now builds on it: the same snapshot, in #2468's `held_pages_` member, covers all of a tracker's ranges, and #2468's tile test stays. - **#2352** merges touching ranges in `note_title_write`. This PR does not touch that function and is about disjoint ranges. - **#2461** changes the batch-draining loop in `write_back_titles`. This PR changes only the loop after it (the per-range calls). The two edit neighbouring lines, so a textual conflict is possible, but no logic is shared. - **RT-WRITEBACK-FAULT-RELOCK** (OreoFR, #2418 is merged): the `writer_` handling is unchanged. Known limit, unchanged by this PR: a page opened by the write-back stays writable by the title until the next refresh guards it again. Before this PR that was already true for the pieces of a single range after the first. ### Tested New test `d3d12_title_window_write_back_ranges` (`d3d12_title_va_test --window-writeback-ranges`). It makes a title window and lets a submission that does not reach the ring guard the pages. Then the GPU writes new words into the window through its arena address, so nothing is noted for that write. Before that submission, the test notes 16 four-byte ranges 16 bytes apart on the first page. The next refresh copies them back. - base `ec91d695c`: fails 3/3. `1/16 four-byte ranges on one guarded page reached it, 48/48 words between them kept the title's` - with the fix: passes 3/3. 16/16 ranges reach the page, the 48 words between them keep the title's, and no word has any other value. Write-back, shadow and title-memory tests (`-R "write_back|writeback|shadow|title_memory|title_va|title_window|placed"`): 19/19 pass, including `d3d12_title_window_write_back_fault` (#2418), `d3d12_placed_write_back` and `d3d12_shadow_keep_refill(_off)`. Full suite (`ctest -C Release -j 4`): 498/502. The four failures: - `big_compile_gate` timed out under `-j 4` and passes alone. - `xs_proxy_mock` failed under `-j 4` and passes alone. - `xbox_present` (`present_planes`) and `d3d12_set_descriptor_heaps` (`recorded_commands`) also fail on the base with the original `d3d12_vulkan_device.cpp`, so they are not from this change. No game files or shaders were needed. GPUs tested: profile M: NVIDIA GeForce RTX 4070 SUPER, 12 GB, desktop, driver 621.01, Windows 11 AI-assisted: yes (Claude Code) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
lixonik commented 2026-11-27 15:20:40 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-27T15:20:40Z.

Code review location: runtime/shims/d3d12_vulkan_device.cpp; line 439

@@ -415,9 +416,27 @@ class ShadowPages {
     // read-only binding's pages alone (guarded, so a write the title makes meanwhile faults and waits on the lock),
     // where opening them for a whole copy lost a write made between the opening and the copy; and of two copies of
     // the same bytes only the one that differs is written, where the last one won.
-    std::size_t write_back(std::uintptr_t from, std::uintptr_t to) {
-        from = std::max(from, first_), to = std::min(to, last_);
-        if (from >= to) return 0;
+    //
+    // All the finished ranges over this tracker come in one call, and which pages are held is decided once for all of
+    // them, before the first copy. One call per range made the first range that differed reopen its page (kProtected
+    // gone), and every later range on that page then read as written by the title and was dropped, though only this
+    // write-back had written there (73N1X, #1608: of 130 four-byte ranges 256 bytes apart, 9 went back). A page
+    // opened here is open to the title until the next refresh guards it again, as it was for the pieces of one range
+    // after the first.
+    std::size_t write_back(const std::pair<std::uintptr_t, std::uintptr_t>* ranges, std::size_t count,
+                           std::size_t* reached = nullptr) {
+        if (reached) *reached = 0;
+        std::uintptr_t lo = last_, hi = first_;  // the pages the ranges cover
+        for (std::size_t r = 0; r < count; ++r) {
+            const std::uintptr_t from = std::max(ranges[r].first, first_), to = std::min(ranges[r].second, last_);
+            if (from >= to) continue;
+            lo = std::min(lo, from & ~(kPage - 1));
+            hi = std::max(hi, (to + kPage - 1) & ~(kPage - 1));
+        }
+        if (lo >= hi) return 0;
+        // Allocated before lock_ is taken: a thread that faults on a guarded page waits on lock_ in reopen(), and may
+        // hold the heap's lock while it does.
+        std::vector<std::uint8_t> held_pages((hi - lo) / kPage);

Good that held_pages is allocated before AcquireSRWLockExclusive(&lock_) and destroyed after ReleaseSRWLockExclusive(&lock_) on every return path, avoiding the fault-handler process-heap deadlock. Keeping it as a reusable Vector<std::uint8_t> (leonida::host_heap) member on ShadowPages (as in #2468) would also avoid per-call process-heap allocations when two ranges touch opposite ends of a large tracker.

<!-- greyfinch-sync:ubiquitarianism/leonida:review-comment:4721091784 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/2470#discussion_r4721091784). Originally posted by [lixonik](https://github.com/lixonik) on 2026-11-27T15:20:40Z. **Code review location:** `runtime/shims/d3d12_vulkan_device.cpp`; line 439 ~~~~diff @@ -415,9 +416,27 @@ class ShadowPages { // read-only binding's pages alone (guarded, so a write the title makes meanwhile faults and waits on the lock), // where opening them for a whole copy lost a write made between the opening and the copy; and of two copies of // the same bytes only the one that differs is written, where the last one won. - std::size_t write_back(std::uintptr_t from, std::uintptr_t to) { - from = std::max(from, first_), to = std::min(to, last_); - if (from >= to) return 0; + // + // All the finished ranges over this tracker come in one call, and which pages are held is decided once for all of + // them, before the first copy. One call per range made the first range that differed reopen its page (kProtected + // gone), and every later range on that page then read as written by the title and was dropped, though only this + // write-back had written there (73N1X, #1608: of 130 four-byte ranges 256 bytes apart, 9 went back). A page + // opened here is open to the title until the next refresh guards it again, as it was for the pieces of one range + // after the first. + std::size_t write_back(const std::pair<std::uintptr_t, std::uintptr_t>* ranges, std::size_t count, + std::size_t* reached = nullptr) { + if (reached) *reached = 0; + std::uintptr_t lo = last_, hi = first_; // the pages the ranges cover + for (std::size_t r = 0; r < count; ++r) { + const std::uintptr_t from = std::max(ranges[r].first, first_), to = std::min(ranges[r].second, last_); + if (from >= to) continue; + lo = std::min(lo, from & ~(kPage - 1)); + hi = std::max(hi, (to + kPage - 1) & ~(kPage - 1)); + } + if (lo >= hi) return 0; + // Allocated before lock_ is taken: a thread that faults on a guarded page waits on lock_ in reopen(), and may + // hold the heap's lock while it does. + std::vector<std::uint8_t> held_pages((hi - lo) / kPage); ~~~~ --- Good that `held_pages` is allocated before `AcquireSRWLockExclusive(&lock_)` and destroyed after `ReleaseSRWLockExclusive(&lock_)` on every return path, avoiding the fault-handler process-heap deadlock. Keeping it as a reusable `Vector<std::uint8_t>` (`leonida::host_heap`) member on `ShadowPages` (as in `#2468`) would also avoid per-call process-heap allocations when two ranges touch opposite ends of a large tracker.
lixonik commented 2026-11-27 15:20:40 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-27T15:20:40Z.

Code review location: runtime/shims/d3d12_vulkan_device.cpp; line 508

@@ -439,48 +458,66 @@ class ShadowPages {
             ReleaseSRWLockExclusive(&lock_);
             return 0;
         }
-        leonida::kernel_writes::for_each_pin(from, to, [&](std::uintptr_t a, std::uintptr_t b) {
-            for (std::uintptr_t p = std::max(a, from) & ~(kPage - 1); p < std::min(b, to); p += kPage)
-                state_[(p - first_) / kPage] |= kPinned;
-            pinned_ = true;
-        });
+        for (std::size_t r = 0; r < count; ++r) {
+            const std::uintptr_t from = std::max(ranges[r].first, first_), to = std::min(ranges[r].second, last_);
+            if (from >= to) continue;
+            leonida::kernel_writes::for_each_pin(from, to, [&](std::uintptr_t a, std::uintptr_t b) {
+                for (std::uintptr_t p = std::max(a, from) & ~(kPage - 1); p < std::min(b, to); p += kPage)
+                    state_[(p - first_) / kPage] |= kPinned;
+                pinned_ = true;
+            });
+        }
         ask_written_locked();
         // A page the title wrote since it was last copied holds the newer bytes already: its GPU result is dropped and
         // the refresh's own copy carries the title's. So is a page whose mapping changed, one a kernel write may be
         // filling, and one xmem maps at another address too (a write there is seen by no guard and no watch here).
-        const auto held = [&](std::size_t i) {
-            const std::uint8_t s = state_[i];
-            return (s & (kZero | kRequery | kPinned | kAliased)) || (!(s & kProtected) && !(s & kClean));
-        };
+        const std::size_t p0 = (lo - first_) / kPage;
+        for (std::size_t r = 0; r < count; ++r) {
+            const std::uintptr_t from = std::max(ranges[r].first, first_), to = std::min(ranges[r].second, last_);
+            if (from >= to) continue;
+            for (std::size_t i = (from - first_) / kPage, i1 = (to - first_ + kPage - 1) / kPage; i < i1; ++i) {
+                const std::uint8_t s = state_[i];
+                held_pages[i - p0] =
+                    (s & (kZero | kRequery | kPinned | kAliased)) || (!(s & kProtected) && !(s & kClean));
+            }
+        }
+        const auto held = [&](std::size_t i) { return held_pages[i - p0] != 0; };
         constexpr std::uintptr_t kPiece = 256;  // compared and copied in pieces this size
         std::size_t written = 0;
-        for (std::uintptr_t at = from & ~(kPage - 1); at < ((to + kPage - 1) & ~(kPage - 1));) {
-            std::size_t pages = 0;
-            while (at + (pages + 1) * kPage <= ((to + kPage - 1) & ~(kPage - 1)) &&
-                   held((at - first_) / kPage + pages) == held((at - first_) / kPage))
-                ++pages;
-            if (!held((at - first_) / kPage)) {
-                const std::uintptr_t a = std::max(at, from), b = std::min(at + pages * kPage, to);
-                bool opened = false;
-                for (const Target& t : targets_) {
-                    const std::uintptr_t x = std::max(a, t.begin), y = std::min(b, t.end);
-                    if (x >= y || !t.shadow) continue;
-                    for (std::uintptr_t c = x; c < y;) {
-                        const std::uintptr_t e = std::min(y, (c + kPiece) & ~(kPiece - 1));
-                        const std::uint8_t* copy = t.shadow + (c - t.begin);
-                        if (std::memcmp(reinterpret_cast<const void*>(c), copy, e - c) != 0) {
-                            if (!opened) {
-                                reopen_locked(at, at + pages * kPage);
-                                opened = true;
+        for (std::size_t r = 0; r < count; ++r) {
+            const std::uintptr_t from = std::max(ranges[r].first, first_), to = std::min(ranges[r].second, last_);
+            if (from >= to) continue;
+            const std::size_t range_written = written;
+            const std::uintptr_t end = (to + kPage - 1) & ~(kPage - 1);
+            for (std::uintptr_t at = from & ~(kPage - 1); at < end;) {
+                std::size_t pages = 0;
+                while (at + (pages + 1) * kPage <= end &&
+                       held((at - first_) / kPage + pages) == held((at - first_) / kPage))
+                    ++pages;
+                if (!held((at - first_) / kPage)) {
+                    const std::uintptr_t a = std::max(at, from), b = std::min(at + pages * kPage, to);
+                    bool opened = false;
+                    for (const Target& t : targets_) {
+                        const std::uintptr_t x = std::max(a, t.begin), y = std::min(b, t.end);
+                        if (x >= y || !t.shadow) continue;
+                        for (std::uintptr_t c = x; c < y;) {
+                            const std::uintptr_t e = std::min(y, (c + kPiece) & ~(kPiece - 1));
+                            const std::uint8_t* copy = t.shadow + (c - t.begin);
+                            if (std::memcmp(reinterpret_cast<const void*>(c), copy, e - c) != 0) {
+                                if (!opened) {
+                                    reopen_locked(at, at + pages * kPage);

Minor: bool opened is reset per range r, so when many disjoint ranges share one guarded page (e.g. 130 four-byte ranges on one page), range 0 clears kProtected and ranges 1..129 still enter reopen_locked(at, at + pages * kPage) and issue a VirtualQuery each time. Skipping reopen_locked when no page in [at, at + pages * kPage) still has kProtected set avoids the redundant VirtualQuery calls.

<!-- greyfinch-sync:ubiquitarianism/leonida:review-comment:4721091793 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/2470#discussion_r4721091793). Originally posted by [lixonik](https://github.com/lixonik) on 2026-11-27T15:20:40Z. **Code review location:** `runtime/shims/d3d12_vulkan_device.cpp`; line 508 ~~~~diff @@ -439,48 +458,66 @@ class ShadowPages { ReleaseSRWLockExclusive(&lock_); return 0; } - leonida::kernel_writes::for_each_pin(from, to, [&](std::uintptr_t a, std::uintptr_t b) { - for (std::uintptr_t p = std::max(a, from) & ~(kPage - 1); p < std::min(b, to); p += kPage) - state_[(p - first_) / kPage] |= kPinned; - pinned_ = true; - }); + for (std::size_t r = 0; r < count; ++r) { + const std::uintptr_t from = std::max(ranges[r].first, first_), to = std::min(ranges[r].second, last_); + if (from >= to) continue; + leonida::kernel_writes::for_each_pin(from, to, [&](std::uintptr_t a, std::uintptr_t b) { + for (std::uintptr_t p = std::max(a, from) & ~(kPage - 1); p < std::min(b, to); p += kPage) + state_[(p - first_) / kPage] |= kPinned; + pinned_ = true; + }); + } ask_written_locked(); // A page the title wrote since it was last copied holds the newer bytes already: its GPU result is dropped and // the refresh's own copy carries the title's. So is a page whose mapping changed, one a kernel write may be // filling, and one xmem maps at another address too (a write there is seen by no guard and no watch here). - const auto held = [&](std::size_t i) { - const std::uint8_t s = state_[i]; - return (s & (kZero | kRequery | kPinned | kAliased)) || (!(s & kProtected) && !(s & kClean)); - }; + const std::size_t p0 = (lo - first_) / kPage; + for (std::size_t r = 0; r < count; ++r) { + const std::uintptr_t from = std::max(ranges[r].first, first_), to = std::min(ranges[r].second, last_); + if (from >= to) continue; + for (std::size_t i = (from - first_) / kPage, i1 = (to - first_ + kPage - 1) / kPage; i < i1; ++i) { + const std::uint8_t s = state_[i]; + held_pages[i - p0] = + (s & (kZero | kRequery | kPinned | kAliased)) || (!(s & kProtected) && !(s & kClean)); + } + } + const auto held = [&](std::size_t i) { return held_pages[i - p0] != 0; }; constexpr std::uintptr_t kPiece = 256; // compared and copied in pieces this size std::size_t written = 0; - for (std::uintptr_t at = from & ~(kPage - 1); at < ((to + kPage - 1) & ~(kPage - 1));) { - std::size_t pages = 0; - while (at + (pages + 1) * kPage <= ((to + kPage - 1) & ~(kPage - 1)) && - held((at - first_) / kPage + pages) == held((at - first_) / kPage)) - ++pages; - if (!held((at - first_) / kPage)) { - const std::uintptr_t a = std::max(at, from), b = std::min(at + pages * kPage, to); - bool opened = false; - for (const Target& t : targets_) { - const std::uintptr_t x = std::max(a, t.begin), y = std::min(b, t.end); - if (x >= y || !t.shadow) continue; - for (std::uintptr_t c = x; c < y;) { - const std::uintptr_t e = std::min(y, (c + kPiece) & ~(kPiece - 1)); - const std::uint8_t* copy = t.shadow + (c - t.begin); - if (std::memcmp(reinterpret_cast<const void*>(c), copy, e - c) != 0) { - if (!opened) { - reopen_locked(at, at + pages * kPage); - opened = true; + for (std::size_t r = 0; r < count; ++r) { + const std::uintptr_t from = std::max(ranges[r].first, first_), to = std::min(ranges[r].second, last_); + if (from >= to) continue; + const std::size_t range_written = written; + const std::uintptr_t end = (to + kPage - 1) & ~(kPage - 1); + for (std::uintptr_t at = from & ~(kPage - 1); at < end;) { + std::size_t pages = 0; + while (at + (pages + 1) * kPage <= end && + held((at - first_) / kPage + pages) == held((at - first_) / kPage)) + ++pages; + if (!held((at - first_) / kPage)) { + const std::uintptr_t a = std::max(at, from), b = std::min(at + pages * kPage, to); + bool opened = false; + for (const Target& t : targets_) { + const std::uintptr_t x = std::max(a, t.begin), y = std::min(b, t.end); + if (x >= y || !t.shadow) continue; + for (std::uintptr_t c = x; c < y;) { + const std::uintptr_t e = std::min(y, (c + kPiece) & ~(kPiece - 1)); + const std::uint8_t* copy = t.shadow + (c - t.begin); + if (std::memcmp(reinterpret_cast<const void*>(c), copy, e - c) != 0) { + if (!opened) { + reopen_locked(at, at + pages * kPage); ~~~~ --- Minor: `bool opened` is reset per range `r`, so when many disjoint ranges share one guarded page (e.g. 130 four-byte ranges on one page), range 0 clears `kProtected` and ranges 1..129 still enter `reopen_locked(at, at + pages * kPage)` and issue a `VirtualQuery` each time. Skipping `reopen_locked` when no page in `[at, at + pages * kPage)` still has `kProtected` set avoids the redundant `VirtualQuery` calls.
lixonik commented 2026-11-27 15:20:40 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-27T15:20:40Z.

Review: COMMENTED


Reviewed and tested at 27c167376 (merged cleanly onto main ec91d695c).

Batching all finished ranges per tracker into one ShadowPages::write_back() call and snapshotting held_pages once before the first copy cleanly fixes the multi-range-on-one-guarded-page drop, and passes all write-back GPU tests on RTX 5070.

Two coordination / optimization notes:

  • Overlap with #2468: snapshotting held_pages across all ranges in one call also addresses #2468's same-tile reopen bug (including #2468's noted multi-range-in-one-tile limit). Both PRs touch the same lines in runtime/CMakeLists.txt, runtime/shims/d3d12_vulkan_device.cpp, and runtime/test/d3d12_title_va_test.cpp; if #2470 lands, pulling in #2468's host_heap held_pages_ member and --window-writeback-fault-tile test covers both issues cleanly.
  • Two minor perf notes inline on held_pages allocation and repeated reopen_locked() calls for ranges sharing a page.

Verified locally on Windows 11 (MSVC 19.44.35230.0, Ninja Release, NVIDIA GeForce RTX 5070, driver 610.88, Vulkan 1.4.341; note VK_LAYER_KHRONOS_validation is not installed locally so Vulkan validation layers did not run):

  • d3d12_title_window_write_back, d3d12_title_window_write_back_fault, d3d12_title_window_write_back_ranges (16/16 four-byte ranges reached the guarded page, 48/48 surrounding words kept), d3d12_placed_write_back: 4/4 passed
  • scripts/check_no_game_data.py and git diff --check: clean

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6090272733 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2470#pullrequestreview-6090272733). Originally posted by [lixonik](https://github.com/lixonik) on 2026-11-27T15:20:40Z. **Review:** COMMENTED --- Reviewed and tested at `27c167376` (merged cleanly onto `main` `ec91d695c`). Batching all finished ranges per tracker into one `ShadowPages::write_back()` call and snapshotting `held_pages` once before the first copy cleanly fixes the multi-range-on-one-guarded-page drop, and passes all write-back GPU tests on RTX 5070. Two coordination / optimization notes: - **Overlap with `#2468`**: snapshotting `held_pages` across all ranges in one call also addresses `#2468`'s same-tile reopen bug (including `#2468`'s noted multi-range-in-one-tile limit). Both PRs touch the same lines in `runtime/CMakeLists.txt`, `runtime/shims/d3d12_vulkan_device.cpp`, and `runtime/test/d3d12_title_va_test.cpp`; if `#2470` lands, pulling in `#2468`'s `host_heap` `held_pages_` member and `--window-writeback-fault-tile` test covers both issues cleanly. - Two minor perf notes inline on `held_pages` allocation and repeated `reopen_locked()` calls for ranges sharing a page. Verified locally on Windows 11 (MSVC 19.44.35230.0, Ninja Release, NVIDIA GeForce RTX 5070, driver 610.88, Vulkan 1.4.341; note `VK_LAYER_KHRONOS_validation` is not installed locally so Vulkan validation layers did not run): - `d3d12_title_window_write_back`, `d3d12_title_window_write_back_fault`, `d3d12_title_window_write_back_ranges` (16/16 four-byte ranges reached the guarded page, 48/48 surrounding words kept), `d3d12_placed_write_back`: 4/4 passed - `scripts/check_no_game_data.py` and `git diff --check`: clean AI-assisted.
djrolfes commented 2026-11-27 15:26:29 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by djrolfes on 2026-11-27T15:26:29Z.


Independent Linux/Wine + NVIDIA check at head 27c167376 (merged cleanly onto origin/main ec91d695c in a local integration stack alongside #2467, #2463, #2469, #2461, #2126, #2091, and two local V# patches).

  • Environment: Linux 7.2.15, wine-11.22, clang-cl + xwin cross-build, NVIDIA GeForce RTX 3070 Ti 8 GB, driver 620.73.04, Ryzen 7 5800X, 32 GB RAM. No game files.
  • CTest:
    • d3d12_title_window_write_back_ranges: passed (6.06 s) — 16/16 four-byte ranges on one guarded page reached it, 48/48 words between them kept the title's, 0 words neither.
    • d3d12_title_va, d3d12_title_va_shadow, d3d12_title_window_cap, d3d12_title_window_write_back: all passed (~6.0 s each).
    • d3d12_title_window_write_back_fault: skipped as expected under Wine (write watching is off).
  • Code review: allocating held_pages before taking lock_ and computing page hold state once across all sorted ranges per shadow cleanly avoids both the same-page reopen drop and the lock-inversion hazard.

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7222061018 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/2470#issuecomment-7222061018). Originally posted by [djrolfes](https://github.com/djrolfes) on 2026-11-27T15:26:29Z. --- Independent Linux/Wine + NVIDIA check at head `27c167376` (merged cleanly onto `origin/main` `ec91d695c` in a local integration stack alongside `#2467`, `#2463`, `#2469`, `#2461`, `#2126`, `#2091`, and two local V# patches). - **Environment:** Linux `7.2.15`, `wine-11.22`, `clang-cl` + `xwin` cross-build, NVIDIA GeForce RTX 3070 Ti 8 GB, driver `620.73.04`, Ryzen 7 5800X, 32 GB RAM. No game files. - **CTest:** - `d3d12_title_window_write_back_ranges`: **passed** (`6.06 s`) — `16/16 four-byte ranges on one guarded page reached it, 48/48 words between them kept the title's, 0 words neither`. - `d3d12_title_va`, `d3d12_title_va_shadow`, `d3d12_title_window_cap`, `d3d12_title_window_write_back`: all **passed** (`~6.0 s` each). - `d3d12_title_window_write_back_fault`: skipped as expected under Wine (`write watching is off`). - **Code review:** allocating `held_pages` before taking `lock_` and computing page hold state once across all sorted ranges per shadow cleanly avoids both the same-page reopen drop and the lock-inversion hazard. AI-assisted.
Tyrannys commented 2026-11-27 16:08:40 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Tyrannys on 2026-11-27T16:08:40Z.

Code review location: runtime/shims/d3d12_vulkan_device.cpp; line 439

@@ -415,9 +416,27 @@ class ShadowPages {
     // read-only binding's pages alone (guarded, so a write the title makes meanwhile faults and waits on the lock),
     // where opening them for a whole copy lost a write made between the opening and the copy; and of two copies of
     // the same bytes only the one that differs is written, where the last one won.
-    std::size_t write_back(std::uintptr_t from, std::uintptr_t to) {
-        from = std::max(from, first_), to = std::min(to, last_);
-        if (from >= to) return 0;
+    //
+    // All the finished ranges over this tracker come in one call, and which pages are held is decided once for all of
+    // them, before the first copy. One call per range made the first range that differed reopen its page (kProtected
+    // gone), and every later range on that page then read as written by the title and was dropped, though only this
+    // write-back had written there (73N1X, #1608: of 130 four-byte ranges 256 bytes apart, 9 went back). A page
+    // opened here is open to the title until the next refresh guards it again, as it was for the pieces of one range
+    // after the first.
+    std::size_t write_back(const std::pair<std::uintptr_t, std::uintptr_t>* ranges, std::size_t count,
+                           std::size_t* reached = nullptr) {
+        if (reached) *reached = 0;
+        std::uintptr_t lo = last_, hi = first_;  // the pages the ranges cover
+        for (std::size_t r = 0; r < count; ++r) {
+            const std::uintptr_t from = std::max(ranges[r].first, first_), to = std::min(ranges[r].second, last_);
+            if (from >= to) continue;
+            lo = std::min(lo, from & ~(kPage - 1));
+            hi = std::max(hi, (to + kPage - 1) & ~(kPage - 1));
+        }
+        if (lo >= hi) return 0;
+        // Allocated before lock_ is taken: a thread that faults on a guarded page waits on lock_ in reopen(), and may
+        // hold the heap's lock while it does.
+        std::vector<std::uint8_t> held_pages((hi - lo) / kPage);

Thanks, done in d7b81dd43. The merge with main brought in #2468's held_pages_ (a leonida::host_heap Vector member), and this branch now uses it for the snapshot over all ranges. I size it before lock_ is taken (only write_back uses it, and one write_back runs at a time under shadow_mutex), so the lock-ordering point still holds and the capacity is reused between calls. AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:review-comment:4721526760 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/2470#discussion_r4721526760). Originally posted by [Tyrannys](https://github.com/Tyrannys) on 2026-11-27T16:08:40Z. **Code review location:** `runtime/shims/d3d12_vulkan_device.cpp`; line 439 ~~~~diff @@ -415,9 +416,27 @@ class ShadowPages { // read-only binding's pages alone (guarded, so a write the title makes meanwhile faults and waits on the lock), // where opening them for a whole copy lost a write made between the opening and the copy; and of two copies of // the same bytes only the one that differs is written, where the last one won. - std::size_t write_back(std::uintptr_t from, std::uintptr_t to) { - from = std::max(from, first_), to = std::min(to, last_); - if (from >= to) return 0; + // + // All the finished ranges over this tracker come in one call, and which pages are held is decided once for all of + // them, before the first copy. One call per range made the first range that differed reopen its page (kProtected + // gone), and every later range on that page then read as written by the title and was dropped, though only this + // write-back had written there (73N1X, #1608: of 130 four-byte ranges 256 bytes apart, 9 went back). A page + // opened here is open to the title until the next refresh guards it again, as it was for the pieces of one range + // after the first. + std::size_t write_back(const std::pair<std::uintptr_t, std::uintptr_t>* ranges, std::size_t count, + std::size_t* reached = nullptr) { + if (reached) *reached = 0; + std::uintptr_t lo = last_, hi = first_; // the pages the ranges cover + for (std::size_t r = 0; r < count; ++r) { + const std::uintptr_t from = std::max(ranges[r].first, first_), to = std::min(ranges[r].second, last_); + if (from >= to) continue; + lo = std::min(lo, from & ~(kPage - 1)); + hi = std::max(hi, (to + kPage - 1) & ~(kPage - 1)); + } + if (lo >= hi) return 0; + // Allocated before lock_ is taken: a thread that faults on a guarded page waits on lock_ in reopen(), and may + // hold the heap's lock while it does. + std::vector<std::uint8_t> held_pages((hi - lo) / kPage); ~~~~ --- Thanks, done in d7b81dd43. The merge with main brought in #2468's `held_pages_` (a `leonida::host_heap` Vector member), and this branch now uses it for the snapshot over all ranges. I size it before `lock_` is taken (only `write_back` uses it, and one `write_back` runs at a time under `shadow_mutex`), so the lock-ordering point still holds and the capacity is reused between calls. AI-assisted (Claude Code).
Tyrannys commented 2026-11-27 16:08:42 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Tyrannys on 2026-11-27T16:08:42Z.

Code review location: runtime/shims/d3d12_vulkan_device.cpp; line 508

@@ -439,48 +458,66 @@ class ShadowPages {
             ReleaseSRWLockExclusive(&lock_);
             return 0;
         }
-        leonida::kernel_writes::for_each_pin(from, to, [&](std::uintptr_t a, std::uintptr_t b) {
-            for (std::uintptr_t p = std::max(a, from) & ~(kPage - 1); p < std::min(b, to); p += kPage)
-                state_[(p - first_) / kPage] |= kPinned;
-            pinned_ = true;
-        });
+        for (std::size_t r = 0; r < count; ++r) {
+            const std::uintptr_t from = std::max(ranges[r].first, first_), to = std::min(ranges[r].second, last_);
+            if (from >= to) continue;
+            leonida::kernel_writes::for_each_pin(from, to, [&](std::uintptr_t a, std::uintptr_t b) {
+                for (std::uintptr_t p = std::max(a, from) & ~(kPage - 1); p < std::min(b, to); p += kPage)
+                    state_[(p - first_) / kPage] |= kPinned;
+                pinned_ = true;
+            });
+        }
         ask_written_locked();
         // A page the title wrote since it was last copied holds the newer bytes already: its GPU result is dropped and
         // the refresh's own copy carries the title's. So is a page whose mapping changed, one a kernel write may be
         // filling, and one xmem maps at another address too (a write there is seen by no guard and no watch here).
-        const auto held = [&](std::size_t i) {
-            const std::uint8_t s = state_[i];
-            return (s & (kZero | kRequery | kPinned | kAliased)) || (!(s & kProtected) && !(s & kClean));
-        };
+        const std::size_t p0 = (lo - first_) / kPage;
+        for (std::size_t r = 0; r < count; ++r) {
+            const std::uintptr_t from = std::max(ranges[r].first, first_), to = std::min(ranges[r].second, last_);
+            if (from >= to) continue;
+            for (std::size_t i = (from - first_) / kPage, i1 = (to - first_ + kPage - 1) / kPage; i < i1; ++i) {
+                const std::uint8_t s = state_[i];
+                held_pages[i - p0] =
+                    (s & (kZero | kRequery | kPinned | kAliased)) || (!(s & kProtected) && !(s & kClean));
+            }
+        }
+        const auto held = [&](std::size_t i) { return held_pages[i - p0] != 0; };
         constexpr std::uintptr_t kPiece = 256;  // compared and copied in pieces this size
         std::size_t written = 0;
-        for (std::uintptr_t at = from & ~(kPage - 1); at < ((to + kPage - 1) & ~(kPage - 1));) {
-            std::size_t pages = 0;
-            while (at + (pages + 1) * kPage <= ((to + kPage - 1) & ~(kPage - 1)) &&
-                   held((at - first_) / kPage + pages) == held((at - first_) / kPage))
-                ++pages;
-            if (!held((at - first_) / kPage)) {
-                const std::uintptr_t a = std::max(at, from), b = std::min(at + pages * kPage, to);
-                bool opened = false;
-                for (const Target& t : targets_) {
-                    const std::uintptr_t x = std::max(a, t.begin), y = std::min(b, t.end);
-                    if (x >= y || !t.shadow) continue;
-                    for (std::uintptr_t c = x; c < y;) {
-                        const std::uintptr_t e = std::min(y, (c + kPiece) & ~(kPiece - 1));
-                        const std::uint8_t* copy = t.shadow + (c - t.begin);
-                        if (std::memcmp(reinterpret_cast<const void*>(c), copy, e - c) != 0) {
-                            if (!opened) {
-                                reopen_locked(at, at + pages * kPage);
-                                opened = true;
+        for (std::size_t r = 0; r < count; ++r) {
+            const std::uintptr_t from = std::max(ranges[r].first, first_), to = std::min(ranges[r].second, last_);
+            if (from >= to) continue;
+            const std::size_t range_written = written;
+            const std::uintptr_t end = (to + kPage - 1) & ~(kPage - 1);
+            for (std::uintptr_t at = from & ~(kPage - 1); at < end;) {
+                std::size_t pages = 0;
+                while (at + (pages + 1) * kPage <= end &&
+                       held((at - first_) / kPage + pages) == held((at - first_) / kPage))
+                    ++pages;
+                if (!held((at - first_) / kPage)) {
+                    const std::uintptr_t a = std::max(at, from), b = std::min(at + pages * kPage, to);
+                    bool opened = false;
+                    for (const Target& t : targets_) {
+                        const std::uintptr_t x = std::max(a, t.begin), y = std::min(b, t.end);
+                        if (x >= y || !t.shadow) continue;
+                        for (std::uintptr_t c = x; c < y;) {
+                            const std::uintptr_t e = std::min(y, (c + kPiece) & ~(kPiece - 1));
+                            const std::uint8_t* copy = t.shadow + (c - t.begin);
+                            if (std::memcmp(reinterpret_cast<const void*>(c), copy, e - c) != 0) {
+                                if (!opened) {
+                                    reopen_locked(at, at + pages * kPage);

Good catch, thanks. Done in d7b81dd43: before calling reopen_locked for a run, write_back now checks whether any page in [at, at + pages * kPage) still has kProtected, and skips the call (and its VirtualQuery) when an earlier range already reopened them. reopen_locked only touches pages of ours, so the result is the same. d3d12_title_window_write_back_ranges and the #2468 tile test still pass. AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:review-comment:4721527089 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/2470#discussion_r4721527089). Originally posted by [Tyrannys](https://github.com/Tyrannys) on 2026-11-27T16:08:42Z. **Code review location:** `runtime/shims/d3d12_vulkan_device.cpp`; line 508 ~~~~diff @@ -439,48 +458,66 @@ class ShadowPages { ReleaseSRWLockExclusive(&lock_); return 0; } - leonida::kernel_writes::for_each_pin(from, to, [&](std::uintptr_t a, std::uintptr_t b) { - for (std::uintptr_t p = std::max(a, from) & ~(kPage - 1); p < std::min(b, to); p += kPage) - state_[(p - first_) / kPage] |= kPinned; - pinned_ = true; - }); + for (std::size_t r = 0; r < count; ++r) { + const std::uintptr_t from = std::max(ranges[r].first, first_), to = std::min(ranges[r].second, last_); + if (from >= to) continue; + leonida::kernel_writes::for_each_pin(from, to, [&](std::uintptr_t a, std::uintptr_t b) { + for (std::uintptr_t p = std::max(a, from) & ~(kPage - 1); p < std::min(b, to); p += kPage) + state_[(p - first_) / kPage] |= kPinned; + pinned_ = true; + }); + } ask_written_locked(); // A page the title wrote since it was last copied holds the newer bytes already: its GPU result is dropped and // the refresh's own copy carries the title's. So is a page whose mapping changed, one a kernel write may be // filling, and one xmem maps at another address too (a write there is seen by no guard and no watch here). - const auto held = [&](std::size_t i) { - const std::uint8_t s = state_[i]; - return (s & (kZero | kRequery | kPinned | kAliased)) || (!(s & kProtected) && !(s & kClean)); - }; + const std::size_t p0 = (lo - first_) / kPage; + for (std::size_t r = 0; r < count; ++r) { + const std::uintptr_t from = std::max(ranges[r].first, first_), to = std::min(ranges[r].second, last_); + if (from >= to) continue; + for (std::size_t i = (from - first_) / kPage, i1 = (to - first_ + kPage - 1) / kPage; i < i1; ++i) { + const std::uint8_t s = state_[i]; + held_pages[i - p0] = + (s & (kZero | kRequery | kPinned | kAliased)) || (!(s & kProtected) && !(s & kClean)); + } + } + const auto held = [&](std::size_t i) { return held_pages[i - p0] != 0; }; constexpr std::uintptr_t kPiece = 256; // compared and copied in pieces this size std::size_t written = 0; - for (std::uintptr_t at = from & ~(kPage - 1); at < ((to + kPage - 1) & ~(kPage - 1));) { - std::size_t pages = 0; - while (at + (pages + 1) * kPage <= ((to + kPage - 1) & ~(kPage - 1)) && - held((at - first_) / kPage + pages) == held((at - first_) / kPage)) - ++pages; - if (!held((at - first_) / kPage)) { - const std::uintptr_t a = std::max(at, from), b = std::min(at + pages * kPage, to); - bool opened = false; - for (const Target& t : targets_) { - const std::uintptr_t x = std::max(a, t.begin), y = std::min(b, t.end); - if (x >= y || !t.shadow) continue; - for (std::uintptr_t c = x; c < y;) { - const std::uintptr_t e = std::min(y, (c + kPiece) & ~(kPiece - 1)); - const std::uint8_t* copy = t.shadow + (c - t.begin); - if (std::memcmp(reinterpret_cast<const void*>(c), copy, e - c) != 0) { - if (!opened) { - reopen_locked(at, at + pages * kPage); - opened = true; + for (std::size_t r = 0; r < count; ++r) { + const std::uintptr_t from = std::max(ranges[r].first, first_), to = std::min(ranges[r].second, last_); + if (from >= to) continue; + const std::size_t range_written = written; + const std::uintptr_t end = (to + kPage - 1) & ~(kPage - 1); + for (std::uintptr_t at = from & ~(kPage - 1); at < end;) { + std::size_t pages = 0; + while (at + (pages + 1) * kPage <= end && + held((at - first_) / kPage + pages) == held((at - first_) / kPage)) + ++pages; + if (!held((at - first_) / kPage)) { + const std::uintptr_t a = std::max(at, from), b = std::min(at + pages * kPage, to); + bool opened = false; + for (const Target& t : targets_) { + const std::uintptr_t x = std::max(a, t.begin), y = std::min(b, t.end); + if (x >= y || !t.shadow) continue; + for (std::uintptr_t c = x; c < y;) { + const std::uintptr_t e = std::min(y, (c + kPiece) & ~(kPiece - 1)); + const std::uint8_t* copy = t.shadow + (c - t.begin); + if (std::memcmp(reinterpret_cast<const void*>(c), copy, e - c) != 0) { + if (!opened) { + reopen_locked(at, at + pages * kPage); ~~~~ --- Good catch, thanks. Done in d7b81dd43: before calling `reopen_locked` for a run, `write_back` now checks whether any page in `[at, at + pages * kPage)` still has `kProtected`, and skips the call (and its `VirtualQuery`) when an earlier range already reopened them. `reopen_locked` only touches pages of ours, so the result is the same. `d3d12_title_window_write_back_ranges` and the #2468 tile test still pass. AI-assisted (Claude Code).
Tyrannys commented 2026-11-27 16:08:44 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Tyrannys on 2026-11-27T16:08:44Z.


Merged upstream/main (no rebase) in d7b81dd43. Main now has #2468, so the conflict is resolved.

Thanks @lixonik for the review and the RTX 5070 run, and @djrolfes for the Linux/Wine check.

How this PR relates to #2468 (OreoFR, RT-WRITEBACK-TILE-REOPEN, now merged):

  • #2468 found and fixed the first half of this: it decided held once per page before the copies, so that a faulting copy's tile reopen on the same thread no longer dropped the later runs of that range. Credit for that snapshot, the held_pages_ member and the --window-writeback-fault-tile test goes to OreoFR (and to DadaCap, whose review found it).
  • This PR widens the same snapshot from one range to all of a tracker's finished ranges in one call. That is what 73N1X's case needs: several disjoint ranges on one guarded page, each handed to write_back alone before.
  • Since #2468 landed first, this PR now builds on it instead of replacing it. One snapshot, kept in #2468's member, covers both cases, and both regression tests stay: d3d12_title_window_write_back_fault_tile and d3d12_title_window_write_back_ranges.

Also from lixonik's notes: a run whose pages an earlier range already reopened skips reopen_locked (no VirtualQuery).

Re-tested after the merge on RTX 4070 SUPER, driver 621.01, Windows 11. ctest -R "write_back|writeback|shadow|title_memory|title_va|title_window|placed": 20/20 pass, including both tests above. AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7222910113 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/2470#issuecomment-7222910113). Originally posted by [Tyrannys](https://github.com/Tyrannys) on 2026-11-27T16:08:44Z. --- Merged `upstream/main` (no rebase) in d7b81dd43. Main now has #2468, so the conflict is resolved. Thanks @lixonik for the review and the RTX 5070 run, and @djrolfes for the Linux/Wine check. **How this PR relates to #2468 (OreoFR, RT-WRITEBACK-TILE-REOPEN, now merged):** - #2468 found and fixed the first half of this: it decided `held` once per page before the copies, so that a faulting copy's tile reopen on the same thread no longer dropped the later runs of that range. Credit for that snapshot, the `held_pages_` member and the `--window-writeback-fault-tile` test goes to OreoFR (and to DadaCap, whose review found it). - This PR widens the same snapshot from one range to all of a tracker's finished ranges in one call. That is what 73N1X's case needs: several disjoint ranges on one guarded page, each handed to `write_back` alone before. - Since #2468 landed first, this PR now builds on it instead of replacing it. One snapshot, kept in #2468's member, covers both cases, and both regression tests stay: `d3d12_title_window_write_back_fault_tile` and `d3d12_title_window_write_back_ranges`. Also from lixonik's notes: a run whose pages an earlier range already reopened skips `reopen_locked` (no `VirtualQuery`). Re-tested after the merge on RTX 4070 SUPER, driver 621.01, Windows 11. `ctest -R "write_back|writeback|shadow|title_memory|title_va|title_window|placed"`: 20/20 pass, including both tests above. AI-assisted (Claude Code).
OreoFR commented 2026-11-27 18:49:40 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-27T18:49:40Z.


Merge test for the #2464 campaign on an 8 GB laptop (profile M). The PR head already contains main ec91d695c. The numbers were recomputed from the raw logs. AI-assisted (Claude Code, Claude Opus 5.5).

RUN m2470m | 2026-11-27 | OreoFR | AI-assisted: Claude Code (Claude Opus 5.5)
BASE:        this PR at d7b81dd43 (contains main ec91d695c) | shaders: main translation + #2447 (one-lane) pack
MACHINE:     RTX 4070 Laptop 8 GB, laptop (profile M) | NVIDIA 621.40 | Windows 11 | 40 GB
RECIPE:      documented + DEVIATIONS: ASYNC_PIPELINES=1 ASYNC_MIN_BYTES=1048576 VALUE_WAIT_TIMEOUT_MS=30000 MAP_READBACK=1 DEVICE_TYPE=6 ARENA_MB=4095 DEVICE_FAULT=1
OS/DRIVER:   TdrDelay 60
TARGET:      regression check against regA (main ec91d695c, same recipe and caches) | PREDICTED: world reached, no loss
MEASURED:    world entry ~228 s (regA 223 s) | 0 device lost, 0 exceptions (regA 0 / 0) | gpu-stall lines 2 (regA 10)
END:         stopped by our script 53 s after world entry (t=281 s): the known display stop after world entry is the same on main
CACHES:      warm | RUN 1 of 1
INSTRUMENTS: device fault checkpoints, thread stacks
VERDICT:     no regression seen (n=1)
  • d3d12_title_va_test from this head, built in RelWithDebInfo: passed (title memory 64/64, all negative controls held).
  • I did not rerun the test on main here.
<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7225912430 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/2470#issuecomment-7225912430). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-27T18:49:40Z. --- Merge test for the #2464 campaign on an 8 GB laptop (profile M). The PR head already contains main ec91d695c. The numbers were recomputed from the raw logs. AI-assisted (Claude Code, Claude Opus 5.5). ``` RUN m2470m | 2026-11-27 | OreoFR | AI-assisted: Claude Code (Claude Opus 5.5) BASE: this PR at d7b81dd43 (contains main ec91d695c) | shaders: main translation + #2447 (one-lane) pack MACHINE: RTX 4070 Laptop 8 GB, laptop (profile M) | NVIDIA 621.40 | Windows 11 | 40 GB RECIPE: documented + DEVIATIONS: ASYNC_PIPELINES=1 ASYNC_MIN_BYTES=1048576 VALUE_WAIT_TIMEOUT_MS=30000 MAP_READBACK=1 DEVICE_TYPE=6 ARENA_MB=4095 DEVICE_FAULT=1 OS/DRIVER: TdrDelay 60 TARGET: regression check against regA (main ec91d695c, same recipe and caches) | PREDICTED: world reached, no loss MEASURED: world entry ~228 s (regA 223 s) | 0 device lost, 0 exceptions (regA 0 / 0) | gpu-stall lines 2 (regA 10) END: stopped by our script 53 s after world entry (t=281 s): the known display stop after world entry is the same on main CACHES: warm | RUN 1 of 1 INSTRUMENTS: device fault checkpoints, thread stacks VERDICT: no regression seen (n=1) ``` - `d3d12_title_va_test` from this head, built in RelWithDebInfo: passed (title memory 64/64, all negative controls held). - I did not rerun the test on main here.
OreoFR commented 2026-11-27 18:53:36 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-27T18:53:36Z.


Addendum to the RUN above: I built this PR's runtime/test/d3d12_title_va_test.cpp against main ec91d695c on the same machine (RTX 4070 Laptop, 621.40). It also passes on main (exit 0, the same 64/64 and negative-control lines), so here it does not show the same-page bug the PR fixes. Either the same-page case only fails on another GPU or driver, or the test does not reach it yet. A case that fails on main would make the fix provable. AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7225978303 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/2470#issuecomment-7225978303). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-27T18:53:36Z. --- Addendum to the RUN above: I built this PR's `runtime/test/d3d12_title_va_test.cpp` against main ec91d695c on the same machine (RTX 4070 Laptop, 621.40). **It also passes on main** (exit 0, the same 64/64 and negative-control lines), so here it does not show the same-page bug the PR fixes. Either the same-page case only fails on another GPU or driver, or the test does not reach it yet. A case that fails on main would make the fix provable. AI-assisted (Claude Code, Claude Opus 5.5).
Tyrannys commented 2026-11-27 19:06:51 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Tyrannys on 2026-11-27T19:06:51Z.


@OreoFR thanks for the merge run and for checking the test on main. That check matters. The same-page case is not in the default run of d3d12_title_va_test. It sits behind a flag, as the ctest d3d12_title_window_write_back_ranges = d3d12_title_va_test --window-writeback-ranges. A run with no arguments (the 64/64 title-memory run) never reaches it, so it passes on both. Sorry the PR body did not make that clear. (@MoonEyes: the same applies to the title_va variants in your #2477 run. That branch does not have this mode, so none of its 14 variants run it.)

The case: 16 disjoint four-byte ranges (words 0, 4, ..., 60) are noted on one guarded page of a write-watched window. The GPU writes all of them. The first range differs from the title's copy and reopens the page. Every later range on that page must still be copied back.

Rebuilt and run now (profile M: RTX 4070 SUPER, driver 621.01, Windows 11), with this PR's runtime/test/d3d12_title_va_test.cpp unchanged:

--window-writeback-ranges exit
on main (current upstream/main, which includes #2468; only the test file taken from the PR) 1/16 four-byte ranges on one guarded page reached it, fails at line 787: reached == kRanges 1 (3 of 3 runs)
this PR (d7b81dd43) 16/16 ... reached it, 48/48 words between them kept the title's, 0 words neither 0 (3 of 3 runs)

On main only the first range gets back: it reopens the page, and each later range then sees the page as written by the title and drops the GPU's data. The 48 words between the ranges stay the title's in both runs, so nothing is copied that should not be. The plain d3d12_title_va_test passes on both (exit 0), as you saw.

To reproduce on your machine: ctest -R d3d12_title_window_write_back_ranges, or the exe with --window-writeback-ranges.

AI-assisted (Claude Code)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7226202502 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/2470#issuecomment-7226202502). Originally posted by [Tyrannys](https://github.com/Tyrannys) on 2026-11-27T19:06:51Z. --- @OreoFR thanks for the merge run and for checking the test on main. That check matters. The same-page case is not in the default run of `d3d12_title_va_test`. It sits behind a flag, as the ctest `d3d12_title_window_write_back_ranges` = `d3d12_title_va_test --window-writeback-ranges`. A run with no arguments (the 64/64 title-memory run) never reaches it, so it passes on both. Sorry the PR body did not make that clear. (@MoonEyes: the same applies to the title_va variants in your #2477 run. That branch does not have this mode, so none of its 14 variants run it.) The case: 16 disjoint four-byte ranges (words 0, 4, ..., 60) are noted on one guarded page of a write-watched window. The GPU writes all of them. The first range differs from the title's copy and reopens the page. Every later range on that page must still be copied back. Rebuilt and run now (profile M: RTX 4070 SUPER, driver 621.01, Windows 11), with this PR's `runtime/test/d3d12_title_va_test.cpp` unchanged: | | `--window-writeback-ranges` | exit | |---|---|---| | on `main` (current `upstream/main`, which includes #2468; only the test file taken from the PR) | `1/16 four-byte ranges on one guarded page reached it`, fails at `line 787: reached == kRanges` | 1 (3 of 3 runs) | | this PR (`d7b81dd43`) | `16/16 ... reached it, 48/48 words between them kept the title's, 0 words neither` | 0 (3 of 3 runs) | On main only the first range gets back: it reopens the page, and each later range then sees the page as written by the title and drops the GPU's data. The 48 words between the ranges stay the title's in both runs, so nothing is copied that should not be. The plain `d3d12_title_va_test` passes on both (exit 0), as you saw. To reproduce on your machine: `ctest -R d3d12_title_window_write_back_ranges`, or the exe with `--window-writeback-ranges`. AI-assisted (Claude Code)
OreoFR commented 2026-11-27 19:38:51 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-27T19:38:51Z.


@Tyrannys thanks, that was it. With the flag, on the same machine (RTX 4070 Laptop, NVIDIA 621.40, Windows 11):

  • This PR (d7b81dd43 + main ec91d695c merged): d3d12_title_va_test --window-writeback-ranges exit 0: 16/16 four-byte ranges on one guarded page reached it, 48/48 words between them kept the title's.
  • Main ec91d695c (this PR's test file only): exit 1: 1/16 four-byte ranges on one guarded page reached it (the 48/48 untouched words are still kept).

So the test fails on main and passes with the PR: the same-page fix is shown here too. This replaces "it also passes on main" in my addendum above. AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7226733035 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2470#issuecomment-7226733035). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-27T19:38:51Z. --- @Tyrannys thanks, that was it. With the flag, on the same machine (RTX 4070 Laptop, NVIDIA 621.40, Windows 11): - **This PR** (d7b81dd43 + main ec91d695c merged): `d3d12_title_va_test --window-writeback-ranges` exit 0: `16/16 four-byte ranges on one guarded page reached it, 48/48 words between them kept the title's`. - **Main ec91d695c** (this PR's test file only): **exit 1**: `1/16 four-byte ranges on one guarded page reached it` (the 48/48 untouched words are still kept). So the test fails on main and passes with the PR: the same-page fix is shown here too. This replaces "it also passes on main" in my addendum above. AI-assisted (Claude Code, Claude Opus 5.5).
lixonik commented 2026-11-27 20:06:20 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-27T20:06:20Z.

Review: APPROVED


Re-reviewed d7b81dd43 (merge with main / #2468 + review fixes) and tested on RTX 5070:

  • Both earlier comments are cleanly addressed: held_pages_ (leonida::host_heap) is sized before AcquireSRWLockExclusive(&lock_) across [lo, hi), and subsequent ranges on already-reopened pages skip reopen_locked / VirtualQuery when no page in the run retains kProtected.
  • Tested on NVIDIA GeForce RTX 5070 (Windows 11, driver 610.88, Vulkan 1.4.341, MSVC 19.44; VK_LAYER_KHRONOS_validation not installed locally):
    • ctest -R "^(d3d12_title_window_write_back|d3d12_title_window_write_back_fault|d3d12_title_window_write_back_fault_tile|d3d12_title_window_write_back_ranges|d3d12_placed_write_back)$": 5/5 passed (1.14 s).

Looks good to merge.

AI-assisted (Antigravity, Gemini).

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6092912940 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2470#pullrequestreview-6092912940). Originally posted by [lixonik](https://github.com/lixonik) on 2026-11-27T20:06:20Z. **Review:** APPROVED --- Re-reviewed `d7b81dd43` (merge with `main` / #2468 + review fixes) and tested on RTX 5070: - Both earlier comments are cleanly addressed: `held_pages_` (`leonida::host_heap`) is sized before `AcquireSRWLockExclusive(&lock_)` across `[lo, hi)`, and subsequent ranges on already-reopened pages skip `reopen_locked` / `VirtualQuery` when no page in the run retains `kProtected`. - Tested on NVIDIA GeForce RTX 5070 (Windows 11, driver 610.88, Vulkan 1.4.341, MSVC 19.44; `VK_LAYER_KHRONOS_validation` not installed locally): - `ctest -R "^(d3d12_title_window_write_back|d3d12_title_window_write_back_fault|d3d12_title_window_write_back_fault_tile|d3d12_title_window_write_back_ranges|d3d12_placed_write_back)$"`: 5/5 passed (1.14 s). Looks good to merge. AI-assisted (Antigravity, Gemini).
Tyrannys commented 2026-11-28 13:09:31 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Tyrannys on 2026-11-28T13:09:31Z.


Merged current main (d48a957bb) in 0ebe31d3a. It conflicted with main's retired-window write-back.

  • ShadowPages::write_back keeps this PR's form: every range of a tracker in one call, with reached. It also takes main's only parameter (a retired window's copy), and runs main's two-pass, byte-level copy for each run of unheld pages. A run reopens its pages only while one of them is still guarded, as before.
  • free_retired_shadow passes its one range in the new form.
  • d3d12_title_va_test's submit_write takes both base (this PR) and wait (main).

Profile M (RTX 4070 SUPER, 621.01, Windows 11), Release:

  • ctest -R "title|write_back|writeback|retire": 23/23 pass, including d3d12_title_window_write_back_ranges (16/16 ranges) and d3d12_title_window_orphans (main's retired-window case).
  • Full suite with -j 14: 509/514 pass. api_ref_state, xs_proxy_mock, d3d12_queue_handover and d3d12_queue_handover_two_queues failed under load and pass when run alone. xbox_present fails at present with VkResult -11 on this machine; it does not use the write-back path changed here.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7239735189 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2470#issuecomment-7239735189). Originally posted by [Tyrannys](https://github.com/Tyrannys) on 2026-11-28T13:09:31Z. --- Merged current `main` (d48a957bb) in 0ebe31d3a. It conflicted with main's retired-window write-back. - `ShadowPages::write_back` keeps this PR's form: every range of a tracker in one call, with `reached`. It also takes main's `only` parameter (a retired window's copy), and runs main's two-pass, byte-level copy for each run of unheld pages. A run reopens its pages only while one of them is still guarded, as before. - `free_retired_shadow` passes its one range in the new form. - `d3d12_title_va_test`'s `submit_write` takes both `base` (this PR) and `wait` (main). Profile M (RTX 4070 SUPER, 621.01, Windows 11), Release: - `ctest -R "title|write_back|writeback|retire"`: 23/23 pass, including `d3d12_title_window_write_back_ranges` (16/16 ranges) and `d3d12_title_window_orphans` (main's retired-window case). - Full suite with `-j 14`: 509/514 pass. `api_ref_state`, `xs_proxy_mock`, `d3d12_queue_handover` and `d3d12_queue_handover_two_queues` failed under load and pass when run alone. `xbox_present` fails at present with `VkResult -11` on this machine; it does not use the write-back path changed here. AI-assisted (Claude Code).
lixonik commented 2026-11-28 13:42:45 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-28T13:42:45Z.

Review: APPROVED


Re-verified merged head 0ebe31d3a (merge with main d48a957bb retired-window write-back).

Code audit:

  • ShadowPages::write_back cleanly preserves the batched multi-range held_pages_ snapshot (sized before AcquireSRWLockExclusive) together with main's only parameter and two-pass byte-level retired-window copy, and skips redundant reopen_locked calls when no page in the run retains kProtected.

Verification at 0ebe31d3a (Windows 11, MSVC 19.44, Ninja Release, LEONIDA_VK_VALIDATION=1):

  • Built d3d12_title_va_test.
  • ctest -R '^(d3d12_title_window_write_back|d3d12_title_window_orphans|d3d12_title_window_write_back_fault|d3d12_title_window_write_back_fault_tile|d3d12_title_window_write_back_ranges|d3d12_placed_write_back)$': 6/6 passed (0 validation errors), including both d3d12_title_window_write_back_ranges and d3d12_title_window_orphans.
  • python -I scripts/check_no_game_data.py: passed.

GPUs tested: NVIDIA GeForce RTX 5070 12 GB (Windows 11, driver 610.88, Vulkan 1.4.341, VK_LAYER_KHRONOS_validation 1.4.363).

AI-assisted (Antigravity, Gemini).

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6098098971 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2470#pullrequestreview-6098098971). Originally posted by [lixonik](https://github.com/lixonik) on 2026-11-28T13:42:45Z. **Review:** APPROVED --- Re-verified merged head `0ebe31d3a` (merge with `main` `d48a957bb` retired-window write-back). Code audit: - `ShadowPages::write_back` cleanly preserves the batched multi-range `held_pages_` snapshot (sized before `AcquireSRWLockExclusive`) together with `main`'s `only` parameter and two-pass byte-level retired-window copy, and skips redundant `reopen_locked` calls when no page in the run retains `kProtected`. Verification at `0ebe31d3a` (Windows 11, MSVC 19.44, Ninja Release, `LEONIDA_VK_VALIDATION=1`): - Built `d3d12_title_va_test`. - `ctest -R '^(d3d12_title_window_write_back|d3d12_title_window_orphans|d3d12_title_window_write_back_fault|d3d12_title_window_write_back_fault_tile|d3d12_title_window_write_back_ranges|d3d12_placed_write_back)$'`: **6/6 passed** (0 validation errors), including both `d3d12_title_window_write_back_ranges` and `d3d12_title_window_orphans`. - `python -I scripts/check_no_game_data.py`: passed. GPUs tested: NVIDIA GeForce RTX 5070 12 GB (Windows 11, driver 610.88, Vulkan 1.4.341, `VK_LAYER_KHRONOS_validation` 1.4.363). AI-assisted (Antigravity, Gemini).
OreoFR commented 2026-11-28 15:33:49 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-28T15:33:49Z.


RUN: #2470 at 0ebe31d3a, merged with main c1ecf04ed: red on main, green with the PR

  • Heads: PR 0ebe31d3ae1e6b1071537cf5657b701e52a49fa8, main c1ecf04edcb827e49b863cb662ecb39fa904d615.
  • Merge: git merge --no-ff 0ebe31d3a on main merged clean (no conflict), giving 778ccf538 (3 files: runtime/CMakeLists.txt +4, runtime/shims/d3d12_vulkan_device.cpp, runtime/test/d3d12_title_va_test.cpp).
  • Red: main + only the PR's runtime/test/d3d12_title_va_test.cpp and its new ctest entry. The shim is main's.
  • Note: at this head the same-page case is --window-writeback-ranges (ctest d3d12_title_window_write_back_ranges), no longer --window-writeback-same-page.

Build: Ninja RelWithDebInfo, MSVC 2022, -DLEONIDA_REQUIRE_VULKAN=ON, target d3d12_title_va_test, -j 6.

d3d12_title_va_test.exe --window-writeback-ranges
d3d12_title_va_test.exe
build --window-writeback-ranges no flag
red (main + test) exit 1: write back ranges: 1/16 four-byte ranges on one guarded page reached it, 48/48 words between them kept the title's, 0 words neither exit 0
green (main + PR) exit 0: write back ranges: 16/16 four-byte ranges on one guarded page reached it, 48/48 words between them kept the title's, 0 words neither / title window write back ranges: every range on one guarded page reached it exit 0

ctest on green (gta6rt launchers excluded):

ctest --output-on-failure -R "d3d12_title|title_va|write_back|writeback|shadow|d3d12_placed|d3d12_geometry_views|d3d12_api_descriptor|d3d12_rebound"
100% tests passed, 0 tests failed out of 24   (exit 0, 21.1 s)

It covers d3d12_title_va, _shadow, d3d12_geometry_views, the 7 d3d12_title_window_* tests (write_back, _fault, _fault_tile, _ranges, cap, orphans, orphans_free), d3d12_placed_* (3), d3d12_shadow_keep_refill(_off), d3d12_api_descriptor_copy(_off), d3d12_rebound_* (3), d3d12_title_index_window, d3d12_title_vertex_window, shadow_keep and title_va_alias.

Verdict: the test fails on main and passes with the PR. With main merged, nothing regressed in the nearby tests.

AI-assisted (Claude Code, Claude Opus 5.5). Follow-up to my RUN at d7b81dd43, re-run after the merge of main d48a957bb. Tested on Windows 11, RTX 4070 Laptop 8 GB, NVIDIA 621.40. No game files used.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7241562343 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2470#issuecomment-7241562343). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-28T15:33:49Z. --- **RUN: #2470 at 0ebe31d3a, merged with main c1ecf04ed: red on main, green with the PR** - Heads: PR `0ebe31d3ae1e6b1071537cf5657b701e52a49fa8`, main `c1ecf04edcb827e49b863cb662ecb39fa904d615`. - Merge: `git merge --no-ff 0ebe31d3a` on main merged clean (no conflict), giving `778ccf538` (3 files: `runtime/CMakeLists.txt` +4, `runtime/shims/d3d12_vulkan_device.cpp`, `runtime/test/d3d12_title_va_test.cpp`). - Red: main + only the PR's `runtime/test/d3d12_title_va_test.cpp` and its new ctest entry. The shim is main's. - Note: at this head the same-page case is `--window-writeback-ranges` (ctest `d3d12_title_window_write_back_ranges`), no longer `--window-writeback-same-page`. Build: Ninja RelWithDebInfo, MSVC 2022, `-DLEONIDA_REQUIRE_VULKAN=ON`, target `d3d12_title_va_test`, `-j 6`. ``` d3d12_title_va_test.exe --window-writeback-ranges d3d12_title_va_test.exe ``` | build | `--window-writeback-ranges` | no flag | |---|---|---| | red (main + test) | **exit 1**: `write back ranges: 1/16 four-byte ranges on one guarded page reached it, 48/48 words between them kept the title's, 0 words neither` | exit 0 | | green (main + PR) | **exit 0**: `write back ranges: 16/16 four-byte ranges on one guarded page reached it, 48/48 words between them kept the title's, 0 words neither` / `title window write back ranges: every range on one guarded page reached it` | exit 0 | ctest on green (gta6rt launchers excluded): ``` ctest --output-on-failure -R "d3d12_title|title_va|write_back|writeback|shadow|d3d12_placed|d3d12_geometry_views|d3d12_api_descriptor|d3d12_rebound" 100% tests passed, 0 tests failed out of 24 (exit 0, 21.1 s) ``` It covers `d3d12_title_va`, `_shadow`, `d3d12_geometry_views`, the 7 `d3d12_title_window_*` tests (`write_back`, `_fault`, `_fault_tile`, `_ranges`, `cap`, `orphans`, `orphans_free`), `d3d12_placed_*` (3), `d3d12_shadow_keep_refill(_off)`, `d3d12_api_descriptor_copy(_off)`, `d3d12_rebound_*` (3), `d3d12_title_index_window`, `d3d12_title_vertex_window`, `shadow_keep` and `title_va_alias`. Verdict: the test fails on main and passes with the PR. With main merged, nothing regressed in the nearby tests. AI-assisted (Claude Code, Claude Opus 5.5). Follow-up to my RUN at d7b81dd43, re-run after the merge of main d48a957bb. Tested on Windows 11, RTX 4070 Laptop 8 GB, NVIDIA 621.40. No game files used.
zmasi commented 2026-11-28 23:23:22 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T23:23:22Z.


#2470 | head 0ebe31d3ae (merged cleanly with main adfb3821a2 — no conflicts on current main) | ctest --test-dir runtime/build -C RelWithDebInfo -R "^(d3d12_title_window_write_back_ranges|d3d12_title_window_write_back|d3d12_title_window_write_back_fault|d3d12_title_window_write_back_fault_tile|d3d12_title_window_orphans|d3d12_title_window_orphans_free|d3d12_placed_write_back|d3d12_title_va|d3d12_title_va_shadow)$" --output-on-failure (LEONIDA_VK_VALIDATION=1) | red on main: building d3d12_title_va_test against main's runtime/shims/d3d12_vulkan_device.cpp fails d3d12_title_window_write_back_ranges (line 791: reached == kRanges, write back ranges: 1/16 four-byte ranges on one guarded page reached it, 48/48 words between them kept the title's, 0 words neither) | green on PR+main: 9/9 CTests (d3d12_title_window_write_back_ranges, d3d12_title_window_write_back, d3d12_title_window_write_back_fault, d3d12_title_window_write_back_fault_tile, d3d12_title_window_orphans, d3d12_title_window_orphans_free, d3d12_placed_write_back, d3d12_title_va, d3d12_title_va_shadow) pass in 5.11 s on RTX 3090 with 0 Khronos validation errors; check_no_game_data.py 0 violations | Windows 11, MSVC 19.44, RTX 3090, Vulkan SDK 1.4.363.1 | AI-assisted: yes

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7247397651 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2470#issuecomment-7247397651). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-28T23:23:22Z. --- #2470 | head 0ebe31d3ae1e6b1071537cf5657b701e52a49fa8 (merged cleanly with main adfb3821a23612263c1c5b195453ed01c4c114db — no conflicts on current `main`) | `ctest --test-dir runtime/build -C RelWithDebInfo -R "^(d3d12_title_window_write_back_ranges|d3d12_title_window_write_back|d3d12_title_window_write_back_fault|d3d12_title_window_write_back_fault_tile|d3d12_title_window_orphans|d3d12_title_window_orphans_free|d3d12_placed_write_back|d3d12_title_va|d3d12_title_va_shadow)$" --output-on-failure` (`LEONIDA_VK_VALIDATION=1`) | red on main: building `d3d12_title_va_test` against `main`'s `runtime/shims/d3d12_vulkan_device.cpp` fails `d3d12_title_window_write_back_ranges` (`line 791: reached == kRanges`, `write back ranges: 1/16 four-byte ranges on one guarded page reached it, 48/48 words between them kept the title's, 0 words neither`) | green on PR+main: `9/9` CTests (`d3d12_title_window_write_back_ranges`, `d3d12_title_window_write_back`, `d3d12_title_window_write_back_fault`, `d3d12_title_window_write_back_fault_tile`, `d3d12_title_window_orphans`, `d3d12_title_window_orphans_free`, `d3d12_placed_write_back`, `d3d12_title_va`, `d3d12_title_va_shadow`) pass in `5.11 s` on RTX 3090 with `0` Khronos validation errors; `check_no_game_data.py` `0` violations | Windows 11, MSVC 19.44, RTX 3090, Vulkan SDK 1.4.363.1 | AI-assisted: yes
DadaCap commented 2026-11-29 01:55:52 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by DadaCap on 2026-11-29T01:55:52Z.


Merged, thank you @Tyrannys! The same-page case fails on main and passes with this PR in OreoFR's and zmasi's runs at this head (0ebe31d3a), the nearby write-back tests stayed green, and it still merges cleanly into today's main. Thanks as well to djrolfes, lixonik, OreoFR and zmasi for testing it.

AI-assisted (Claude Code, Claude Opus 5.5), on behalf of DadaCap.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7249104159 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2470#issuecomment-7249104159). Originally posted by [DadaCap](https://github.com/DadaCap) on 2026-11-29T01:55:52Z. --- Merged, thank you @Tyrannys! The same-page case fails on main and passes with this PR in OreoFR's and zmasi's runs at this head (`0ebe31d3a`), the nearby write-back tests stayed green, and it still merges cleanly into today's main. Thanks as well to djrolfes, lixonik, OreoFR and zmasi for testing it. AI-assisted (Claude Code, Claude Opus 5.5), on behalf of DadaCap.
Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
ProjectLeonida/mandy!2470
No description provided.