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

Open
github-bot wants to merge 2 commits from github-bot/gh-1083 into main AGit
Owner

@⁠adamdotpy on GitHub · 2026-11-24 15:35 UTC · original
adamdotpy:shader/descriptor-dwords → main · +344 −9 · 1 files · 2 commits · open

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** on GitHub · 2026-11-24 15:35 UTC · [original](https://github.com/Marvisak/VIctory/pull/1083) `adamdotpy:shader/descriptor-dwords` → `main` · +344 −9 · 1 files · 2 commits · open *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.
The census's largest refusal row (771 programs at ffe310e) came from
three different places under one reason, so a census could not tell
which one to lower. Each now names what the program reads:

- a descriptor that scalar buffer loads (s_buffer_load_dword*) use
  first: its record count (dword 2) by the view's kind (raw,
  structured, constant buffer, other), or its address or format;
  "used by scalar loads before a vector access" when a vector access
  later decides the view;
- s_memtime and s_memrealtime as timestamps,
  s_get_waveid_in_workgroup as the wave's index in its group;
- scalar stores, scalar scratch loads and cache instructions.

A load through a root view's address now says it reads that view's
memory rather than "a descriptor read only as data".

Only the reasons change: every read stops the program as before, no
IR is emitted for them, and what translates today is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A descriptor dword the translation cannot rebuild from the host view
stopped the program with "a descriptor's address or format read as
data" (92 programs at ffe310e), whatever the dword. 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 census can then tell which ones a program
needs, as a buffer's stride, say, can come from the used-resource list.

Only the reasons change. Dwords past the descriptor keep the old one.

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

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

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.

**@⁠adamdotpy** on GitHub · 2026-11-24 16:05 UTC · [original](https://github.com/Marvisak/VIctory/pull/1083#issuecomment-7137101173) 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.
Author
Owner

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

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).

**@⁠Zipettte** on GitHub · 2026-11-24 16:29 UTC · [original](https://github.com/Marvisak/VIctory/pull/1083#issuecomment-7137755871) 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)._
Author
Owner

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

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.

**@⁠adamdotpy** on GitHub · 2026-11-24 17:10 UTC · [original](https://github.com/Marvisak/VIctory/pull/1083#issuecomment-7138792998) 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.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 00:34 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:34 UTC · [original](https://github.com/Marvisak/VIctory/pull/1083#issuecomment-7148646483) <!-- 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 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/1083/head:github-bot/gh-1083'
git switch 'github-bot/gh-1083'

Merge

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