Shader tests: share one D3D12 queue per adapter #3093
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!3093
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3093"
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?
@neonbyte1 on GitHub · 2026-11-26 07:30 UTC · original
neonbyte1:pr/shader-test-queue→main· +300 −83 · 6 files · 5 commits · openSplit out of #2973, as asked in its review: this changes how every
victory-shaderGPU test runs, Windows included.The shader tests made a D3D12 device and a command queue for every test. They now share one device and one queue per adapter for the whole test process, and each test waits for its own work to finish, as before.
Why: under Wine/vkd3d-proton,
victory-shader's test process was killed with SIGKILL at exit: hundreds of queues were still being torn down when the process ended. With one queue per adapter it exits normally.Tested (Linux, GE-Proton11-14 Wine, RTX 5090):
victory-shadertests undercargo xtask wine-test(#1218), 298 passed, 4 failed, no SIGKILL. All four failures happen onmainwithout this change too:rounding_matches_the_hardwareis fixed by #2968.stub_pipeline_is_createdis tracked in #1266.hosts_that_do_not_fuse_are_namedanda_heap_buffer_read_where_no_buffer_view_is_reads_zerosare fixed by #2973.Not tested on Windows: I have no Windows machine. A run of
cargo test -p victory-shader --libon a Windows GPU, and once with WARP, would close that gap. A test that left the queue in a bad state would now affect the tests after it; on this run none did.AI-assisted (Claude); measured on my machine, no game data shared.
@Dukestar69 on GitHub · 2026-11-26 07:49 UTC · original · approved these changes
Tested locally merged onto
origin/main(63bcca4) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP):cargo test -p victory-shader emit::host -- --test-threads=1: 1 passed, 0 failed (parallel_warp_pipelines_and_draws).cargo test -p victory-shader a_branch_to_fallthrough_keeps_both_values_at_a_join -- --test-threads=1(RTX 5090 & WARP): 1 passed, 0 failed on both.cargo clippy -p victory-shader --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
@oni-swr on GitHub · 2026-11-26 07:53 UTC · original
Independent WARP verification of this PR at
dc56cd73against its pre-series base63bcca43(the claim is #1633). No source changes and no PR from me.Setup: Windows 11,
x86_64-pc-windows-msvc, Rust 1.98.1,--locked. Separate binaries per tree, run withVICTORY_WARP=1. I confirmed the adapter with a throwaway probe test first:Microsoft Basic Render Driver, software flag set, 0 dedicated video memory. The physical GPU was not used, so the PR's hardware-adapter queue (HARDWARE_DEVICE) was never exercised. The SDKdxil.dllwas present. Synthetic inputs only, no game data.Queue creation:
CreateCommandQueueappears 3 times invictory-shaderon base and once on head, increate_queue. The three submission sites now callHost::queue().Repeated parallel runs. The full
victory-shaderlib suite, default test threads, 10 runs each, alternating base and head:The four failing tests are the same on both and are hardware-lane checks that WARP does not satisfy. Skipping those four, 6 further runs each exited 0 on both (298 passed, 0 failed, 3 ignored). The head was also exit 0 at
--test-threads=1(10.0 s) and--test-threads=16(11.9 s). No hang, crash or changed result between base and head. The head is about 3 to 4 s faster, which fits one queue instead of one per call. That is only a WARP timing from this machine.Limits: this does not test the PR's stated reason (Wine/vkd3d-proton SIGKILL at exit), and it does not cover a hardware adapter or the "a test leaves the queue in a bad state" risk the description mentions. On WARP,
Hostwork is already serialised byWARP_LOCK, so a poisoned queue would be less visible here than on a GPU.AI use: Claude Code (Claude Sonnet 5.5) ran the verification, coordinated by Codex (gpt-6.2-sol).
@YaBulochka on GitHub · 2026-11-26 08:10 UTC · original
Offline validation on the retail corpus, with the current main as the baseline:
main63bcca4— 24 850 programs validatedpull/3093/head) — 24 850 programs validatedSo no regression and no change in the count on this corpus. Environment: Wine 11.22 on CachyOS (kernel 7.3.5), retail 1.0.2.1
shaders.rpf(26,503 containers), built with--features diagnostics,victory translate <shaders.rpf> --validate --list, unchanged prefix and settings for both runs.If the change is meant to move that number, it does not on this dump; if it is about correctness of the emitted DXIL for an instruction shape the corpus does not hit, then parity is the expected result and this says only that nothing else moved.
Numbers only, no game files or dumps.
@Marvisak on GitHub · 2026-11-26 08:19 UTC · original
Automated triage for the maintainers.
Merge candidate.
crates/victory-shader/src/emit/host.rs:Host::newnow hands out one device and one direct queue per adapter kind (HARDWARE_DEVICE/WARP_DEVICE), and the three submission sites useHost::queue()in place of a new queue per call. Each submission still makes its own fence and waits on it, and the WARP path still creates its device underWARP_LOCK. AHost::from_devicehost (used byvictory-gpu'sfuses_fmadprobe) makes its queue once, lazily.Host::new(false)is also used byvictory translate(apps/victory/src/translate.rs), which only makes pipelines there, so the shared queue does not affect it.A Windows WARP run comparing this branch with
mainhas been posted here. The hardware-adapter path is still not run on Windows; a run ofcargo test -p victory-shader --libon a Windows GPU would close that gap.CI: passing.
Generated by Claude Code
@fuzeofficlal on GitHub · 2026-11-26 08:29 UTC · original · requested changes
The wall-clock improvement on real hardware is huge! Tested locally on Windows 11 (RTX 5090, running the
victory-shaderlib suite excluding the pre-existingheap_direct_texture_reads_mark_their_heap_indexcrash):63bcca43: 523.12s (298 passed, 3 pre-existing failures)dc56cd73: 33.56s (298 passed, same 3 pre-existing failures) — a 15.6x speedup, and concurrent submission is sound on the happy path because each call owns its own allocator, command list, resources, and fence.However, caching the hardware
(device, queue)permanently in aLazyLockintroduces a few correctness issues incrates/victory-shader/src/emit/host.rs:Host::new(false)permanently returns a removed device afterDEVICE_REMOVED(emit/host.rs:183-188, 206-224): OnceHARDWARE_DEVICEinitializes toOk(...), any subsequentHost::new(false)clones and returns the same device/queue even if the GPU has since enteredDEVICE_REMOVED. Previously,create_device(false)surfaced device removal when callers likeemit/semantics_tests.rs:577-585requested a freshHostafter a failure. Please checkGetDeviceRemovedReason()on construction (and decide/document whether an initial creation failure should stay cached forever).pub devicecan diverge from the private cachedqueue(emit/host.rs:17-20, 191-195, 215-234):Host.deviceispub, so replacing it leaves the cachedqueuebound to the old device whilefuses_fmad/draw/dispatchcreate allocators, lists, and fences on the new device. Keepingdeviceandqueuepaired behind read-only access (or rebuilding the queue when the device changes) prevents mismatched-device submissions.UINT64_MAX(DEVICE_REMOVED) as success infuses_fmadanddispatch(emit/host.rs:751-763, 2011-2023):drawchecksGetDeviceRemovedReason()after exiting the wait loop (:1285-1288), butfuses_fmadanddispatchonly check it insidewhile fence.GetCompletedValue() < 1. OnDEVICE_REMOVED,GetCompletedValue()returnsu64::MAX, exiting the loop immediately and mapping incomplete readback data. Now that a removed device is shared across tests, sharing a single completion-check helper across all three paths is much more important.:2055-2097) currently exercises the serializedWARP_LOCKpath. Adding a hardware-path concurrency test (when not forced to WARP) with distinct per-thread readback payloads would directly cover the concurrent queue path this PR enables.@steven-seagull27 on GitHub · 2026-11-26 09:57 UTC · original
@neonbyte1 @fuzeofficlal I ran the hardware concurrency check requested in review item 4. On
dc56cd73, eight RTX 5080 workers using the shared D3D12 queue each got back their own value on every dispatch. The same test applies to the parent,63bcca43. Test-only commitEach cell covers four fresh processes. In each process, eight workers synchronized after pipeline creation, then each submitted 16 dispatches with distinct root constants. The shader wrote one word of a two-word UAV. The untouched neighbor stayed zero in every readback. The test identified the adapter by its D3D12 device LUID. WARP used its existing serialization. This run covers successful submissions; the device-removal questions in the review are still open.
To try it on this PR:
Set
VICTORY_WARP=1for the software control. Each completed run prints the adapter name and 128 matched readbacks. AI-assisted test and write-up, run locally on Windows.@neonbyte1 on GitHub · 2026-11-26 10:01 UTC · original
Thanks for the Windows hardware run and the four points. All four are addressed in a follow-up commit,
deedac2:Host::newchecksGetDeviceRemovedReason()and, if the cached device is removed, drops the pair and makes a new one. Creation failures aren't cached: before this PR,Host::new(false)tried again on every call, and an adapter that appears later should still work.Host::deviceis private now, behind a read-onlydevice()accessor. The cache only hands out the device and its queue together, so nothing can swap a device under a cached queue. In-tree callers are updated.fuses_fmad,drawanddispatchshare onewait_for_completion(). It treatsu64::MAXand anyGetDeviceRemovedReason()error as failure, and checks again after the last fence read, before any readback is mapped.parallel_hardware_dispatches_on_shared_queue: eight threads take hosts on the shared hardware queue, each dispatch writes its own token, and each thread checks its own readback. It deliberately ignoresVICTORY_WARP. It skips, with a message, only when there's no SM 6.6 hardware adapter.Tested on the RTX 5090 under Wine (vkd3d-proton):
victory-shaderlib suite has 299 passed and the same 4 failures asmainunder Wine, and no SIGKILL at exit.diagnostics, andcargo xtask policy, are clean.Not run on native Windows.
AI-assisted (Claude); measured on my machine, no game data shared.
@steven-seagull27 on GitHub · 2026-11-26 10:16 UTC · original
@neonbyte1 I ran your new
parallel_hardware_dispatches_on_shared_queueatdeedac2e7on native Windows. It passed in four fresh processes on the RTX 5080, with eight workers checking their own token each time (32/32 readbacks).I also reran the longer test from my earlier comment, updated to use the new
device()accessor. In four fresh processes per adapter, each worker made 16 submissions. The RTX 5080 returned 512/512 correct payloads, and all 512 untouched neighbor words stayed zero. Windows inbox WARP returned the same counts through its serialized path. Optional 16-round test on your new revisionI found one failure path in the new test itself. If one worker fails host or pipeline setup, it panics before reaching the eight-worker barrier. I injected one setup error on a healthy device. All seven peers reached the barrier, none reached dispatch, and I stopped the test after 10 seconds. Carrying the setup result across the barrier let the seven peers return their correct tokens and the test report the injected error in 0.25 seconds. With the injected error removed, the fix passed 24/24 worker readbacks across three RTX runs. Affected lines · Test-only fix
To pick up just the barrier fix on
deedac2e7Windows 11, NVIDIA driver 621.40, inbox WARP 10.0.26100.10068. The injected error exercised worker setup on a healthy adapter. Hardware device-removal recovery remains untested here. AI-assisted testing with synthetic inputs.
@fuzeofficlal on GitHub · 2026-11-26 10:17 UTC · original · requested changes
deedac2ecleanly addresses the earlier review items:SharedDevicepairsdeviceandqueueand recreates onGetDeviceRemovedReason(),Host::deviceis private behinddevice(), andfuses_fmad/draw/dispatchsharewait_for_completionwithu64::MAXand pre/post-read device-removal checks.One blocker in the new
parallel_hardware_dispatches_on_shared_queuetest (emit/host.rs:2221-2238): each of the eight spawned threads callsHost::new_for(false).expect(...)andhost.compute_pipeline(shader).expect(...)insidestd::thread::scopebeforebarrier.wait(). If any worker fails during host setup or PSO creation, the remaining workers deadlock permanently onbarrier.wait()andthread::scopenever returns. Please complete fallible setup before entering the fixed-count barrier (or propagate setup failures). It would also help to assert queue sharing alongsidefirst.device() == second.device(), and to only skip when adapter creation itself fails rather than onCreateCommandQueueerrors.Verified locally on Windows 11 x64 (RTX 5090 + WARP +
dxil.dll,deedac2e):cargo run --locked -p xtask -- policy&cargo check --workspace --all-targets --locked: passedcargo clippy -p victory-shader --all-targets --locked -- -D warnings(default and--all-features): cleanemit::host::tests(--test-threads=1and default parallel on RTX 5090, plusVICTORY_WARP=1): 2 passed, 0 failedemit::tests/emit::semantics_tests(parallel on RTX 5090 andVICTORY_WARP=1): 17 / 34 passed, 0 failed (1 ignored)@neonbyte1 on GitHub · 2026-11-26 10:31 UTC · original
@fuzeofficlal @steven-seagull27 Thanks both. Two new commits:
b0fed71. Each worker's host and pipeline setup is now aResultcarried across the barrier, so a worker whose setup fails still releases the others, and the test reports the error afterwards. To check it, I made one worker's setup return an error before any GPU work. The test then failed in 0.8 s withhardware Host::new: "injected setup error"instead of hanging. The injected error is removed again.076c0e7checks that two hosts get the same queue, not just the same device. Each of the eight workers also checks that its host has that same queue.Host::newstill fails, for example inCreateCommandQueue, the test fails.@steven-seagull27, thanks also for the native Windows runs and the 16-round test (
50342b8). I didn't add it because it covers the same shared-queue readbacks as this test. It's a good heavier stress check to run by hand, and your 512/512 results on the RTX 5080 and on WARP are a useful record here.Tested on the RTX 5090 under Wine (vkd3d-proton):
victory-shaderlib suite has 299 passed and the same 4 failures asmainunder Wine, and no SIGKILL at exit.diagnostics), policy and format checks are clean.Not run on native Windows.
AI-assisted (Claude); measured on my machine, no game data shared.
@steven-seagull27 on GitHub · 2026-11-26 10:46 UTC · original
@neonbyte1 I retested
076c0e7on native Windows 11 with the RTX 5080 (driver 621.40). The upstream identity test passed in four fresh processes. In each process both initial hosts shared the same device and queue, and all eight workers used that queue. All 32 worker tokens matched.I also checked both failure paths on the RTX. Giving worker 0 a second queue on the same D3D12 device triggered
thread 0 has its own queue. Injecting a setup error in worker 0 made the test fail normally after the barrier. Its seven peers returned the correct tokens in both runs.The separate 16-round stress test passed in four fresh processes per adapter. The RTX returned 512/512 expected tokens and Windows WARP (10.0.26100.10068) returned 512/512. The adjacent word stayed zero on every readback. Stress test used
@fuzeofficlal on GitHub · 2026-11-26 11:01 UTC · original · approved these changes
Verified the updates in
076c0e7eon RTX 5090 and WARP: movingHost::new_for(false)andcompute_pipelineahead ofbarrier.wait(), asserting shared device/queue identity across all 8 worker threads (first.queue() == second.queue()and matchingown.as_raw()while keepingfirstalive), and distinguishing hardware adapter absence from queue failure all cleanly resolve the previous review blockers.Verified locally on Windows 11 x64 (
076c0e7e):rustfmt --edition 2024 --checkon all 6 modified files,cargo run --locked -p xtask -- policy(191 files ok),cargo check --workspace --all-targets, andcargo clippy --workspace --all-targets -- -D warnings(default and--all-features): clean.--test-threads=1and default parallel) &VICTORY_WARP=1:emit::host::tests2/2,emit::tests17/17,emit::semantics_tests34/34 (1 ignored).Two minor edge notes (non-blocking):
parallel_hardware_dispatches_on_shared_queue, ifHost::new_for(false)succeeds at device creation and fails queue creation, and the fallbackcreate_device(false)check then fails transiently, the test would still skip instead of surfacing the original queue failure stage.Host::from_deviceuses a per-instanceOnceLock<Result<ID3D12CommandQueue, String>>, so unlikeshared()(which checksremoved()and retries), a transient or post-removal queue error on an externally created device remains cached for the lifetime of thatHost.@Jackster on GitHub · 2026-11-26 16:24 UTC · original
Windows 11, Radeon RX 7900 XTX (gfx1100, 32.0.32029.2010),
63bcca4+ this PR. You asked forcargo test -p victory-shader --libon a Windows GPU and once with WARP:VICTORY_WARP=1): 299 passed, 4 failed, 3 ignored —gathers_at_a_level_match_the_hardware("lane 4 against its gather"),permutes_read_the_lane_named_and_zero_from_lanes_left_out,permutes_mask_high_address_bits_and_divergent_branches,a_mask_joined_with_data_at_a_uniform_loop_is_its_number.63bcca4with the same WARP setup: 298 passed, 4 failed — the exact same four. So the shared queue adds nothing new here; those four are the pre-existing WARP gaps.Note: on this host
victory-shaderhas to be built with--features host, otherwise the hardware backend silently skips. Synthetic only. AI-assisted.@neonbyte1 on GitHub · 2026-11-26 16:43 UTC · original
@fuzeofficlal thanks for the approval and the two notes; both are addressed in
8d1518d:parallel_hardware_dispatches_on_shared_queue: when the shared host fails, the test now skips only if no SM 6.6 hardware device can be made, and the skip message includes both errors (device and shared queue). If a device can be made, it fails with the queue error instead of skipping.Host::from_device: the queue cell caches only success now. A failed creation returns the error and is retried on the next call, so a transient or post-removal error no longer sticks for the host's lifetime, matchingshared().Tested under Wine on the RTX 5090:
emit::host::testspass.victory-gpu'sread_marks_of_both_bitmaps_are_taken, which goes throughfrom_device, passes.hosts_that_do_not_fuse_are_namedfails here both with and without this commit: under Wine, DXVK maps "WARP" to the RTX 5090, which fuses FMad. That's unrelated to this change; #2973 makes that test report the Wine case.AI-assisted (Claude); measured on my machine, no game data shared.
@fuzeofficlal on GitHub · 2026-11-26 18:26 UTC · original · approved these changes
Verified the follow-up commit
8d1518de285e37a444292795e7d864d5077f0a12on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP):Host::from_device(crates/victory-shader/src/emit/host.rs:17, 263-292) now storesOnceLock<ID3D12CommandQueue>and caches successes only, so transient or post-removalcreate_queuefailures are retried cleanly.parallel_hardware_dispatches_on_shared_queue(host.rs:2214-2235) surfaces both the device-probe and shared-queue errors when skipping without a hardware SM 6.6 adapter.cargo test -p xtask --locked policy::tests::repository_passes_policy:1 passed(asset policy: 191 files ok);cargo clippy --locked -p victory-shader --all-targets -- -D warnings(default and--all-features): clean.VICTORY_WARP=0):emit::host::tests2 passed, 0 failed(parallel0.29s,--test-threads=10.28s); full--libskipping the pre-existingheap_direct_texture_reads_mark_their_heap_indexcrash:299 passed; 3 failed; 3 ignored; 1 filtered outin 17.72s (same 3 pre-existing failures asmain).VICTORY_WARP=1):299 passed; 4 failed; 3 ignoredin6.73s(parallel_hardware_dispatches_on_shared_queuepasses).cargo test --locked -p victory-gpu --lib read_marks_of_both_bitmaps_are_taken:1 passed, 0 failed(0.34s, exercisingHost::from_device).Both post-approval notes are cleanly resolved — ready to merge.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.