diff options
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) { |