From 84db5cd02736759eab9ffb4deedc98c52027c050 Mon Sep 17 00:00:00 2001 From: Jan Trencansky Date: Thu, 26 Nov 2026 14:47:29 -0500 Subject: d3d12: console heap slots record what their V#s resolved to; a release re-fixes only the slots naming it (RT-VSHARP-SLOT-RECORDS) After any arena release, title-window or geometry block destroyed, or alias change, the next submission walked every live V# slot of the console heap (about 580,000 in world runs), reading each from the copy in ReBAR VRAM: 1.1-1.5 s a walk whatever the scene, about 2.9 s of a 4.6 s frame. It existed only because nothing recorded which slot resolved into which backing. Each V# half of a console resource heap's copy now has a record in host RAM (src/console_heap_slot_records.h): the title's base and span, the device address its copy names, and whether it resolved or waits. Two indexes (by base, by target; per power-of-two span class and 64 KiB-or-larger granule) find the halves near a range. fix_console_slot, the only writer of a slot's copy, writes them; a zeroed range, a deferred slot and a rewritten slot drop theirs; a destroyed heap takes them with it. Releases (backing(), title_block_gone), alias ranges removed or replaced (TitleVaAliases tells its listeners as it happens, forget_copy included) and additions (backings, alias ranges, title memory) go on an unbounded per-device list. refresh_console_heaps takes it whole; every heap re-fixes exactly the slots it touches: a release or removal every half naming the range, an addition the waiting halves over it. A new heap log line gives the changes, slots looked at, slots fixed again and ms per submission. Removed: the live_vsharps walk and its bitset (console_heap_vsharp_slots.h and its test), the release generation checks (released_backings, TitleVaAliases::invalidations), LEONIDA_CONSOLE_RELEASE_FILTER, the 4,096-entry DescriptorRangeChanges ring with its full-sweep overflow and changed_ranges(), the empty-slot probe and retry_unmapped_slots (unreachable: nothing set its flag). LEONIDA_CONSOLE_GPU_FILTER now defaults to unset instead of the removed variable's value. The T# retries (retry_console_slots) stay. Tests: console_heap_slot_records_test (portable): releasing a buffer 10 of 60,010 slots name looks at 10 entries and fixes 10 slots; an alias moved, removed and added back; overwritten and zeroed slots; partial overlap; two slots on one backing; a buffer back; a refused alias copy backed later; a large span; a destroyed heap; and 400 random rounds compared with a full re-resolution of every slot. d3d12_unmapped_vsharp_test now expects all 128 waiting slots restored at the first submission after their alias comes (was: 16 by the probe in 64 submissions), none after it goes, and the slots naming a released buffer null. title_va_alias_test and geometry_views_test check the listener in place of the ring. Linux ctest 113/113; Windows suite under Wine (clang-cl, iGPU, RADV) equal to main 2d43417d4 test by test. Co-Authored-By: Claude Opus 5.5 --- runtime/src/descriptor_range_changes.h | 46 ---------------------------------- 1 file changed, 46 deletions(-) delete mode 100644 runtime/src/descriptor_range_changes.h (limited to 'runtime/src/descriptor_range_changes.h') diff --git a/runtime/src/descriptor_range_changes.h b/runtime/src/descriptor_range_changes.h deleted file mode 100644 index 5a4d7717f..000000000 --- a/runtime/src/descriptor_range_changes.h +++ /dev/null @@ -1,46 +0,0 @@ -#pragma once -#include -#include -#include -#include - -namespace leonida { -// A separate cursor per console heap. The owning backing/alias registry locks record() and read(). -struct DescriptorRanges { - struct Range { uint64_t first, last; }; // inclusive, including UINT64_MAX - std::vector ranges; - void merge() { - std::sort(ranges.begin(), ranges.end(), [](auto a, auto b) { return a.first < b.first; }); - size_t n = 0; - for (auto r : ranges) { - if (n && r.first <= ranges[n-1].last) - ranges[n-1].last = (std::max)(ranges[n-1].last, r.last); - else ranges[n++] = r; - } - ranges.resize(n); - } - bool overlaps(uint64_t base, uint64_t bytes) const { - if (!bytes) return false; - auto it = std::lower_bound(ranges.begin(), ranges.end(), base, - [](auto r, uint64_t v) { return r.last < v; }); - return it != ranges.end() && (it->first <= base || it->first - base < bytes); - } -}; -class DescriptorRangeChanges { - std::array ring_{}; - uint64_t serial_{}; -public: - void record(uint64_t start, uint64_t bytes) { - if (bytes) { - ring_[serial_++ % ring_.size()] = {start, start + (std::min)(UINT64_MAX-start, bytes-1)}; - } - } - bool read(uint64_t& cursor, DescriptorRanges& out) const { - const auto previous = cursor; - cursor = serial_; - if (serial_ - previous > ring_.size()) return false; - for (auto i = previous; i != serial_; ++i) out.ranges.push_back(ring_[i % ring_.size()]); - return true; - } -}; -} -- cgit v1.2.3