Skip to content

d3d12: say how many submissions were not yet seen finished when the device went (D3D12-REMOVAL-CONTEXT-IN-AIR) - #2705

Merged
MoonEyes merged 2 commits into
ProjectLeonida:mainfrom
Kal0s-design:fix/removal-context-in-air
Dec 1, 2026
Merged

MoonEyes merged 2 commits into
ProjectLeonida:mainfrom
Kal0s-design:fix/removal-context-in-air

Conversation

@Kal0s-design

@Kal0s-design Kal0s-design commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: D3D12-REMOVAL-CONTEXT-IN-AIR (#2570 (comment))

What and why

When the host device is removed, host::removal_context writes what the submitting thread was doing. For every phase except "waiting for the card" it appends "(nothing of ours was running on the card)". With submissions sent ahead, the submitting thread is often preparing the next submission while earlier ones haven't been seen finished. The same line then ends with submissions started X finished Y, and X > Y contradicts the claim that the card was idle. Someone reading a removal report takes the wrong lead from it.

The phase text now comes from a small submitting_phase(phase, in_air), where in_air is STARTED - FINISHED: the submissions of ours started and not yet seen finished. It says "nothing of ours was running" only when that number is 0. Otherwise it gives the number, as "1 submission / N submissions of ours started and not yet seen finished" (STARTED counts a submission from the start of its preparation, so the one being prepared is included; wording corrected in d359078 after review). That count is of what wasn't observed complete, not proof that those lists were still executing, and the wording says only that. "Waiting for the card" and everything else in the report are unchanged.

This is the same change as TaynanGT/Vice-Tay#451 on the same code (VIctory lineage).

Tested

  • New host::trail::the_removal_phase_names_submissions_not_yet_seen_finished checks the five shapes (idle, 1, N, waiting, copy-back). As a negative control, ignoring in_air makes it fail. The existing the_removal_report_says_the_newest_things_done still passes.
  • cargo test -p leonida-gpu --lib: 560 passed, 0 failed, 50 ignored.
  • cargo clippy -p leonida-gpu --all-targets: no warning in the changed lines. The workspace-wide -D warnings run already stops on main, in leonida-lua and leonida-shader.
  • Windows only; Linux and macOS not covered.

GPUs tested: n/a (CPU unit tests)

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

🤖 Generated with Claude Code

…evice went

The device-removed report (removal_context) said "(nothing of ours was
running on the card)" for every phase of the submitting thread but
"waiting for the card", also when submissions sent ahead were still not
seen finished: the same line's "submissions started X finished Y" could
say otherwise, and the report read as an idle card when it may not have
been.

The phase now carries the number of submissions of ours sent and not yet
seen finished (STARTED less FINISHED), and says nothing of ours was
running only when that number is 0. Nothing else in the report changes.

Same change as TaynanGT/Vice-Tay#451 on the same code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@merzleckeier

Copy link
Copy Markdown
Contributor

Independent Wine check of 0695de54 merged onto main 171af5d93. The two stock host::trail tests passed on RTX 4070 SUPER (NVIDIA 620.73.04) and Radeon 610M (RADV 26.3.1), Wine 11.22, VKD3D-Proton 3.1.0, Rust 1.98.1 MSVC diag with diagnostics.

There is a distinction between started and sent in the report. Host::submit increments STARTED at submit: gathering what to ask about, before preparing the lists and advancing the queue sequence or calling ExecuteCommandLists. Consequently STARTED - FINISHED includes the current submission during preparation.

I captured the actual removal_context() immediately after that increment in a fresh process submitting a synthetic 512-byte copy. On both real adapters the snapshot had queue sequence 0, STARTED=1, FINISHED=0. The line was preparing a submission (1 submission of ours sent and not yet seen finished). After the synchronous submission returned, the queue sequence was 1, STARTED=FINISHED=1, and all 512 readback bytes matched. The test invoked the formatter alone during preparation and completed on healthy GPUs.

I verified the wording 1 submission of ours started and not yet seen finished (plus the plural equivalent) in a local comparison. Both stock tests and the new preparation test passed, 3/3 on each GPU. This wording describes the existing counter, including preparation.

AI-assisted: yes (OpenAI Codex).

STARTED is counted at the start of a submission's preparation, before its
lists go to the queue, so while the submitting thread prepares one, that one
is among STARTED less FINISHED. 'sent' claimed more than the counter holds;
'started and not yet seen finished' is what it counts (review by
merzleckeier).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Kal0s-design

Copy link
Copy Markdown
Contributor Author

Thanks, that's right: STARTED is counted at the start of preparation, so the one being prepared is in STARTED - FINISHED. Pushed d359078, which says "started and not yet seen finished" (singular and plural) and notes in the doc comment what the counter includes. host::trail tests pass (2/2).

AI-assisted: yes

@merzleckeier

Copy link
Copy Markdown
Contributor

Confirmed d35907845 merged onto main 4014af7fe with the original synthetic 512-byte copy under Wine 11.22 / VKD3D-Proton 3.1.0. On both RTX 4070 SUPER and Radeon 610M the report now says 1 submission of ours started and not yet seen finished while the queue sequence is still 0. After submission, all 512 bytes match. The two stock host::trail tests and the preparation probe passed 3/3 on each adapter.

AI-assisted: yes (OpenAI Codex).

@KelboLive

Copy link
Copy Markdown

Independent check on Windows (not the author), at d35907845.

  • cargo test --locked --jobs 8 -p leonida-gpu --lib -- --test-threads=8: 560 passed, 0 failed, 50 ignored in 14.2 s.

The diff is host.rs only (no new unit test), so this is compile + regression coverage; I did not repeat the Wine/512-byte-copy scenario already reported above.

Environment: Ryzen 9 7950X3D, Windows 11 Pro 10.0.26200.9711, NVIDIA RTX 4070 Ti SUPER (driver 621.01), Rust 1.98.1 pinned.

AI-assisted: yes (opencode).

@Kal0s-design

Copy link
Copy Markdown
Contributor Author

@KelboLive thanks for the Windows run. One correction: the diff does add a unit test in host.rs, host::trail::the_removal_phase_names_submissions_not_yet_seen_finished, which checks the in-air count in the removal-phase text (cargo test -p leonida-gpu --lib -- the_removal_phase_names).

AI-assisted: yes

@MoonEyes

MoonEyes commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

RUN - VERIFY-2705-RTX4060 - by MoonEyes (another person than the author) on head d35907845, with #2836, #2835, #2695, #2696, #2689, #2699 and #2705 merged together into main 9372a4d4f (clean).

  • Machine: RTX 4060 8 GB, Windows 11, diag profile, features diagnostics,mimalloc, Series S, BAR window off, texture budget 1024 MB.
  • In-game, no scripted action, 480 s asked, a session that loads into the world and stays: main 9372a4d4f and then main + the seven, one run each, same save: 0 device lost, 0 panics, 0 exceptions in both, about 490 s in the world each, alive at the time limit. Frame rate median 17.8 with the seven and 15.0 on main, not a comparison: other work ran on the PC during the main run.
  • Picture: screenshots every 60 s. The last four show the same scene in both runs (water, sky, the boat, the map) and look the same; the first four are cutscenes at different moments and were only looked at for broken textures (none seen). No screenshot is posted.
  • Tests on main 9372a4d4f + the seven (Windows): leonida-hle 243, leonida-gpu 602, leonida-formats 47, leonida 47, leonida-shader 403 of 405: two source_hash_tests failed on a stale build script of mine (a target folder shared with an older branch) and pass after a rebuild of it (3 of 3).

Limits: one card, one run per arm, two arms only, the seven together. Values only, no game data.

AI-assisted (Claude Code).

@MoonEyes

MoonEyes commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Merging. Head d35907845 merges cleanly with main 3bf2844a5 and does not force a rebase of #2566. CI green on this head and on main. In-game run on the RTX 4060 posted above (this head, with the six others, about 490 s in the world, 0 device lost, pictures compared with main). Tests on main + the seven: leonida-hle, leonida-gpu, leonida-formats, leonida, leonida-shader, 0 failed. Verified on it by KelboLive (Windows) and merzleckeier (Wine). Merged by MoonEyes.

AI-assisted (Claude Code).

@MoonEyes
MoonEyes merged commit 7fbcd45 into ProjectLeonida:main Dec 1, 2026
5 checks passed
@fiestorra

Copy link
Copy Markdown
Contributor

done: the merge is clean on Windows: descriptor/host.rs's sibling, host.rs, and the runner's suite with it.

main 7fbcd456e (after #2705, two commits, host.rs +36/-9), three runs of cargo test -p leonida-gpu --lib:

run 1:  ok. 600 passed; 0 failed; 55 ignored
run 2:  ok. 600 passed; 0 failed; 55 ignored
run 3:  ok. 600 passed; 0 failed; 55 ignored

Three runs because this crate is the one with the known concurrency flake - and none of them hit it, which is a sample of three and not evidence the flake is gone. What the three do establish is that the merge did not introduce a failure: 600 is one more than main had before, so #2705 brings a test with it.

And it lands on top of #2766 and #2852's area without any of the descriptor tests moving, which is the third change to descriptor/host.rs or host.rs today that the suite has absorbed.

AI-assisted: yes - DeepSeek v4.1 (flash), three runs on the merged tree.

Written with an AI assistant.

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.

5 participants