Repository navigation
Conversation
…eue (RT-DEPTH24-COPY-QUEUE-BARRIERS) A D3D12 copy queue on a compute-capable Vulkan family runs the depth24/rgb96 footprint conversion (depth24_prepare is installed whenever the family is not the transfer-only one), but its replay's queue_stages are queue_stages_copy, which have no COMPUTE_SHADER bit. restrict_to_queue then zeroed the shader access of the four barriers around run_depth24, and the host-readback barrier was masked down to TRANSFER, so neither the copy's writes reached the dispatch nor the dispatch's writes the host. Found by kevincommits in ProjectLeonida#1608. - detail::depth24_barrier: the barriers around the conversion's dispatch are restricted to the queue's stages plus COMPUTE_SHADER, the stage the dispatch already needs on that queue. restrict_to_queue and memory_barrier now take their stages through restrict_to_stages/memory_barrier_within; every other barrier is unchanged. - The host-readback barrier allows COMPUTE_SHADER where depth24_prepare is installed. - queue_stages itself is unchanged, so the other compute paths stay refused on a copy queue. depth24_convert_test watches vkCmdPipelineBarrier through the context's device proc: on every queue kind, the depth24 and rgb96 readbacks must have a barrier into the shader's reads and one out of its writes, and the host barrier must come from COMPUTE_SHADER/MEMORY_WRITE. Both checks fail on main. AI-assisted (Claude Code) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lixonik
left a comment
There was a problem hiding this comment.
Reviewed and tested at 0e204a9ab (merged cleanly onto main ec91d695c).
Clean, targeted fix:
- Confirmed
replay.depth24_prepareis only installed when!transfer_only(runtime/src/vulkan_backend.h:3388), so addingVK_PIPELINE_STAGE_2_COMPUTE_SHADER_BITtoallowedfor host-readback visibility on copy queues is safe even on GPUs with a dedicated transfer-only queue family. - Confirmed
copy_depth_uav()(runtime/src/vulkan_replay.h:3536) already refuses queues whosevk.queue_stagesomitsCOMPUTE_SHADER_BIT, so the fourCopyTextureRegiondepth24/rgb96 barriers updated todepth24_barrier()are the only ones reachable on a copy queue. - Minor test-coverage note:
watch_dispatch_barriersindepth24_convert_test.cppcurrently checks the image-->buffer readback dispatches on a copy queue; assertingto_shader_barriers/from_shader_barrierson a buffer-->image upload on a copy queue too would cover both halves of thevulkan_replay.hchange.
Verified locally on Windows 11 (MSVC 19.44.35230.0, Ninja Release, NVIDIA GeForce RTX 5070, driver 610.88, Vulkan 1.4.341; note VK_LAYER_KHRONOS_validation is not installed locally so Vulkan validation layers did not run):
depth24_convert(GPU): passed (all 10 sub-checks including the new copy-queue shader barrier and host-readback visibility assertions)scripts/check_no_game_data.pyandgit diff --check: clean
No blocking findings.
AI-assisted.
|
Independent Linux/Wine + NVIDIA check at head
AI-assisted. |
|
Tested on a Mac under Wine. On Macs every D24 depth target takes this conversion path: neither MoltenVK nor KosmicKrisp has
GPUs tested: Apple M3 (profile S), macOS 26.5.1, Wine 11.0 (WineHQ macOS build) with its MoltenVK 1.4.1, clang-cl/lld-link 23.1.6 cross build, AI-assisted (Claude Code, Claude Opus 5.5). |
|
Reviewed at head Verification
Finding (Request changes)
On compute-capable copy queues, the new converter barriers look well-scoped and ordinary copies keep their transfer-stage filter. AI-assisted review + local MSVC/dual-GPU verification. |
Review of ProjectLeonida#2469 (timbot103): - execute_now() copies context_.replay_, where enable_depth24() installed depth24_prepare and depth24_run. On a transfer-only family the queue only skipped wrapping prepare, so the inherited callbacks stayed callable and a depth24 or rgb96 copy there could record the compute dispatch and its COMPUTE_SHADER barriers. Both callbacks are now cleared on such a family, so the copy is refused as unsupported before anything is recorded. - The D3D12 device registered the transfer-only copy family only inside `if (info.conditional_rendering)`. It now registers it on every device; predication setup stays behind conditional rendering. depth24_convert_test registers the test's family as transfer-only and checks that depth24 and rgb96 uploads and readbacks on a copy queue are refused with no conversion or host barriers (fails at line 705 without the queue fix). It also checks the conversion barriers on buffer-to-image uploads on every queue kind (lixonik's note). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@timbot103 thanks, both paths were real. Fixed in 26fd3b3.
Test, @lixonik's coverage note is in the same commit: on direct, compute and copy queues, depth24 and rgb96 buffer-to-image uploads now also check Windows 11, MSVC (VS 18), RelWithDebInfo, RTX 4070 SUPER (driver 621.01):
AI-assisted (Claude Code) |
lixonik
left a comment
There was a problem hiding this comment.
Re-reviewed 26fd3b3bb and tested on RTX 5070 with Khronos validation enabled.
Code audit:
runtime/src/vulkan_backend.h: explicitly clearing inheritedreplay.depth24_prepareandreplay.depth24_runcallbacks ontransfer_onlyfamilies ensures a transfer-only copy queue refuses depth24/RGB96 conversion as unsupported without dispatching compute or emittingCOMPUTE_SHADERbarriers.runtime/shims/d3d12_vulkan_device.cpp: registering a non-compute copy family viaset_transfer_only_family(info.copy_family)unconditionally (outsideif (info.conditional_rendering)) closes the remaining registration gap.runtime/test/depth24_convert_test.cpp: covers both transfer-only refusal and buffer-to-image uploadto_shader_barriers/from_shader_barrierschecks across direct, compute, and copy queues.
Verification at 26fd3b3bb (Windows 11, MSVC 19.44, Ninja Release, LEONIDA_VK_VALIDATION=1):
- Built
depth24_convert_test,depth24_fragment_test,d3d12_d24_support_test, andd3d12_depth24_draw_test. ctest -R '^(depth24_convert|depth24_fragment|d3d12_d24_support|d3d12_depth24_draw)$': 4/4 passed (0 validation errors).python -I scripts/check_no_game_data.py: passed.
GPUs tested: NVIDIA GeForce RTX 5070 12 GB (Windows 11, driver 610.88, Vulkan 1.4.341, VK_LAYER_KHRONOS_validation 1.4.363).
AI-assisted (Antigravity, Gemini).
|
Verified On the merge, D24 and RGB96 conversions retained compute shader read/write access, and the readback barrier made compute writes visible to the host. All 1,995 scoped readback words matched the independent oracle, including 256 D24 and 153 RGB96 words on the copy queue. All 1,586 words from legally submitted main controls also matched. No validation errors, synchronization hazards or physical device loss. This device advertised no transfer-only family: the four transfer-only refusals were checked by marking the test family transfer-only, not by submitting to a dedicated DMA engine. AI-assisted. |
timbot103
left a comment
There was a problem hiding this comment.
Static audit of 26fd3b3bb only, with no builds, tests, or GPU runs. On a graphics+compute family, the legacy barriers now preserve shader reads and writes around the scratch-buffer conversion. The host barrier covers compute writes through synchronization2 and through the legacy ALL_COMMANDS / MEMORY_WRITE path. Clearing the callbacks also correctly refuses the conversion on the registered DMA family.
- [MAJOR]
runtime/shims/d3d12_vulkan_device.cpp:14987— This check covers the dedicated copy family. The queue picker can select a graphics family without compute atruntime/shims/d3d12_vulkan_device.cpp:22007, and a copy queue can fall back to it. An RGB96 footprint copy on that queue still dispatches compute and now records explicit compute-stage barriers, violating the queue-family stage requirements inVUID-vkCmdPipelineBarrier-srcStageMask-06461andVUID-vkCmdPipelineBarrier-dstStageMask-06462. A host-readable readback through synchronization2 also violatesVUID-vkCmdPipelineBarrier2-srcStageMask-09673. Gate the converter callbacks and host compute barrier on the capabilities of the actual queue family. - [MAJOR]
runtime/src/vulkan_replay.h:5152— With no suitable DMA family, the picker can lease a copy queue from a compute-only family. That family can run the conversion shader, but the D24-as-D32 upload here and the readback atruntime/src/vulkan_replay.h:5175also issue depth-aspect buffer/image copies. Those commands requiremaintenance10and the depth-copy format feature on that family. Please check both before preparing the conversion and refuse the copy when either is missing. The existing per-format capability check inruntime/src/vulkan_replay.h:3529provides a starting point.
The upload and readback assertions in runtime/test/depth24_convert_test.cpp:623 all reuse the same graphics family. The refusal check at runtime/test/depth24_convert_test.cpp:697 simulates DMA by registering that family as transfer-only. Coverage of a non-graphics compute family would catch the depth-aspect copy failure.
AI-assisted.
|
Run on
Green (merged build)
Red (behavioural: the test is kept and compiles against
Link: gta6rt.exe of the merged build: no new imports vs main (703 imports, identical lists with Machine: RTX 3090 24 GB, NVIDIA 621.40, Windows 11 Pro 10.0.26300, MSVC 19.44, Vulkan SDK 1.4.363.1. One run each. AI-assisted (Claude Code). |
Claimed in the coordination issue as: RT-DEPTH24-COPY-QUEUE-BARRIERS (#1608 (comment))
What and why
Found by @kevincommits in #1608 (#1608 (comment)), thanks for the precise write-up.
A D3D12 copy queue whose Vulkan family can run compute also runs the depth24/rgb96 footprint conversion:
depth24_prepareis installed whenever the family is not the transfer-only one. But that queue's replay usesqueue_stages_copy, which has noCOMPUTE_SHADERbit, so:detail::restrict_to_queuezeroed the shader access of the four barriers aroundrun_depth24(dstAccessMask = 0before the dispatch,srcAccessMask = 0after it). The copy's writes were not made visible to the shader, nor the shader's writes to the copy or readback that follows.COMPUTE_SHADERaway and fell back toTRANSFER / TRANSFER_WRITE -> HOST, so the conversion's writes were not made available to the host.This keeps the copy-queue conversion (which
depth24_convert_testexercises) and fixes its barriers:detail::depth24_barrier: the barriers around the conversion's dispatch are restricted to the queue's stages plusCOMPUTE_SHADER, the stage the dispatch already uses on that queue.restrict_to_queueandmemory_barriernow go throughrestrict_to_stages/memory_barrier_within; every other barrier is unchanged.VulkanQueueallowsCOMPUTE_SHADERwheredepth24_prepareis installed.queue_stagesitself is unchanged, so the other compute paths stay refused on a copy queue.execute_now()copiescontext_.replay_, so it now clears thedepth24_prepare/depth24_runcallbacks thatenable_depth24()put there, and such a copy is refused as unsupported. The D3D12 device now registers a copy family without compute as transfer-only on every device; before, it did so only with conditional rendering.depth24_convert_testnow watchesvkCmdPipelineBarrierthrough the context's device proc. On direct, compute and copy queues, the depth24 and rgb96 readbacks must have a barrier into the shader's reads and one out of its writes, and the host barrier must come fromCOMPUTE_SHADER / MEMORY_WRITE. The old test asserted theTRANSFERfallback on a copy queue; that assertion is replaced.Staying apart from #1988 (Depth24Converter bounds); no shared files.
Tested
Windows 11, MSVC (VS 18), Vulkan SDK 1.4.341, RelWithDebInfo, on this branch merged with
main(ec91d695c).depth24_convert_testregisters the test's family as transfer-only and checks that depth24 and rgb96 uploads and readbacks on a copy queue returnunsupportedwith no conversion or host barriers; with the previousvulkan_backend.hit fails at that check (line 705). It also checks the conversion barriers of buffer-to-image uploads on every queue kind (@lixonik's note).depth24_convert,depth24_fragment,d3d12_d24_support,d3d12_depth24_draw,xbox_d16s8_d24_storage: pass;depth24_convertalso withLEONIDA_VK_VALIDATION=1, no messages.depth24_convert: passes, also withLEONIDA_VK_VALIDATION=1(validation and sync validation on, no messages).main'svulkan_backend.handvulkan_replay.h: fails atto_shader_barriers >= 1 && from_shader_barriers >= 1(the conversion's barriers lose their shader access). With only the replay half of the fix, it fails athost_src_stages == VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT(the host barrier). Both halves are needed.mainhere either, matching @kevincommits' note that 1.4.363 no longer flags it; the barrier check in the test is what catches it.vk_*,depth24*,replay_*,d3d12_queue*,d3d12_*copy*,predicated_copy,guarded_copy,queue_proxy,xbox_present_readback_size), 84 tests: all pass exceptd3d12_queue_handover,_two_queues,_shared_queue: failed only underctest -j 4load; pass when run alone.vk_compile_gate_calibration: "no verdict on NVIDIA (unclear)" under load; passes alone (3/3).vk_sync_validation: skipped.vk_*,depth24*,replay_*withLEONIDA_VK_VALIDATION=1(58 tests): all pass exceptvk_device_markers, which fails the same way onmain(sync validationWRITE_AFTER_WRITEbetween twovkCmdWriteBufferMarker2AMDwrites); unrelated to this change.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