Repository navigation
vulkan: depth24 scratch and the device marker buffer are shared across queue families (RT-QUEUE-FAMILY-SHARING-DEPTH24-MARKERS) - #2489
Conversation
…ue families The depth24 converter's scratch chunks are reused by copies on every D3D12 queue (direct, compute and compute-backed copy). Every queue writes the LEONIDA_DEVICE_MARKERS buffer. Both were created VK_SHARING_MODE_EXCLUSIVE and used by several queue families with no ownership transfer. They now take the device's distinct queue families and call share_across_queue_families, as ScratchBuffers, IndirectArgumentClamp and BindlessSet do. With two or more families a buffer is CONCURRENT; otherwise it stays EXCLUSIVE, as before. From kevincommits' finding in ProjectLeonida#1608 (items 1 and 2). A new CPU test, depth24_scratch_sharing_test, and a new queue_family_sharing case in vulkan_device_markers_test check the create infos with a faked driver. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lixonik
left a comment
There was a problem hiding this comment.
Reviewed 9df6b03cc (vulkan_depth24.h, vulkan_device_markers.h, vulkan_device_fault.h, vulkan_backend.h, d3d12_vulkan_device.cpp, tests) and tested:
- Passing
state_.familiesintoenable_depth24andconfigure_device_fault->DeviceMarkers::createand applyingshare_across_queue_familiescleanly matchesScratchBuffers,IndirectArgumentClamp, andBindlessSetfor multi-family devices (while keepingVK_SHARING_MODE_EXCLUSIVEwhen there is only one family). - Tested on Windows 11 (MSVC 19.44):
vulkan_device_markerspassed (0.04 s) anddepth24_scratch_sharingpassed (0.03 s).
Looks good to merge.
AI-assisted (Antigravity, Gemini).
|
Reviewed at head Verification
Notes
Approve. AI-assisted review + local MSVC verification. |
|
@Tyrannys — thanks for catching the MSVC C2397 in our marker test. I checked Sharing works on two real queue families. I recorded the create infos passed to the driver: both the marker buffer and converter-owned depth scratch stayed On both the PR merge and the combination, graphics family 0 converted 64 D24 words into scratch; family 1 copied the float payload and converted it back using the same retired/reused scratch handle and range. 64/64 float words and 64/64 returned D24 words matched, and each queue’s own marker pair read back correctly. The copy used the compute-capable family, not a third DMA family. Zero Khronos validation errors or sync hazards in this cross-family check. Separate same-slot regression: AI-assisted. |
timbot103
left a comment
There was a problem hiding this comment.
Reviewed head 9df6b03cc. In runtime/shims/d3d12_vulkan_device.cpp, both buffer creation paths receive the deduplicated list of configured queue families. The helper in runtime/src/queue_families.h selects concurrent sharing with two or more families and leaves the create info exclusive with zero or one. The family arrays stay alive through each vkCreateBuffer call in runtime/src/vulkan_depth24.h and runtime/src/vulkan_device_markers.h.
I traced scratch retirement and reuse in runtime/src/vulkan_backend.h, the transfer and compute barriers in runtime/src/vulkan_replay.h, and marker writes to per-queue slots in runtime/src/vulkan_device_fault.h. The CPU tests in runtime/test/depth24_scratch_sharing_test.cpp and runtime/test/vulkan_device_markers_test.cpp check multi-family create infos and the exclusive fallback. I reviewed their CMake registration for Windows and Linux.
Static audit only. No builds, tests, or GPU runs performed as part of this review. No findings.
AI-assisted.
|
Tested 9df6b03 merged (no commit) with main 8fb9748: MSVC 19.52, Windows 11 10.0.26300.
AI-assisted (Claude Code). |
|
Independent native Linux cross-family check of
Synthetic fixtures only. AI-assisted with OpenAI Codex. |
Claimed in the coordination issue as: RT-QUEUE-FAMILY-SHARING-DEPTH24-MARKERS (#1608 (comment))
What and why
Items 1 and 2 of @kevincommits' finding in #1608 (#1608 (comment)). Thanks for the audit.
The device's other shared pools get
state_.familiesand callshare_across_queue_families:ScratchBuffers,IndirectArgumentClampandBindlessSet. Two buffers that every queue uses were stillVK_SHARING_MODE_EXCLUSIVE, with no queue-family ownership transfer. On a GPU with separate graphics, async-compute and copy families, that use is invalid (Vulkan "Resource Sharing Mode").Depth24Converterscratch chunks (vulkan_depth24.h).spare_after its submission and is handed to the next copy, on whichever D3D12 queue that copy runs: direct, compute, or a compute-backed copy queue (vulkan: the depth24 conversion keeps its shader barriers on a copy queue (RT-DEPTH24-COPY-QUEUE-BARRIERS) #2469).enable_depth24and the converter now take the device's families.make_chunkcallsshare_across_queue_families(info, families_).d3d12_vulkan_device.cpppassesstate_.families, asenable_copy_scratchandenable_indirect_clampalready do just above it.LEONIDA_DEVICE_MARKERSbuffer (vulkan_device_markers.h).vkCmdWriteBufferMarker[2]AMD.configure_device_fault,DeviceFaultDiagnosticsandDeviceMarkers::createnow take the families, and the buffer is shared across them.The new parameters are optional and default to no families. With one family, or none given, both buffers stay
EXCLUSIVE, as before (share_across_queue_familiesneeds two or more). Callers and tests that construct these classes directly are unchanged.Separate from #2469 (the depth24 barriers on a copy queue). This PR does not depend on it. Overlap, checked with
git merge-tree:vulkan_depth24.h) or vulkan: the depth24 conversion keeps its shader barriers on a copy queue (RT-DEPTH24-COPY-QUEUE-BARRIERS) #2469.vulkan_device_markers.hand its test, on adjacent lines only: itsif (!get)check goes right below the newcreatesignature, and its test additions sit next to the new case. Whichever lands second keeps both sides.Not included: the early return before the query pool is destroyed in
depth24_convert_test.cpp, which kevincommits also noted. That file is #2469's.Tested
Windows 11, MSVC (VS 18), RelWithDebInfo, on
main43a9d56.New
depth24_scratch_sharing_test(CPU, faked driver).prepare()makes one scratch chunk, and itsVkBufferCreateInfois checked:CONCURRENTover them;EXCLUSIVE.With
main'svulkan_depth24.hthe converter has no families parameter, so the test does not compile. With only the parameter threaded through andmake_chunkleft as onmain, it fails on the first case.vulkan_device_markers_testgainsqueue_family_sharing. ThroughDeviceFaultDiagnosticsand throughDeviceMarkers::create, the marker buffer isCONCURRENTover {0, 1, 2}, {0, 2} and {3, 1}, andEXCLUSIVEwith {0}. Withmake_chunk's andcreate'sEXCLUSIVElines as onmain, the new checks fail.ctest -R "^(depth24_scratch_sharing|vulkan_device_markers|vulkan_device_fault|depth24_convert|vk_device_markers|vk_semaphore_lifetime|d3d12_depth24_draw)$": 7/7 pass. The GPU tests among them (depth24_convert,vk_device_markers,vk_semaphore_lifetime,d3d12_depth24_draw) run on the RTX 4070 SUPER, which has separate graphics, compute and transfer families; together they take about 12 s.scripts/check_no_game_data.py: clean.GPUs tested: profile M: NVIDIA GeForce RTX 4070 SUPER, 12 GB, desktop, driver 621.01, Windows 11
AI-assisted: yes (Claude Code)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no translator change)🤖 Generated with Claude Code