Shaders: recover record counts for descriptor-only structured buffers #329

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

@⁠Raxstreams on GitHub · 2026-11-24 02:20 UTC · original
Raxstreams:codex/data-only-buffer-records → main · +159 −37 · 3 files · 1 commits · open

Some compute shaders load a four-dword buffer descriptor and test its record count without ever issuing a buffer access. The emitter previously needed a resource instruction to infer the view type and stopped at a descriptor read only as data.

For a static table load at an exact binding offset, the emitter can recover the record count with GetDimensions when the native metadata supplies a valid structured stride and the original PSV0 declarations confirm a structured buffer. Conflicting declarations across register spaces, unknown bindings, and dynamic ranges keep the existing unsupported path.

On Windows with an RTX 3080 Ti, the isolated CS_MinTimestepReduce shader validated and created a D3D12 compute pipeline on this branch, based on upstream main. A synthetic GPU test checks the actual returned counts for buffers with 3 and 11 records and covers conflicting declarations. All 70 shader library tests and the repository asset-policy check passed.

This is independent of the SGPR spill work in #298 and #309 and leaves the world-rendering issue open.

**@⁠Raxstreams** on GitHub · 2026-11-24 02:20 UTC · [original](https://github.com/Marvisak/VIctory/pull/329) `Raxstreams:codex/data-only-buffer-records` → `main` · +159 −37 · 3 files · 1 commits · open Some compute shaders load a four-dword buffer descriptor and test its record count without ever issuing a buffer access. The emitter previously needed a resource instruction to infer the view type and stopped at `a descriptor read only as data`. For a static table load at an exact binding offset, the emitter can recover the record count with `GetDimensions` when the native metadata supplies a valid structured stride and the original PSV0 declarations confirm a structured buffer. Conflicting declarations across register spaces, unknown bindings, and dynamic ranges keep the existing unsupported path. On Windows with an RTX 3080 Ti, the isolated `CS_MinTimestepReduce` shader validated and created a D3D12 compute pipeline on this branch, based on upstream main. A synthetic GPU test checks the actual returned counts for buffers with 3 and 11 records and covers conflicting declarations. All 70 shader library tests and the repository asset-policy check passed. This is independent of the SGPR spill work in #298 and #309 and leaves the world-rendering issue open.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:59:28 +00:00
Author
Owner

@⁠SpaghettiMaster545 on GitHub · 2026-11-24 03:12 UTC · original

Tested 02564c5 merged alone onto main d2a4bae, with the title, against main on the same machine.

  • NVIDIA GeForce RTX 5070 Ti, driver 621.24 (32.0.16.2124); Ryzen 7 9800X3D; Windows 11 10.0.26100; Rust 1.98.1; diag build, its own empty VICTORY_CACHE_DIR, scripted keys into story mode, until the host GPU failure (#71, unrelated).
  • a descriptor read only as data: on main, 21 programs stop with this reason (15–21 over three runs, depending on how far each run gets). With this PR, 1 of those 21 translates and 20 still stop with the same reason. No program stops with it that did not on main.
  • Program by program against main, nothing that ran there stops with this PR.

So on this title the PR's case covers one of the programs with this reason. The other 20 load the descriptor in some other way than a static table load at an exact binding offset with a native structured stride, or lack one of the conditions the PR checks. I have not looked at which.

Not tested

  • AMD GPUs, a release build, the PR's synthetic GPU test on this card.

(Claude Code, Claude Opus 5.5: ran the title on both builds and compared the logs program by program.)

**@⁠SpaghettiMaster545** on GitHub · 2026-11-24 03:12 UTC · [original](https://github.com/Marvisak/VIctory/pull/329#issuecomment-7120877236) **Tested** `02564c5` merged alone onto `main` `d2a4bae`, with the title, against `main` on the same machine. - NVIDIA GeForce RTX 5070 Ti, driver 621.24 (32.0.16.2124); Ryzen 7 9800X3D; Windows 11 10.0.26100; Rust 1.98.1; diag build, its own empty `VICTORY_CACHE_DIR`, scripted keys into story mode, until the host GPU failure (#71, unrelated). - `a descriptor read only as data`: on `main`, 21 programs stop with this reason (15–21 over three runs, depending on how far each run gets). With this PR, 1 of those 21 translates and 20 still stop with the same reason. No program stops with it that did not on `main`. - Program by program against `main`, nothing that ran there stops with this PR. So on this title the PR's case covers one of the programs with this reason. The other 20 load the descriptor in some other way than a static table load at an exact binding offset with a native structured stride, or lack one of the conditions the PR checks. I have not looked at which. **Not tested** - AMD GPUs, a release build, the PR's synthetic GPU test on this card. (Claude Code, Claude Opus 5.5: ran the title on both builds and compared the logs program by program.)
Author
Owner

@⁠EduAzevedo on GitHub · 2026-11-24 04:55 UTC · original

Measured 02564c5 on the retail shaders (v1.0.2.1, Series X package), offline with victory translate --jobs 8 --list, all 26,148 programs, against main d2a4bae, alone and merged with #309 (64c7188, clean merge):

main this PR #309 this PR + #309
Vertex and pixel programs emitted 12,284 12,302 12,380 12,398
a descriptor read only as data 183 164 692 673

19 more programs translate (18 pixel, 1 compute); none that translate on main stop. For comparison on the same corpus, #180 takes a descriptor read only as data to 1 (with or without #309), so the two overlap; I have not measured them together.

AI-assisted.

**@⁠EduAzevedo** on GitHub · 2026-11-24 04:55 UTC · [original](https://github.com/Marvisak/VIctory/pull/329#issuecomment-7122455668) Measured `02564c5` on the retail shaders (v1.0.2.1, Series X package), offline with `victory translate --jobs 8 --list`, all 26,148 programs, against `main` `d2a4bae`, alone and merged with #309 (`64c7188`, clean merge): | | `main` | this PR | #309 | this PR + #309 | |---|---|---|---|---| | Vertex and pixel programs emitted | 12,284 | 12,302 | 12,380 | 12,398 | | `a descriptor read only as data` | 183 | 164 | 692 | 673 | 19 more programs translate (18 pixel, 1 compute); none that translate on `main` stop. For comparison on the same corpus, #180 takes `a descriptor read only as data` to 1 (with or without #309), so the two overlap; I have not measured them together. AI-assisted.
Author
Owner

@⁠EduAzevedo on GitHub · 2026-11-24 05:02 UTC · original

Follow-up to the overlap question above, from the same logs: the 19 programs this PR makes translate do not translate with #180 (5ff639e, alone or with #309). With #180, 18 of them get past a descriptor read only as data and stop at a scalar memory read as data; the other 1 is the single a descriptor read only as data program #180 leaves. So on the title's shaders the two are complementary rather than redundant: this PR finishes those 19, #180 covers the other ~160.

AI-assisted.

**@⁠EduAzevedo** on GitHub · 2026-11-24 05:02 UTC · [original](https://github.com/Marvisak/VIctory/pull/329#issuecomment-7122575377) Follow-up to the overlap question above, from the same logs: the **19 programs this PR makes translate do not translate with #180** (`5ff639e`, alone or with #309). With #180, 18 of them get past `a descriptor read only as data` and stop at `a scalar memory read as data`; the other 1 is the single `a descriptor read only as data` program #180 leaves. So on the title's shaders the two are complementary rather than redundant: this PR finishes those 19, #180 covers the other ~160. AI-assisted.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 00:14 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/mod.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:14 UTC · [original](https://github.com/Marvisak/VIctory/pull/329#issuecomment-7148309349) <!-- victory-triage v1 head=02564c5d9561021eb6cfba01e91b1898192a60ac 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/mod.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/mod.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/329/head:github-bot/gh-329'
git switch 'github-bot/gh-329'

Merge

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