d3d12: CPU subresource copies wait for their own submission only (STAGED-COPY-OWN-WAIT) #407
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/407"
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?
Imported from ubiquitarianism/leonida. Originally posted by Kokonotcu on 2026-11-24T04:45:13Z.
Claim: STAGED-COPY-OWN-WAIT
What was wrong
WriteToSubresource/ReadFromSubresourceon a texture the host cannot copy (noVK_EXT_host_image_copy, or not in GENERAL) replay aCopyTextureRegionon a stagingVulkanQueueand wait for it. The wait wasVulkanQueue::idle():vkQueueWaitIdleoninfo.queue(the VkQueue the first D3D12 direct queue also uses), held under the device's submit lock. Every such CPU copy waited for all the work queued on that queue, and no other queue could submit meanwhile.What changed
VulkanQueue::wait_submitted()waits on the queue's own progress timeline for what it submitted, without the submit lock (100 ms slices, wakes on device loss). The staging copy uses it instead ofidle().info.queueas before.Testing
RTX 3080 Laptop GPU, i7-11800H, Windows 10 19045, NVIDIA driver, MSVC 2022 RelWithDebInfo, Vulkan SDK 1.4.350.
d3d12_staged_copy_wait_test(standalone device): a staged 64x64WriteToSubresourcewhile the direct queue has ~32 ms of buffer copies queued: 31.8 ms before, 0.1-0.6 ms after (the direct queue still busy after it); the bytes round-trip. Fails before the change (its check that the write takes under half the queued work).d3d12_subresource_copy(both paths, 109 steps against the host runtime and Microsoft's recorded answers): 0 mismatches.d3d12_rgb96: pass.LEONIDA_VK_VALIDATION=1(0 validation errors).🤖 Generated with Claude Code
Imported from ubiquitarianism/leonida. Originally posted by DadaCap on 2026-11-25T00:44:26Z.
A measurement from a retail run that supports this change (not a test of this branch: I ran into the same problem in a local stack and only then found this pull request).
Retail 1.0.2.1, Windows 11, RTX 5080 (NVIDIA 621.24). In my stack the textures the title places on its own pages are uploaded with these staged copies from one worker thread, several hundred waiting at a time while the world loads. With the wait being
VulkanQueue::idle():VulkanQueue::acquire>completed_retire_ticket, waiting forsubmit_mutex_, in 4 of 4 stack samples, while the worker was insidevkQueueWaitIdle;ExecuteCommandListswas 19.6 s of a 19.2 s window for 31 submissions (about 0.6 s each), and the title presented one frame in that window.With the wait changed to the queue object's own timeline semaphore and no submit lock (the first bullet of this pull request, written independently, same idea): 114 ms inside
ExecuteCommandListsin a 15 s window of the same phase.So the lock half of the description ("no other queue could submit meanwhile") is not only a 32 ms effect: with a caller that copies in a loop it stops the title's frame loop. I did not try the second half (the staging queue on another VkQueue), so nothing to report on that.
Counts and frame names only, no game data. AI-assisted (Claude Code).