diff options
| author | Jan Trencansky <jan.trencansky@protonmail.com> | 2026-11-25 03:41:48 -0500 |
|---|---|---|
| committer | Jan Trencansky <jan.trencansky@protonmail.com> | 2026-11-25 03:41:48 -0500 |
| commit | 8b771908c3c8d7d233e66f39d535a5a7c63047aa (patch) | |
| tree | a5aa45227ef725edba1f021f7f2e10fcb898a834 /runtime/src | |
| parent | f9792cc56de10067f1bbdb233eaac23cd5b2074f (diff) | |
| parent | 237deb64ce2b567283f304b7b89a23152e7b60c0 (diff) | |
Merge main into feat/gdk-lifecycle-window-hook (#769)feat/gdk-lifecycle-window-hook
scripts/build_runtime.ps1 conflicted in the $files list of the build
without CMake: main added shims\silent_audio.cpp there (#1598) after this
branch had merged main, and this branch adds shims\lifecycle.cpp. Both
entries are kept, lifecycle.cpp where this branch had it. The branch's
other change in that file (user32.lib on the link line) merged cleanly.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'runtime/src')
| -rw-r--r-- | runtime/src/title_page_watch.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/runtime/src/title_page_watch.h b/runtime/src/title_page_watch.h index b83e71b7b..580edf622 100644 --- a/runtime/src/title_page_watch.h +++ b/runtime/src/title_page_watch.h | |||
| @@ -636,6 +636,31 @@ inline void end_write(std::uint64_t id, bool pending) { | |||
| 636 | s.count.store(s.pins.size(), std::memory_order_release); | 636 | s.count.store(s.pins.size(), std::memory_order_release); |
| 637 | } | 637 | } |
| 638 | 638 | ||
| 639 | // For as long as the GPU may use [buffer, buffer + bytes) as host memory (the D3D12 layer's VK_EXT_external_memory_host | ||
| 640 | // imports): pins the range until release() and opens it. Unlike begin_write it records the pin before any tracker | ||
| 641 | // exists, so a tracker made later passes over the pages too. RADV checks an import's pages again at every submission, | ||
| 642 | // and once one of them is read-only the kernel rejects that submission and every later one ("The CS has been | ||
| 643 | // rejected", then VK_ERROR_DEVICE_LOST; found and measured by NateWeav, #14), so no guard may land on them. Returns | ||
| 644 | // the pin's id, 0 for an empty range. | ||
| 645 | inline std::uint64_t hold(const void* buffer, std::size_t bytes) { | ||
| 646 | if (!buffer || !bytes) return 0; | ||
| 647 | State& s = state(); | ||
| 648 | const auto begin = reinterpret_cast<std::uintptr_t>(buffer); | ||
| 649 | std::uint64_t id = 0; | ||
| 650 | { | ||
| 651 | std::lock_guard lock(s.mutex); | ||
| 652 | id = s.next_id++; | ||
| 653 | s.pins.push_back({begin, begin + bytes, nullptr, id}); | ||
| 654 | s.count.store(s.pins.size(), std::memory_order_release); | ||
| 655 | } | ||
| 656 | // After the pin: a guard a refresh made before it is lifted, and no refresh from here on makes one. | ||
| 657 | if (const Opener opener = s.opener.load(std::memory_order_acquire)) opener(begin, begin + bytes); | ||
| 658 | return id; | ||
| 659 | } | ||
| 660 | |||
| 661 | // The import is freed: its pin ends. | ||
| 662 | inline void release(std::uint64_t id) { end_write(id, false); } | ||
| 663 | |||
| 639 | // Readies [buffer, buffer + bytes) for a retry after ERROR_NOACCESS: commits xmem's pages that wait for their first | 664 | // Readies [buffer, buffer + bytes) for a retry after ERROR_NOACCESS: commits xmem's pages that wait for their first |
| 640 | // touch (the kernel's write does not fault them in) and opens watched pages again. false: neither side is set. | 665 | // touch (the kernel's write does not fault them in) and opens watched pages again. false: neither side is set. |
| 641 | inline bool reopen(const void* buffer, std::size_t bytes) { | 666 | inline bool reopen(const void* buffer, std::size_t bytes) { |