From 7557fe87f43e0ca7751c989ae1a6f2103be0c6e5 Mon Sep 17 00:00:00 2001 From: lixonik <71736299+lixonik@users.noreply.github.com> Date: Wed, 25 Nov 2026 18:46:54 +0300 Subject: [PATCH 1/2] Keep live VA mappings when mirroring a stream pool --- runtime/shims/d3d12_vulkan_device.cpp | 85 ++++++++----------- runtime/src/title_va_alias.h | 66 +++++++++++++- runtime/src/title_window_plan.h | 13 +++ runtime/test/title_va_alias_test.cpp | 36 ++++++++ .../test/title_window_plan_bounds_test.cpp | 10 +++ 5 files changed, 156 insertions(+), 54 deletions(-) diff --git a/runtime/shims/d3d12_vulkan_device.cpp b/runtime/shims/d3d12_vulkan_device.cpp index f2fa3a45c2..d4d3ad5f5d 100644 --- a/runtime/shims/d3d12_vulkan_device.cpp +++ b/runtime/shims/d3d12_vulkan_device.cpp @@ -3376,67 +3376,50 @@ struct DeviceState { std::max(bytes, 1))); const std::uint64_t twin = leonida::title_gpu_views::other_view(static_cast(source)); const std::uint64_t twin_view = twin ? twin : source; // the pair always has two addresses - if (!readable_page(source)) { + auto& aliases = leonida::title_va_aliases(); + const auto other = source == va ? twin_view : source; + const auto max_size = std::min(view.size - offset, kPoolExtentMax); + const auto reuse = [&] { return aliases.reuse_pool_mapping(va, other, max_size, out); }; + const auto unbacked = [&] { out = 0; ++unbacked_requests; note_unbacked("stream pool", va, bytes); return true; - } + }; + if (reuse()) return true; + if (!readable_page(source)) return unbacked(); const std::uint64_t pool_end = (source >= view.gpu && source - view.gpu < view.size ? view.gpu : view.cpu) + view.size; const std::uint64_t run_end = readable_run_end(source & ~(kTitleWindowAlign - 1), std::min(pool_end, source + kPoolExtentMax)); leonida::TitleWindowRange extent{}; if (!leonida::title_pool_extent(source - offset, pool_end, source, run_end, kTitleWindowAlign, kPoolExtentMax, - extent)) { - out = 0; - ++unbacked_requests; - note_unbacked("stream pool", va, bytes); - return true; - } - const std::uint64_t twin_start = twin_view - (source - extent.start); // the same pages in the other view - auto& aliases = leonida::title_va_aliases(); - // A mapping that already holds the extent's start (a buffer made over these pages, or a window from another - // request) serves the request only as far as it reaches: claim that much, never bytes it does not cover. - std::uint64_t shader = 0, available = 0; - if (aliases.range_of(extent.start, shader, available) || - aliases.range_of(twin_start, shader, available)) { - if (available < extent.size) { - if (available <= source - extent.start) shader = 0; - else extent.size = available; - } - } - if (shader) { - // Both addresses must reach it. The address the mapping was found at keeps its own (possibly wider) - // range: adding a shorter one over it would drop bytes another view still uses. - if (aliases.shader_va(twin_start) == twin_start) aliases.add(twin_start, extent.size, shader); - if (aliases.shader_va(extent.start) == extent.start) aliases.add(extent.start, extent.size, shader); - } else { - bool geometry_copy = false; - if (geometry.cap() && watch_shadow_writes() && !context->knows_buffer_va(extent.start, extent.size)) { - shader = geometry.resolve(*this, extent.start, extent.size, copy_geometry); - geometry_copy = shader != 0; - } - if (!shader) shader = make_title_window(extent.start, extent.size); - if (!shader) { - out = 0; - ++unbacked_requests; - note_unbacked("stream pool", va, bytes); - return true; - } - aliases.add_twin(extent.start, twin_start, extent.size, shader); - pool_spans.push_back({extent.start, twin_start, shader, extent.size, geometry_copy}); - pool_span_count.store(pool_spans.size(), std::memory_order_relaxed); - pool_span_bytes += extent.size; - if (pool_spans.size() <= 4 || !(pool_spans.size() & (pool_spans.size() - 1))) - std::fprintf(stderr, - "[rt] d3d12: a %llu KiB stream-pool extent is one %s mapping (alias 0x%llx and CPU view " - "0x%llx share shader VA 0x%llx; %zu extents, %llu KiB)\n", - static_cast(extent.size >> 10), - geometry_copy ? "geometry-copy" : "window", static_cast(twin_view), - static_cast(source), static_cast(shader), - pool_spans.size(), static_cast(pool_span_bytes >> 10)); - } + extent)) + return unbacked(); + std::uint64_t source_lo, source_hi, twin_lo, twin_hi; + aliases.gap(source, source_lo, source_hi); + aliases.gap(twin_view, twin_lo, twin_hi); + if (!leonida::clip_title_pool_extent(extent, source, twin_view, source_lo, source_hi, twin_lo, twin_hi)) + return reuse() || unbacked(); + const auto twin_start = twin_view - (source - extent.start); + std::uint64_t shader = 0; + if (geometry.cap() && watch_shadow_writes() && !context->knows_buffer_va(extent.start, extent.size)) + shader = geometry.resolve(*this, extent.start, extent.size, copy_geometry); + const bool geometry_copy = shader != 0; + if (!shader) shader = make_title_window(extent.start, extent.size); + if (!shader || !aliases.add_twin(extent.start, twin_start, extent.size, shader)) + return reuse() || unbacked(); + pool_spans.push_back({extent.start, twin_start, shader, extent.size, geometry_copy}); + pool_span_count.store(pool_spans.size(), std::memory_order_relaxed); + pool_span_bytes += extent.size; + if (pool_spans.size() <= 4 || !(pool_spans.size() & (pool_spans.size() - 1))) + std::fprintf(stderr, + "[rt] d3d12: a %llu KiB stream-pool extent is one %s mapping (alias 0x%llx and CPU view " + "0x%llx share shader VA 0x%llx; %zu extents, %llu KiB)\n", + static_cast(extent.size >> 10), + geometry_copy ? "geometry-copy" : "window", static_cast(twin_view), + static_cast(source), static_cast(shader), + pool_spans.size(), static_cast(pool_span_bytes >> 10)); out = shader + (source - extent.start); return true; } diff --git a/runtime/src/title_va_alias.h b/runtime/src/title_va_alias.h index c49880d923..245156d882 100644 --- a/runtime/src/title_va_alias.h +++ b/runtime/src/title_va_alias.h @@ -65,9 +65,40 @@ class TitleVaAliases { // The two addresses of one stream-pool extent (a GPU-only alias and the CPU view of the same pages, gfxgeom // section 3): both name the same shader VA, so a title view carrying either resolves to the one mapping. bool add_twin(std::uint64_t va, std::uint64_t twin, std::uint64_t bytes, std::uint64_t shader_va) { - if (va == twin) return add(va, bytes, shader_va); - const bool first = add(va, bytes, shader_va); - return add(twin, bytes, shader_va) && first; + if (!bytes || va > UINT64_MAX - bytes || twin > UINT64_MAX - bytes) return false; + if (va != twin && va < twin + bytes && twin < va + bytes) return false; + std::unique_lock lock(mutex_); + if (overlaps(va, va + bytes) || (va != twin && overlaps(twin, twin + bytes))) return false; + decltype(ranges_) pending; + pending.try_emplace(va, Range{va + bytes, shader_va}); + pending.try_emplace(twin, Range{twin + bytes, shader_va}); + publish_pool_ranges(pending); + return true; + } + + bool reuse_pool_mapping(std::uint64_t va, std::uint64_t twin, std::uint64_t max_size, std::uint64_t& shader_va) { + std::unique_lock lock(mutex_); + const auto next = ranges_.upper_bound(va); + if (next != ranges_.begin()) { + const auto existing = std::prev(next); + if (va < existing->second.end) { + shader_va = existing->second.shader_va + (va - existing->first); + return true; + } + } + const auto other_next = ranges_.upper_bound(twin); + if (other_next == ranges_.begin()) return false; + const auto other = std::prev(other_next); + if (twin >= other->second.end) return false; + const auto end = next == ranges_.end() ? UINT64_MAX : next->first; + const auto bytes = std::min({max_size, other->second.end - twin, end - va}); + if (!bytes) return false; + const auto shader = other->second.shader_va + (twin - other->first); + decltype(ranges_) pending; + pending.try_emplace(va, Range{va + bytes, shader}); + publish_pool_ranges(pending); + shader_va = shader; + return true; } // Forgets the range that starts at title_va, if it still maps to shader_va (a newer range at the same VA keeps @@ -92,6 +123,16 @@ class TitleVaAliases { void forget_copy(std::uint64_t title_va, std::uint64_t bytes, std::uint64_t shader_va) { if (!bytes) return; std::unique_lock lock(mutex_); + for (auto it = ranges_.lower_bound(title_va); it != ranges_.end() && it->first - title_va < bytes;) { + if (it->second.shader_va - shader_va != it->first - title_va) { + ++it; + continue; + } + by_shader_.erase(it->second.shader_va, it->first); + notify(Change::removed, it->first, it->second.end - it->first, it->second.shader_va); + it = ranges_.erase(it); + } + count_.store(ranges_.size(), std::memory_order_release); notify(Change::removed, title_va, bytes, shader_va); note_removed(shader_va, bytes); generation_.fetch_add(1, std::memory_order_release); @@ -423,6 +464,25 @@ class TitleVaAliases { std::uint64_t shader_va; // what the range's first byte becomes }; + void publish_pool_ranges(std::map& pending) { + try { + for (const auto& [base, range] : pending) by_shader_.insert(range.shader_va, range.end - base, base); + } catch (...) { + for (const auto& [base, range] : pending) by_shader_.erase(range.shader_va, base); + throw; + } + for (const auto& [base, range] : pending) notify(Change::added, base, range.end - base, range.shader_va); + ranges_.merge(pending); + count_.store(ranges_.size(), std::memory_order_release); + generation_.fetch_add(1, std::memory_order_release); + } + + bool overlaps(std::uint64_t begin, std::uint64_t end) const { + const auto next = ranges_.lower_bound(begin); + return (next != ranges_.end() && next->first < end) || + (next != ranges_.begin() && std::prev(next)->second.end > begin); + } + void erase_overlapping(std::uint64_t begin, std::uint64_t end) { auto it = ranges_.lower_bound(begin); if (it != ranges_.begin()) { diff --git a/runtime/src/title_window_plan.h b/runtime/src/title_window_plan.h index cd17bc5961..a289515035 100644 --- a/runtime/src/title_window_plan.h +++ b/runtime/src/title_window_plan.h @@ -63,4 +63,17 @@ inline bool title_pool_extent(std::uint64_t pool_lo, std::uint64_t pool_hi, std: return true; } +inline bool clip_title_pool_extent(TitleWindowRange& extent, std::uint64_t source, std::uint64_t twin, + std::uint64_t source_lo, std::uint64_t source_hi, + std::uint64_t twin_lo, std::uint64_t twin_hi) { + if (source < source_lo || source >= source_hi || twin < twin_lo || twin >= twin_hi || + source < extent.start || source - extent.start >= extent.size) + return false; + const auto prefix = source - extent.start; + const auto before = std::min({prefix, source - source_lo, twin - twin_lo}); + const auto after = std::min({extent.size - prefix, source_hi - source, twin_hi - twin}); + extent = {source - before, before + after}; + return true; +} + } // namespace leonida diff --git a/runtime/test/title_va_alias_test.cpp b/runtime/test/title_va_alias_test.cpp index 6eadb4beaf..d068d0f86b 100644 --- a/runtime/test/title_va_alias_test.cpp +++ b/runtime/test/title_va_alias_test.cpp @@ -138,6 +138,42 @@ int main() { EXPECT(!a.shader_side(arena) && a.shader_side(0xA0000ff) && !a.shader_side(0xA000100)); a.remove(title + 0x100, 0xA000000); EXPECT(a.size() == 0 && !a.shader_side(0xA000000)); + + constexpr std::uint64_t twin = title + 0x10000000; + EXPECT(a.add(twin + size, size, arena)); + first.clear(); + a.add_listener(&first, hear); + const auto pool_generation = a.generation(); + EXPECT(!a.add_twin(title, twin, size * 2, 0x5000000)); + EXPECT(a.generation() == pool_generation && !a.shader_side(0x5000000)); + EXPECT(a.size() == 1 && a.shader_va(title) == title && a.shader_va(twin) == twin); + EXPECT(a.shader_va(twin + size) == arena); + EXPECT(a.add_twin(title, twin, size, 0x5000000)); + EXPECT(a.generation() != pool_generation && a.shader_side(0x5000000)); + EXPECT(first.size() == 2); + EXPECT(first[0].change == Change::added && first[0].title_va == title && first[0].bytes == size); + EXPECT(first[1].change == Change::added && first[1].title_va == twin && first[1].bytes == size); + a.remove_listener(&first); + EXPECT(a.size() == 3 && a.shader_va(title) == 0x5000000 && a.shader_va(twin) == 0x5000000); + EXPECT(a.shader_va(twin + size) == arena); + + a.remove(title, 0x5000000); + EXPECT(a.add(title + size / 2, size, 0x7000000)); + EXPECT(a.reuse_pool_mapping(title, twin, size, to) && to == 0x5000000); + EXPECT(a.range_of(title, to, room) && room == size / 2); + EXPECT(a.shader_va(title + size / 2) == 0x7000000); + EXPECT(a.reuse_pool_mapping(title + size / 2, twin + size / 2, size, to) && to == 0x7000000); + EXPECT(!a.add_twin(title + 4 * size, title + 5 * size, size * 2, arena)); + EXPECT(a.add(title + 4 * size, size, 0x8000000)); + EXPECT(a.add(twin + 5 * size - 16, 16, 0x9000000)); + EXPECT(a.reuse_pool_mapping(twin + 4 * size + 16, title + 4 * size + 16, size, to) && to == 0x8000010); + a.remove(title + 4 * size, 0x8000000); + EXPECT(a.shader_side(0x8000010)); + a.forget_copy(twin + 4 * size, size, 0x8000000); + EXPECT(!a.shader_side(0x8000010)); + EXPECT(a.shader_va(twin + 4 * size + 16) == twin + 4 * size + 16); + EXPECT(a.shader_va(twin + 5 * size - 16) == 0x9000000); + std::printf("title_va_alias: translation inside a title-placed range, identity outside it and after release\n"); return 0; } diff --git a/runtime/test/title_window_plan_bounds_test.cpp b/runtime/test/title_window_plan_bounds_test.cpp index 93cf2bed46..52a9ea12db 100644 --- a/runtime/test/title_window_plan_bounds_test.cpp +++ b/runtime/test/title_window_plan_bounds_test.cpp @@ -83,6 +83,16 @@ int test_title_pool_extent_bounds() { EXPECT(leonida::title_pool_extent(pool_lo, pool_hi, pool_lo + 0x28000, pool_hi, kAlign, kMiB, second)); EXPECT(first.start == pool_lo + 0x20000 && first.size == 0xE0000); EXPECT(second.start == first.start && second.size == first.size); + + const auto source = pool_lo + 0x28000; + const auto twin = source + 2 * kMiB; + EXPECT(leonida::clip_title_pool_extent(first, source, twin, source - 0x4000, source + 0x60000, + twin - 0x10000, twin + 0x10000)); + EXPECT(first.start == source - 0x4000 && first.size == 0x14000); + EXPECT(!leonida::clip_title_pool_extent(second, source, twin, source + 1, pool_hi, + twin - 0x10000, twin + 0x10000)); + EXPECT(!leonida::clip_title_pool_extent(second, source, twin, pool_lo, pool_hi, twin, twin)); + EXPECT(second.start == pool_lo + 0x20000 && second.size == 0xE0000); return 0; } From d78b0e90ab74cf74832f17b85fe5d682d2adf2d8 Mon Sep 17 00:00:00 2001 From: lixonik <71736299+lixonik@users.noreply.github.com> Date: Fri, 27 Nov 2026 11:32:29 +0300 Subject: [PATCH 2/2] Refuse stream-pool mappings shorter than the requested span DadaCap identified the short-mapping case in the review of PR #1920. Reuse and allocation now require full coverage, preserving both live aliases when a request spans a boundary. --- runtime/shims/d3d12_vulkan_device.cpp | 33 +++++++++++++++------------ runtime/src/title_va_alias.h | 22 ++++++++++++------ runtime/test/d3d12_title_va_test.cpp | 14 ++++++++++++ runtime/test/title_va_alias_test.cpp | 9 +++++--- 4 files changed, 54 insertions(+), 24 deletions(-) diff --git a/runtime/shims/d3d12_vulkan_device.cpp b/runtime/shims/d3d12_vulkan_device.cpp index d4d3ad5f5d..52ebaac02b 100644 --- a/runtime/shims/d3d12_vulkan_device.cpp +++ b/runtime/shims/d3d12_vulkan_device.cpp @@ -3366,26 +3366,24 @@ struct DeviceState { // held. bool resolve_pool_memory(std::uint64_t va, std::uint64_t bytes, std::uint64_t& out) { leonida::title_gpu_views::Range view{}; - if (!leonida::title_gpu_views::view_at(static_cast(va), - static_cast(std::max(bytes, 1)), view)) - return false; + if (!leonida::title_gpu_views::view_at(static_cast(va), 1, view)) return false; + const auto want = std::max(bytes, 1); + const auto unbacked = [&] { + out = 0; + ++unbacked_requests; + note_unbacked("stream pool", va, bytes); + return true; + }; const std::uint64_t offset = va >= view.gpu && va - view.gpu < view.size ? va - view.gpu : va - view.cpu; + if (want > view.size - offset) return unbacked(); // Rule B: the CPU view where the host reads the frames, the GPU-only pages only when that view has none. - const std::uint64_t source = leonida::title_gpu_views::to_host_view(static_cast(va), - static_cast( - std::max(bytes, 1))); + const std::uint64_t source = leonida::title_gpu_views::to_host_view(static_cast(va), want); const std::uint64_t twin = leonida::title_gpu_views::other_view(static_cast(source)); const std::uint64_t twin_view = twin ? twin : source; // the pair always has two addresses auto& aliases = leonida::title_va_aliases(); const auto other = source == va ? twin_view : source; const auto max_size = std::min(view.size - offset, kPoolExtentMax); - const auto reuse = [&] { return aliases.reuse_pool_mapping(va, other, max_size, out); }; - const auto unbacked = [&] { - out = 0; - ++unbacked_requests; - note_unbacked("stream pool", va, bytes); - return true; - }; + const auto reuse = [&] { return aliases.reuse_pool_mapping(va, other, want, max_size, out); }; if (reuse()) return true; if (!readable_page(source)) return unbacked(); const std::uint64_t pool_end = (source >= view.gpu && source - view.gpu < view.size ? view.gpu : view.cpu) + @@ -3401,6 +3399,7 @@ struct DeviceState { aliases.gap(twin_view, twin_lo, twin_hi); if (!leonida::clip_title_pool_extent(extent, source, twin_view, source_lo, source_hi, twin_lo, twin_hi)) return reuse() || unbacked(); + if (want > std::min(extent.size - (source - extent.start), run_end - source)) return reuse() || unbacked(); const auto twin_start = twin_view - (source - extent.start); std::uint64_t shader = 0; if (geometry.cap() && watch_shadow_writes() && !context->knows_buffer_va(extent.start, extent.size)) @@ -3490,12 +3489,18 @@ struct DeviceState { } const std::uint64_t want = std::max(bytes, 1); std::lock_guard lock(title_window_mutex); - if (const std::uint64_t made = aliases.shader_va(va); made != va) { // another thread made it meanwhile + std::uint64_t made = 0, available = 0; + const bool has_mapping = aliases.range_of(va, made, available) && made != va; + if (has_mapping && available >= want) { out = made; return true; } // A stream pool's address: one mapping for its readable run, shared by both of its views. if (resolve_pool_memory(va, bytes, out)) return true; + if (has_mapping) { + out = made; + return true; + } if (readable_page(va)) { std::uint64_t lo = 0, hi = UINT64_MAX; aliases.gap(va, lo, hi); // never over a slot-133 buffer's range or another window diff --git a/runtime/src/title_va_alias.h b/runtime/src/title_va_alias.h index 245156d882..c0079599fa 100644 --- a/runtime/src/title_va_alias.h +++ b/runtime/src/title_va_alias.h @@ -76,12 +76,15 @@ class TitleVaAliases { return true; } - bool reuse_pool_mapping(std::uint64_t va, std::uint64_t twin, std::uint64_t max_size, std::uint64_t& shader_va) { + bool reuse_pool_mapping(std::uint64_t va, std::uint64_t twin, std::uint64_t want, std::uint64_t max_size, + std::uint64_t& shader_va) { + if (!want) return false; std::unique_lock lock(mutex_); const auto next = ranges_.upper_bound(va); if (next != ranges_.begin()) { const auto existing = std::prev(next); if (va < existing->second.end) { + if (want > existing->second.end - va) return false; shader_va = existing->second.shader_va + (va - existing->first); return true; } @@ -92,7 +95,7 @@ class TitleVaAliases { if (twin >= other->second.end) return false; const auto end = next == ranges_.end() ? UINT64_MAX : next->first; const auto bytes = std::min({max_size, other->second.end - twin, end - va}); - if (!bytes) return false; + if (bytes < want) return false; const auto shader = other->second.shader_va + (twin - other->first); decltype(ranges_) pending; pending.try_emplace(va, Range{va + bytes, shader}); @@ -218,11 +221,12 @@ class TitleVaAliases { // read or write). Counted by kind: translated, or in the title's memory and left as it was. std::uint64_t resolve(std::uint64_t va, std::uint64_t bytes, Kind kind) { if (!va) return va; - std::uint64_t to = shader_va(va); - if (to != va) { + std::uint64_t mapped = va, available = 0; + const bool has_mapping = range_of(va, mapped, available) && mapped != va; + if (has_mapping && bytes <= available) { translated_[kind].fetch_add(1, std::memory_order_relaxed); note_reached(va, bytes); - return to; + return mapped; } Resolver resolver; void* context; @@ -231,9 +235,13 @@ class TitleVaAliases { resolver = resolver_; context = hook_context_; } - if (!resolver || !resolver(context, va, bytes, to)) return va; + std::uint64_t to = va; + if (!resolver || !resolver(context, va, bytes, to)) { + if (!has_mapping) return va; + to = mapped; + } (to != va ? translated_ : untranslated_)[kind].fetch_add(1, std::memory_order_relaxed); - if (to != va) note_reached(va, bytes); + if (to && to != va) note_reached(va, bytes); return to; } diff --git a/runtime/test/d3d12_title_va_test.cpp b/runtime/test/d3d12_title_va_test.cpp index 90eddc66a6..6763a21ba0 100644 --- a/runtime/test/d3d12_title_va_test.cpp +++ b/runtime/test/d3d12_title_va_test.cpp @@ -963,6 +963,18 @@ int check_stream_pool(Context& c, int& checks) { aliases.add_title_memory(gpu_va, pool_bytes); EXPECT(leonida::title_gpu_views::to_host_view(gpu_va + 0x2000, 0x100) == cpu_va + 0x2000); + constexpr UINT64 seam = pool_bytes / 2; + constexpr UINT64 existing = 0x100000; + const auto root = leonida::TitleVaAliases::root_view; + EXPECT(aliases.add(cpu_va + seam, 0x1000, existing)); + const auto ranges_at_seam = aliases.size(); + EXPECT(aliases.resolve(gpu_va + seam - 0x100, 0x200, root) == 0); + EXPECT(aliases.resolve(gpu_va + seam, 0x2000, root) == 0); + EXPECT(aliases.resolve(cpu_va + seam, 0x2000, root) == 0); + EXPECT(aliases.size() == ranges_at_seam); + EXPECT(aliases.shader_va(cpu_va + seam) == existing); + aliases.remove(cpu_va + seam, existing); + const D3D12_DESCRIPTOR_HEAP_DESC heap_desc{D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, 4, D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE, 0}; Ref heap; @@ -984,6 +996,8 @@ int check_stream_pool(Context& c, int& checks) { EXPECT(aliases.shader_va(gpu_va + 0x2000) == aliases.shader_va(cpu_va + 0x2000)); // Two ranges (the two views' addresses), each a page-aligned run of the pool: one mapping, not one per view. EXPECT(aliases.size() == ranges_before + 2); + EXPECT(aliases.resolve(gpu_va + pool_bytes - 0x100, 0x200, root) == 0); + EXPECT(aliases.size() == ranges_before + 2); std::printf("stream pool: GPU-only alias 0x%llx and CPU view 0x%llx share one %llu KiB mapping (V# base " "0x%llx); a second view naming the twin made no mapping\n", static_cast(gpu_va), static_cast(cpu_va), diff --git a/runtime/test/title_va_alias_test.cpp b/runtime/test/title_va_alias_test.cpp index d068d0f86b..7cc51cf920 100644 --- a/runtime/test/title_va_alias_test.cpp +++ b/runtime/test/title_va_alias_test.cpp @@ -159,14 +159,17 @@ int main() { a.remove(title, 0x5000000); EXPECT(a.add(title + size / 2, size, 0x7000000)); - EXPECT(a.reuse_pool_mapping(title, twin, size, to) && to == 0x5000000); + EXPECT(!a.reuse_pool_mapping(title, twin, size, size, to)); + EXPECT(a.shader_va(title) == title); + EXPECT(a.reuse_pool_mapping(title, twin, size / 2, size, to) && to == 0x5000000); + EXPECT(!a.reuse_pool_mapping(title, twin, size / 2 + 1, size, to)); EXPECT(a.range_of(title, to, room) && room == size / 2); EXPECT(a.shader_va(title + size / 2) == 0x7000000); - EXPECT(a.reuse_pool_mapping(title + size / 2, twin + size / 2, size, to) && to == 0x7000000); + EXPECT(a.reuse_pool_mapping(title + size / 2, twin + size / 2, size, size, to) && to == 0x7000000); EXPECT(!a.add_twin(title + 4 * size, title + 5 * size, size * 2, arena)); EXPECT(a.add(title + 4 * size, size, 0x8000000)); EXPECT(a.add(twin + 5 * size - 16, 16, 0x9000000)); - EXPECT(a.reuse_pool_mapping(twin + 4 * size + 16, title + 4 * size + 16, size, to) && to == 0x8000010); + EXPECT(a.reuse_pool_mapping(twin + 4 * size + 16, title + 4 * size + 16, size - 32, size, to) && to == 0x8000010); a.remove(title + 4 * size, 0x8000000); EXPECT(a.shader_side(0x8000010)); a.forget_copy(twin + 4 * size, size, 0x8000000);