Shaders: a heap handle is keyed on both resource properties (fixes #852) #1036

Closed
acleofe wants to merge 1 commit from upstream-pr/1036 into main
acleofe commented 2026-11-24 15:14:37 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by acleofe on 2026-11-24T15:14:37Z.


What

The block-local cache of heap handles in Lower::handle is keyed on both words of the resource properties, not only the first. A test-only heap_props list (beside nonuniform_handles) records each heap handle's properties.

Why

The key held props.0 (kind and UAV bit) but not props.1 (component type, or structure stride). In one block, an image size query or load on a UAV makes a handle annotated as a float RWTexture2D<4xF32> (0x409); an image_atomic_* on the same descriptor afterwards asks for a 32-bit integer one (0x105) and got the cached float handle back. The atomic then runs on a float-annotated handle: dxil.dll accepts the module, but NVIDIA's compiler crashes on it (#852). A structured buffer read with two strides in one block had the same collision.

Test

  • an_image_atomic_after_a_size_query_has_its_own_handle: image_get_resinfo then image_atomic_add on one descriptor make two handles, float then integer. Before this change it made one.
  • cargo clippy --workspace --all-targets [--all-features] --locked -- -D warnings and cargo test --workspace --locked pass.

Not run on an NVIDIA GPU. The shader cache keys on the build, so cached translations are redone.

🤖 Generated with Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:issue:6585030300 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1036). Originally posted by [acleofe](https://github.com/acleofe) on 2026-11-24T15:14:37Z. --- ## What The block-local cache of heap handles in `Lower::handle` is keyed on both words of the resource properties, not only the first. A test-only `heap_props` list (beside `nonuniform_handles`) records each heap handle's properties. ## Why The key held `props.0` (kind and UAV bit) but not `props.1` (component type, or structure stride). In one block, an image size query or load on a UAV makes a handle annotated as a float `RWTexture2D<4xF32>` (`0x409`); an `image_atomic_*` on the same descriptor afterwards asks for a 32-bit integer one (`0x105`) and got the cached float handle back. The atomic then runs on a float-annotated handle: dxil.dll accepts the module, but NVIDIA's compiler crashes on it (#852). A structured buffer read with two strides in one block had the same collision. ## Test - `an_image_atomic_after_a_size_query_has_its_own_handle`: `image_get_resinfo` then `image_atomic_add` on one descriptor make two handles, float then integer. Before this change it made one. - `cargo clippy --workspace --all-targets [--all-features] --locked -- -D warnings` and `cargo test --workspace --locked` pass. Not run on an NVIDIA GPU. The shader cache keys on the build, so cached translations are redone. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
shortselow-byte commented 2026-11-24 16:05:24 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by shortselow-byte on 2026-11-24T15:51:38Z.


This PR has no CI run yet, so I ran the CI's checks at head 8d898b1 (on main ffe310e): Windows 11, Rust 1.98.1 MSVC, AMD Radeon RX 6900 XT (RDNA2).

  • cargo test --workspace --locked -- --test-threads=1: 343 passed, 0 failed, including an_image_atomic_after_a_size_query_has_its_own_handle (GPU tests on the AMD device and WARP).
  • cargo clippy --workspace --all-targets --locked -- -D warnings, and with --all-features: clean.
  • cargo xtask policy: ok.

Not run on NVIDIA either, so the driver crash from #852 itself is still unchecked.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7136734237 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1036#issuecomment-7136734237). Originally posted by [shortselow-byte](https://github.com/shortselow-byte) on 2026-11-24T15:51:38Z. --- This PR has no CI run yet, so I ran the CI's checks at head `8d898b1` (on `main` `ffe310e`): Windows 11, Rust 1.98.1 MSVC, AMD Radeon RX 6900 XT (RDNA2). - `cargo test --workspace --locked -- --test-threads=1`: 343 passed, 0 failed, including `an_image_atomic_after_a_size_query_has_its_own_handle` (GPU tests on the AMD device and WARP). - `cargo clippy --workspace --all-targets --locked -- -D warnings`, and with `--all-features`: clean. - `cargo xtask policy`: ok. Not run on NVIDIA either, so the driver crash from #852 itself is still unchecked.
upstream-sync closed this pull request 2026-11-24 17:03:03 +00:00
Zipettte commented 2026-11-24 17:04:32 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Zipettte on 2026-11-24T16:30:29Z.


Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 8d898b1: cargo test -p victory-shader passes, 121 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).

Tested with AI assistance (Claude).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7137773254 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1036#issuecomment-7137773254). Originally posted by [Zipettte](https://github.com/Zipettte) on 2026-11-24T16:30:29Z. --- Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 8d898b1: `cargo test -p victory-shader` passes, 121 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed). _Tested with AI assistance (Claude)._

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!1036
No description provided.