runtime: add LEONIDA_TARGET_DUMP per-pass target dumper (RT-PASS-TARGET-DUMP) #2466
Closed
lixonik wants to merge 9 commits from
upstream-pr/2466 into main
pull from: upstream-pr/2466
merge into: ProjectLeonida:main
ProjectLeonida:main
ProjectLeonida:claude/loop-total
ProjectLeonida:claude/pops-collision-seed
ProjectLeonida:claude/dstorage-hold-page-reads
ProjectLeonida:claude/host-image-copy-switch
ProjectLeonida:feat/gdk-lifecycle-window-hook
ProjectLeonida:claude/d16s8-uav-nvidia-fallback
ProjectLeonida:feat/mfplat-offline-shim
ProjectLeonida:claude/gameinput-slow-reader
ProjectLeonida:fix/rt-null-barrier-clear
ProjectLeonida:claude/depth-resolve-sample-positions
ProjectLeonida:integration/palmetto-parity
ProjectLeonida:claude/valu-literal-sext
ProjectLeonida:claude/slot74-pool-handle
ProjectLeonida:claude/rgb9e5-uint-alias-view
ProjectLeonida:claude/fssm-root-layout-tables
ProjectLeonida:feat/gdk-speech-display-lifecycle
ProjectLeonida:asset-audio-skip-current
ProjectLeonida:qemmhd/old-9940-rectangle-quad-lists
ProjectLeonida:feat/ws2-offline-shim
ProjectLeonida:qemmhd/rt-d16-unorm-uav
ProjectLeonida:feat/xs-device-stops-7-9
ProjectLeonida:qemmhd/rt-depth-same-base-shapes
ProjectLeonida:qemmhd/rt-lazy-attachment-variant
ProjectLeonida:feat/acphal-xma2-decoder
ProjectLeonida:asset-audio-skip
ProjectLeonida:codex/coord-claim-check-20261124-7e48
ProjectLeonida:feat/xs-frame-pacing-presentx
ProjectLeonida:feat/xs-device-vm-options
ProjectLeonida:old-pr/9844
ProjectLeonida:old-pr/9978
ProjectLeonida:old-pr/9815
ProjectLeonida:old-pr/10057
ProjectLeonida:old-pr/9874
ProjectLeonida:old-pr/9965
ProjectLeonida:old-pr/9863
ProjectLeonida:old-pr/10068
ProjectLeonida:old-pr/10066
ProjectLeonida:old-pr/10067
ProjectLeonida:old-pr/10007
ProjectLeonida:old-pr/10061
ProjectLeonida:old-pr/10065
ProjectLeonida:old-pr/10059
ProjectLeonida:old-pr/10063
ProjectLeonida:old-pr/10055
ProjectLeonida:old-pr/10062
ProjectLeonida:old-pr/10042
ProjectLeonida:old-pr/10041
ProjectLeonida:old-pr/10049
ProjectLeonida:old-pr/10047
ProjectLeonida:old-pr/10046
ProjectLeonida:old-pr/10045
ProjectLeonida:old-pr/10056
ProjectLeonida:old-pr/10043
ProjectLeonida:old-pr/10036
ProjectLeonida:old-pr/10034
ProjectLeonida:old-pr/9984
ProjectLeonida:old-pr/10052
ProjectLeonida:old-pr/10038
ProjectLeonida:old-pr/10033
ProjectLeonida:old-pr/10028
ProjectLeonida:old-pr/10050
ProjectLeonida:old-pr/9891
ProjectLeonida:old-pr/9889
ProjectLeonida:old-pr/10051
ProjectLeonida:old-pr/10019
ProjectLeonida:old-pr/10027
ProjectLeonida:old-pr/10029
ProjectLeonida:old-pr/10031
ProjectLeonida:old-pr/10026
ProjectLeonida:old-pr/9941
ProjectLeonida:old-pr/10030
ProjectLeonida:old-pr/10040
ProjectLeonida:old-pr/9990
ProjectLeonida:old-pr/10021
ProjectLeonida:old-pr/9962
ProjectLeonida:old-pr/10022
ProjectLeonida:old-pr/10020
ProjectLeonida:old-pr/10015
ProjectLeonida:old-pr/10025
ProjectLeonida:old-pr/9886
ProjectLeonida:old-pr/10048
ProjectLeonida:old-pr/10014
ProjectLeonida:old-pr/10011
ProjectLeonida:old-pr/9861
ProjectLeonida:old-pr/10010
ProjectLeonida:old-pr/10008
ProjectLeonida:old-pr/9860
ProjectLeonida:old-pr/10006
ProjectLeonida:old-pr/9920
ProjectLeonida:old-pr/9995
ProjectLeonida:old-pr/10000
ProjectLeonida:old-pr/10016
ProjectLeonida:old-pr/10004
ProjectLeonida:old-pr/10023
ProjectLeonida:old-pr/9982
ProjectLeonida:old-pr/9981
ProjectLeonida:old-pr/9983
ProjectLeonida:old-pr/9970
ProjectLeonida:old-pr/9969
ProjectLeonida:old-pr/9968
ProjectLeonida:old-pr/9971
ProjectLeonida:old-pr/9972
ProjectLeonida:old-pr/9942
ProjectLeonida:old-pr/9963
ProjectLeonida:old-pr/9960
ProjectLeonida:old-pr/9964
ProjectLeonida:old-pr/9985
ProjectLeonida:old-pr/9973
ProjectLeonida:old-pr/9862
ProjectLeonida:old-pr/9953
ProjectLeonida:old-pr/10017
ProjectLeonida:old-pr/9952
ProjectLeonida:old-pr/9955
ProjectLeonida:old-pr/9946
ProjectLeonida:old-pr/9954
ProjectLeonida:old-pr/9938
ProjectLeonida:old-pr/9956
ProjectLeonida:old-pr/9856
ProjectLeonida:old-pr/9947
ProjectLeonida:old-pr/9924
ProjectLeonida:old-pr/9961
ProjectLeonida:old-pr/9927
ProjectLeonida:old-pr/9979
ProjectLeonida:old-pr/10032
ProjectLeonida:old-pr/9926
ProjectLeonida:old-pr/5237
ProjectLeonida:old-pr/9951
ProjectLeonida:old-pr/9931
ProjectLeonida:old-pr/9902
ProjectLeonida:old-pr/9921
ProjectLeonida:old-pr/9994
ProjectLeonida:old-pr/9775
ProjectLeonida:old-pr/9768
ProjectLeonida:old-pr/9905
ProjectLeonida:old-pr/9936
ProjectLeonida:old-pr/9901
ProjectLeonida:old-pr/9904
ProjectLeonida:old-pr/9906
ProjectLeonida:old-pr/9988
ProjectLeonida:old-pr/9908
ProjectLeonida:old-pr/9909
ProjectLeonida:old-pr/9911
ProjectLeonida:old-pr/9912
ProjectLeonida:old-pr/9913
ProjectLeonida:old-pr/9887
ProjectLeonida:old-pr/9916
ProjectLeonida:old-pr/9919
ProjectLeonida:old-pr/9925
ProjectLeonida:old-pr/9933
ProjectLeonida:old-pr/9935
ProjectLeonida:old-pr/9918
ProjectLeonida:old-pr/9879
ProjectLeonida:old-pr/9880
ProjectLeonida:old-pr/9881
ProjectLeonida:old-pr/9996
ProjectLeonida:old-pr/9876
ProjectLeonida:old-pr/9892
ProjectLeonida:old-pr/9899
ProjectLeonida:old-pr/9915
ProjectLeonida:old-pr/9914
ProjectLeonida:old-pr/9872
ProjectLeonida:old-pr/9869
ProjectLeonida:old-pr/9866
ProjectLeonida:old-pr/9819
ProjectLeonida:old-pr/10012
ProjectLeonida:old-pr/9857
ProjectLeonida:old-pr/9893
ProjectLeonida:old-pr/9897
ProjectLeonida:old-pr/9928
ProjectLeonida:old-pr/9868
ProjectLeonida:old-pr/9917
ProjectLeonida:old-pr/9940
ProjectLeonida:old-pr/9873
ProjectLeonida:old-pr/9816
ProjectLeonida:old-pr/10009
ProjectLeonida:old-pr/9900
ProjectLeonida:old-pr/9966
ProjectLeonida:old-pr/9859
ProjectLeonida:old-pr/9843
ProjectLeonida:old-pr/9991
ProjectLeonida:old-pr/10058
ProjectLeonida:old-pr/9883
ProjectLeonida:old-pr/9838
ProjectLeonida:old-pr/9835
ProjectLeonida:old-pr/9959
ProjectLeonida:old-pr/9895
ProjectLeonida:old-pr/9837
ProjectLeonida:old-pr/9858
ProjectLeonida:old-pr/9865
ProjectLeonida:old-pr/9864
ProjectLeonida:old-pr/9840
ProjectLeonida:old-pr/9820
ProjectLeonida:old-pr/4669
ProjectLeonida:old-pr/9848
ProjectLeonida:old-pr/9850
ProjectLeonida:old-pr/9810
ProjectLeonida:old-pr/9799
ProjectLeonida:old-pr/9853
ProjectLeonida:old-pr/9875
ProjectLeonida:old-pr/9831
ProjectLeonida:old-pr/9796
ProjectLeonida:old-pr/9801
ProjectLeonida:old-pr/9813
ProjectLeonida:old-pr/9794
ProjectLeonida:old-pr/7417
ProjectLeonida:old-pr/9781
ProjectLeonida:old-pr/9806
ProjectLeonida:old-pr/9958
ProjectLeonida:old-pr/9809
ProjectLeonida:old-pr/9791
ProjectLeonida:old-pr/9792
ProjectLeonida:old-pr/10053
ProjectLeonida:old-pr/9784
ProjectLeonida:old-pr/9789
ProjectLeonida:old-pr/9849
ProjectLeonida:old-pr/9846
ProjectLeonida:old-pr/9773
ProjectLeonida:old-pr/9785
ProjectLeonida:old-pr/9803
ProjectLeonida:old-pr/9826
ProjectLeonida:old-pr/9839
ProjectLeonida:old-pr/9922
ProjectLeonida:old-pr/9948
ProjectLeonida:old-pr/7189
ProjectLeonida:old-pr/9957
ProjectLeonida:old-pr/9823
ProjectLeonida:old-pr/9807
ProjectLeonida:old-pr/9851
ProjectLeonida:old-pr/9774
ProjectLeonida:old-pr/9830
ProjectLeonida:old-pr/9836
ProjectLeonida:old-pr/9822
ProjectLeonida:old-pr/9783
ProjectLeonida:old-pr/9833
ProjectLeonida:old-pr/9890
ProjectLeonida:old-pr/9770
ProjectLeonida:old-pr/9769
ProjectLeonida:old-pr/9772
ProjectLeonida:old-pr/9787
ProjectLeonida:old-pr/9852
ProjectLeonida:old-pr/9834
ProjectLeonida:old-pr/9845
ProjectLeonida:old-pr/9871
ProjectLeonida:old-pr/9771
ProjectLeonida:old-pr/9776
ProjectLeonida:old-pr/10005
ProjectLeonida:old-pr/9949
ProjectLeonida:old-pr/9923
ProjectLeonida:old-pr/9805
ProjectLeonida:old-pr/9829
ProjectLeonida:old-pr/9790
ProjectLeonida:old-pr/9827
ProjectLeonida:old-pr/9929
ProjectLeonida:old-pr/9855
ProjectLeonida:old-pr/9934
ProjectLeonida:old-pr/9907
ProjectLeonida:old-pr/9910
ProjectLeonida:old-pr/9779
ProjectLeonida:old-pr/9780
ProjectLeonida:old-pr/9885
ProjectLeonida:old-pr/9882
ProjectLeonida:old-pr/9877
ProjectLeonida:old-pr/9998
ProjectLeonida:old-pr/4251
ProjectLeonida:old-pr/9987
ProjectLeonida:old-pr/9989
ProjectLeonida:old-pr/9950
ProjectLeonida:old-pr/9777
ProjectLeonida:old-pr/10044
ProjectLeonida:old-pr/9884
ProjectLeonida:old-pr/2906
ProjectLeonida:old-pr/5076
ProjectLeonida:old-pr/9937
ProjectLeonida:old-pr/9986
ProjectLeonida:old-pr/3014
ProjectLeonida:old-pr/9943
ProjectLeonida:old-pr/9939
ProjectLeonida:old-pr/4682
ProjectLeonida:old-pr/4765
No reviewers
Labels
Clear labels
No items
No labels
Milestone
Clear milestone
No items
No milestone
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Reference
ProjectLeonida/mandy!2466
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2466"
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 lixonik on 2026-11-27T13:15:15Z.
Implements
RT-PASS-TARGET-DUMP(claimed in https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7218711636).Summary
runtime/src/target_dump.himplementingLEONIDA_TARGET_DUMP=<dir>,<frame>(1-basedframe > 0).leonida::present_dump::texel_sizeandleonida::present_dump::write_pngdirectly fromruntime/src/present_dump.h(without editingpresent_dump.h, avoiding conflicts with #2146)..png(forpresent_dump-supported formats) or tightly packed.raw(for other uncompressed color/depth formats), skipping multisampled and block-compressed images cleanly.index.json(frame, pass number, pass kind, slot, format, dimensions, mip/layer, bytes per texel, encoding, filename) via exclusive sibling.tmpcreation + rename so pre-existing hard links outside the dump directory are never overwritten.ReplayFunctions::target_dumpstaysnullptrwhen unset, invalid, or once the target frame has completed and drained, reducing replay overhead to a single predicted null-pointer check inemit_commandswith zero staging buffer allocations or copies.runtime/src/vulkan_replay.h(ReplayFunctions::target_dump,ComputePipeline::writes_storage_image, UAV state tracking on transitions/enhanced texture barriers/UAV clears, and post-rendering-scope / post-dispatch hooks inemit_commands) and lifecycle integration inruntime/src/vulkan_backend.h(memory properties forwarding viaset_occlusion_resolve_memory, per-submission commit/rollback on retire tickets, drain on ticket completion and queue/context teardown).LEONIDA_TARGET_DUMPinruntime/README.md(marked*Diagnostic.*, noting files stay local).runtime/test/vk_target_dump_test.cppregistered inruntime/CMakeLists.txt(vk_target_dump,vk_target_dump_off,vk_target_dump_frame2,vk_target_dump_invalid,SKIP_RETURN_CODE 77).This is a diagnostic tool (not a workaround for a defect) and stays off by default.
Verification
main(690dea519):vk_target_dump_test.cppfails to compile againstmainbecausetarget_dump.hand its replay/context hooks are absent.0068b2cd8, base17d3af0b6):vk_target_dump-- PASS: two rendering scopes (scope 1 draws solid color to RT0; scope 2 overwrites RT0 with a second color and writesVK_FORMAT_R32_UINTraw values to RT1), one skipped non-storage compute dispatch, and one storage-image compute dispatch writinguav0; verifiesindex.json, independent PNG decoding (zlib_inflate+ CRC32), exact per-pixel/per-texel values across all 3 passes, and hard-link safety.vk_target_dump_off-- PASS: unset env var keeps target dump disabled with 0vkCreateBufferand 0vkCmdCopyImageToBuffercalls and no files written.vk_target_dump_frame2-- PASS:<dir>,2skips frame 1, dumps frame 2 only, and disables automatically once frame 3 starts and frame 2 retires.vk_target_dump_invalid-- PASS: parser/format unit checks plus invalid<dir>,0leaves dump disabled and does not create the directory.vk_command_replay,vk_queue,vk_present_dump,vk_present_dump_default,vk_present_dump_invalid-- 9/9 PASS;gta6rt.exebuilt cleanly.-std=c++20 -O1 -g -fsanitize=undefined,address -Wall -Wextra -Werror) ontarget_dump.h-- PASS with 0 warnings.python -I -B tests/test_docs_env_vars.py(5/5 OK),python -I -B scripts/check_no_game_data.py(clean),git diff --check(clean).VK_LAYER_KHRONOS_validationis not installed locally on this machine, so GPU tests ran without Vulkan validation layers. The test checksvalidation_errors() == 0underLEONIDA_VK_VALIDATION=1and skips with exit code77when no Vulkan 1.3 / 1.2+KHR device is available.GPUs tested: NVIDIA GeForce RTX 5070 (driver 610.88, Vulkan 1.4.341), Windows 11, MSVC 19.44 Release (without VK_LAYER_KHRONOS_validation).
AI-assisted (Antigravity, Gemini 4 Neon).
Imported from ubiquitarianism/leonida. Originally posted by tiguan26 on 2026-11-28T01:52:36Z.
Review: APPROVED
Approving. Merged onto current main (
431ceba4f) with no conflicts, cross-builtvk_target_dump_test(clang-cl 19 + xwin) and ran it under Wine 11.22 on llvmpipe (Mesa, LLVM 20.1.2): all four entries pass (vk_target_dump,_off,_frame2,_invalid, exit 0, not skipped).What that covers, read from the test: the default and
--frame2runs check exact pixels of both scopes' targets (the R8G8B8A8 one and the R32_UINT tag) and of the storage image the second dispatch writes, with the no-op dispatch before it dumping nothing;--offproves "free when off" by counting zerovkCmdCopyImageToBufferand zerovkCreateBuffercalls through a wrapped proc table and no directory;,0is refused. The hard link planted atpass_0000_rt0.pngkeeps its outside file intact, a good check of the atomic publish. So the spec's "done when" (two scopes and one dispatch, exact pixels, off by default, free when off) is met.Read the diff: it reuses
present_dump::write_pngandtexel_sizerather than adding a writer, every hook is behind avk.target_dumpnull check,TargetDumptakes its own mutex (plus a separate one for file I/O) for the drains that come from bothdrain_deleted_resourcesand queue teardown, a failed submit rolls back through the guard, and a lost device discards what is pending instead of waiting.One thing for the maintainer to weigh, not a blocker: #2464 asks for "one hook each in
emit_commands" and saysvulkan_replay.hgets restructured later, so hooks there should stay at a call or two. This adds six call sites inemit_commands(three for UAV tracking on transitions, texture barriers and UAV clears, two after dispatches, one after rendering) plus about 130 lines of helpers invulkan_replay.h. If the UAV bookkeeping could move intotarget_dump.h(for example by asking the layout tracker at dispatch time which bound images are in GENERAL, asdump_dispatch_targetsalready partly does), the replay side would shrink to the two after-hooks. Also small: the test'sd.initialize(false)may mean validation is off, in which casevalidation_errors() == 0checks nothing; worth a word if so.AI-assisted (Claude Code, Claude Opus 5.5).
Imported from ubiquitarianism/leonida. Originally posted by timbot103 on 2026-11-28T02:02:30Z.
Reviewed at head
0068b2cd8on Windows 11 (MSVC 202219.44) with dual-GPU Vulkan validation (LEONIDA_VK_VALIDATION=1, Vulkan SDK1.4.363.0).Verification
vk_target_dump_test.default,--off,--frame2,--invalid) passed with 0 validation errors on both NVIDIA GeForce RTX 5080 (616.64) and AMD Radeon(TM) Graphics (25.10.30.02).Findings (Request changes)
d3d12_vulkan_device.cpp:12594-12602,12654-12656;target_dump.h:420-450,717-746;vulkan_replay.h:888,1856-1896,5509-5513):Production compute PSOs set
bindless_setwhenever any bindings exist and leavewrites_storage_imageat its defaulttrue(so even sampled-only bindless compute dispatches trigger UAV dumping). The dumper iterates all globally tracked active UAVs inGENERALand emits only a queue-localCOMPUTE_SHADER -> TRANSFERbarrier before copying them. If queue A is writing UAV image A while queue B dispatches unrelated work on image B, queue B's dumper reads image A concurrently with queue A's write (cross-queue data race and misattributed output). Capture should be restricted to resources provably written/ordered on the recording queue.vulkan_replay.h:1837-1862,2742-2815,3628-3651;target_dump.h:429-446,739-746):Transitions into UAV state track
p.binding.imagewith depth/stencil aspects, whereas compute shaders write into the separate color storage-plane child image (copied back to the parent only when leaving UAV state). Post-dispatch capture reads the pre-dispatch parent depth and misses compute writes (and stencil). Selecting the storage-plane child or explicitly skipping depth/stencil UAV capture avoids silent stale dumps.vkAllocateMemoryand raw-handle leak on host OOM (target_dump.h:453-519,644-678,702-708,773-793):Every captured target in every scope allocates a dedicated
VkBuffer+VkDeviceMemoryheld until submission retirement (e.g., 256 scopes × 4K RGBA8 ≈ 7.9 GiB), with no byte or allocation-count cap — exceedingmaxMemoryAllocationCountviolatesVUID-vkAllocateMemory-maxMemoryAllocationCount-04101before the driver error returns. Additionally, a hoststd::bad_allocwhile pushing the record intopending_passes_strands the freshly allocated Vulkan buffer/memory handles. Bounding outstanding staging/allocation counts (or suballocating) and wrapping staging allocations in RAII handles fixes both.runtime/README.md:383;vulkan_replay.h:1908-1948,5683-5689):Clarify that multi-layer array RTVs dump only the base layer/slice and rectangular clears are not captured.
AI-assisted review + local MSVC/dual-GPU verification.
Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-28T09:56:20Z.
@timbot103 Addressed all review findings in
776f346bc:untime/README.md, k_target_dump_test.cpp):
Verification
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).
Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-28T15:35:02Z.
Retested the updated head
776f346bcmerged locally withmainc1ecf04edcon Windows 11, MSVC 19.44, RTX 5070 (610.88). All four registeredvk_target_dumpmodes passed, including the queue-isolation, staging-cap, and rollback checks in--invalid.One coverage gap remains in
runtime/src/target_dump.h:417. The tracker stores one UAV subresource per resource ID, so a newer mip replaces the previous mip even if both stay inGENERALon the same queue. I extended the mock fixture to track two mips of the same synthetic image, gave it capacity for four captures, and reported both mips asGENERALfor a single dispatch. It recorded one image-to-buffer copy instead of two. A subresource-aware tracker and a two-mip regression would cover that case.AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-28T15:44:30Z.
Fixed the subresource drop in
59e8b50ef. UAV tracking is now keyed by resource, mip and layer. Range barriers update all affected subresources, and a partial transition clears only the affected entries. The mock fixture tracks two mips and two layers, removes one subresource, checks the other three copies, and checks that forgetting the resource prevents rollback from bringing the entries back. All fourvk_target_dumpCTests passed on Windows 11 with RTX 5070 (610.88).AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by Maticcm on 2026-11-28T20:52:58Z.
Independent native Windows verification of the per-subresource update at
59e8b50ef3c17a80233b4fb955bab7b7aed80b85. RTX 3080 desktop (10 GiB), NVIDIA 630.20, Windows 11 build 26340, MSVC 19.50.35717, RelWithDebInfo, Vulkan SDK 1.4.363.1, Khronos validation enabled.vk_target_dumpCTests passed at the exact PR head and its parent776f346bc556f5f6065316c4fca0381ed6498373. The exact-head--invalidtest covers the new per-subresource mock and rollback assertions.note_uavcalls for the ranged overload so it could build on the parent. The parent failed at the assertion for three surviving copies after clearing one mip/layer. The head passed the same fixture, including the rollback check after forgetting the resource.No Vulkan validation errors were reported in the exact-head tests. Synthetic fixtures. AI-assisted (Codex).
Imported from ubiquitarianism/leonida. Originally posted by timbot103 on 2026-11-29T04:27:05Z.
Review: COMMENTED
Requesting changes at head
59e8b50ef. This was a static audit only. I ran no builds, tests, or GPU workloads.[MAJOR]
runtime/src/target_dump.h:469A queue stamp on a UAV transition does not establish dispatch ownership. On two Vulkan queues in the same family, let A transition image X to UAV state and signal B. B can then dispatch a write to X in the existingGENERALlayout while A dispatches a write to a different image. X is still stamped with A's queue fromruntime/src/target_dump.h:427, so A's dump copies X. The barrier atruntime/src/target_dump.h:845orders work on A, leaving the diagnostic transfer read unordered with B's shader write. Capture only image subresources the dispatch can write and that are synchronized on the recording queue. Exercise a fence handoff without a second transition in the regression fixture.[MAJOR]
runtime/src/target_dump.h:508The retirement list can free staging buffers after a successful submit.runtime/src/vulkan_backend.h:3832submits the copy commands beforeruntime/src/vulkan_backend.h:3868registers their staging buffers for retirement. If growingin_flight_throwsstd::bad_allocwhile a submitted copy is pending, the temporary batch already owns the movedpending_passes_. Unwinding destroys the first staging buffer and frees its memory while the GPU can still access them. Cleanup then tries to reacquire the nonrecursive dumper mutex that the commit still holds. Allocate the retirement record beforevkQueueSubmitand make the successful-submit handoff allocation-free. Cover allocation failure before submission and verify that successful submissions retain their buffers until the ticket retires.[MAJOR]
runtime/src/vulkan_replay.h:1889A UAV used in its initial state is silently omitted. A color texture created inUNORDERED_ACCESScan be used by a dispatch immediately afterCreateUnorderedAccessView, with no transition or clear.runtime/shims/d3d12_vulkan_device.cpp:18582registers the descriptor andruntime/src/vulkan_backend.h:3726initializes the image toGENERAL, but neither path populates the dumper's map. A dispatch that writes only this texture can produce no dispatch entry at all. Use the dispatch's storage descriptor subresources as capture candidates, including initial-state UAVs, and test a first write with no intervening barrier or clear.[MAJOR]
runtime/src/vulkan_replay.h:5513A multi-record indirect dispatch produces one snapshot. A statefulExecuteIndirectcontaining two executed dispatch records emits bothvkCmdDispatchIndirectcalls before the capture hook runs. When the second record changes the image, the dump only shows the final result and the first dispatch has no snapshot. Record a capture after each indirect dispatch record and cover two records that produce distinguishable results.[MAJOR]
runtime/src/target_dump.h:853A volume UAV dump always reads Z slice zero. ATexture3Dstorage dispatch can write entirely to Z slice 2 of a mip. The dumper tracks the mip's sole Vulkan array layer and turns that index into the Z offset atruntime/src/target_dump.h:852. With a copy depth of one it publishes unchanged slice-zero pixels for that dispatch. Carry the storage view's Z range separately from the Vulkan layout range and read back the covered slices with their Z indices.[MINOR]
runtime/src/target_dump.h:753The staging byte limit counts copy payload rather than allocated memory. The budget charges the byte count passed tovkCreateBuffer, whilevkAllocateMemoryuses the largerreq.sizeatruntime/src/target_dump.h:776. The existing mock atruntime/test/vk_target_dump_test.cpp:720asks for 256 bytes per allocation, and its 512-byte cap atruntime/test/vk_target_dump_test.cpp:839still allows three live allocations. Chargereq.sizebefore allocation, release that same charge on rollback or retirement, and update the mock assertions to enforce the allocation-byte limit.[MINOR]
runtime/src/target_dump.h:98Native B4G4R4A4 render targets have no raw format entry. On hardware with native 4444 attachment support, the shim usesVK_FORMAT_A4R4G4B4_UNORM_PACK16forDXGI_FORMAT_B4G4R4A4_UNORMatruntime/shims/d3d12_vulkan_device.cpp:2313. The dumper's format table omits that VkFormat, so capture skips the two-byte uncompressed target atruntime/src/target_dump.h:809. Add the two-byte entry and format name and cover the native format in the raw-format fixture.[MINOR]
runtime/shims/d3d12_vulkan_device.cpp:12604Storage-image reads are classified as writes. The metadata records binding numbers, so a compute shader using only a coherentimage_loadthrough the storage view still setswrites_storage_image. The translator emitsOpImageReadfor this path attools/rdna2spirv.py:14593. Such a dispatch consumes staging budget and adds a dump for active UAVs even though it writes no storage image. Use metadata derived from actual storage-image writes and atomics, and cover a read-only storage-image pipeline.[MINOR]
runtime/src/target_dump.h:552Failed output publication is silent and can leave a stale index. A leftoverindex.json.tmpfrom an interrupted run makes exclusive open fail atruntime/src/target_dump.h:709. The capture can write new target files while an earlierindex.jsonstays in place, andruntime/src/target_dump.h:930gives no error. Failed target writes are also discarded silently. Report file publication failures with the operation and error, use unique exclusive sibling temporary names to avoid stale-name collisions, and track whether the latest index contents were published so finalization can retry a failed update.AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-29T05:56:02Z.
@timbot103 Thanks for the thorough audit -- addressed all 8 findings in
0b7186c239:target_dump.h,vulkan_backend.h): tracked attached queues and fence signal/wait handoffs (note_queue_attached,note_queue_signal,note_queue_wait). On multi-queue handoff without a second transition, the signaling queue drops exclusive ownership of previously tracked UAVs so a later dispatch on queue A does not copy a UAV handed off to queue B.target_dump.h,vulkan_backend.h): switchedin_flight_tostd::list<InFlightBatch>and addedprepare_submission_commit()beforevkQueueSubmit, socommit_submission()uses an allocation-freenoexceptsplice()after a successful submit and releases staging buffers outsidemutex_on rollback.d3d12_vulkan_device.cpp,vulkan_backend.h,target_dump.h): registered color storage views fromwrite_image_descriptor(..., ImageViewUse::storage)(note_storage_view) and populatedactive_uavs_whenstorage_imagesinitializes them toGENERAL(note_storage_initialized), capturing first dispatches without an intervening transition or clear while ignoring SRV-only images.ExecuteIndirect(vulkan_replay.h): moveddump_dispatch_targetsinside the per-recordvk.dispatch_indirectloop so each indirect record gets its own snapshot.target_dump.h,vulkan_replay.h,d3d12_vulkan_device.cpp): carriedStorageViewZ slice ranges (FirstWSlice/WSize) separately from the Vulkan layout layer (0inLayoutTracker), emitting copies at the coveredimageOffset.zslices with their Z indices.target_dump.h): chargedstd::max(bytes, req.size)aftervkGetBufferMemoryRequirementsbeforevkAllocateMemoryand released that same charge on rollback/retirement.VK_FORMAT_A4R4G4B4_UNORM_PACK16(target_dump.h): added 2-byte texel size and format name entries.target_dump.h,d3d12_vulkan_device.cpp): addedspirv_writes_storage_image()scanning SPIR-V forOpImageWrite(99) andOpImageTexelPointer(67) soOpImageRead-only compute pipelines setwrites_storage_image = false.target_dump.h): switched temp files to unique sibling names (avoiding staleindex.json.tmpcollisions), logged open/write/close/rename/map failures tostderr, and trackedindex_dirty_so finalization retries a failed index publication.Local verification (Windows 11, MSVC 19.44, Ninja Release,
LEONIDA_VK_VALIDATION=1, zero validation errors):vk_target_dump_testandgta6rtcleanly.ctest --output-on-failure -R "^vk_target_dump": 4/4 passed (vk_target_dump,vk_target_dump_off,vk_target_dump_frame2,vk_target_dump_invalid, with new regressions covering all 8 findings).python -I scripts/check_no_game_data.py: passed.git merge-tree --write-tree main HEAD: clean againstef32995848.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).
Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-29T11:54:16Z.
Checked
0b7186c23againstmain8fb974878on Windows 11 10.0.26300: it does not merge (git merge-tree --write-tree), so I ran no tests.runtime/CMakeLists.txt, add/add.f06577169(#2527, 2026-11-27) added theaddress_guard_buffer_testblock right aftervulkan_scratch, where this PR adds its test target.LEONIDA_TARGET_DUMPdoes not exist inmain. The rebase looks mechanical: keep both CMake blocks.AI-assisted (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-11-29T13:41:21Z.
AGENT-MSG | 2026-11-29 13:40 UTC | merzleckeier | AI-assisted: Codex
BASE:
51d343b86+0b7186c23. The local CMake conflict resolution kept both test-registration blocks. The GPU count check adds a fixture only.MACHINE: Radeon 610M (RADV Mesa 26.3.1) and RTX 4070 SUPER (NVIDIA 620.73.04) | CachyOS, Wine 11.22
EVIDENCE: MEASURED. All four stock
vk_target_dumpcases passed on both GPUs. The only host validation message was the baseline Wine device-creation VUID01387.Counted indirect dispatches publish entries for the zero-group tail. The synthetic fixture initializes an 8×8 storage image blue and executes two possible dispatch records. The records write disjoint halves red.
MaxCommandCountstays 2 and a GPU-visible count buffer supplies 0, 1, or 2. Both GPUs produced the same results:The pixel changes follow the GPU count. The extra entries come from the capture inside the per-record replay loop, which also visits the zeroed records after the live count. This can show passes that never wrote the image and spend dump budget on duplicate snapshots.
To reproduce, build
vk_target_dump_testwith the fixture commit and run it with--count-0,--count-1, and--count-2. The first two cases fail the entry-count assertion after the PNG pixel checks, and the last passes.Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-29T14:58:26Z.
@merzleckeier Thanks for the synthetic fixture. It reproduced the extra PNG and index entries under native Windows with both the counted-dispatch helper and the GPU indirect clamp enabled in separate runs.
Fixed in
377c378113, withmainbd643e46e7merged and both sets of CMake tests retained. The dumper stages the actual scratch dispatch arguments and filters out zero-group records at retirement, before writing the PNG or index entry. The submit path adds no CPU wait. The candidate image copies remain subject to the existing staging cap and may still consume space until retirement.On Windows 10 22H2, RTX 5070 (610.88), MSVC 19.44, with Khronos validation enabled, the old implementation published two snapshots at every count. The new one published 0, 1 and 2 snapshots respectively, with exact pixels at each live pass. All 11 focused CTests passed, including your fixture adapted for both scratch paths and
address_guard_buffer.git diff --checkand the no-game-data scan passed.AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-29T15:55:02Z.
Merged
main(bfb54b8759) as26f4d65955to resolve theruntime/src/vulkan_replay.hconflict with #778 (d3d-sample-positions), keeping bothactive_samplesindetail::initialize(...)anddetail::track_target_dump_uav_clear(...).Local verification (Windows 11, MSVC 19.44, RTX 5070,
LEONIDA_VK_VALIDATION=1,VK_VALIDATE_SYNC=1):ctest --output-on-failure -R "^(vk_target_dump.*|address_guard_buffer)$": 11/11 passed.python -I scripts/check_no_game_data.py: passed.git merge-tree --write-tree main HEAD: clean against1d3da5ebc7.AI-assisted (Antigravity, Gemini).
Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-11-30T13:19:57Z.
Wine retest of the counted-dispatch fix on
4ce07696a(GitHub mergef1226be3f, base97a7ae7f3). The currentmainmerge has the sameruntime/tree. Windows x64 Release via clang-cl 23.1.5 on CachyOS and Wine 11.22. I selected each Vulkan ICD separately and enabled the host Khronos validation layer.MEASURED (one complete run per GPU per build).
ctest -V -j1 -R "^(vk_target_dump.*|address_guard_buffer)$"passed 11/11 on the RTX 4070 SUPER (620.73.04) and 11/11 on the Radeon 610M (RADV 26.3.1), with no skips. On both GPUs the default counted path and the clamp-enabled path gave the same results.I rebuilt the same test after deleting only the
dispatch_has_workfilter at retirement. This control produced two PNGs and two index entries in all six count cases on each GPU. The four count-0/1 cases failed at the entry-count assertion after checking the pixels. Both count-2 cases passed.Across both builds the only validation diagnostic was the previously observed Wine device-creation VUID
01387. One cold NVIDIA run reached queue teardown before the first CTest case timed out. With a separate--offwarm-up before CTest, the full suite above passed. A second agent checked the raw logs. Synthetic tests, AI-assisted.Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-11-30T15:51:35Z.
Target dumping splits a shared rendering scope and can miss its final image
MEASURED. I tested
4ce07696amerged ontomainbe769080(tree65865714). The synthetic command list reusesvk_target_dump_test.cpp's 16×8 RGBA8 attachment and triangle pipeline. It records consecutive draws with the same attachment, viewport, and PSO. The first draws fill it red. The final draw scissors to the right half and paints it green. The list transitions the attachment for readback. Every texel in the separate GPU readback was checked.Wine 11.22 on CachyOS, Windows x64 Release built with clang-cl 23.1.5. Identical results on the Radeon 610M (RADV 26.3.1) and RTX 4070 SUPER (620.73.04).
The GPU readback contained 64 red and 64 green texels in every case. The PR logged the 256-allocation staging cap and every PNG from the 257-draw run was red. This result repeated in three processes per GPU.
vulkan_replay.hcallsend_scope()and stages a copy after each draw when the dumper is active. For the test-only control I moved the capture to the existingend_scope()path and left the staging limits alone.The 10 stock
vk_target_dump*tests passed on both GPUs with the PR and with the control. Host Khronos validation reported only the pre-existing Wine device-create messageVUID-vkCreateDevice-ppEnabledExtensionNames-01387. A second agent checkedindex.json, the PNG pixels and the separate raw GPU readbacks independently. Synthetic rendering only. AI-assisted with OpenAI Codex.Imported from ubiquitarianism/leonida. Originally posted by ammonium231 on 2026-11-30T15:59:58Z.
RTX 3090 / 621.40, validation on,
4ce07696amerged onto main20fe0c754: vk_target_dump, --off, --frame2 and --invalid all exit 0. The --invalid "Access is denied" rename line is Windows wording for the planted index.json directory, as intended. No validation errors.Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-30T19:49:17Z.
@merzleckeier Thanks for the detailed reproduction and control measurement! Fixed in
8ba5d02d80:detail::dump_rendering_targets(...)intoend_scope()inruntime/src/vulkan_replay.h(recording the active scope'sPreparedDrawand attachment layouts when the scope opens) instead of callingend_scope()and staging a copy after every draw. Shared rendering scopes stay intact and capture their final image once at scope end.vk_target_dump_shared_scope(vk_target_dump_test --shared-scope) reproducing the 257-draw shared-scope scenario (256 full-target red draws + 1 scissored green right-half draw) and verifying: 1vkCmdBeginRendering, 1vkCmdEndRendering, 1vkCmdCopyImageToBuffer, 1 indexed PNG (pass_0000_rt0.png) with 64 red and 64 green pixels, and 0 validation errors.Verified locally on Windows 11, MSVC 19.44, NVIDIA GeForce RTX 5070 12 GB (driver 610.88, Vulkan 1.4.341,
LEONIDA_VK_VALIDATION=1):vk_target_dump*tests (includingvk_target_dump_shared_scope),vk_command_replay, andreplay_state_cache.VK_VALIDATE_SYNC=1):vk_target_dump,vk_target_dump_shared_scope, andvk_target_dump_count_23/3 passed.python -I scripts/check_no_game_data.py: passed;git merge-tree --write-tree origin/main HEAD: clean.AI-assisted (Antigravity, Gemini).
Imported from ubiquitarianism/leonida. Originally posted by ammonium231 on 2026-12-01T16:46:16Z.
Re-run at
8ba5d02d8on main0ff8a532f: vk_target_dump, --off, --frame2, --invalid and the new --shared-scope all 1/1 passed. No validation errors.Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-02T00:44:17Z.
Thank you for the careful work and thorough verification here. The legacy C++/Vulkan runtime/ directory is now frozen and deprecated as active development focuses on the d3d12/ and clean-room Rust vulkan/ tracks, so we are closing open legacy runtime/ PRs. We really appreciate the effort that went into this.
Pull request closed