Device-method slot interface names + exit-time call summary (on top of #376) #495

Open
github-bot wants to merge 2 commits from github-bot/gh-495 into main AGit
Owner

@⁠ZaneIceMaster11 on GitHub · 2026-11-25 01:35 UTC · original
ZaneIceMaster11:feature/device-method-interface-names → main · +220 −17 · 7 files · 2 commits · open

Depends on #376 (VICTORY_SHADER_DIAG) - this diff includes that PR's changes too since GitHub won't let a PR target a branch that only exists on the fork. Once #376 merges this will shrink to just device.rs/lifecycle.rs.

What this adds

Addresses a review comment on #376: when a slot number is in the detail field, name the resolved D3D12 interface too, and add a per-slot total at process exit next to the running per-call counter.

Interface resolution

Computed exact PC vtable slot boundaries for IUnknown through ID3D12Device4 directly from the pinned windows 0.62.2 crate source (counting each ID3D12DeviceN_Vtbl's fields, accounting for how windows-rs keeps feature-gated fields at a fixed slot with a dummy type rather than removing them - confirmed this by reading the actual generated vtable structs, not assuming). Deliberately hedged past ID3D12Device4 (slot 56): this module's own doc comment already says the title's vtable only matches PC order until "console additions follow", and I found that boundary is demonstrably at or before Device5 - the file's existing hand-written comment claims Device5/Device8 each add 9 methods, but the pinned crate has 8 and 5. Both slots this project actually hits (0x1c8, 0x218) are past that boundary, so they now report "ID3D12Device5-or-later, console layout may diverge from PC here" rather than a wrong confident name - a bad guess here would be worse than the honest uncertainty.

Exit summary

unknown_pipeline's per-monomorphization static CALLS: [AtomicU32; 2] (a separate array per const-generic SLOT, despite looking shared) became one module-level Mutex<BTreeMap<usize, u32>> both instantiations write into, so report_unimplemented_calls() can summarize every slot at once. Called from lifecycle::end() next to the existing pipeline-cache save, since the process terminates via TerminateProcess there (no atexit/normal shutdown runs).

Verification

Real run (Series X, opening cutscene, no crash): exit summary printed exactly as designed, matching the live per-call counters seen during the run (slot=0x1c8 calls=25450, slot=0x218 calls=2689). Build, clippy (-p victory-gpu -p victory-hle --all-targets --release --features diagnostics), and tests (213, both crates) all clean.

Co-authored with Claude Code (Claude Sonnet 5).

**@⁠ZaneIceMaster11** on GitHub · 2026-11-25 01:35 UTC · [original](https://github.com/fxceless/victory-fork/pull/495) `ZaneIceMaster11:feature/device-method-interface-names` → `main` · +220 −17 · 7 files · 2 commits · open **Depends on #376 (VICTORY_SHADER_DIAG)** - this diff includes that PR's changes too since GitHub won't let a PR target a branch that only exists on the fork. Once #376 merges this will shrink to just `device.rs`/`lifecycle.rs`. ## What this adds Addresses a review comment on #376: when a slot number is in the detail field, name the resolved D3D12 interface too, and add a per-slot total at process exit next to the running per-call counter. ### Interface resolution Computed exact PC vtable slot boundaries for IUnknown through ID3D12Device4 directly from the pinned `windows` 0.62.2 crate source (counting each `ID3D12DeviceN_Vtbl`'s fields, accounting for how windows-rs keeps feature-gated fields at a fixed slot with a dummy type rather than removing them - confirmed this by reading the actual generated vtable structs, not assuming). Deliberately hedged past `ID3D12Device4` (slot 56): this module's own doc comment already says the title's vtable only matches PC order until "console additions follow", and I found that boundary is demonstrably at or before Device5 - the file's existing hand-written comment claims Device5/Device8 each add 9 methods, but the pinned crate has 8 and 5. Both slots this project actually hits (`0x1c8`, `0x218`) are past that boundary, so they now report `"ID3D12Device5-or-later, console layout may diverge from PC here"` rather than a wrong confident name - a bad guess here would be worse than the honest uncertainty. ### Exit summary `unknown_pipeline`'s per-monomorphization `static CALLS: [AtomicU32; 2]` (a separate array per const-generic `SLOT`, despite looking shared) became one module-level `Mutex<BTreeMap<usize, u32>>` both instantiations write into, so `report_unimplemented_calls()` can summarize every slot at once. Called from `lifecycle::end()` next to the existing pipeline-cache save, since the process terminates via `TerminateProcess` there (no `atexit`/normal shutdown runs). ## Verification Real run (Series X, opening cutscene, no crash): exit summary printed exactly as designed, matching the live per-call counters seen during the run (`slot=0x1c8 calls=25450`, `slot=0x218 calls=2689`). Build, clippy (`-p victory-gpu -p victory-hle --all-targets --release --features diagnostics`), and tests (213, both crates) all clean. Co-authored with Claude Code (Claude Sonnet 5).
Every existing shader/pipeline failure path already had its own ad hoc
tracing::warn!/info! (shader translation, root signature, mesh/graphics/
compute pipeline creation, the depth-bounds-test and rectangle-geometry-stage
shortcuts, the two unimplemented device methods at vtable slots 0x1c8/0x218).
That's fine for watching a live log, but there was no single, structured,
greppable place to answer "why doesn't this draw look right" across a whole
run - which is exactly what's needed to chase reports of low-poly models and
shaders not rendering: is a given pipeline hitting missing-shader, a refused
root signature or PSO, a dropped partial-support shortcut, or the device-
method gap, and how often.

VICTORY_SHADER_DIAG=<dir> (new, crates/victory-gpu/src/shader_diag.rs,
diagnostics-feature-gated like capture.rs/copystat.rs) appends one JSONL
record per classification to <dir>/shader-diag.jsonl: a classification
(ok/missing-shader/root-signature-refused/mesh-pipeline-refused/
pipeline-refused/rect-gs-fallback/depth-bounds-unsupported/state-not-kept/
device-method-unimplemented), the shaders involved (stage + content hash,
same hash VICTORY_SHADER_SAVE and crash reports use), and whatever detail
was already on hand at that call site - the graphics state's existing
describe() (input layout, render target/depth formats, blend, rasterizer)
on success, the host's rejection error on failure. Every hook sits next to
an existing tracing call and reuses its data; nothing new is computed only
for this. Off by default, zero cost when unset (the env var is read once
via OnceLock and short-circuits).

Also documents VICTORY_KEYBOARD_PAD in the README (added on another branch,
not yet merged) and fixes a crash::tests::unwinds_like_the_system_walk-class
regression gate issue: cherry-picked the .gitignore fix from that same
branch since this branch needed it too for the policy test to pass.

Verified: cargo build --release --workspace and --profile diag --features
diagnostics both clean. cargo clippy --workspace --all-targets --release,
with and without the diagnostics feature, both clean, 0 warnings.
cargo test --workspace: green except the two already-documented flaky tests
(state/findings/flaky-tests.md), both confirmed still at their established
rates, neither new.

Found and ruled out as a false lead while verifying: cargo test -p
victory-gpu --features diagnostics occasionally crashes
(STATUS_ACCESS_VIOLATION) under parallel test execution. Reproduced on the
unmodified code too (1/5 runs) and on this change (1/6 runs across two
batches) - statistically the same pre-existing rate, not caused by this
change. Documented as a third known-flaky pattern, same root cause class as
victory-shader's already-documented "two GPU tests at once on WARP can end
the test process with an access violation".

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Built on #376's VICTORY_SHADER_DIAG. A code-review suggestion on that PR:
when a slot number is in the detail field, name the resolved D3D12
interface too (even approximately), and add a per-slot total at exit
alongside the running per-call counter.

Interface resolution (crates/victory-gpu/src/device.rs): computed the exact
PC vtable slot boundaries for IUnknown through ID3D12Device4 from the
`windows` crate version this workspace actually pins (0.62.2), counting
each ID3D12DeviceN_Vtbl's fields with this workspace's enabled cargo
features (feature-gated fields keep their slot either way - windows-rs
gives them a dummy type when off, never removes them, so counting by
feature doesn't change the slot count). Verified against this crate's own
layout anchors (f[7] = GetNodeCount at 0x38, i.e. slot 7, matches IUnknown
being 3 methods + ID3D12Object's own 4). Deliberately hedged past
ID3D12Device4 (slot 56): the module's own doc comment already says the
title's vtable matches PC order only until "console additions follow", and
that boundary is demonstrably at or before ID3D12Device5 - this file's
existing hand-written comment claims ID3D12Device5 and ID3D12Device8 each
add 9 methods, but counting the pinned windows crate directly gives 8 and
5. A wrong confident interface name for the two slots this project actually
hits (0x1c8, 0x218 - both past that boundary) would be worse than the
honest "ID3D12Device5-or-later, console layout may diverge from PC here"
this now reports.

Exit summary: replaced unknown_pipeline's per-monomorphization `static
CALLS: [AtomicU32; 2]` (a separate array per const-generic SLOT
instantiation, despite looking shared) with one module-level
`UNIMPLEMENTED_CALLS: Mutex<BTreeMap<usize, u32>>` both instantiations
write into, so a single `report_unimplemented_calls()` can summarize every
slot hit. Called from victory_hle::modules::lifecycle::end(), next to the
existing `pipeline::save_pipeline_cache()` call - the process ends via
TerminateProcess there, which runs no atexit/normal-shutdown code, so this
has to be an explicit call at that one spot, not a registered handler.

Verified against a real run (Series X, the opening cutscene through a
scene transition, no crash): printed at shutdown exactly as designed -
`slot=0x1c8 calls=25450 interface="ID3D12Device5-or-later..."` and
`slot=0x218 calls=2689` - matching the per-call counters seen live during
the run.

cargo build --profile diag --features diagnostics, cargo clippy -p
victory-gpu -p victory-hle --all-targets --release --features diagnostics,
and cargo test for both crates (213 tests) are all clean.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:44:41 +00:00
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/pipeline/host.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

Merge

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