Shaders: a descriptor picked from the view heap reads its own dwords #127

Open
starnotes-xj wants to merge 1 commit from upstream-pr/127 into main
starnotes-xj commented 2026-11-25 14:10:59 +00:00 (Migrated from github.com)
First-time contributor

Imported from Zettrox/ztrx. Originally posted by starnotes-xj on 2026-11-25T13:13:59Z.


The console compiler loads a descriptor from the view heap and reads its words as numbers: the record count (to bound a walk), the format and type (to pick a path), the buffer's address (to hand to s_load). Translated code served only the root-table form of that (USER_VIEW_ADDRESS) and refused every heap form with a descriptor read only as data — 40 programs of the title's pack, among them the seven PS_PuddleDetect variants and the five shadowmask:CS_TraceShadowRays_* programs.

Now the host keeps a table of four dwords a view-heap slot — the title's own console descriptor words (the buffer's address, its record count, and its format and type) — filled as it makes each slot, bound as root SRV t252 (SLOT_VIEW_WORDS). Zeros stand for slots without a buffer view; dwords past the fourth still stop the program, by name.

Measured (victory translate over shaders.rpf, 26,503 containers)

before after
programs failing on a descriptor read as data 40 0
vertex and pixel programs emitted 14,164 14,199
compute programs emitted 2,668 2,672

victory translate --validate --pipelines on the dumped containers (RTX 4060 Laptop): PS_PuddleDetect #8660e9822ebe4b62 and CS_TraceShadowRays Eighth/Quarter/Half (#96ccb14ef981fd85, #0e64f14fae060d04, #002e93a6cc2aa355) emit, validate with dxil.dll and get their D3D12 pipeline. CS_TraceShadowRays_Full (#07c93bfb77fecebb) validates but the host refuses its pipeline (E_INVALIDARG — upstream's 0x80070057 refusal for one compute program); FullAdaptive is still stopped later, by a lane mask read as data.

Tests

  • cargo test -p victory-gpu --release: 112 passed.
  • cargo test -p victory-shader --release: 211 passed, 2 ignored.
  • cargo clippy --release -p victory-shader -p victory-gpu: clean.

Cost

Four dwords a slot (32 MB) per view heap, made with the heap. It could be made on first use if that matters; a title without such shaders never reads it.

Not yet run in the world: the next run will show whether the ray-traced shadow mask programs now produce shadows.

<!-- greyfinch-sync:Zettrox/ztrx:issue:6605306214 --> Imported from [Zettrox/ztrx](https://github.com/Zettrox/ztrx/pull/127). Originally posted by [starnotes-xj](https://github.com/starnotes-xj) on 2026-11-25T13:13:59Z. --- The console compiler loads a descriptor from the view heap and reads its words as numbers: the record count (to bound a walk), the format and type (to pick a path), the buffer's address (to hand to `s_load`). Translated code served only the root-table form of that (`USER_VIEW_ADDRESS`) and refused every heap form with `a descriptor read only as data` — 40 programs of the title's pack, among them the seven `PS_PuddleDetect` variants and the five `shadowmask:CS_TraceShadowRays_*` programs. Now the host keeps a table of four dwords a view-heap slot — the title's own console descriptor words (the buffer's address, its record count, and its format and type) — filled as it makes each slot, bound as root SRV `t252` (`SLOT_VIEW_WORDS`). Zeros stand for slots without a buffer view; dwords past the fourth still stop the program, by name. ## Measured (`victory translate` over `shaders.rpf`, 26,503 containers) | | before | after | |---|---|---| | programs failing on a descriptor read as data | 40 | **0** | | vertex and pixel programs emitted | 14,164 | **14,199** | | compute programs emitted | 2,668 | **2,672** | `victory translate --validate --pipelines` on the dumped containers (RTX 4060 Laptop): `PS_PuddleDetect` `#8660e9822ebe4b62` and `CS_TraceShadowRays` Eighth/Quarter/Half (`#96ccb14ef981fd85`, `#0e64f14fae060d04`, `#002e93a6cc2aa355`) emit, validate with `dxil.dll` and get their D3D12 pipeline. `CS_TraceShadowRays_Full` (`#07c93bfb77fecebb`) validates but the host refuses its pipeline (E_INVALIDARG — upstream's `0x80070057` refusal for one compute program); `FullAdaptive` is still stopped later, by a lane mask read as data. ## Tests - `cargo test -p victory-gpu --release`: 112 passed. - `cargo test -p victory-shader --release`: 211 passed, 2 ignored. - `cargo clippy --release -p victory-shader -p victory-gpu`: clean. ## Cost Four dwords a slot (32 MB) per view heap, made with the heap. It could be made on first use if that matters; a title without such shaders never reads it. Not yet run in the world: the next run will show whether the ray-traced shadow mask programs now produce shadows.
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/127:upstream-pr/127'
git switch 'upstream-pr/127'

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