runtime: add LEONIDA_TARGET_DUMP per-pass target dumper (RT-PASS-TARGET-DUMP) #2466

Open
github-bot wants to merge 1 commit from github-bot/gh-2466 into main AGit
Owner

@⁠lixonik on GitHub · 2026-11-27 13:15 UTC · original
lixonik:rt-pass-target-dump → main · +1900 −0 · 6 files · 1 commits · open

Implements RT-PASS-TARGET-DUMP (claimed in #1608).

Summary

  • Add runtime/src/target_dump.h implementing LEONIDA_TARGET_DUMP=<dir>,<frame> (1-based frame > 0).
    • Reuses leonida::present_dump::texel_size and leonida::present_dump::write_png directly from runtime/src/present_dump.h (without editing present_dump.h, avoiding conflicts with #2146).
    • Dumps render targets (color attachments and depth attachment) after each rendering scope and active storage-image UAVs after each storage-writing compute dispatch during the selected frame, as .png (for present_dump-supported formats) or tightly packed .raw (for other uncompressed color/depth formats), skipping multisampled and block-compressed images cleanly.
    • Atomically publishes each target file and index.json (frame, pass number, pass kind, slot, format, dimensions, mip/layer, bytes per texel, encoding, filename) via exclusive sibling .tmp creation + rename so pre-existing hard links outside the dump directory are never overwritten.
    • Off by default and free when off: ReplayFunctions::target_dump stays nullptr when unset, invalid, or once the target frame has completed and drained, reducing replay overhead to a single predicted null-pointer check in emit_commands with zero staging buffer allocations or copies.
  • Wire minimal hooks in 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 in emit_commands) and lifecycle integration in runtime/src/vulkan_backend.h (memory properties forwarding via set_occlusion_resolve_memory, per-submission commit/rollback on retire tickets, drain on ticket completion and queue/context teardown).
  • Document LEONIDA_TARGET_DUMP in runtime/README.md (marked *Diagnostic.*, noting files stay local).
  • Add runtime/test/vk_target_dump_test.cpp registered in runtime/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

  • Red check on main (690dea519): vk_target_dump_test.cpp fails to compile against main because target_dump.h and its replay/context hooks are absent.
  • Green check on rebased HEAD (0068b2cd8, base 17d3af0b6):
    • vk_target_dump -- PASS: two rendering scopes (scope 1 draws solid color to RT0; scope 2 overwrites RT0 with a second color and writes VK_FORMAT_R32_UINT raw values to RT1), one skipped non-storage compute dispatch, and one storage-image compute dispatch writing uav0; verifies index.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 0 vkCreateBuffer and 0 vkCmdCopyImageToBuffer calls and no files written.
    • vk_target_dump_frame2 -- PASS: <dir>,2 skips 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>,0 leaves dump disabled and does not create the directory.
    • Adjacent GPU tests: vk_command_replay, vk_queue, vk_present_dump, vk_present_dump_default, vk_present_dump_invalid -- 9/9 PASS; gta6rt.exe built cleanly.
    • WSL Ubuntu GCC 11.4 (-std=c++20 -O1 -g -fsanitize=undefined,address -Wall -Wextra -Werror) on target_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).
  • Note: VK_LAYER_KHRONOS_validation is not installed locally on this machine, so GPU tests ran without Vulkan validation layers. The test checks validation_errors() == 0 under LEONIDA_VK_VALIDATION=1 and skips with exit code 77 when 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).

**@⁠lixonik** on GitHub · 2026-11-27 13:15 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2466) `lixonik:rt-pass-target-dump` → `main` · +1900 −0 · 6 files · 1 commits · open Implements `RT-PASS-TARGET-DUMP` (claimed in https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608). ### Summary - Add `runtime/src/target_dump.h` implementing `LEONIDA_TARGET_DUMP=<dir>,<frame>` (1-based `frame > 0`). - Reuses `leonida::present_dump::texel_size` and `leonida::present_dump::write_png` directly from `runtime/src/present_dump.h` (without editing `present_dump.h`, avoiding conflicts with #2146). - Dumps render targets (color attachments and depth attachment) after each rendering scope and active storage-image UAVs after each storage-writing compute dispatch during the selected frame, as `.png` (for `present_dump`-supported formats) or tightly packed `.raw` (for other uncompressed color/depth formats), skipping multisampled and block-compressed images cleanly. - Atomically publishes each target file and `index.json` (frame, pass number, pass kind, slot, format, dimensions, mip/layer, bytes per texel, encoding, filename) via exclusive sibling `.tmp` creation + rename so pre-existing hard links outside the dump directory are never overwritten. - Off by default and free when off: `ReplayFunctions::target_dump` stays `nullptr` when unset, invalid, or once the target frame has completed and drained, reducing replay overhead to a single predicted null-pointer check in `emit_commands` with zero staging buffer allocations or copies. - Wire minimal hooks in `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 in `emit_commands`) and lifecycle integration in `runtime/src/vulkan_backend.h` (memory properties forwarding via `set_occlusion_resolve_memory`, per-submission commit/rollback on retire tickets, drain on ticket completion and queue/context teardown). - Document `LEONIDA_TARGET_DUMP` in `runtime/README.md` (marked `*Diagnostic.*`, noting files stay local). - Add `runtime/test/vk_target_dump_test.cpp` registered in `runtime/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 - **Red check on `main` (`690dea519`)**: `vk_target_dump_test.cpp` fails to compile against `main` because `target_dump.h` and its replay/context hooks are absent. - **Green check on rebased HEAD (`0068b2cd8`, base `17d3af0b6`)**: - `vk_target_dump` -- PASS: two rendering scopes (scope 1 draws solid color to RT0; scope 2 overwrites RT0 with a second color and writes `VK_FORMAT_R32_UINT` raw values to RT1), one skipped non-storage compute dispatch, and one storage-image compute dispatch writing `uav0`; verifies `index.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 0 `vkCreateBuffer` and 0 `vkCmdCopyImageToBuffer` calls and no files written. - `vk_target_dump_frame2` -- PASS: `<dir>,2` skips 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>,0` leaves dump disabled and does not create the directory. - Adjacent GPU tests: `vk_command_replay`, `vk_queue`, `vk_present_dump`, `vk_present_dump_default`, `vk_present_dump_invalid` -- 9/9 PASS; `gta6rt.exe` built cleanly. - WSL Ubuntu GCC 11.4 (`-std=c++20 -O1 -g -fsanitize=undefined,address -Wall -Wextra -Werror`) on `target_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). - Note: `VK_LAYER_KHRONOS_validation` is not installed locally on this machine, so GPU tests ran without Vulkan validation layers. The test checks `validation_errors() == 0` under `LEONIDA_VK_VALIDATION=1` and skips with exit code `77` when 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).
Add LEONIDA_TARGET_DUMP=<dir>,<frame> in runtime/src/target_dump.h to
dump render targets after each rendering scope and active storage image
targets after each storage-writing compute dispatch during one 1-based
frame, alongside an atomically published index.json.

Reuses leonida::present_dump::write_png for PNG-supported formats and
writes exact tightly packed .raw files for other uncompressed color and
depth formats. Off by default with a single null-pointer check in
emit_commands and zero staging allocations when unset or once the target
frame completes.

Add vk_target_dump_test covering two rendering scopes (PNG + raw MRT),
one storage-image compute dispatch, off-by-default zero-copy behavior,
frame selection, invalid settings, and hard-link-safe atomic output.

AI-assisted (Antigravity, Gemini 4 Neon).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 13:19:49 +00:00
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2466/head:github-bot/gh-2466'
git switch 'github-bot/gh-2466'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2466'
git switch 'github-bot/gh-2466'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2466'
git switch 'github-bot/gh-2466'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2466'
git switch 'main'
git merge --squash 'github-bot/gh-2466'
git switch 'main'
git merge --ff-only 'github-bot/gh-2466'
git switch 'main'
git merge 'github-bot/gh-2466'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.