mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-27 00:15:51 +01:00
[PR #2240] [MERGED] d3d12,xmem: sync TitleTexture readability against title_memory_map between passes (RT-TITLE-TEXTURE-MAP-GEN) #2244
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#2244
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/2240
Author: @zmasi
Created: 11/26/2026
Status: ✅ Merged
Merged: 11/26/2026
Merged by: @aslan2142
Base:
main← Head:fix/title-texture-map-generation📝 Commits (1)
d088ea7Sync title texture readability with map journal between refresh passes📊 Changes
7 files changed (+258 additions, -12 deletions)
View changed files
📝
runtime/shims/d3d12_vulkan_device.cpp(+13 -5)📝
runtime/shims/xmem.cpp(+5 -3)📝
runtime/shims/xmem.h(+1 -1)📝
runtime/src/title_texture_memory.h(+26 -2)📝
runtime/test/d3d12_existing_heap_test.cpp(+137 -0)📝
runtime/test/title_memory_map_test.cpp(+44 -1)📝
runtime/test/xmem_test.cpp(+32 -0)📄 Description
Claimed in the coordination issue as:
RT-TITLE-TEXTURE-MAP-GEN(https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7188273837)What and why
Device::title_texture_readable(runtime/shims/d3d12_vulkan_device.cpp) cached positive readability (generation = 0,cache_success = true) and relied solely onrefresh_title_textures()(throttled toLEONIDA_TITLE_TEXTURE_PERIOD_MS = 16ms ahead ofExecuteCommandLists) to drainleonida::title_memory_map::changes_sinceand callt.memory.retry().When
CopyPageMappingsBatchXorXMemMapPhysicalPagesunmaps or maps 64 KiB tiles (title_memory_map::changed) and a title thread calls synchronous Slot-70write_placed_texture_view(or the async fill worker runs) before the next 16 ms pass (!title_pass_):title_texture_readablereturned staletruewithout probingVirtualQuery, faulting insidehash_bytes(:239) while holdingtitle_texture_mutex.pending()(cache_failure = true) returned stalefalsewithout re-probing until the next pass, delaying bindless publication of newly mapped tiles.xmem::physical_page_fault(runtime/shims/xmem.cpp:1675) recorded read faults (access == 0) over unmapped window pages asFaultExit::left_to_titlewithout checkingtitle_code(pc), andmix_words/hash_byteslackedLEONIDA_GUARDED_NO_BUILTIN(and calledstd::memcpyinside a__trycallee).Changes:
map_generation_inTextureReadability::sync_map(pass_generation, cpu, size)(runtime/src/title_texture_memory.h), called fromtitle_texture_readablewhen!title_pass_ && guard && !mapped. Unchanged generations cost oneO(1)atomic load; non-overlapping map changes advancemap_generation_with0extraVirtualQueryprobes; overlapping unmaps defer immediately (0first-chance AVs) and overlapping maps wake pending textures immediately.LEONIDA_GUARDED_NO_BUILTINand a packedUnalignedWord64load tomix_words/hash_bytes.from_title(title_code(pc)) onaccess == 0inxmem::physical_page_faultso host guarded reads exit viaFaultExit::passed_guardedwithout falseleft_to_titlecounts, while title-code reads and all write faults retainleft_to_title.Tested
ctest --test-dir runtime/build -C RelWithDebInfo --output-on-failure:title_memory_map: verifiessync_map(0probes on non-overlapping change, immediate defer on overlapping unmap, immediate wake on overlapping map).d3d12_existing_heap,d3d12_existing_heap_no_write_watch,d3d12_existing_heap_write_watch: newcheck_placed_view_map_changescase on bothVK_EXT_host_image_copyand staged devices verifies0first-chance AVs viaAddVectoredExceptionHandlerafter interiorMEM_DECOMMIT+title_memory_map::changedon a512 KiB(> 256 KiBsampled-hash) placed texture, and immediate bindless publication afterMEM_COMMIT+title_memory_map::changedwithoutExecuteCommandLists.xmem,xmem_pool_zero_read,xmem_no_write_watch,xmem_write_watch: new non-title executable-stub read test verifiesFaultExit::passed_guardedincrements with0left_to_titleincrements while title-image reads still incrementleft_to_title.460 / 463runnable tests pass (0regressions vsmain).python -I tests/test_text_write_line_endings.py&python -I scripts/check_no_game_data.pyacross all 7 touched files (exit 0).GPUs tested: NVIDIA GeForce RTX 3090, driver 610.88 (Vulkan 1.4.341), Windows 11 x64
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.