Image atomic after a size query reuses an f32 handle: invalid SPIR-V, NVIDIA driver crash (fix ready on fork) #852

Open
opened 2026-11-26 04:14:04 +00:00 by github-bot · 4 comments
Owner

@⁠NicolaiVdS on GitHub · 2026-11-24 12:28 UTC · original

Bug

The cache in Lower::handle (crates/victory-shader/src/emit/lower.rs) keys a heap handle by its first resource-property word only (kind and UAV flag). Suppose a block does a size query on an image UAV (image_get_resinfo, f32 x4, 0x409) and then an atomic on the same image (image_atomic_*, u32 x1, 0x105). The atomic reuses the query's f32 handle. dxil-spirv then declares a float image and emits:

%3252 = OpAtomicUMax %float %3251 %uint_5 %uint_0 %3180

spirv-val rejects this: AtomicUMax: expected Result Type to be integer scalar type. NVIDIA's compiler crashes on it under vkd3d-proton (vkCreateGraphicsPipelines Exception 0xc0000005 in Unix call), which ends the title while it loads into the world. AMD's D3D12 driver seems to tolerate it, but the DXIL is wrong on every GPU.

Fix (ready on my fork)

Branch: https://github.com/NicolaiVdS/VIctory/tree/shader/atomic-handle-type
Commit: github.com/NicolaiVdS/VIctory@ae7e0bef6a
Diff against main: https://github.com/Marvisak/VIctory/compare/main...NicolaiVdS:VIctory:shader/atomic-handle-type

  • The fix: the cache key holds both property words. Every caller goes through this one cache, so structured buffers read with two strides get separate handles too.
  • The regression test: an_image_atomic_after_a_size_query_gets_an_integer_handle. It sees one handle ([0x409]) before the fix and two ([0x409, 0x105]) after.
  • Checks: cargo test -p victory-shader passes. Clippy on the Windows target, with and without --all-features, is clean with -D warnings.
  • Verified on an RTX 5070 Ti, Wine 11, vkd3d-proton master 30b0eb9:
    • translate --pipelines over shaders.rpf builds 21,566 pipelines with no driver crashes.
    • All 13,274 SPIR-V modules vkd3d-proton dumped pass spirv-val.
    • The title loads into the world with no driver crashes.

Request

@⁠Marvisak, PR creation here is limited to collaborators, so I couldn't open a PR. Could you give me collaborator access so I can send this and later fixes as PRs? Or a collaborator could cherry-pick ae7e0be directly, whichever you prefer.

Side note for Linux/NVIDIA

This one isn't a VIctory bug. vkd3d-proton 3.1's dxil-spirv produces invalid SPIR-V for 40 of the title's shaders (structured-exit and empty-merge-block errors), and NVIDIA crashes on one of them (0xc000001d). vkd3d-proton master fixes all 40, so Linux users need a version newer than 3.1.

**@⁠NicolaiVdS** on GitHub · 2026-11-24 12:28 UTC · [original](https://github.com/Marvisak/VIctory/issues/852) ## Bug The cache in `Lower::handle` (`crates/victory-shader/src/emit/lower.rs`) keys a heap handle by its first resource-property word only (kind and UAV flag). Suppose a block does a size query on an image UAV (`image_get_resinfo`, f32 x4, `0x409`) and then an atomic on the same image (`image_atomic_*`, u32 x1, `0x105`). The atomic reuses the query's **f32** handle. dxil-spirv then declares a float image and emits: ``` %3252 = OpAtomicUMax %float %3251 %uint_5 %uint_0 %3180 ``` `spirv-val` rejects this: `AtomicUMax: expected Result Type to be integer scalar type`. NVIDIA's compiler crashes on it under vkd3d-proton (`vkCreateGraphicsPipelines Exception 0xc0000005 in Unix call`), which ends the title while it loads into the world. AMD's D3D12 driver seems to tolerate it, but the DXIL is wrong on every GPU. ## Fix (ready on my fork) Branch: https://github.com/NicolaiVdS/VIctory/tree/shader/atomic-handle-type Commit: https://github.com/NicolaiVdS/VIctory/commit/ae7e0bef6a9bc834358d48f39902c284f3d9218e Diff against main: https://github.com/Marvisak/VIctory/compare/main...NicolaiVdS:VIctory:shader/atomic-handle-type - **The fix:** the cache key holds both property words. Every caller goes through this one cache, so structured buffers read with two strides get separate handles too. - **The regression test:** `an_image_atomic_after_a_size_query_gets_an_integer_handle`. It sees one handle (`[0x409]`) before the fix and two (`[0x409, 0x105]`) after. - **Checks:** `cargo test -p victory-shader` passes. Clippy on the Windows target, with and without `--all-features`, is clean with `-D warnings`. - **Verified on an RTX 5070 Ti, Wine 11, vkd3d-proton master `30b0eb9`:** - `translate --pipelines` over `shaders.rpf` builds 21,566 pipelines with no driver crashes. - All 13,274 SPIR-V modules vkd3d-proton dumped pass `spirv-val`. - The title loads into the world with no driver crashes. ## Request @⁠Marvisak, PR creation here is limited to collaborators, so I couldn't open a PR. Could you give me collaborator access so I can send this and later fixes as PRs? Or a collaborator could cherry-pick `ae7e0be` directly, whichever you prefer. ## Side note for Linux/NVIDIA This one isn't a VIctory bug. vkd3d-proton 3.1's dxil-spirv produces invalid SPIR-V for 40 of the title's shaders (structured-exit and empty-merge-block errors), and NVIDIA crashes on one of them (`0xc000001d`). vkd3d-proton master fixes all 40, so Linux users need a version newer than 3.1.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:14:04 +00:00
Author
Owner

@⁠Sunkiller-qc on GitHub · 2026-11-24 13:09 UTC · original

This is the bug #177 fixes (Ortomanic, open since 01:08 UTC). handle() keys the cache by props.0 only, so an atomic on a UAV that was also read as float gets the float handle. dxil-spirv then emits an atomic on a float pointer, and you get the same spirv-val error ("expected Result Type to be integer scalar type") and the same NVIDIA driver crash under vkd3d-proton as the title enters the world. #177 adds props.1 to the key, which is what your branch does.

#177 was tested against #144 (the NVIDIA + vkd3d-proton crash in vkCreateComputePipelines). MichaelSmithAI also found the size-query + atomic case on #728 and stacked it on #177's key. Your regression test (an_image_atomic_after_a_size_query_gets_an_integer_handle) would be a good addition to #177.

**@⁠Sunkiller-qc** on GitHub · 2026-11-24 13:09 UTC · [original](https://github.com/Marvisak/VIctory/issues/852#issuecomment-7132419835) This is the bug #177 fixes (Ortomanic, open since 01:08 UTC). `handle()` keys the cache by `props.0` only, so an atomic on a UAV that was also read as float gets the float handle. dxil-spirv then emits an atomic on a float pointer, and you get the same `spirv-val` error ("expected Result Type to be integer scalar type") and the same NVIDIA driver crash under vkd3d-proton as the title enters the world. #177 adds `props.1` to the key, which is what your branch does. #177 was tested against #144 (the NVIDIA + vkd3d-proton crash in `vkCreateComputePipelines`). MichaelSmithAI also found the size-query + atomic case on #728 and stacked it on #177's key. Your regression test (`an_image_atomic_after_a_size_query_gets_an_integer_handle`) would be a good addition to #177.
Author
Owner

@⁠LAKSHYA-cmd-tech on GitHub · 2026-11-24 13:37 UTC · original

Verified and merged downstream in PR #23. Keying handles by both property words eliminates OpAtomicUMax %float and driver crashes in kCreateGraphicsPipelines on NVIDIA hardware during cutscene and world streaming transitions.

**@⁠LAKSHYA-cmd-tech** on GitHub · 2026-11-24 13:37 UTC · [original](https://github.com/Marvisak/VIctory/issues/852#issuecomment-7133090095) Verified and merged downstream in PR #23. Keying handles by both property words eliminates OpAtomicUMax %float and driver crashes in kCreateGraphicsPipelines on NVIDIA hardware during cutscene and world streaming transitions.
Author
Owner

@⁠MamaLeVrai on GitHub · 2026-11-24 19:45 UTC · original

@⁠NicolaiVdS your fix for this issue is now in a pull request, #1610, with seven other fixes from contributors' forks: the branch is merged as it is, with your commit(s) and your name unchanged, onto main ffe310e. Clippy (both runs) and cargo test --workspace pass on the result. If you would rather open your own pull request for this one, say so and I will take it out of #1610. AI-assisted (Claude Code); no game data.

**@⁠MamaLeVrai** on GitHub · 2026-11-24 19:45 UTC · [original](https://github.com/Marvisak/VIctory/issues/852#issuecomment-7142547010) @⁠NicolaiVdS your fix for this issue is now in a pull request, #1610, with seven other fixes from contributors' forks: the branch is merged as it is, with your commit(s) and your name unchanged, onto `main` `ffe310e`. Clippy (both runs) and `cargo test --workspace` pass on the result. If you would rather open your own pull request for this one, say so and I will take it out of #1610. AI-assisted (Claude Code); no game data.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 06:49 UTC · original

Automated triage for the maintainers.

Confirmed on current main: in crates/victory-shader/src/emit/lower.rs, Lower::handle caches heap handles under a key that holds only the first property word (props.0), so an image atomic after a size query on the same descriptor in the same block reuses the query's float handle. Open PR #177 adds the second word to the key, the same change as the fork branch; the bundle #1610 that carried this branch was closed without merging. Pull requests are open to everyone now, so the regression test an_image_atomic_after_a_size_query_gets_an_integer_handle would be welcome as a PR or added to #177.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 06:49 UTC · [original](https://github.com/Marvisak/VIctory/issues/852#issuecomment-7155201432) <!-- victory-issue-triage v1 verdict=confirmed seen=2026-11-24T19:45:29Z at=2026-11-25T06:49:45Z --> Automated triage for the maintainers. Confirmed on current `main`: in `crates/victory-shader/src/emit/lower.rs`, `Lower::handle` caches heap handles under a key that holds only the first property word (`props.0`), so an image atomic after a size query on the same descriptor in the same block reuses the query's float handle. Open PR #177 adds the second word to the key, the same change as the fork branch; the bundle #1610 that carried this branch was closed without merging. Pull requests are open to everyone now, so the regression test `an_image_atomic_after_a_size_query_gets_an_integer_handle` would be welcome as a PR or added to #177. --- _Generated by [Claude Code](https://claude.ai/code)_
This discussion has been locked. Commenting is limited to contributors.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory#852
No description provided.