Repository navigation
d3d12,xmem: sync TitleTexture readability against title_memory_map between passes (RT-TITLE-TEXTURE-MAP-GEN) - #2240
Conversation
Between periodic refresh_title_textures passes, synchronous slot-70 view creation and the async fill worker checked TextureReadability with a constant generation, missing title_memory_map range changes since the last pass. Track the map generation on TextureReadability and consult title_memory_map::changes_since outside refresh passes so unmapped or decommitted pages defer before hashing and newly mapped pages publish immediately without waiting for a submission. Also mark mix_words and hash_bytes LEONIDA_GUARDED_NO_BUILTIN using an unaligned 64-bit load so clang-cl cannot emit CRT memcpy calls inside the __try frame, and classify non-title read faults over unmapped title pages in xmem::physical_page_fault as FaultExit::passed_guarded.
lixonik
left a comment
There was a problem hiding this comment.
Built this head with MSVC on Windows 11. title_memory_map, all three d3d12_existing_heap variants, and the xmem_pool_zero_read and write-watch variants passed. GPU: NVIDIA GeForce RTX 5070, driver 610.88. The first default xmem run failed only the memory-charge assertion for touching 512 pages. Two subsequent default runs passed at this head, and two passed at the base with the same toolchain. The new host/title read-classification assertions passed even in the first run. I could not reproduce a failure in the changed behavior.
AI-assisted.
|
Overlap note: #2267 (RT-TITLE-TEXTURE-SHOW-AFTER-UPLOAD) also touches the TitleTexture path. The logic is separate (it changes |
|
Independent verification of head Windows 11 Pro, RTX 4070 SUPER (NVIDIA 621.01), MSVC 19.52.37029, RelWithDebInfo.
Diff read, one question: in No game files used. AI-assisted (Claude Code). |
|
Thank you, @zmasi. This went into AI-assisted (Claude Code, Claude Opus 5.5 and Claude Fable 5.2) |
Claimed in the coordination issue as:
RT-TITLE-TEXTURE-MAP-GEN(#1608 (comment))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.