Shaders: name what a scalar memory read is, and which descriptor dword it reads #1083

Open
adamdotpy wants to merge 2 commits from upstream-pr/1083 into main
adamdotpy commented 2026-11-24 15:35:15 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by adamdotpy on 2026-11-24T15:35:15Z.


AI-assisted; measured on my own machine.

What

Two commits on the descriptor-data path, both about what a refusal says rather than what translates.

Name what a scalar memory read is. A scalar instruction that is not a load of dwords stopped the program with one string, "a scalar memory read as data", whatever it was. Each now names it: a timestamp (s_memtime/s_memrealtime), a wave's index in its group, a scalar cache instruction, a scalar store, a scratch load, or — the common one — a scalar memory read as data.

Name which descriptor dword. A descriptor dword the translation cannot rebuild from the host view stopped it with "a descriptor's address or format read as data" (92 programs at ffe310e), whichever dword it was. Each now names what it holds: an image's address, array pitch or mip limits, compression fields or metadata address; a buffer's address, stride or high address, or format and swizzle. A descriptor that a vector access uses later keeps a reason of its own, because an error at that point would give every dword the same one.

Only the reasons change; nothing translates that did not before. The point is victory translate and census output: it can say which descriptor dwords the title's programs actually need, and that is what decides whether a dword can come from the used-resource list (a buffer's stride can, for one).

Testing

  • cargo test -p victory-shader: 123 passed, 1 ignored (the new tests cover the instruction names and a table of image and buffer dwords).
  • cargo clippy -p victory-shader --all-targets --all-features -- -D warnings: clean.
  • cargo build --release -p victory: builds.

I did not run victory translate over the title's shader set for this revision — no title data on this machine — so the census numbers a full set gives are still to be measured.

Stacked

This is the naming change plus the per-dword reasons only. The root-view commit, which reads a root view's memory for scalar loads, is #1056 and is deliberately not included here.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6585465027 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1083). Originally posted by [adamdotpy](https://github.com/adamdotpy) on 2026-11-24T15:35:15Z. --- *AI-assisted; measured on my own machine.* ## What Two commits on the descriptor-data path, both about what a refusal says rather than what translates. **Name what a scalar memory read is.** A scalar instruction that is not a load of dwords stopped the program with one string, "a scalar memory read as data", whatever it was. Each now names it: a timestamp (`s_memtime`/`s_memrealtime`), a wave's index in its group, a scalar cache instruction, a scalar store, a scratch load, or — the common one — a scalar memory read as data. **Name which descriptor dword.** A descriptor dword the translation cannot rebuild from the host view stopped it with "a descriptor's address or format read as data" (92 programs at `ffe310e`), whichever dword it was. Each now names what it holds: an image's address, array pitch or mip limits, compression fields or metadata address; a buffer's address, stride or high address, or format and swizzle. A descriptor that a vector access uses later keeps a reason of its own, because an error at that point would give every dword the same one. Only the reasons change; nothing translates that did not before. The point is `victory translate` and census output: it can say which descriptor dwords the title's programs actually need, and that is what decides whether a dword can come from the used-resource list (a buffer's stride can, for one). ## Testing - `cargo test -p victory-shader`: 123 passed, 1 ignored (the new tests cover the instruction names and a table of image and buffer dwords). - `cargo clippy -p victory-shader --all-targets --all-features -- -D warnings`: clean. - `cargo build --release -p victory`: builds. I did not run `victory translate` over the title's shader set for this revision — no title data on this machine — so the census numbers a full set gives are still to be measured. ## Stacked This is the naming change plus the per-dword reasons only. The root-view commit, which reads a root view's memory for scalar loads, is #1056 and is deliberately not included here.
adamdotpy commented 2026-11-24 17:04:15 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by adamdotpy on 2026-11-24T16:05:26Z.


A reviewer's note on this one, since it is the least risky of the open shader PRs and the diff is bigger than it looks.

It cannot change what translates. Why is type Why = &'static str and the only consumers are the refusal message and the error text, so there is no decision downstream that reads a reason. descriptor_field has exactly one call site (lower.rs:3137, descriptor_field(image.is_some(), rel).unwrap_or(OTHER)), and every arm returns a string; the _ => return None arm keeps the old generic wording, so an unlisted dword cannot start behaving differently.

The one structural change, and it is the interesting half to review: the per-descriptor path collects all uses (filter_map(...).collect() into uses) instead of find_map-ing the first, so it can ask whether a vector access uses the descriptor later (uses[1..]) and give that its own reason. It is a read-only widening of what the diagnostic can see; the Some(&(at, first)) = uses.first() guard keeps the original path when there are no uses.

Measured on dbea3a1 (Windows 11, Rust 1.98.1): cargo test -p victory-shader 123 passed, 1 ignored; clippy -D warnings clean; cargo build --release -p victory builds. Base is current main (ffe310e), so it merges as it stands.

The one claim nobody here can check is the census number — "92 programs at ffe310e" and which dwords they read needs the title's shader set. That is the number that decides whether a dword can come from the used-resource list, so it is worth a re-measure by anyone with the pack before the follow-up that acts on it.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7137101173 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1083#issuecomment-7137101173). Originally posted by [adamdotpy](https://github.com/adamdotpy) on 2026-11-24T16:05:26Z. --- A reviewer's note on this one, since it is the least risky of the open shader PRs and the diff is bigger than it looks. **It cannot change what translates.** `Why` is `type Why = &'static str` and the only consumers are the refusal message and the error text, so there is no decision downstream that reads a reason. `descriptor_field` has exactly one call site (`lower.rs:3137`, `descriptor_field(image.is_some(), rel).unwrap_or(OTHER)`), and every arm returns a string; the `_ => return None` arm keeps the old generic wording, so an unlisted dword cannot start behaving differently. **The one structural change**, and it is the interesting half to review: the per-descriptor path collects all uses (`filter_map(...).collect()` into `uses`) instead of `find_map`-ing the first, so it can ask whether a *vector* access uses the descriptor later (`uses[1..]`) and give that its own reason. It is a read-only widening of what the diagnostic can see; the `Some(&(at, first)) = uses.first()` guard keeps the original path when there are no uses. **Measured on `dbea3a1`** (Windows 11, Rust 1.98.1): `cargo test -p victory-shader` 123 passed, 1 ignored; clippy `-D warnings` clean; `cargo build --release -p victory` builds. Base is current `main` (`ffe310e`), so it merges as it stands. The one claim nobody here can check is the census number — "92 programs at `ffe310e`" and which dwords they read needs the title's shader set. That is the number that decides whether a dword can come from the used-resource list, so it is worth a re-measure by anyone with the pack before the follow-up that acts on it.
Zipettte commented 2026-11-24 17:04:30 +00:00 (Migrated from github.com)

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


Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at dbea3a1: cargo test -p victory-shader passes, 123 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:7137755871 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1083#issuecomment-7137755871). Originally posted by [Zipettte](https://github.com/Zipettte) on 2026-11-24T16:29:49Z. --- Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at dbea3a1: `cargo test -p victory-shader` passes, 123 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed). _Tested with AI assistance (Claude)._
adamdotpy commented 2026-11-24 18:05:34 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by adamdotpy on 2026-11-24T17:10:19Z.


Thanks for the run @Zipettte — 123 passed / 0 failed at dbea3a1, baseline green. As noted on the branch this one is diagnostic-only, so a green run is the expected result; the dword reasons are what the next shader PRs will consume.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7138792998 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1083#issuecomment-7138792998). Originally posted by [adamdotpy](https://github.com/adamdotpy) on 2026-11-24T17:10:19Z. --- Thanks for the run @Zipettte — 123 passed / 0 failed at `dbea3a1`, baseline green. As noted on the branch this one is diagnostic-only, so a green run is the expected result; the dword reasons are what the next shader PRs will consume.
Marvisak commented 2026-11-25 01:08:03 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:34:06Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148646483 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1083#issuecomment-7148646483). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T00:34:06Z. --- <!-- victory-triage v1 head=dbea3a10d8f111ae132ab9fc292f22e4c5dd6ac6 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 cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1083:upstream-pr/1083'
git switch 'upstream-pr/1083'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/1083'
git switch 'upstream-pr/1083'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1083'
git switch 'upstream-pr/1083'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1083'
git switch 'main'
git merge --squash 'upstream-pr/1083'
git switch 'main'
git merge --ff-only 'upstream-pr/1083'
git switch 'main'
git merge 'upstream-pr/1083'
git push origin 'main'
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!1083
No description provided.