fix: put the runtime's background shader threads at idle priority when it refuses to stop them #307
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/307"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from LooperSalty/AnyXboxX. Originally posted by Skyfrye on 2026-11-26T02:05:27Z.
Change
The launcher's set has
VICTORY_D3D12_BACKGROUND=0, which asks the D3D12 runtime to switch its background work off (ID3D12Device6::SetBackgroundProcessingMode(DISABLE_BACKGROUND_WORK)). On a Windows without Developer Mode the runtime refuses: every run here loggedthe host's background shader work is switched off (VICTORY_D3D12_BACKGROUND=0) ok=false, and with this change the error is named: "The application requested an operation that depends on an SDK component that is missing". The driver then goes on recompiling shaders on four "D3D Background Thread"s in our process.What that costs, measured here (RTX 5080, Ryzen 7 9800X3D, launcher fast set):
nvgpucomp64.dll);Now, when the runtime refuses,
crate::background::watchstarts a thread of ours (lowest priority) that looks every 2 s for this process's threads named "D3D Background Thread" and puts each one found at idle priority, once. They still compile, on cores nothing else wants.windows-sysgets theWin32_System_Diagnostics_ToolHelpfeature for the thread list. Where the runtime accepts the switch, nothing changes.Linked issue: none.
Verification
Windows 11 26300, Rust 1.98.1 (MSVC), on upstream
mainatc4c93bd, fromthird_party/victory:The 3 failures are the same on
mainwithout this change:descriptor::host::tests::spans_say_the_next_start_and_the_lowest_level_viewed,indirect::tests::warp_card_fetch_copies_flagged_pieces_to_their_slots,indirect::tests::warp_card_patch_writes_the_masked_bytes_and_no_others.New test
threads_named_so_go_to_idle_priority_once: two threads of the test, one named with the prefix it looks for; that one is at idle priority after the call, the other is not, and a second call idles nothing. Revert check: without theSetThreadPrioritycall it fails (left: 0,right: -15).In the game (my copy, world, launcher fast set): the log says
the host refused to switch its background shader work off ... its threads go to idle priorityand, 34 ms later,the runtime's background shader threads put at idle priority ... idled=4 all=4.What I could not measure cleanly: the frame rate it gives. In four runs of a build with this and other changes, the first runs after an update of the translator still had the driver recompiling the new shaders on those threads, 3.0 cores at idle priority on cores that were free, and 0.0-0.3 cores in the later runs; the scene and the shader cache moved the frame rate more than this can. What it does do, as the log shows: the threads no longer run at the priority of ours.
Draft until a cleaner A/B (a run with the driver's work still to do, with and without the change).
Oracle and test data
No game file. The test makes its own threads.
Checklist
E_NOTIMPL), never a fake success. (Nothing unimplemented here.)AI assistance: written with Claude Code. Claude Opus 5.5 found the refusal in the logs and the threads in a profile, wrote the change and its test, and wrote this description.
🤖 Generated with Claude Code
Imported from LooperSalty/AnyXboxX. Originally posted by KainanP on 2026-11-26T10:32:29Z.
Test report for #307 on three adapters.
Merges cleanly onto current main. Setup: current
origin/main(c4c93bd) merged with this PR, Windows 11,cargo test --lockedinthird_party/victory. Adapters: RTX 4060 Laptop (DXGI 0), Intel UHD 8086:a78b (16-lane waves, no FP64), WARP. The hardware adapter is picked by name through a local, uncommitted test hook and confirmed in its log; WARP for victory-gpu is--features diagnostics+VICTORY_D3D12_WARP=1. victory-gpu runs with--test-threads=1.victory-gpu --lib"main's 3" =
descriptor::host::tests::spans_say_the_next_start_and_the_lowest_level_viewed,indirect::tests::warp_card_fetch_copies_flagged_pieces_to_their_slots,indirect::tests::warp_card_patch_writes_the_masked_bytes_and_no_others. They fail on all three adapters on main too.threads_named_so_go_to_idle_priority_oncepasses everywhere. No new failure.Notes from reading the diff:
donekeys on thread ids. If the runtime ends a background thread and a new one gets the same id, the new one is never idled. A minor case, but you could keep(tid, creation time)fromGetThreadTimes, or just re-check the priority.TH32CS_SNAPTHREADsnapshots every thread on the system, not only ours, every 2 s for the life of the process. That is cheap, but the watcher could stop once it has found the runtime's usual 4 threads and seen nothing new for a while.AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this.
Imported from LooperSalty/AnyXboxX. Originally posted by LooperSalty on 2026-11-27T13:03:01Z.
Closing: this draft conflicts with main and has had no activity from its author for more than 24 hours. Please reopen after a rebase on main if it is still wanted.
Pull request closed