d3d12-hle: terminating a composite task queue cancels only its own tasks (D3D12-HLE-XTASKQUEUE-COMPOSITE-TERMINATE) #2824
No reviewers
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
No due date set.
Reference
leonida/mandy!2824
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/xasync-composite-terminate"
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?
Pull request successfully merged and closed
Claimed in the coordination issue as: D3D12-HLE-XTASKQUEUE-COMPOSITE-TERMINATE (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7277115631)
What and why
A composite task queue (
XTaskQueueCreateComposite) shares its ports with the queue they came from.XTaskQueueTerminate(d3d12/crates/leonida-hle/src/modules/xasync.rs) drained every task on each of the terminated queue's ports. Terminating the composite therefore also took the other queue's pending tasks and ran them as canceled, while that queue was still open. The comment next to the drain already said the other queues' dispatches wait on; the code didn't do it for their tasks.The change:
Queue::id, from a counter, never reused).This ports ahmetbagci's fix from the sibling VIctory tree (TaynanGT/Vice-Tay
fa10fa3, GPL-3.0), credited as co-author.Tested
modules::xasync::tests::terminating_a_composite_queue_leaves_other_queues_tasks_queued: queue A and a composite B on A's ports each queue a task; terminating B cancels B's task and leaves A's queued, and A's then runs uncanceled. Onmain(90c514437) it fails (the other queue's task stays queued,left: 2,right: 0); with the change it passes.cargo test -p leonida-hle --lib: 241 passed, 0 failed, 2 ignored.cargo clippy -p leonida-hle --lib --tests: no warning in the changed lines.GPUs tested: n/a (CPU unit tests)
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no translator change)🤖 Generated with Claude Code
Verified on Windows with a mutation at the line the change exists for, and it fails in both directions - cancel your own, spare the others.
main90c514437, cherry-picked (the branch is atmain),cargo 1.98.1:The test arriving with the code is not the interesting part, so I made the change it names in
xasync.rs:415and watched both halves:So the tests pin the property from both sides:
truebreaks only the "spare the others" case,falsebreaks that one and the "cancel your own" case. That is the shape a fix like this needs - a one-sided test would pass withfalsein place and the queue would never cancel anything.What the change is, from the code: each queued task carries the id of the queue that queued it (
submit(owner, task)), and terminating partitions the queue by that id instead of draining it. A staticNEXT_QUEUE: AtomicU64hands out the ids; the comment says never reused.What I did not test: the real
XTaskQueueTerminatepath against a title's composite queue - that needs the game. The mock'srecordcallback and the two states it stores are what the tests drive, and they are green.AI-assisted: yes - DeepSeek v4.1 (flash), two mutations and three runs.
Written with an AI assistant.
Merging as part of a group. Head 156827c18; the group branch main 1e3e316c5 + #2862 + #2824 + #2873 (7988c1c89, merged in that order) passed the full CI (https://github.com/OreoFR/leonida/actions/runs/46740411028, the same workflow file as here, run on that branch) and No Game Data (https://github.com/OreoFR/leonida/actions/runs/46740416586); main was 1e3e316c5 with its CI green when the group merged. Claim: D3D12-HLE-XTASKQUEUE-COMPOSITE-TERMINATE (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7277115631). Red/green: fiestorra (Windows, mutation fails both ways), KelboLive review on this head (test fails on base, passes here). I ran: the five PRs #2860-#2862, #2824 and #2873 merged together onto main ab374c7d5 (main since gained only #2935, a CI workflow change, and #2860 and #2861, both part of that test), with the shader (418 passed, 0 failed), gpu (644/0) and hle (247/0) cargo tests. In-game run: RTX 4070 Laptop 8 GB, NVIDIA 621.40, a cold start to the world then a 330 s warm walking run, 0 device lost, no panic. CI: green on head, main and the group branch. AI-assisted: Claude Code (oreofr-agent), merge approved in writing by OreoFR.
VERIFY-2824 — Linux, Fedora 45, Rust 1.98.1 (the pinned toolchain), Wine 11.21, no GPU device, no game files
Verdict: PASS. The repository's own red/green idea holds under Wine: the new test fails on the merge base and passes with the pull request, and nothing that worked before is broken.
Head
156827c1, base the currentmain, merge base90c51443, 1 file, +54/−7:d3d12/crates/leonida-hle/src/modules/xasync.rs.1. What it changes
A composite task queue shares its ports with the queue it came from.
XTaskQueueTerminatedrained the port's whole task queue:so terminating a composite queue also cancelled the parent queue's tasks that were still queued on the shared port. The pull request gives every queue an id that is never reused, tags each queued task with the queue that queued it, and drains only that queue's own tasks:
2. Red and green, run under Wine
leonida-hledoes not build on Linux (upstream: "The crates are Windows-only today … Linux follows #2577"), so I cross-compiled it forx86_64-pc-windows-gnuand ran the tests under Wine 11.21:modules::xasync::tests::terminating_a_composite_queue_leaves_other_queues_tasks_queued— fails on the base, passes with the pull requestmodules::net::tests::only_loopback_is_reachable("ws2_32.dll lacks WSAConnectByList") andmodules::xgamesave::tests::a_kept_blob_past_the_link_limit_is_copied("the temp folder must be on NTFS"). Both are the environment, not this changeThe new test is the right shape for the change: it queues one task on the parent queue and one on the composite, terminates the composite, and checks that the composite's own task was canceled while the parent's stays queued and later runs uncanceled — which is what the old
drain(..)made impossible.3. The ids are never reused
A queue's id is taken once, when the queue is made, from a counter that only goes up — so a task tagged with a dead queue's id can never be mistaken for a later queue's task, which is what makes the partition by owner safe.
Relaxedis enough for it: the id is only ever compared with another id taken from the same counter.4. What I did not check
XTaskQueue*is documented elsewhere in the runtime; I did not compare the composite-queue behaviour with the console's.WSAConnectByListand its filesystem, not this change.AI-assisted: MiniMax M3.1 Flash.