mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 22:00:52 +01:00
[PR #1887] [MERGED] d3d12: track live console-heap V# slots in a host-RAM bitset (RT-CONSOLE-HEAP-VSHARP-BITSET) #1900
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#1900
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/1887
Author: @IlyassRS3
Created: 11/25/2026
Status: ✅ Merged
Merged: 11/25/2026
Merged by: @aslan2142
Base:
main← Head:rt-console-heap-vsharp-bitset📝 Commits (1)
3233b98d3d12: track live console-heap V# slots in a host-RAM bitset📊 Changes
4 files changed (+392 additions, -9 deletions)
View changed files
📝
runtime/CMakeLists.txt(+6 -0)📝
runtime/shims/d3d12_vulkan_device.cpp(+12 -9)➕
runtime/src/console_heap_vsharp_slots.h(+115 -0)➕
runtime/test/console_heap_vsharp_slots_test.cpp(+259 -0)📄 Description
Item:
RT-CONSOLE-HEAP-VSHARP-BITSETClaim: https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7164694343
Summary
Eliminates uncached write-combined GPU memory reads from
heap.copyduring console resource-heap invalidation scans inrefresh_console_heap()(runtime/shims/d3d12_vulkan_device.cpp).released_backingsortitle_va_aliases().invalidations()advanced,refresh_console_heap()scanned every 32-byte slot ofheap.copylinearly (for (size_t at = 0; at + kDescriptorSize <= heap.bytes; at += kDescriptorSize)) checking!(w[3] >> 30) && (w[2] || w[6]). Whenheap.copyfalls back toarena.mapped(uncached WC GPU memory — e.g. whenimport_console_heapcannot land within 4 GiB ofarena.addressor host-memory import is unavailable), reading 4–5.5+ MiB of WC memory triggers ~130k–180k uncached PCIe reads per buffer release (hundreds of ms/submission); even in cached scratch memory it linearly scans all empty and T# slots.leonida::ConsoleHeapVsharpSlots(runtime/src/console_heap_vsharp_slots.h), a dense host-RAMuint64_tbitset (~22 KiB for a 5.5 MiB heap, L1-resident) with O(1)empty()fast path,clear_range()for zeroed page runs,std::countr_zeroiteration safe against in-place bit clears inside the callback, andis_live_vsharp(w)matching the exact legacy predicate!(w[3] >> 30) && (w[2] || w[6]).heap.live_vsharpssynchronized at every resource-heap write toheap.copy:add_console_heap(reset),fix_console_slot(set),fix_console_slotsdeferred zeroing (clear), andfor_each_zeroed(clear_range).heap.live_vsharps.for_each(...)inrefresh_console_heapinstead of readingheap.copy.No overlap with
#1728or#1867.Verification
d3d12_vulkan_device.cppis Windows-only and verified by inspection + Windows CI)runtime/test/console_heap_vsharp_slots_test.cpp(CTestconsole_heap_vsharp_slots), including a 4,000-step differential model against a linear 32-byte slot buffer (fix_console_slot,not_tsharp, deferred zeroing,clear_range, in-place invalidation clears) and 5.5 MiB sparse heap check:clang++ -std=c++20 -Wall -Wextra -Werror -O1 -g -fsanitize=address,undefined: passedclang++ -std=c++20 -Wall -Wextra -Werror -O1 -g -fsanitize=thread: passedclang++ -std=c++20 -Wall -Wextra -Werror -O2(3 runs): passed-O2on Apple Silicon): linear scan60.30 usvs bitset0.93 us(64.9x faster even in cached RAM; eliminates 100% of WC reads fromheap.copywhenheap.copyis inarena.mapped)python3 -I scripts/check_no_game_data.pyon all changed files: passedpython3 -I tests/test_text_write_line_endings.py: passed (3 tests)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.