diff options
| author | Zack <zmasi21@gmail.com> | 2026-11-26 02:02:47 -0800 |
|---|---|---|
| committer | Zack <zmasi21@gmail.com> | 2026-11-26 02:02:47 -0800 |
| commit | d088ea79b8394c04a46ec19efb2922a7cd3faae3 (patch) | |
| tree | 47526a94199ce24c66f9436a46886173914628a1 /runtime/test/title_memory_map_test.cpp | |
| parent | a73a57e1339be072baf5522351c8ec7f1482b56b (diff) | |
Sync title texture readability with map journal between refresh passes
Between periodic refresh_title_textures passes, synchronous slot-70 view creation and the async fill worker checked TextureReadability with a constant generation, missing title_memory_map range changes since the last pass. Track the map generation on TextureReadability and consult title_memory_map::changes_since outside refresh passes so unmapped or decommitted pages defer before hashing and newly mapped pages publish immediately without waiting for a submission.
Also mark mix_words and hash_bytes LEONIDA_GUARDED_NO_BUILTIN using an unaligned 64-bit load so clang-cl cannot emit CRT memcpy calls inside the __try frame, and classify non-title read faults over unmapped title pages in xmem::physical_page_fault as FaultExit::passed_guarded.
Diffstat (limited to 'runtime/test/title_memory_map_test.cpp')
| -rw-r--r-- | runtime/test/title_memory_map_test.cpp | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/runtime/test/title_memory_map_test.cpp b/runtime/test/title_memory_map_test.cpp index ba5a518a1..ff226d648 100644 --- a/runtime/test/title_memory_map_test.cpp +++ b/runtime/test/title_memory_map_test.cpp | |||
| @@ -7,7 +7,8 @@ | |||
| 7 | // 3. a reader further behind than the journal holds is told so (it then looks at everything); | 7 | // 3. a reader further behind than the journal holds is told so (it then looks at everything); |
| 8 | // 4. a change with no range overlaps every reader; | 8 | // 4. a change with no range overlaps every reader; |
| 9 | // 5. TextureReadability keeps a positive answer, when asked to, until a retry; | 9 | // 5. TextureReadability keeps a positive answer, when asked to, until a retry; |
| 10 | // 6. a pass over 20,000 waiting textures probes only those under the one mapped block. | 10 | // 6. a pass over 20,000 waiting textures probes only those under the one mapped block; |
| 11 | // 7. between passes, sync_map retries only when a map change overlaps the texture's footprint. | ||
| 11 | #include <windows.h> | 12 | #include <windows.h> |
| 12 | 13 | ||
| 13 | #include <cstdint> | 14 | #include <cstdint> |
| @@ -142,6 +143,48 @@ int main() { | |||
| 142 | check(pass() == 4 && probes == 0, "a pass with no change probes nothing"); | 143 | check(pass() == 4 && probes == 0, "a pass with no change probes nothing"); |
| 143 | } | 144 | } |
| 144 | 145 | ||
| 146 | // 7. Synchronous view checks between passes (sync_map): unrelated map changes cost no probe, an overlapping unmap | ||
| 147 | // defers without reading, and an overlapping map wakes a waiting texture before the next pass. | ||
| 148 | { | ||
| 149 | constexpr std::uintptr_t cpu = kBase + 0x20000000; | ||
| 150 | constexpr std::uint64_t size = 512 * 1024; | ||
| 151 | const std::uint64_t pass_generation = map::generation(); | ||
| 152 | bool mapped = true; | ||
| 153 | unsigned probes = 0; | ||
| 154 | leonida::TextureReadability r; | ||
| 155 | const auto probe = [&] { | ||
| 156 | ++probes; | ||
| 157 | return mapped; | ||
| 158 | }; | ||
| 159 | check(r.check(0, true, probe, true) && probes == 1 && !r.pending(), | ||
| 160 | "sync_map: initial probe caches a readable answer"); | ||
| 161 | for (std::uintptr_t i = 0; i < 32; ++i) | ||
| 162 | map::changed(cpu + size + i * 0x10000, cpu + size + (i + 1) * 0x10000); | ||
| 163 | r.sync_map(pass_generation, cpu, size); | ||
| 164 | check(r.check(0, true, probe, true) && probes == 1, | ||
| 165 | "sync_map: map changes outside the footprint keep the cached answer"); | ||
| 166 | r.sync_map(pass_generation, cpu, size); | ||
| 167 | check(r.check(0, true, probe, true) && probes == 1, | ||
| 168 | "sync_map: a second check at the same generation does nothing"); | ||
| 169 | |||
| 170 | mapped = false; | ||
| 171 | map::changed(cpu + 0x10000, cpu + 0x20000); | ||
| 172 | r.sync_map(pass_generation, cpu, size); | ||
| 173 | check(!r.check(0, true, probe, true) && r.pending() && probes == 2, | ||
| 174 | "sync_map: an overlapping unmap between passes reprobes and defers"); | ||
| 175 | |||
| 176 | map::changed(cpu - 0x10000, cpu); | ||
| 177 | r.sync_map(pass_generation, cpu, size); | ||
| 178 | check(!r.check(0, true, probe, true) && r.pending() && probes == 2, | ||
| 179 | "sync_map: an adjacent non-overlapping change leaves a pending texture waiting"); | ||
| 180 | |||
| 181 | mapped = true; | ||
| 182 | map::changed(cpu, cpu + size); | ||
| 183 | r.sync_map(pass_generation, cpu, size); | ||
| 184 | check(r.check(0, true, probe, true) && !r.pending() && probes == 3, | ||
| 185 | "sync_map: an overlapping map between passes wakes a pending texture at once"); | ||
| 186 | } | ||
| 187 | |||
| 145 | std::printf("%d checks, %d failures\n", g_checks, g_failures); | 188 | std::printf("%d checks, %d failures\n", g_checks, g_failures); |
| 146 | return g_failures ? 1 : 0; | 189 | return g_failures ? 1 : 0; |
| 147 | } | 190 | } |