Skip to content

CLI: reuse the D3D12 host across translation workers - #1415

Closed
gurvancampion wants to merge 1 commit into
Marvisak:mainfrom
gurvancampion:topic/translate-shared-host
Closed

gurvancampion wants to merge 1 commit into
Marvisak:mainfrom
gurvancampion:topic/translate-shared-host

Conversation

@gurvancampion

Copy link
Copy Markdown
Contributor

Summary

victory translate --pipelines now opens one D3D12 host and builds one pixel stub before scanning files. Each worker borrows both, and VICTORY_PAIRS reuses the host after the workers finish. Initialization errors reach the caller before the scan. Explicit VICTORY_WARP=1 runs serialize pipeline creation while translation and DXIL validation remain parallel.

 translate::run
-  Host::new → drop after availability check
+  Host::new + stub_ps → keep for the scan
   each file → each worker
-    Host::new().ok() → stub_ps on success
+    borrow Host and stub_ps
     check emitted shaders
   VICTORY_PAIRS
-    Host::new
+    reuse Host when --pipelines is enabled

Evidence

Base ffe310e and head 61f2848 ran under GE-Proton11-12 with GPU and display access disabled. The regression test scans two synthetic files with two workers per file. The base control mirrors the old initialization order and fails with five initializations. Head passes with one and verifies that all four workers receive the same value.

Command Base Head
cargo xwin clippy --workspace --all-targets --locked --target x86_64-pc-windows-msvc -- -D warnings Pass Pass
cargo xwin clippy --workspace --all-targets --all-features --locked --target x86_64-pc-windows-msvc -- -D warnings Pass Pass
cargo xwin test -p victory --locked --target x86_64-pc-windows-msvc translate::tests::shares_pipeline_checks_across_files_and_workers 1 failed with 5 initializations 1 passed with 1 initialization
cargo xwin test -p victory --locked --target x86_64-pc-windows-msvc 1 passed 2 passed
cargo xwin test --workspace --locked --target x86_64-pc-windows-msvc --no-fail-fast 322 passed, 20 failed 323 passed, same 20 failures
cargo xwin test --workspace --all-features --locked --target x86_64-pc-windows-msvc --no-fail-fast 326 passed, 20 failed 327 passed, same 20 failures
cargo test -p victory-core -p victory-formats -p victory-game -p victory-pipeline -p victory-shader -p xtask --locked 140 passed 140 passed
cargo test -p victory-core -p victory-formats -p victory-game -p victory-pipeline -p victory-shader -p xtask --all-features --locked 140 passed 140 passed
cargo test -p xtask --locked repository_passes_policy Pass Pass
cargo xtask policy --staged Pass Pass
cargo fmt --all -- --check Existing differences Same differences
rustfmt --check --edition 2024 apps/victory/src/translate.rs Pass Pass
git diff --check origin/main HEAD Pass Pass

The unfiltered Windows failures require a D3D12 SM 6.6 device, a window, a missing Wine export, a working probe build path, or Git in the guest. Filtering those 20 tests passed both feature sets on both revisions.

Not verified

Native Windows, hardware and WARP pipeline creation, and scan timings remain unverified under the GPU halt. The WARP lock addresses the explicit software-adapter path described in the upstream concurrency report. PR #244

Merge Danger

Door Two-way. Reverting restores the previous host lifetime. The change involves no persisted state.

Blast Radius Local. The device lifetime affects the offline pipeline checks in victory translate, including the final pair pass when --pipelines is set.

AI disclosure

OpenAI Codex (gpt-6.2-sol) traced the call paths, implemented the change and regression test, ran verification, and drafted this description. Antigravity (Gemini 4 Neon) coordinated and reviewed the diff. The author reviewed the diff and description before opening the PR.

@DenRakEiw DenRakEiw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested merged cleanly onto main (ffe310e) on Windows 11 x64 (Rust 1.98.1 MSVC):

  • cargo test -p victory: 2 passed, 0 failed
  • cargo clippy -p victory --all-targets: 0 warnings
  • cargo xtask policy: ok

Clean CLI improvement reusing the D3D12 host across translation workers. Approving.

AI-assisted (Gemini 4 Neon).

Marvisak commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Merge candidate (unchanged). The new head 3ebc8e8 is a plain rebase onto main (67e8ae1). git range-diff shows the patch is identical to the previously reviewed 8668932. main's changes since then to crates/victory-shader/src/emit/host.rs are test-harness additions that don't touch Host::new or pipeline creation. So the earlier review still holds: scan in apps/victory/src/translate.rs builds one Host and stub pixel shader before the walk, returns a creation error instead of silently dropping the checks, and lends both to every worker and to VICTORY_PAIRS.

Minor, still not blocking: the test's temp directory is named by process id and made with create_dir, so a directory left over from an aborted run would fail it.

CI: passing.


Generated by Claude Code

@gurvancampion
gurvancampion force-pushed the topic/translate-shared-host branch from 8668932 to 3ebc8e8 Compare November 25, 2026 16:36
@Marvisak

Copy link
Copy Markdown
Owner

Automated triage for the maintainers, second look (a review against current main, with builds and tests where they could change the verdict).

Closing because main already has its effects. translate creates a Host once up front and fails if that fails. D3D12 devices are per-adapter singletons, so the workers of a file already share one device, and this only saves a device re-creation per file. The WARP serialisation is done more completely by #244 (now merged), which locks inside Host for every caller. The new test checks that scan calls its factory once, which is the new plumbing rather than a defect of main.

If this is mistaken, reply here with what was missed and it will be looked at again. Thank you for the contribution.

@Marvisak Marvisak closed this Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants