Shaders: scalar loads from a root view's address read its memory #1056

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

@⁠adamdotpy on GitHub · 2026-11-24 15:21 UTC · original
adamdotpy:shader/root-view-scalar-loads → main · +275 −0 · 3 files · 1 commits · open

What

An s_load_dword* whose address comes from a root descriptor, and whose result the program never uses as a descriptor, reads that buffer's data. On main it goes to descriptor_data. That function finds no resource use of the load, so the program stops with "a descriptor read only as data". In the ffe310e census in #293 that row has 394 programs, 305 of them compute; I can't say how many of them are this case.

Such a load is now read the way global loads from a root view already are (Lower::flat):

  • a root SRV raw (rawBufferLoad on root_srv_handle);
  • a root CBV, or a root view the used-resource list does not name, as a constant buffer (cbufferLoadLegacy via cbuffer_dword);
  • a root UAV still stops, with its own reason: "a root UAV read with scalar loads".

A load whose result is used as a descriptor (a descriptor stored in a root buffer) goes to descriptor_data as before. loads_descriptor checks every descriptor source, Loaded and Fetched, for the load site.

Related, without overlap: #667 binds addresses passed in two root constants as root views. #709 reads structured buffer accesses through a root view's raw handle. Neither changes s_load from a root descriptor's address.

Test

scalar_loads_read_a_root_srv_and_a_root_cbv (new emit/root_view_tests.rs) runs a synthetic program with a root view in user SGPRs 0-1 and a table holding a raw UAV. It reads dwords 2 and 3 of the view's memory with one s_load_dwordx2 and stores them. The test:

  • checks every hand-written encoding by decoding it;
  • runs once with a root SRV and once with a root CBV;
  • checks the declared root view (root_srvs / root_cbvs);
  • compares the stored values with the buffer's.

The results are exact on an RTX 4060 Ti and on WARP. On main the program stops with "a descriptor read only as data".

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:21 UTC · [original](https://github.com/Marvisak/VIctory/pull/1056) `adamdotpy:shader/root-view-scalar-loads` → `main` · +275 −0 · 3 files · 1 commits · open ## What An `s_load_dword*` whose address comes from a root descriptor, and whose result the program never uses as a descriptor, reads that buffer's data. On `main` it goes to `descriptor_data`. That function finds no resource use of the load, so the program stops with **"a descriptor read only as data"**. In the `ffe310e` census in #293 that row has 394 programs, 305 of them compute; I can't say how many of them are this case. Such a load is now read the way global loads from a root view already are (`Lower::flat`): - a root SRV raw (`rawBufferLoad` on `root_srv_handle`); - a root CBV, or a root view the used-resource list does not name, as a constant buffer (`cbufferLoadLegacy` via `cbuffer_dword`); - a root UAV still stops, with its own reason: "a root UAV read with scalar loads". A load whose result *is* used as a descriptor (a descriptor stored in a root buffer) goes to `descriptor_data` as before. `loads_descriptor` checks every descriptor source, `Loaded` and `Fetched`, for the load site. Related, without overlap: #667 binds addresses passed in two root constants as root views. #709 reads structured buffer accesses through a root view's raw handle. Neither changes `s_load` from a root descriptor's address. ## Test `scalar_loads_read_a_root_srv_and_a_root_cbv` (new `emit/root_view_tests.rs`) runs a synthetic program with a root view in user SGPRs 0-1 and a table holding a raw UAV. It reads dwords 2 and 3 of the view's memory with one `s_load_dwordx2` and stores them. The test: - checks every hand-written encoding by decoding it; - runs once with a root SRV and once with a root CBV; - checks the declared root view (`root_srvs` / `root_cbvs`); - compares the stored values with the buffer's. The results are exact on an RTX 4060 Ti and on WARP. On `main` the program stops with "a descriptor read only as data". ## 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)
An s_load_dword* whose address is a root descriptor's, and whose
result the program never uses as a descriptor, reads that buffer's
data. It stopped with "a descriptor read only as data". It is now read
as global loads from a root view already are: a root SRV raw, a root
CBV (or a root view the used-resource list does not name) as a
constant buffer. A root UAV still stops, with its own reason.

Test: dwords 2 and 3 of a root SRV and of a root CBV read with one
s_load_dwordx2 and stored, exact on the hardware GPU and WARP; main
refuses the program.

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:36 +00:00
Author
Owner

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

Independent Linux/Wine validation of 417f4e30d22f8ffc1801d60e1b480bbc29781594, based on ffe310e. The new scalar_loads_read_a_root_srv_and_a_root_cbv regression passes: both root-view kinds produce the exact [0x2002, 0x2003] readback. The declared SRV/CBV root-view checks also pass.

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:30 UTC · [original](https://github.com/Marvisak/VIctory/pull/1056#issuecomment-7136152446) Independent Linux/Wine validation of `417f4e30d22f8ffc1801d60e1b480bbc29781594`, based on `ffe310e`. The new `scalar_loads_read_a_root_srv_and_a_root_cbv` regression passes: both root-view kinds produce the exact `[0x2002, 0x2003]` readback. The declared SRV/CBV root-view checks also pass. 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

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

This PR has no CI run yet, so I ran the CI's checks at head 417f4e3 (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_loads_read_a_root_srv_and_a_root_cbv (AMD device and WARP).
  • cargo clippy --workspace --all-targets --locked -- -D warnings, and with --all-features: clean.
  • cargo xtask policy: ok.
**@⁠shortselow-byte** on GitHub · 2026-11-24 16:09 UTC · [original](https://github.com/Marvisak/VIctory/pull/1056#issuecomment-7137198362) This PR has no CI run yet, so I ran the CI's checks at head `417f4e3` (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_loads_read_a_root_srv_and_a_root_cbv` (AMD device and WARP). - `cargo clippy --workspace --all-targets --locked -- -D warnings`, and with `--all-features`: clean. - `cargo xtask policy`: ok.
Author
Owner

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

This is the red/green I asked for: the same fixture on the copy-only control fails before dispatch with a descriptor read only as data at offset 36, and the PR's lowering produces the exact [0x2002, 0x2003] readback on the RX 7900 XT. Combined with the Wine runs on two other adapters, that closes the question on this one — the fix is what makes the difference, not the environment. Noted on dxil.dll validation being unavailable in that run; the other two environments did validate.

**@⁠adamdotpy** on GitHub · 2026-11-24 16:19 UTC · [original](https://github.com/Marvisak/VIctory/pull/1056#issuecomment-7137467698) This is the red/green I asked for: the same fixture on the copy-only control fails before dispatch with `a descriptor read only as data` at offset 36, and the PR's lowering produces the exact `[0x2002, 0x2003]` readback on the RX 7900 XT. Combined with the Wine runs on two other adapters, that closes the question on this one — the fix is what makes the difference, not the environment. Noted on dxil.dll validation being unavailable in that run; the other two environments did validate.
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 417f4e3: 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/1056#issuecomment-7137765102) Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 417f4e3: `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

@⁠jtrudeau1530 on GitHub · 2026-11-24 16:13 UTC · original · edited 2026-11-24 16:44 UTC

Independent red/green check on RX 7900 XT / RADV 26.2.3, Wine 11.18 and vkd3d-proton 3.2.0 (cae8353): exact 417f4e30d2 source delta applied to ffe310e + the separate host-only copy fallback 61474f6.

emit::root_view_tests::scalar_loads_read_a_root_srv_and_a_root_cbv executed successfully, including both hardware: scalar loads from a root Srv exact and hardware: scalar loads from a root Cbv exact. The same fixture on the copy-only control, with production lowering unchanged, fails before dispatch with a descriptor read only as data at offset36.

Limits: dxil.dll validation was unavailable. The fixture's WARP-labelled Wine route also passed but used another hardware adapter; this is not a Windows WARP result. No title/world-rendering improvement is claimed from this synthetic check.

Update 16:44 UTC: repeated the same root-load test executable with Microsoft DXIL validator release 1.7.2308 available through VICTORY_DXIL. Both SRV and CBV modules validated and the exact hardware readbacks passed. The Wine WARP-labelled path still selects hardware; this does not add native Windows WARP coverage.

**@⁠jtrudeau1530** on GitHub · 2026-11-24 16:13 UTC · [original](https://github.com/Marvisak/VIctory/pull/1056#issuecomment-7137329857) · edited 2026-11-24 16:44 UTC Independent red/green check on RX 7900 XT / RADV 26.2.3, Wine 11.18 and vkd3d-proton 3.2.0 (cae8353): exact 417f4e30d22f8ffc1801d60e1b480bbc29781594 source delta applied to ffe310e + the separate host-only copy fallback 61474f6. `emit::root_view_tests::scalar_loads_read_a_root_srv_and_a_root_cbv` executed successfully, including both `hardware: scalar loads from a root Srv exact` and `hardware: scalar loads from a root Cbv exact`. The same fixture on the copy-only control, with production lowering unchanged, fails before dispatch with `a descriptor read only as data` at offset36. Limits: dxil.dll validation was unavailable. The fixture's WARP-labelled Wine route also passed but used another hardware adapter; this is not a Windows WARP result. No title/world-rendering improvement is claimed from this synthetic check. Update 16:44 UTC: repeated the same root-load test executable with Microsoft DXIL validator release 1.7.2308 available through VICTORY_DXIL. Both SRV and CBV modules validated and the exact hardware readbacks passed. The Wine WARP-labelled path still selects hardware; this does not add native Windows WARP coverage.
Author
Owner

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

Thanks for the RDNA3 run @⁠Zipettte — 121 passed / 0 failed at 417f4e3, baseline green on main. Together with the RX 7900 XT red/green this branch's scalar root-view loads are now confirmed on two RDNA3-era and one RDNA2-era part. Nothing actionable.

**@⁠adamdotpy** on GitHub · 2026-11-24 17:10 UTC · [original](https://github.com/Marvisak/VIctory/pull/1056#issuecomment-7138792625) Thanks for the RDNA3 run @⁠Zipettte — 121 passed / 0 failed at `417f4e3`, baseline green on main. Together with the RX 7900 XT red/green this branch's scalar root-view loads are now confirmed on two RDNA3-era and one RDNA2-era part. Nothing actionable.
Author
Owner

@⁠Parakeet-Wheat on GitHub · 2026-11-24 21:06 UTC · original · edited 2026-11-24 21:21 UTC

Ran the offline corpus check on 417f4e3 (contains main ffe310e) against ffe310e, to answer how many of the 394 "a descriptor read only as data" programs are this case.

  • Setup: Windows 11 26300, NVIDIA GeForce RTX 3070 (8 GB, driver 610.88), Ryzen 5 5600X, Rust 1.98.1 (x86_64-pc-windows-msvc), dxil.dll 1.8.2502, title 1.0.2.1.
  • victory translate <exe> shaders.rpf --list --validate, matched program by program (25,891): 0 outcome changes (21,726 validated / 4,003 failed / 162 rejected on both). No failing program's message changed either: "a descriptor read only as data" stays at 394, so none of them is a scalar load from a root view's address in this title, at least on main alone.
  • cargo test -p victory-shader --locked: 121 passed, 0 failed, 1 ignored, including scalar_loads_read_a_root_srv_and_a_root_cbv.
  • Also 0 on top of #1084 (which moves 205 compute programs from "a select on an untracked mask" to this refusal): with both merged, all 600 "a descriptor read only as data" programs still fail the same way; tests 122 passed, 0 failed, 1 ignored.

Offline translation and validation only; no shader contents or extracted data included. AI-assisted (Claude Code); run on my machine.

**@⁠Parakeet-Wheat** on GitHub · 2026-11-24 21:06 UTC · [original](https://github.com/Marvisak/VIctory/pull/1056#issuecomment-7144494873) · edited 2026-11-24 21:21 UTC Ran the offline corpus check on `417f4e3` (contains `main` `ffe310e`) against `ffe310e`, to answer how many of the 394 "a descriptor read only as data" programs are this case. - **Setup:** Windows 11 26300, NVIDIA GeForce RTX 3070 (8 GB, driver `610.88`), Ryzen 5 5600X, Rust 1.98.1 (`x86_64-pc-windows-msvc`), `dxil.dll` 1.8.2502, title 1.0.2.1. - `victory translate <exe> shaders.rpf --list --validate`, matched program by program (25,891): **0 outcome changes** (21,726 validated / 4,003 failed / 162 rejected on both). No failing program's message changed either: "a descriptor read only as data" stays at **394**, so none of them is a scalar load from a root view's address in this title, at least on `main` alone. - `cargo test -p victory-shader --locked`: **121 passed, 0 failed, 1 ignored**, including `scalar_loads_read_a_root_srv_and_a_root_cbv`. - Also 0 on top of #1084 (which moves 205 compute programs from "a select on an untracked mask" to this refusal): with both merged, all 600 "a descriptor read only as data" programs still fail the same way; tests 122 passed, 0 failed, 1 ignored. *Offline translation and validation only; no shader contents or extracted data included. AI-assisted (Claude Code); run on my machine.*
Author
Owner

@⁠adamdotpy on GitHub · 2026-11-24 21:26 UTC · original

Thanks for the corpus check — that negative result is useful: it confirms none of the title's 394 "a descriptor read only as data" programs is a scalar load from a root view's address, so #1056 stays a correctness fix for the general case rather than a recovery for a known title program. The 0 outcome changes on 25,891 programs also matches what I measured locally on the head (unit + GPU tests green, no golden changes).

**@⁠adamdotpy** on GitHub · 2026-11-24 21:26 UTC · [original](https://github.com/Marvisak/VIctory/pull/1056#issuecomment-7144942932) Thanks for the corpus check — that negative result is useful: it confirms none of the title's 394 "a descriptor read only as data" programs is a scalar load from a root view's address, so #1056 stays a correctness fix for the general case rather than a recovery for a known title program. The 0 outcome changes on 25,891 programs also matches what I measured locally on the head (unit + GPU tests green, no golden changes).
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.

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/1056#issuecomment-7148619851) <!-- victory-triage v1 head=417f4e30d22f8ffc1801d60e1b480bbc29781594 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`. 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
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/1056/head:github-bot/gh-1056'
git switch 'github-bot/gh-1056'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1056'
git switch 'github-bot/gh-1056'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1056'
git switch 'github-bot/gh-1056'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1056'
git switch 'main'
git merge --squash 'github-bot/gh-1056'
git switch 'main'
git merge --ff-only 'github-bot/gh-1056'
git switch 'main'
git merge 'github-bot/gh-1056'
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!1056
No description provided.