Repository navigation
Shaders: keep buffer offsets below 2 GiB (NVIDIA + vkd3d-proton world device loss) - #542
gingertonik wants to merge 2 commits into
Conversation
|
Another NVIDIA / Linux data point, with the workaround only (no code change), in case it helps place this next to #493. RTX 5080, driver 615.71.09, CachyOS, proton-cachyos (vkd3d-proton 3.2.0), Series X 1.0.2.1, diagnostics build of
So on this card the hang I see is the one #493 removes, and disabling raw access chains alone did not stop it. That does not say anything against the fault this PR's synthetic tests show; it may just not be what ends these runs here, or both may be present. I did not run with AI-assisted (Claude Code); numbers from the runs' logs and the kernel log. |
|
Tested
No game data used. AI-assisted (Claude Code, Claude Opus 5.5). |
LAKSHYA-cmd-tech
left a comment
There was a problem hiding this comment.
Verified on Windows 11 D3D12 (WARP):
- All 75 tests in \�ictory-shader\ pass, specifically confirming the 6 new \oob_*\ tests on Windows:
- \oob_raw_store_does_not_corrupt_element_zero\ (ok)
- \oob_structured_stride16_at_0x10000000\ (ok)
- \oob_structured_stride4_at_0x40000000\ (ok)
- \oob_raw_dwordx4_at_0xfffffffc\ (ok)
- \oob_structured_stride32_at_0x08000000\ (ok)
- \oob_raw_dword_high_offsets\ (ok)
- \cargo clippy -p victory-shader -- -D warnings\ is completely clean.
- \cargo xtask policy\ passes (151 files checked, zero violations).
|
Check on Linux, not Windows: pass. Head
On: AMD Ryzen 7 5700, 62 GB RAM, Artix Linux 7.3.4-artix1-2, rustc 1.98.1 (the repo's pinned toolchain), cargo-xwin 0.24.1. No game data. Automated check only: the code itself was not reviewed. |
|
Tested this PR's code (not just the extension workaround) on an RTX 5080 under Linux: AMD Ryzen 9 9950X3D, CachyOS, proton-cachyos 11.0 with vkd3d-proton and the AI-assisted (Claude Code). |
|
Corpus run on the full retail shader pack (26,503 containers), Windows 11, AMD RX 9070 (Adrenalin), dxil.dll from SDK 10.0.26100. This PR conflicts with current main, so it was built at its own base (main before #612; there
So one of the modules this PR emits seems to crash the host pipeline path (the driver or our D3D12 calls) on AMD, even though it does not change the translation counts. I have not isolated the module yet ( |
catminou4
left a comment
There was a problem hiding this comment.
Test-merge with current main (ffe310e) conflicts — needs a rebase. Main moved recently (PR #566 waterfall loops touched lower.rs/resource.rs/valu_tests.rs), so shader PRs opened before it need rebasing. I'll re-review once it merges cleanly.
|
For reference: the test helper this adds ( |
…stalls Host::execute waited for each submission with no end. A host that loses its device need not signal the fences of the work it dropped: vkd3d-proton after a GPU fault does not, and by default does not report the device removed either. The title's submit thread then stays in our wait, its render thread blocks on its full submission ring, and 30 s later the title's own watchdog ends the run at image+0x23cf683 (Marvisak#1118), with nothing of ours in crashes.log to say that the GPU faulted. The wait now goes in 250 ms slices: * between slices the device is asked whether it was removed; if so the wait ends and the existing check after the submission reports it; * a submission still running is said so at 10 s and 20 s; * at 25 s it is given up with a report of its own ("has not finished a submission ... and reports no removal"). The limit is below the title's 30 s so the run ends with the cause, not with the title's null write. vkd3d-proton's own source calls a wait of over 5 s a lost device; Windows resets a device after about 2 s. A fence that comes is taken as before; a device that is removed and signals (Windows) is reported by the check after the wait, as before. Tested on Linux only (RTX 5080, driver 620.70, GE-Proton11-6's Wine, vkd3d-proton 30b0eb9), on main + Marvisak#177 + Marvisak#259, where the world faults the GPU in every run (Xid 13, fixed by Marvisak#542): * without this, with or without VKD3D_CONFIG=fault: the title's crash at +0x23cf683 24 to 30 s after the Xid, in 9 of 9 runs, and no report; * with this and VKD3D_CONFIG=fault: "device removed: 0x887A0005" 4 s after the Xid; * with this and vkd3d-proton's defaults: the two warnings, then the stall report 25 s after the submission began. New unit test of the wait (no GPU); cargo test --workspace under Proton: 333 passed, the same ten environmental failures as main; clippy -D warnings with and without --all-features; cargo xtask policy. Not run on Windows. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Automated triage for the maintainers. Needs rebase. This PR does not merge cleanly into current The content has not been reviewed yet; it will be once the branch is rebased onto Generated by Claude Code |
…stalls Host::execute waited for each submission with no end. A host that loses its device need not signal the fences of the work it dropped: vkd3d-proton after a GPU fault does not, and by default does not report the device removed either. The title's submit thread then stays in our wait, its render thread blocks on its full submission ring, and 30 s later the title's own watchdog ends the run at image+0x23cf683 (Marvisak#1118), with nothing of ours in crashes.log to say that the GPU faulted. The wait now goes in 250 ms slices: * between slices the device is asked whether it was removed; if so the wait ends and the existing check after the submission reports it; * a submission still running is said so at 10 s and 20 s; * at 25 s it is given up with a report of its own ("has not finished a submission ... and reports no removal"). The limit is below the title's 30 s so the run ends with the cause, not with the title's null write. vkd3d-proton's own source calls a wait of over 5 s a lost device; Windows resets a device after about 2 s. A fence that comes is taken as before; a device that is removed and signals (Windows) is reported by the check after the wait, as before. Tested on Linux only (RTX 5080, driver 620.70, GE-Proton11-6's Wine, vkd3d-proton 30b0eb9), on main + Marvisak#177 + Marvisak#259, where the world faults the GPU in every run (Xid 13, fixed by Marvisak#542): * without this, with or without VKD3D_CONFIG=fault: the title's crash at +0x23cf683 24 to 30 s after the Xid, in 9 of 9 runs, and no report; * with this and VKD3D_CONFIG=fault: "device removed: 0x887A0005" 4 s after the Xid; * with this and vkd3d-proton's defaults: the two warnings, then the stall report 25 s after the submission began. New unit test of the wait (no GPU); cargo test --workspace under Proton: 333 passed, the same ten environmental failures as main; clippy -D warnings with and without --all-features; cargo xtask policy. Not run on Windows. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Upstream superseded Marvisak#635 and Marvisak#568 (reverted just before this merge); Marvisak#189, Marvisak#334, Marvisak#437, Marvisak#542, Marvisak#587 and Marvisak#1529 are still open upstream and are kept. Resolutions: - emit::Options is upstream's struct with Marvisak#189's `wave64` added; TranslateOptions stays as its alias. lower::Parts carries both `options` and upstream's `view_marks`. - Shader cache: upstream's cached refusals and hit flag, keyed by Marvisak#189's Wave64 mode byte as before. - lower.rs: Marvisak#542's 2 GiB bound applies to raw and structured views; title memory (upstream's MEMORY path and root views read as memory) is not bounded again, being checked where it is looked up. Scalar loads take upstream's raw views plus Marvisak#437's UAVs. The descriptor-kind use keeps Marvisak#437's preference for image/vector uses inside upstream's fallback. image() is upstream's (its own a16 bias/compare, gather4_l and _cl grads), replacing Marvisak#437's parallel version. - Marvisak#189: AddH (upstream's f16 wave sum) in apply_wave_op; 16-bit reductions are refused in an emulated 64-lane wave. mask_dword checks Marvisak#189's deferred ballot errors before upstream's mask_number. - Marvisak#334: indirect arguments keep the per-list buffer states (no indirect::done); upstream's single-group clamp dispatch is taken, and its diagnostics readback copies from the read state without barriers. - GPU adapter: upstream still creates its device on the default adapter, so host_adapter() stays. The shader test host keeps the high-performance adapter pick and adds upstream's dedicated-memory requirement. - Marvisak#1529: gameinput.rs as the PR's own merge of main (scripted keys first, then keyboard and mouse); run.rs configures controls and FidelityFX.
What
Translated buffer loads, stores and atomics are kept below 2 GiB, so 32-bit offset arithmetic cannot wrap past 4 GiB:
offset < 0x7FFF_FFC0index < 0x7000_0000 / strideandoffset < 0x0FFF_FFE0index < 0x1000_0000An out-of-range load reads at 0 and its result is replaced by 0. An out-of-range store or atomic is skipped (the bound is folded into the existing lane guard). Two commits: synthetic GPU tests first, then the fix.
Why
Under Wine + vkd3d-proton on NVIDIA, every world run here lost the device 20-75 s in (Xid 13 MMU fault, then Xid 109). vkd3d-proton's fault report (
VKD3D_CONFIG=fault) gave aReadInvalidaddress equal to the host address of one 90 MiB title buffer plus exactly0x1_0000_0000in 9 of 9 runs that logged host addresses.The tests in this PR reproduce that shape with no game data: a four-word raw load at byte offset
0xFFFFFFFC(index -1 times 4). dxil-spirv lowers it toOpRawAccessChainNV ... RobustnessPerComponentNVand a 16-byteOpLoad. Component 0 is out of range. Component 1's offset wraps to 0 in 32 bits and passes the check, and the load faults 4 GiB above the buffer. The console's buffer descriptors bound such a read. Structured loads whereindex * stridereaches 2^32 do not fault but return element 0 where 0 is correct.We did not isolate the game shader or its runtime offset; the link to the game is the fault address shape plus the two A/B runs below.
Workaround with no code change, for NVIDIA under Proton:
VKD3D_DISABLE_EXTENSIONS=VK_NV_raw_access_chains.Tested
RTX 4080 16 GB, driver 620.73.04, Linux 7.3.5, Proton Experimental's vkd3d-proton (2576c0b4a). Unattended runs, scripted input, no network.
Synthetic tests (
emit::valu_tests::oob_*, one process per test):oob_raw_dword_high_offsetsoob_raw_dwordx4_at_0xfffffffc0x1_0bd00000oob_structured_stride4_at_0x40000000oob_structured_stride16_at_0x10000000oob_structured_stride32_at_0x08000000oob_raw_store_does_not_corrupt_element_zeroIn the game, opening cutscene,
d2a4bae+ #177 as the base:VK_NV_raw_access_chainsdisabledThe run with this PR ended on the title's own breakpoint (
0x80000003), not on the GPU. The scene is still dark.Gates:
cargo test -p victory-shader --lib56 passed;rustfmt --checkclean on both files; clippy adds no warnings;cargo xtask policy:asset policy: 151 files ok.Not tested: Windows (any vendor), AMD, Intel, WARP. Typed buffers on NVIDIA (their bound is defensive). Frame-time cost: each load gains a compare and a select, each store a branch; no controlled A/B was run.
Limits: this is a cannot-wrap guard, not a per-view length check. Below 2 GiB it relies on the host view's own bounds, which the single-word test shows working on this driver for a heap view. A root SRV has no view length (#493 covers that case).
AI-assisted (Hermes): the +4 GiB match, the tests and the fix were produced by AI agents under my direction; I ran everything above on my hardware.