Shaders: query a descriptor's level count only when word 3 is read #259
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/259"
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 Marvisak/VIctory. Originally posted by desplmfao on 2026-11-24T01:53:14Z.
Problem
On NVIDIA under Wine with vkd3d-proton (#144), loading into the world ends the process inside the driver:
vkCreateComputePipelines Exception 0xc0000005 in Unix call, with nocrashes.logentry. On current vkd3d-proton (3.2.0) and with #177 applied, the remaining crashing compute shaders here were9938c251a313fe28,ef05293f6107fc99,a3d1a26ad0c8c2cdandb80cd30e37e3fa05.When a program reads an image descriptor as data,
descriptor_datarebuilds the descriptor words fromgetDimensionsand always extracts the level count for word 3. vkd3d-proton turns that intoOpImageQueryLevels. On a 3D image inside a loop, NVIDIA's Vulkan compiler crashes on it. These shaders load the whole descriptor (s_load_dwordx8) in a loop but never read word 3 as data.How it was found
VKD3D_SHADER_DUMP_PATH). It passesspirv-val. Creating a pipeline from it in a small native Linux Vulkan program (no Wine, no vkd3d-proton) segfaults the NVIDIA driver too.spirv-reduceagainst that native crash leaves a module of a few blocks. It crashes only with all three:OpImageQueryLevels, a 3D image, and the query inside a loop.OpImageQuerySizeLodinstead, a 2D image, or the query moved out of the loop all build.Change
descriptor_dataextracts the level count only when some instruction or phi reads word 3's register as data, not as the resource operand of a memory instruction, which takes the descriptor whole. Otherwise the level count is not queried; word 3's value is then unused. Programs that do read word 3 are unchanged.Testing
victory translate <dir> --pipelineson the four shaders: all crashed before, all create their pipeline after.cargo test -p victory-shaderpasses.What else this was run with
These are separate, and this PR does not include them:
5d113aa6830760b6and the pixel shaders that crashed invkCreateGraphicsPipelines).d3d12.dll,d3d12core.dllfrom Proton Experimental 11.0-20261112) next tovictory.exe. Older vkd3d-proton builds crash on other shaders (8bb272e763f76148,4e296b1885c37b29,6a62009bc6a4146e); see #144.Related: #144.
🤖 Generated with Claude Code
Imported from Marvisak/VIctory. Originally posted by MisaXz on 2026-11-24T02:08:55Z.
Test report on Windows, which the description lists as not tested.
Tested
e232d3d(based2a4bae):cargo test --workspace --no-fail-fast: 264 passed, 0 failed, 4 ignored. Same counts asmaind2a4baeon this machine.Not tested
VICTORY_CONSOLE_DXC). Release build, AMD.AI use
Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T08:08:21Z.
Review: APPROVED
Tested
e232d3don Windows 11, RTX 5070, MSVC:cargo test --workspace --no-fail-fastpasses (264 passed, 0 failed).victory translate <title exe> --validate --pipelinesgives the same counts before and after: 12 of 12 programs emitted, 12 validated, 12 pipelines. Not tested under Wine or vkd3d-proton.onethere instead of querying the level count can't change any result, and it removes thegetDimensionslevel query that vkd3d-proton turns intoOpImageQueryLevels.read_as_dataerrs the safe way. A phi use counts as a data read, so a word that flows through a loop still gets the real level count, and only direct resource operands of image, buffer and SMEM instructions are exempt. The worst case is the old behaviour.OpImageQueryLevelsall needed for the crash) is well isolated. This narrows the trigger without changing the semantics of shaders that do read word 3. Those can still hit the driver bug, which is outside our control.No issues found.
AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by Mumogg on 2026-11-24T11:51:00Z.
Test report on NVIDIA 615.78.08, where #177 alone did not get past the compile crash (my rows in #144).
Setup: RTX 5070 Ti, driver 615.78.08, Nobara 44 (kernel 7.3.4), Wine 11.21 Staging, vkd3d-proton and DXVK
dxgi.dllfrom GE-Proton11-14, diag build cross-compiled on Linux. Tree:ffe310e+ #454 (d2c93fa) + #177 (ce945d6), then the same with this PR (e232d3d) merged on top; it merges cleanly there. Series X 1.0.2.1, network off.VKD3D_DISABLE_EXTENSIONS=VK_NV_raw_access_chains,VICTORY_NO_WATCHDOG=1.Offline:
victory translate shaders.rpf --pipelines --jobs 1(with a local print of each shader before its pipeline, to name the one the driver dies on)d1dd30f425ea54d475aa1158d1443760b80cd30e37e3fa0529dc5583465849069c15f00bc28065f6dafaedf3b3cf3c09ab8bd5a9904baf7620ab5ea44cad8dca7398df71d31fc190vkCreateComputePipelines Exception 0xc0000005 in Unix callThose nine are the ones I found before stopping the search (one per pass, skipping the previous ones), so there may be more on this driver;
b80cd30e37e3fa05is also in your list.The same cause, checked independently. For
d1dd30f425ea54d4: the SPIR-V fromVKD3D_SHADER_DUMP_PATHpassesspirv-val, and a small native Vulkan program (no Wine) that creates a compute pipeline from it segfaults inlibnvidia-gpucomp.so.615.78.08.spirv-reduceagainst that crash left 119 lines with one instruction of substance:OpImageQueryLevelson a 3D image in a loop header, faulting at the same address in the driver as the full shader. (My reducer run replaced the image operand by anOpUndef, so by itself it is weaker evidence than yours; it agrees with it.)In the title, one run each:
vkCreateComputePipelines Exception 0xc0000005at frame 1425, about 64 s inXid 109 … CTX SWITCH TIMEOUTfromtitle-mainin the kernel log; the process ended (exit 137) 158 s inSo on this driver the PR removes the compile crash, and the run then reaches the Xid 109 stop that #71 and #144 describe on 620.73.04. With this PR, 76 compute pipelines were refused with
Invalid parameter (0x80070057)in that run; I have not looked into those.Not tested: Windows, AMD,
cargo test(I only built and ran), more than one title run per tree.AI-assisted (Claude Code): it built the trees, ran the tests and wrote this report from the logs. No game data attached.
Imported from Marvisak/VIctory. Originally posted by hh-ze on 2026-11-24T15:41:41Z.
Verified #259 on an RTX 5060 Ti with NVIDIA driver 595.99.02. All five compute pipelines that had crashed during my testing compiled after applying this PR. Story Mode also created all five in-game with
VICTORY_SKIP_PIPELINESunset and reached the “Vice City, two years ago” title card.Setup
7.0.0-43-generic, Ryzen 5 760011.0 (Staging), vkd3d-proton 3.2.0 buildcae8353ed7959c4ffe310ewith #177, the #439 Wave64 stack, and #190. Cherry-picked #259 ate232d3das local commit40d3abd.1.98.1, cross-built forx86_64-pc-windows-gnuwith thediagprofile, diagnostics enabled, and a 16 MiB thread stack1.0.2.1, withVKD3D_DISABLE_EXTENSIONS=VK_NV_raw_access_chainsResults for #259
All five passed a compile-only
victory translate --pipelines --jobs 1 --listrun and subsequently logged successful host pipeline creation in Story Mode:ede59e0c382bd4d9reproducedvkCreateComputePipelines Exception 0xc0000005on its own before the patch. With #259, its generated SPIR-V went from 46OpImageQueryLevelsinstructions to zero. All five patched modules passedspirv-valfor Vulkan 1.3. The nativevictory-shadersuite reported 100 passed and 1 ignored.Other PRs I tested
The world was still running at roughly 0.1–0.3 fps, with buffer copies taking several seconds per frame. During teardown, the log printed
free(): corrupted unsorted chunksafter the nested display connection closed. The desktop and GPU stayed responsive, and the kernel logged no NVIDIA Xid during the run. Playable gameplay remains unverified.AI-assisted testing and log analysis. Shader hashes and test results only.
Imported from Marvisak/VIctory. Originally posted by Yaekai on 2026-11-24T16:37:55Z.
Independent verification on Windows 11 + NVIDIA RTX 3070 (Rust 1.98.1) at head
e232d3d:cargo test -p victory-shader --lib -- --skip valu_tests --skip waterfall_tests: 62 passed, 0 failed.cargo clippy -p victory-shader -- -D warnings: 0 warnings.1.0.2.1,--console series-s, 19-min world run): no regressions. Ready to merge once rebased onmain!Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:24:10Z.
Automated triage for the maintainers.
Merge candidate. In
Lower::descriptor_data(crates/victory-shader/src/emit/lower.rs), an image descriptor rebuilt fromgetDimensionsnow extracts the level count (field 3) only when the program reads word 3's register as data, through the newLower::read_as_data. Phis count as data reads; image, buffer and scalar-memory operands, which take the whole descriptor, do not. Otherwise word 3 is built with one level. I checked thatlevelsfeeds onlyd3, so when no instruction or phi reads word 3 the generated value is never used, and programs that do read it are unchanged. The evidence for the driver crash is concrete (aspirv-reducereduction toOpImageQueryLevelson a 3D image in a loop, reproduced natively and on several driver versions in the comments). The merge commit keeps main's new scalar-load functions unchanged.Thanks for the merge with main. It now merges cleanly against
940d32f, and the conflict resolution inlower.rskeeps both sides as you describe.CI: passing (
check).Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by desplmfao on 2026-11-25T04:22:18Z.
Rebased for the triage's "needs rebase":
31a6137merges currentmain(940d32f) into the branch as a new commit, so the history above stays as it was. The only conflict was inemit/lower.rs, wheremainadded new scalar-load functions (user_data_smem,memory_smem,add64and others) next to this PR'sread_as_data. Both are kept unchanged. GitHub shows the PR as mergeable again.Checked on an RTX 5080 (Linux, proton-cachyos 11.0, vkd3d-proton 3.2.0),
victory-shadertests with--test-threads 1: 241 passed, 6 failed. Plainmaingives exactly the same result, with the same six tests failing, so the merge adds no failures. The six are NVIDIA/Wine issues covered elsewhere (#2037, #1994, #1777/#1779), or they only happen under Wine.Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T21:58:30Z.
Automated triage for the maintainers, second look (a review against current
main, with builds and tests where they could change the verdict).Closing because
mainalready does this in a more general form. Since286a00e9the DXIL writer leaves out everything no live instruction reads, so when nothing reads descriptor word 3 the level-count extract and the arithmetic built on it are not emitted at all. That also covers cases this change would still query (a word carried through a phi, a dead read). The test reports here predate that commit; if the crash still shows on currentmain, please open an issue with the shader hash.If this is mistaken, reply here with what was missed and it will be looked at again. Thank you for the contribution.
Pull request closed