Shaders: scalar buffer loads from a UAV read it raw #1055

Open
github-bot wants to merge 1 commit from github-bot/gh-1055 into main AGit
Owner

@⁠adamdotpy on GitHub · 2026-11-24 15:20 UTC · original
adamdotpy:shader/smem-uav-raw → main · +28 −2 · 2 files · 1 commits · open

What

Lower::smem reads a scalar buffer load (s_buffer_load_dword*) through a raw handle when the descriptor's range is an SRV. Any other kind took the constant-buffer path (handle(.., (13, 0x1_0000)), then cbufferLoadLegacy), a table's UAV included. That is a CBV handle at the heap index where the host has a UAV.

A scalar buffer load from a UAV now reads it raw. It uses a handle with UAV properties (11 | 0x1000, 0), which is how a raw SRV is read here and how vector buffer accesses read a UAV, so all of a load site's accesses share one handle. Root UAVs are unchanged; they are still refused with "a root UAV or typed root view".

Why

Reading a UAV through a CBV handle removes the device. On main (ffe310e) with VICTORY_WARP=1, the test below fails with "The GPU device instance has been suspended". I did not run the unfixed program on hardware, because it is undefined behaviour there.

How often the title does this is unknown. A translation census can't show it, since these programs translate. Any program that does would remove the device, so this may be one cause of device-removal reports such as #653.

Related: #1015 fixes the neighbouring case, a heap descriptor with no listed kind that vector loads also read. This PR covers a descriptor whose listed kind is a UAV. The two touch the same lines of smem, so whichever lands second needs a small rebase.

Test

scalar_buffer_loads_read_a_uav_through_its_table (emit/valu_tests.rs) uses build_valu_cs, whose output UAV is a raw UAV in a table. The program:

  1. writes root constant 0 to the UAV's dword 0;
  2. reads it back with s_buffer_load_dword;
  3. stores that value.

The test removed the WARP device before this change. With the change it passes on an RTX 4060 Ti and on WARP.

Checks

  • cargo test --workspace --locked: 343 passed, 0 failed, 6 ignored. The GPU tests ran on an RTX 4060 Ti and WARP, with no "skipped" lines.
  • cargo clippy --workspace --all-targets --locked -- -D warnings and the same with --all-features: clean.
  • cargo xtask policy: ok.

No title data was used.

🤖 Generated with Claude Code

**@⁠adamdotpy** on GitHub · 2026-11-24 15:20 UTC · [original](https://github.com/Marvisak/VIctory/pull/1055) `adamdotpy:shader/smem-uav-raw` → `main` · +28 −2 · 2 files · 1 commits · open ## What `Lower::smem` reads a scalar buffer load (`s_buffer_load_dword*`) through a raw handle when the descriptor's range is an SRV. Any other kind took the constant-buffer path (`handle(.., (13, 0x1_0000))`, then `cbufferLoadLegacy`), **a table's UAV included**. That is a CBV handle at the heap index where the host has a UAV. A scalar buffer load from a UAV now reads it raw. It uses a handle with UAV properties `(11 | 0x1000, 0)`, which is how a raw SRV is read here and how vector buffer accesses read a UAV, so all of a load site's accesses share one handle. Root UAVs are unchanged; they are still refused with "a root UAV or typed root view". ## Why Reading a UAV through a CBV handle removes the device. On `main` (`ffe310e`) with `VICTORY_WARP=1`, the test below fails with *"The GPU device instance has been suspended"*. I did not run the unfixed program on hardware, because it is undefined behaviour there. How often the title does this is unknown. A translation census can't show it, since these programs translate. Any program that does would remove the device, so this may be one cause of device-removal reports such as #653. Related: #1015 fixes the neighbouring case, a heap descriptor with no listed kind that vector loads also read. This PR covers a descriptor whose listed kind is a UAV. The two touch the same lines of `smem`, so whichever lands second needs a small rebase. ## Test `scalar_buffer_loads_read_a_uav_through_its_table` (`emit/valu_tests.rs`) uses `build_valu_cs`, whose output UAV is a raw UAV in a table. The program: 1. writes root constant 0 to the UAV's dword 0; 2. reads it back with `s_buffer_load_dword`; 3. stores that value. The test removed the WARP device before this change. With the change it passes on an RTX 4060 Ti and on WARP. ## Checks - `cargo test --workspace --locked`: 343 passed, 0 failed, 6 ignored. The GPU tests ran on an RTX 4060 Ti and WARP, with no "skipped" lines. - `cargo clippy --workspace --all-targets --locked -- -D warnings` and the same with `--all-features`: clean. - `cargo xtask policy`: ok. No title data was used. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
s_buffer_load_dword* through a table's UAV took the constant buffer
path: a CBV handle at the heap index of a UAV. Reading through it
removes the device (WARP: "The GPU device instance has been
suspended"). Such a load now reads the UAV raw, as a raw SRV is read
and as vector buffer accesses read a UAV.

The test writes a value to the VALU tests' raw UAV, reads it back with
a scalar buffer load and stores that; it removed the WARP device before
this change and passes on the hardware GPU and WARP after.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:18:35 +00:00
Author
Owner

@⁠ThomasHFWright on GitHub · 2026-11-24 15:29 UTC · original

Independent Linux/Wine validation of 21d1b4682735b59a2742b6cf4696716e07e04d99, based on ffe310e. The new scalar_buffer_loads_read_a_uav_through_its_table regression passes: both patterns (0x12345678, 0xDEADBEEF) survive the UAV store/scalar-load/readback path. I did not run the unfixed device-removal case on hardware.

Full workspace unit/integration suite, all features, all 14 generated Windows MSVC test executables:

Tree Passed Failed Ignored
ffe310e baseline 341 5 6
This PR alone, unmodified 342 5 6

The five failures match baseline: empty pipeline library (#347), missing Wine Winsock export (#217), checksum-rejection expectation, nested Cargo fixture build, and Windows xtask attempting to launch host Git. Native Linux shader tests separately pass 96 / 0 / 1, xtask 4 / 0 / 0, and asset policy passes. Windows-target workspace Clippy with all targets/features and -D warnings passes.

Environment: Rust 1.98.1, Wine 11.22, RTX 5090 / NVIDIA 620.73.04, vkd3d-proton 30b0eb9bc12dc9f; native d3dcompiler_47 supplied for GPU fixtures, identical runtime DLLs to baseline. Both requested device paths in the new test completed, but this Wine/DXVK setup is not genuine Windows WARP coverage. Optional dxil.dll validation was unavailable; GPU pipeline creation and dispatch/readback executed.

Offline and offscreen, no game data or gameplay. No native Windows or Wine doctests. Aggregate counts include existing early-return tests without optional console compilers or the DXIL validator; the new regression executed. AI-assisted testing with Codex.

**@⁠ThomasHFWright** on GitHub · 2026-11-24 15:29 UTC · [original](https://github.com/Marvisak/VIctory/pull/1055#issuecomment-7136115376) Independent Linux/Wine validation of `21d1b4682735b59a2742b6cf4696716e07e04d99`, based on `ffe310e`. The new `scalar_buffer_loads_read_a_uav_through_its_table` regression passes: both patterns (`0x12345678`, `0xDEADBEEF`) survive the UAV store/scalar-load/readback path. I did not run the unfixed device-removal case on hardware. Full workspace unit/integration suite, all features, all 14 generated Windows MSVC test executables: | Tree | Passed | Failed | Ignored | | --- | ---: | ---: | ---: | | `ffe310e` baseline | 341 | 5 | 6 | | This PR alone, unmodified | 342 | 5 | 6 | The five failures match baseline: empty pipeline library (#347), missing Wine Winsock export (#217), checksum-rejection expectation, nested Cargo fixture build, and Windows xtask attempting to launch host Git. Native Linux shader tests separately pass **96 / 0 / 1**, xtask **4 / 0 / 0**, and asset policy passes. Windows-target workspace Clippy with all targets/features and `-D warnings` passes. Environment: Rust 1.98.1, Wine 11.22, RTX 5090 / NVIDIA 620.73.04, vkd3d-proton `30b0eb9bc12dc9f`; native `d3dcompiler_47` supplied for GPU fixtures, identical runtime DLLs to baseline. Both requested device paths in the new test completed, but this Wine/DXVK setup is not genuine Windows WARP coverage. Optional `dxil.dll` validation was unavailable; GPU pipeline creation and dispatch/readback executed. Offline and offscreen, no game data or gameplay. No native Windows or Wine doctests. Aggregate counts include existing early-return tests without optional console compilers or the DXIL validator; the new regression executed. AI-assisted testing with Codex.
Author
Owner

@⁠adamdotpy on GitHub · 2026-11-24 16:02 UTC · original

Thanks — that is the second independent environment (Wine 11.22, RTX 5090, vkd3d-proton) on this branch, and the 342/5/6 line matches the baseline failures one for one, so the fix costs nothing elsewhere.

One thing would close this completely, and it is the half you flagged: the red side. The test asserts the load succeeds; the bug it fixes is the device, so the evidence that matters is that the same program on unfixed ffe310e either removes the device or reads back the wrong dword. If your harness can run the regression against the base commit once and paste the failure, the PR stops needing anyone to take the mechanism on trust. If the unfixed path is hard to reach there (device removal is the expected symptom, not a clean assertion), say so and I will leave it — the mechanism is written out in the commit message either way.

**@⁠adamdotpy** on GitHub · 2026-11-24 16:02 UTC · [original](https://github.com/Marvisak/VIctory/pull/1055#issuecomment-7137020827) Thanks — that is the second independent environment (Wine 11.22, RTX 5090, vkd3d-proton) on this branch, and the 342/5/6 line matches the baseline failures one for one, so the fix costs nothing elsewhere. One thing would close this completely, and it is the half you flagged: the red side. The test asserts the load succeeds; the bug it fixes is the *device*, so the evidence that matters is that the same program on unfixed `ffe310e` either removes the device or reads back the wrong dword. If your harness can run the regression against the base commit once and paste the failure, the PR stops needing anyone to take the mechanism on trust. If the unfixed path is hard to reach there (device removal is the expected symptom, not a clean assertion), say so and I will leave it — the mechanism is written out in the commit message either way.
Author
Owner

@⁠shortselow-byte on GitHub · 2026-11-24 16:08 UTC · original

This PR has no CI run yet, so I ran the CI's checks at head 21d1b46 (on main ffe310e) natively on Windows with an AMD GPU, to complement the Linux/Wine run above: 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 scalar_buffer_loads_read_a_uav_through_its_table (AMD device and WARP).
  • cargo clippy --workspace --all-targets --locked -- -D warnings, and with --all-features: clean.
  • cargo xtask policy: ok.

Like you, I did not run the unfixed program on the hardware device.

**@⁠shortselow-byte** on GitHub · 2026-11-24 16:08 UTC · [original](https://github.com/Marvisak/VIctory/pull/1055#issuecomment-7137197486) This PR has no CI run yet, so I ran the CI's checks at head `21d1b46` (on `main` `ffe310e`) natively on Windows with an AMD GPU, to complement the Linux/Wine run above: 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 `scalar_buffer_loads_read_a_uav_through_its_table` (AMD device and WARP). - `cargo clippy --workspace --all-targets --locked -- -D warnings`, and with `--all-features`: clean. - `cargo xtask policy`: ok. Like you, I did not run the unfixed program on the hardware device.
Author
Owner

@⁠adamdotpy on GitHub · 2026-11-24 16:19 UTC · original

Thanks — that is the native-Windows/AMD half of the evidence the Wine run could not give, and it matches the other two environments (343 passed / 0 failed with the new regression, clippy and xtask policy clean). Nothing further needed from us on this branch; the only open item anywhere here is whether the unfixed program can be made to fail on a hardware device, and both testers have said the same thing — that it is the device-removal symptom rather than a clean assertion, so I will leave it as it stands rather than ask a third person to chase it.

**@⁠adamdotpy** on GitHub · 2026-11-24 16:19 UTC · [original](https://github.com/Marvisak/VIctory/pull/1055#issuecomment-7137467247) Thanks — that is the native-Windows/AMD half of the evidence the Wine run could not give, and it matches the other two environments (343 passed / 0 failed with the new regression, clippy and `xtask policy` clean). Nothing further needed from us on this branch; the only open item anywhere here is whether the unfixed program can be made to fail on a hardware device, and both testers have said the same thing — that it is the device-removal symptom rather than a clean assertion, so I will leave it as it stands rather than ask a third person to chase it.
Author
Owner

@⁠Zipettte on GitHub · 2026-11-24 16:30 UTC · original

Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 21d1b46: 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).

**@⁠Zipettte** on GitHub · 2026-11-24 16:30 UTC · [original](https://github.com/Marvisak/VIctory/pull/1055#issuecomment-7137765872) Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 21d1b46: `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)._
Author
Owner

@⁠adamdotpy on GitHub · 2026-11-24 17:10 UTC · original

Thanks for the RDNA3 run @⁠Zipettte — 121 passed / 0 failed at 21d1b46 with the workspace baseline green on main noted, that's the fourth independent validation of this branch (Wine + RDNA3 hardware here, RX 7900 XT by jtrudeau1530 earlier). Nothing actionable in the report.

**@⁠adamdotpy** on GitHub · 2026-11-24 17:10 UTC · [original](https://github.com/Marvisak/VIctory/pull/1055#issuecomment-7138792281) Thanks for the RDNA3 run @⁠Zipettte — 121 passed / 0 failed at `21d1b46` with the workspace baseline green on main noted, that's the fourth independent validation of this branch (Wine + RDNA3 hardware here, RX 7900 XT by jtrudeau1530 earlier). Nothing actionable in the report.
Author
Owner

@⁠MamaLeVrai on GitHub · 2026-11-24 17:23 UTC · original

Heads-up: this PR and #1015 both change the raw-view choice for a scalar buffer load of a descriptor in emit/lower.rs and conflict with each other. The resolution (SRV range reads a raw SRV view, UAV range a raw UAV view, descriptor of no listed kind the heap buffer view) is in the bundle #1319, with both PRs' tests kept; clippy and tests pass on it. AI-assisted (Claude Code); no game data.

**@⁠MamaLeVrai** on GitHub · 2026-11-24 17:23 UTC · [original](https://github.com/Marvisak/VIctory/pull/1055#issuecomment-7139131587) Heads-up: this PR and #1015 both change the raw-view choice for a scalar buffer load of a descriptor in `emit/lower.rs` and conflict with each other. The resolution (SRV range reads a raw SRV view, UAV range a raw UAV view, descriptor of no listed kind the heap buffer view) is in the bundle #1319, with both PRs' tests kept; clippy and tests pass on it. AI-assisted (Claude Code); no game data.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 00:32 UTC · original

Automated triage for the maintainers.

Needs rebase. This PR does not merge cleanly into current main (ac2525d). Conflicting files: crates/victory-shader/src/emit/lower.rs, crates/victory-shader/src/emit/valu_tests.rs.

The content has not been reviewed yet; it will be once the branch is rebased onto main.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 00:32 UTC · [original](https://github.com/Marvisak/VIctory/pull/1055#issuecomment-7148615112) <!-- victory-triage v1 head=21d1b4682735b59a2742b6cf4696716e07e04d99 verdict=needs-rebase at=2026-11-25T00:13:20Z --> Automated triage for the maintainers. **Needs rebase.** This PR does not merge cleanly into current `main` (ac2525d). Conflicting files: `crates/victory-shader/src/emit/lower.rs`, `crates/victory-shader/src/emit/valu_tests.rs`. The content has not been reviewed yet; it will be once the branch is rebased onto `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
This pull request has changes conflicting with the target branch.
  • crates/victory-shader/src/emit/lower.rs
  • crates/victory-shader/src/emit/valu_tests.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1055/head:github-bot/gh-1055'
git switch 'github-bot/gh-1055'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1055'
git switch 'github-bot/gh-1055'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1055'
git switch 'github-bot/gh-1055'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1055'
git switch 'main'
git merge --squash 'github-bot/gh-1055'
git switch 'main'
git merge --ff-only 'github-bot/gh-1055'
git switch 'main'
git merge 'github-bot/gh-1055'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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!1055
No description provided.