mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 23:30:53 +01:00
[PR #1993] d3d12: fix TitleBufferWindows cap/bias guards and add O(log B) lookup and tail tracking (RT-TITLE-BUFFER-WINDOWS-BOUNDS-AND-INDEX) #1999
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#1999
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/1993
Author: @IlyassRS3
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:perf/rt-title-buffer-windows-bounds-and-index📝 Commits (1)
70aa27fd3d12: fix TitleBufferWindows cap/bias guards and add O(log B) lookup and tail tracking📊 Changes
3 files changed (+315 additions, -25 deletions)
View changed files
📝
runtime/CMakeLists.txt(+4 -0)📝
runtime/shims/d3d12_title_buffer_windows.h(+71 -25)➕
runtime/test/title_buffer_windows_test.cpp(+240 -0)📄 Description
Item ID:
RT-TITLE-BUFFER-WINDOWS-BOUNDS-AND-INDEX(claimed in #1608)Summary
Hardens and optimizes
rt::d3d12::TitleBufferWindows(runtime/shims/d3d12_title_buffer_windows.h), backing bothDeviceState::external_windows(slot-133 shadow mirrors) andGeometryViews::pool_(geometry copies):b.capacity > cap - reserved_andreq.size > cap - reserved_previously underfloweduint64_twheneverreserved_ > cap, bypassing the memory cap. Now checksreserved_ > cap || ...before subtracting.b.address >= d.arena.addressbefore checkingb.address - d.arena.address < (1ull << 47), preventing a low block address against a high arena VA from wrapping modulo 2⁶⁴ into the positive 47-bit shader VA window.bytes == 0up front and guardsb.used > UINT64_MAX - (alignment - 1)intake()before rounding up.lookup()via sorted device-address index: maintains a sorted(address, block_index)vector updated once per 4 MiB slab allocation solookup()usesstd::upper_boundinstead of scanning every slab linearly.open_tails_+max_open_tail_): preserves exact most-recent-first reuse of earlier slab tails ondevice_localallocations while skipping full slabs and requests larger than any remaining tail in O(1), pruning exhausted slabs as they fill.release()state reset and a new portable pure-CPU unit testruntime/test/title_buffer_windows_test.cppwired intoruntime/CMakeLists.txt(title_buffer_windows).Benchmarks (
-O2, 256 × 4 MiB slabs, bit-exact A/B vsupstream/main)lookup()(256 slabs, 200k queries): 7.853 ms → 1.181 ms (6.65× faster)allocate()(256 full slabs, 50k requests): 3.843 ms → 0.133 ms (28.88× faster)Testing & Disclosure
clang++ -std=c++20 -g -O1 -fsanitize=address,undefined -fno-omit-frame-pointer -Wall -Wextra -Werror -Wno-missing-field-initializers -I<vulkan-headers> runtime/test/title_buffer_windows_test.cpp: PASSclang++ -std=c++20 -g -O1 -fsanitize=thread -fno-omit-frame-pointer -Wall -Wextra -Werror -Wno-missing-field-initializers -I<vulkan-headers> runtime/test/title_buffer_windows_test.cpp: PASSclang++ -std=c++20 -O2 -Wall -Wextra -Werror -Wno-missing-field-initializers -I<vulkan-headers> runtime/test/title_buffer_windows_test.cpp: PASSpython3 -I scripts/check_no_game_data.py runtime/shims/d3d12_title_buffer_windows.h runtime/test/title_buffer_windows_test.cpp runtime/CMakeLists.txt: PASSpython3 -I tests/test_text_write_line_endings.py: PASS (3/3)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.