Repository navigation
d3d12: blocks of textures and staging buffers are made with their pool's lock released (D3D12-POOL-GROW-UNLOCKED) - #2693
Conversation
…l's lock released (D3D12-POOL-GROW-UNLOCKED) A new 64 MiB block of textures (CreateHeap, MakeResident, the wait for its mapping) or of staging buffers was made inside the pool's mutex, and with blocks made ahead (LEONIDA_RIPE_BLOCKS) one is made each time one is begun. Meanwhile every pooled texture let go, every read of texture_room() (the residency policy and the once-a-second sweep) and every other texture or staging piece, even one with room in a block, waited for it. Pool::take_or_need now only finds a piece, or says a block is to be made first; take_unlocked makes it with the lock released and adds it. One block at a time is made for want of room: a thread that needs one while another is made waits for that one on a condvar, and the maker takes the first piece of its block before the others are woken. Blocks being made count toward the blocks made ahead. A block that failed is not asked for again for half a second, and a later failure never shortens that. texture_room() reads a block count kept beside the pool and takes no lock. A block is counted as made by the submissions begun when it is added, after its making. LEONIDA_POOL_GROW_UNLOCKED=0 keeps the old path, with the submissions begun asked for under the lock as before. With diagnostics, the memory line gives the blocks made and the time they took, and the waits for the pools' locks and for blocks being made.
|
Independent native Windows 10 check of
This checks the pool's synthetic allocation and synchronization behavior. The GPU-only test can return early on setup, so I did not count it as verified driver-side growth. The no-game-data check passed on both changed files. AI-assisted. |
|
Independent check on Windows 11 (Rust toolchain from
AI-assisted (Claude Code). |
|
The |
|
Independent Wine A/B for
I also reproduced the reported F16 semantic failure on AI-assisted: yes (Codex). |
|
RUN - in-game gate (Verified by OreoFR), PROVISIONAL - RTX 4070 Laptop 8 GB, NVIDIA 621.40, Windows 11.
Result: PASS - 0 device loss, 0 panics, every run alive at the end (653-668 s of world frames).
This run was AI-assisted (Claude Code, oreofr-agent). |
|
@TheGeogeo the in-game gate on an RTX 4070 (OreoFR, above) passes on this head, and the only red check is AI-assisted (Claude Code). |
|
Closing and reopening so that CI runs against current AI-assisted (Claude Code). |
|
Verified by MoonEyes on head
AI-assisted (Claude Code). |
|
Merging. Head AI-assisted (Claude Code). |
… 1D wave-base (ProjectLeonida#2685), NaN-exact, by_due texture queue, unlocked pool growth (ProjectLeonida#2693), pipeline wait queue (ProjectLeonida#2622)
Claimed in the coordination issue as: D3D12-POOL-GROW-UNLOCKED (#2570 (comment))
What and why
On
main, the texture pool and the staging pool make a new 64 MiB block while they hold the pool's mutex:lock(&TEXTURES).take_ripe(.., || CreateHeap + MakeResident + wait for the mapping);lock(&STAGING).take(.., || upload_buffer(BLOCK)).With blocks made ahead (
LEONIDA_RIPE_BLOCKS, 12), a block is made each time one is begun. While it is being made, everything else that takes the same mutex waits:release->give);texture_room(), which the residency policy (resource.rs) and the once-a-second sweep read;This change:
Pool::take_or_needfinds a piece, or says that a block has to be made first. It never makes anything.take_unlockedmakes the block with the lock released, then adds it.texture_room()reads a block count kept next to the pool and takes no lock.LEONIDA_POOL_GROW_UNLOCKED=0keeps the old path.diagnostics, the memory line now also reports the blocks made and their time, and the waits for the pools' locks and for blocks being made.The callers of
pool::texture/pool::stagingare unchanged. The two call sites only change the function they call.Tested
On Windows 11, from
d3d12\:pool::tests:the_room_in_texture_blocks_is_read_without_their_lock: fails onmain(texture_room()waits for the lock held by the test) and passes with the change;a_piece_or_a_block_to_make_first,a_block_is_made_with_its_pools_lock_free,threads_wanting_room_wait_for_the_block_being_made(four threads that each need an eighth of a block make one block),a_block_that_failed_is_not_made_again_at_once,a_maker_that_panics_leaves_no_one_waiting.cargo test -p leonida-gpu --locked: 558 passed, 49 ignored. Thepooltests also pass with--features diagnostics.cargo clippy -p leonida-gpu --all-targets --locked --features diagnostics: nothing in the changed lines.git diff --checkandcheck_no_game_data.pyare clean.MakeResidentand the mapping wait are no longer nested inside it. Its other findings are fixed in this change.build-nvidia.ps1,diagnostics,dlss,mimalloc) built.texture), runtime, d3d12: memory leak fixes from one sweep (RT-LEAK-SWEEP) #2569 (staging's signature; that pull request's own conflicts withmainare elsewhere) and d3d12: a landing pool asks its limit once a batch, and parks no thread without LEONIDA_AB (D3D12-LAND-POOL-LIMIT-ONCE) #2692 (git merge-tree).=0(old path)=0(old path, cutscene cut short at 69 s)How to read it:
Limits of this measurement:
GPUs tested: NVIDIA GeForce RTX 3080 10 GB, driver 32.0.16.2140, Windows 11 Pro 10.0.26300.
AI-assisted: yes
Checklist
mainand merges cleanly (also with d3d12-gpu: castable R9G9B9E5 views over R32_UINT/SINT textures without copying (D3D12-ALIAS-CAST-R9G9B9E5) #2660, runtime, d3d12: memory leak fixes from one sweep (RT-LEAK-SWEEP) #2569 and d3d12: a landing pool asks its limit once a batch, and parks no thread without LEONIDA_AB (D3D12-LAND-POOL-LIMIT-ONCE) #2692).docs/design.md, with how it was confirmed. (Not applicable: no translator change.)