Skip to content

Add a mapped D3D12 trace sink for instrumented boot - #8271

Closed
gabrielsteglich wants to merge 2 commits into
ProjectLeonida:mainfrom
gabrielsteglich:feat/mapped-d3d12-boot-trace
Closed

gabrielsteglich wants to merge 2 commits into
ProjectLeonida:mainfrom
gabrielsteglich:feat/mapped-d3d12-boot-trace

Conversation

@gabrielsteglich

Copy link
Copy Markdown
Contributor

Claimed in coordination issue #8047

What and why

Boot diagnostics reported that flushing every D3D12 trace line to a busy disk could trigger the title's startup watchdog. Add --trace-d3d12-file FILE to write ordered records into a dedicated 64 MiB mapped file. Write complete lines before publishing them, mark a full file once, and keep the existing trace filtering active through exhaustion. Normal exit flushes and trims the file. boot_trace.py can read completed lines after a process terminates abnormally. The existing --trace-d3d12 stderr sink remains available.

Tested

  • Windows 11 build 26300, MSVC 19.44.35229, RelWithDebInfo, commit ad8cef77f over dde82f27e. Three focused CTests and all 23 test_boot_trace.py tests passed. Covered concurrent record ordering, normal exit, process termination, saturation, existing-file refusal, and stderr compatibility.
  • Three interleaved runs per mode with 100,000 synthetic lines on a local NTFS SATA SSD. Median writer time went from 149.379 ms for stderr to 16.544 ms for the mapped sink, or 29.924 ms including mapped-file finalization. This measures the synthetic writer on this SSD.
  • Also tested in a local integration with xmem: avoid a CRT init guard in physical-page startup tracing #8121 and Keep persistent storage paths within the boot caller buffer #8137 on NVIDIA RTX 3090 driver 621.01, Windows SDK 10.0.26100.0, Vulkan SDK 1.4.363.0 and Vulkan validation enabled. All 12 focused CTests passed. tiny_frame exited zero with both sinks, producing the same 19 ordered D3D12 records and zero validation errors.
  • Crash recovery uses the OS file cache. Retail watchdog behavior, Wine execution, and persistence after power loss remain unverified.

AI-assisted (Codex).

  • Synthetic fixtures only. No game data, keys or decryption.

@MartinIndra02

Copy link
Copy Markdown
Contributor

Independent build + test: PASS

AI-assisted (Claude Code). Windows 11 x64, MSVC 19.44.35220, Ninja RelWithDebInfo, Python 3.13 (-I). GPU (not used): NVIDIA GeForce RTX 3080 driver 621.24 / 32.0.16.2124.

Head ad8cef77f, merged locally with current main 867d922f0 (CMakeLists.txt, docs/boot.md, tools/boot_trace.py and tests/test_boot_trace.py auto-merged). Reconfigured and built d3d12_trace_file_fixture, gta6rt, tiny_game and startup_trace_test.

Test Result
`ctest -R "^(d3d12_trace_file startup_trace)$"`
python -I -m unittest discover -s tests -p test_boot_trace.py Ran 24 tests, OK

Code check:

  • record() bounds each line so that written + line + truncation line stays within the mapping. The terminator byte start[length] therefore stays inside the view, including when the truncation line itself is appended.
  • --run closes and trims the file before ExitProcess, and the CloseD3D12Trace guard covers the other return paths.

One note: if the host process is killed (crash, Task Manager), the file stays at the full 64 MiB with zeros after the last record. The \0-terminated reader handles that, but it's worth one line in runtime/README.md. No issues found.

@kristofbarany

Copy link
Copy Markdown

Tested ad8cef7 merged onto main 6312c05 (clean merge) on Windows 11 Pro 26300, CPython 3.12.10: pass.

  • python -I tests/test_boot_trace.py: Ran 24 tests, OK; main has 22, also OK.

No game data used. AI-assisted (Claude Code).

@comtek21516

Copy link
Copy Markdown

Tested ad8cef77f on main at 867d922f0, in one tree with #8163, #8050, #8222, #8221 (five clean merges; the changes do not depend on each other): pass.

For this change. Native: the new ctest d3d12_trace_file passes, and so do d3d12_trace and startup_trace; tests/test_boot_trace.py in the merged tree: 24 tests, OK. Under Wine startup_trace passes; d3d12_trace_file and d3d12_trace are skipped there because the runner does not start Python-driven tests, so the mapped sink itself is only exercised natively in this run.

Setup. Built with MSVC 14.52 (Visual Studio 18), Windows SDK 10.0.26100, Vulkan SDK 1.4.363.1, Ninja RelWithDebInfo on Windows Server 2025 (no Vulkan driver there), then the same binaries run through scripts/run_wine_tests.py under wine-11.0 (WineHQ stable, xvfb-run) on a Quadro RTX 4000 (Turing), NVIDIA 615.71.09, Ubuntu 22.04.5, where the layer tests report device: Quadro RTX 4000.

passed failed skipped
native Windows, this tree 148 4 124
Wine on the GPU, main 867d922f0 210 12 54
Wine on the GPU, this tree 210 12 55

Under Wine the tree is test by test the same as main; the one extra skip is #8271's new d3d12_trace_file, which the Wine runner does not start (it is driven by Python). The four native failures are gameinput_host, d3d12_sparse_queue_family, vk_bindless_ps_tex and vk_bindless_ps_imgatomic, which fail the same way on main on that machine (#7452). The 12 under Wine are the same 12 as on main: host comparisons Wine cannot answer and three tests also reported failing on native NVIDIA (d3d12_xdxr_rt, d3d12_indirect_rt, d3d12_indirect_dispatch_count).

Because the five were built together, there is no per-PR negative control in this run: a regression would have shown as a difference from main, and there is none. No game files used. AI-assisted (Claude Code).

@Kerwinss

Copy link
Copy Markdown

Tested ad8cef7 on Windows 11 Pro 10.0.26300, MSVC 14.51 (VS Build Tools 2026), Windows SDK 10.0.26100, NVIDIA GeForce RTX 4060 / 621.24, Khronos Vulkan headers via -DLEONIDA_VULKAN_HEADERS_FETCH=ON: pass, no regression.

Merged onto main 6312c05 (clean), full runtime build, ctest -C RelWithDebInfo -j4: 238/240. The only failures are the two main has on this GPU (d3d12_depth_resolve, fixed by #7985; d3d12_vulkan_device:6574).

The new d3d12_trace_file passes, as do startup_trace, d3d12_trace and device_proxy_trace. python -I tests/test_boot_trace.py passes with this PR merged (and on main).

AI-assisted (Claude Code). No game files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants