diff options
| author | Aslan2142 <jan.trencansky@protonmail.com> | 2026-11-26 01:12:59 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-11-26 01:12:59 +0100 |
| commit | 61732aca16fb0d63deb5e9987f9758d4e6ce0228 (patch) | |
| tree | e365199d7d86ebf592a5a0dc2f07cda4b74b58a7 /runtime/src | |
| parent | c50ed94b35b37b697ab9c5fd176f3738480b4db5 (diff) | |
| parent | 8d832fd10913064e1c8aec74191e3ba8f70211c8 (diff) | |
Merge pull request #2122 from OreoFR/rt-title-every-budget
d3d12: the title texture pass can time-box its mapped and stale visits (RT-TITLE-EVERY-BUDGET)
Diffstat (limited to 'runtime/src')
| -rw-r--r-- | runtime/src/title_texture_refresh.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/runtime/src/title_texture_refresh.h b/runtime/src/title_texture_refresh.h index a652e6281..feb8a0cc2 100644 --- a/runtime/src/title_texture_refresh.h +++ b/runtime/src/title_texture_refresh.h | |||
| @@ -107,4 +107,38 @@ void poll_title_textures(const std::vector<Entry>& entries, std::uint64_t& curso | |||
| 107 | } | 107 | } |
| 108 | } | 108 | } |
| 109 | 109 | ||
| 110 | // Visit the marked textures of a snapshot (mapped by the title, or known stale) under a time limit | ||
| 111 | // (LEONIDA_TITLE_EVERY_BUDGET_US). Those `urgent` answers true for (a mapped texture never filled yet) are all | ||
| 112 | // visited first, in placement order, whatever the limit. The others are visited | ||
| 113 | // from `cursor`, as poll_title_textures does for the unmarked ones, until `exhausted()` answers true after a visit; | ||
| 114 | // the next pass resumes at the entry after the last one visited, so every marked texture gets its turn however many | ||
| 115 | // there are. An entry skipped as unmarked costs no check. | ||
| 116 | template<class Entry, class Visit, class Urgent, class Exhausted> | ||
| 117 | void visit_marked_title_textures(const std::vector<Entry>& entries, std::uint64_t& cursor, Visit visit, Urgent urgent, | ||
| 118 | Exhausted exhausted) { | ||
| 119 | if (entries.empty()) return; | ||
| 120 | // Which entries are urgent is decided before any visit: a visit fills the texture, and it must not come round | ||
| 121 | // again in the rotation of the same pass. | ||
| 122 | std::vector<char> was_urgent(entries.size()); | ||
| 123 | for (std::size_t i = 0; i < entries.size(); ++i) { | ||
| 124 | const auto& texture = entries[i].second; | ||
| 125 | was_urgent[i] = (texture->mapped || texture->stale) && urgent(*texture); | ||
| 126 | } | ||
| 127 | for (std::size_t i = 0; i < entries.size(); ++i) | ||
| 128 | if (was_urgent[i]) visit(*entries[i].second); | ||
| 129 | const auto first = std::lower_bound(entries.begin(), entries.end(), cursor, | ||
| 130 | [](const Entry& entry, std::uint64_t at) { return entry.first < at; }); | ||
| 131 | auto index = std::size_t(first - entries.begin()); | ||
| 132 | if (index == entries.size()) index = 0; | ||
| 133 | for (auto left = entries.size(); left; --left) { | ||
| 134 | const auto& [address, texture] = entries[index]; | ||
| 135 | cursor = address + 1; | ||
| 136 | if ((texture->mapped || texture->stale) && !was_urgent[index]) { | ||
| 137 | visit(*texture); | ||
| 138 | if (exhausted()) break; | ||
| 139 | } | ||
| 140 | index = index + 1 == entries.size() ? 0 : index + 1; | ||
| 141 | } | ||
| 142 | } | ||
| 143 | |||
| 110 | } // namespace leonida | 144 | } // namespace leonida |