shader: take a descriptor's address however many dwords the load reads #118

Open
xiaotu030202 wants to merge 2 commits from upstream-pr/118 into main
xiaotu030202 commented 2026-11-25 13:06:11 +00:00 (Migrated from github.com)
First-time contributor

Imported from Zettrox/ztrx. Originally posted by xiaotu030202 on 2026-11-25T12:39:02Z.


shader: take a descriptor's address however many dwords the load reads

A descriptor read only as data — nothing uses it as a descriptor, the code
just wants its address — is answered with the host's USER_VIEW_ADDRESS
dwords. That path required count <= 4, so s_load_dwordx8 (8) and
s_load_dwordx16 (16) were refused outright:

a descriptor read only as data

Four shaders in #38 hit this (2fd01fca16993001, 6b6db9f1a526daeb,
abc6a80d46edc294, 7d0f14ce44746d7e). Nothing about the host side needs the
limit: it fills dwords 0 and 1 from the view at that table offset
(draw.rs, USER_VIEW_ADDRESS, descriptor::view(table + dword * 4)) and
never looks at how many dwords were read.

The rest of the load's dwords are Missing, exactly as dwords 2 and 3
already were for a s_load_dwordx4. So a program that only takes the address
works at any length, and one that does arithmetic on the other dwords is
refused where it uses them — the same contract at 1, 2, 4, 8 and 16.

view_address also accepted only a 4-dword table entry; it now takes the
console's other buffer size, 8.

Tests, and both directions of each

Mine — a_descriptor_load_of_eight_dwords_answers_with_the_address, a
s_load_dwordx8 s[8:15], s[4:5], 0x0 of an unused table entry, asserted to ask
the host for exactly the two address dwords. Fails on the code before this
change, passes after.

Zhelezniak Artem's (@Artking175, from ecfda9ec), which cover the case mine
does not — a s_load_dwordx16, and what happens when a consuming store reads
a dword the host has no value for:

  • a_sixteen_dword_descriptor_load_supplies_both_address_words — stores both
    address dwords to a separate UAV, for 4- and 8-dword table entries, and
    validates the DXIL.
  • a_sixteen_dword_descriptor_load_refuses_storing_a_missing_word — uses dword
    15 in the stored value and asserts the refusal at the store, 0x24:
    a descriptor's address or format read as data.

I reproduced his result before taking the patch: reinstating count <= 4 on
this branch makes both his tests fail with a descriptor read only as data at offset: 36 (0x24), which is what he reported for main.

Verification

Windows 11, RTX 5070 Ti, Rust 1.98.1 (pinned), MSVC 14.44.35207, Windows SDK
10.0.26100.0, VICTORY_DXIL set. No game files.

$ cargo test -p victory-shader --lib -- --test-threads=1
test result: ok. 218 passed; 0 failed; 2 ignored     (216 with mine alone)

$ cargo clippy -p victory-shader --all-targets
clean

$ cargo xtask policy
asset policy: 172 files ok

What is not claimed

I have not seen those four shaders translate. What is established: the length
is no longer a reason to refuse, the address path is exercised at 8 and 16 by
tests that fail without the change, and 218 tests pass. Whether each of the
four now lowers, or stops at a later and real limit, is what
victory translate --list over shaders.rpf would say — and that needs game
files.

The fifth shader I first counted, ceb5eb68cd99cb07, reads a descriptor's
format as data rather than only its address. It is a different code path and
this change does not move it; …refuses_storing_a_missing_word above is what
pins where it stops.

<!-- greyfinch-sync:Zettrox/ztrx:issue:6604667710 --> Imported from [Zettrox/ztrx](https://github.com/Zettrox/ztrx/pull/118). Originally posted by [xiaotu030202](https://github.com/xiaotu030202) on 2026-11-25T12:39:02Z. --- shader: take a descriptor's address however many dwords the load reads A descriptor read only as data — nothing uses it as a descriptor, the code just wants its address — is answered with the host's `USER_VIEW_ADDRESS` dwords. That path required `count <= 4`, so `s_load_dwordx8` (8) and `s_load_dwordx16` (16) were refused outright: a descriptor read only as data Four shaders in #38 hit this (`2fd01fca16993001`, `6b6db9f1a526daeb`, `abc6a80d46edc294`, `7d0f14ce44746d7e`). Nothing about the host side needs the limit: it fills dwords 0 and 1 from the view at that table offset (`draw.rs`, `USER_VIEW_ADDRESS`, `descriptor::view(table + dword * 4)`) and never looks at how many dwords were read. The rest of the load's dwords are `Missing`, exactly as dwords 2 and 3 already were for a `s_load_dwordx4`. So a program that only takes the address works at any length, and one that does arithmetic on the other dwords is refused where it uses them — the same contract at 1, 2, 4, 8 and 16. `view_address` also accepted only a 4-dword table entry; it now takes the console's other buffer size, 8. ## Tests, and both directions of each **Mine** — `a_descriptor_load_of_eight_dwords_answers_with_the_address`, a `s_load_dwordx8 s[8:15], s[4:5], 0x0` of an unused table entry, asserted to ask the host for exactly the two address dwords. Fails on the code before this change, passes after. **Zhelezniak Artem's** (@Artking175, from `ecfda9ec`), which cover the case mine does not — a `s_load_dwordx16`, and what happens when a *consuming* store reads a dword the host has no value for: - `a_sixteen_dword_descriptor_load_supplies_both_address_words` — stores both address dwords to a separate UAV, for 4- and 8-dword table entries, and validates the DXIL. - `a_sixteen_dword_descriptor_load_refuses_storing_a_missing_word` — uses dword 15 in the stored value and asserts the refusal at the store, `0x24`: `a descriptor's address or format read as data`. I reproduced his result before taking the patch: reinstating `count <= 4` on this branch makes **both** his tests fail with `a descriptor read only as data` at `offset: 36` (0x24), which is what he reported for `main`. ## Verification Windows 11, RTX 5070 Ti, Rust 1.98.1 (pinned), MSVC 14.44.35207, Windows SDK 10.0.26100.0, `VICTORY_DXIL` set. No game files. ``` $ cargo test -p victory-shader --lib -- --test-threads=1 test result: ok. 218 passed; 0 failed; 2 ignored (216 with mine alone) $ cargo clippy -p victory-shader --all-targets clean $ cargo xtask policy asset policy: 172 files ok ``` ## What is not claimed I have not seen those four shaders translate. What is established: the length is no longer a reason to refuse, the address path is exercised at 8 and 16 by tests that fail without the change, and 218 tests pass. Whether each of the four now lowers, or stops at a later and real limit, is what `victory translate --list` over `shaders.rpf` would say — and that needs game files. The fifth shader I first counted, `ceb5eb68cd99cb07`, reads a descriptor's *format* as data rather than only its address. It is a different code path and this change does not move it; `…refuses_storing_a_missing_word` above is what pins where it stops.
Artking175 commented 2026-11-25 15:08:45 +00:00 (Migrated from github.com)
Author
First-time contributor

Imported from Zettrox/ztrx. Originally posted by Artking175 on 2026-11-25T14:14:20Z.


I added two synthetic regression tests for the s_load_dwordx16 case on top of ab387f1. Test commit · Patch

  • The first shader stores both address dwords to a separate UAV. It checks the two host address inputs for both 4- and 8-dword table entries.
  • The second uses dword 15 in the stored value. On this PR it is refused at the consuming store (0x24) with a descriptor's address or format read as data.

With the same tests on main (90b529f), both reproduced a descriptor read only as data at 0x24. Reinstating just the count <= 4 guard on this PR also reproduced that refusal in the first test.

Both tests passed on macOS and on Windows 10 22H2 with an RTX 2060 (driver 531.41). On Windows both builds included #121 and #11 for the test runtime, used Agility SDK 1.608.2 and confirmed hardware SM 6.6. DXIL for both address cases passed the pinned 1.8.2505.32 validator. The full Windows shader suite finished with 214 passed, 0 failed, and 3 ignored. Windows Clippy passed with all targets, all features, and -D warnings.

This was a synthetic check. The five shader containers from #38 still need an offline comparison.

<!-- greyfinch-sync:Zettrox/ztrx:comment:7164969770 --> Imported from [Zettrox/ztrx](https://github.com/Zettrox/ztrx/pull/118#issuecomment-7164969770). Originally posted by [Artking175](https://github.com/Artking175) on 2026-11-25T14:14:20Z. --- I added two synthetic regression tests for the `s_load_dwordx16` case on top of `ab387f1`. [Test commit](https://github.com/Artking175/ztrx/commit/ecfda9ecb74e7c115bd1600f532f6c6ebae61ab7) · [Patch](https://github.com/Artking175/ztrx/commit/ecfda9ecb74e7c115bd1600f532f6c6ebae61ab7.patch) - The first shader stores both address dwords to a separate UAV. It checks the two host address inputs for both 4- and 8-dword table entries. - The second uses dword 15 in the stored value. On this PR it is refused at the consuming store (`0x24`) with `a descriptor's address or format read as data`. With the same tests on main (`90b529f`), both reproduced `a descriptor read only as data` at `0x24`. Reinstating just the `count <= 4` guard on this PR also reproduced that refusal in the first test. Both tests passed on macOS and on Windows 10 22H2 with an RTX 2060 (driver 531.41). On Windows both builds included #121 and #11 for the test runtime, used Agility SDK 1.608.2 and confirmed hardware SM 6.6. DXIL for both address cases passed the pinned 1.8.2505.32 validator. The full Windows shader suite finished with 214 passed, 0 failed, and 3 ignored. Windows Clippy passed with all targets, all features, and `-D warnings`. This was a synthetic check. The five shader containers from #38 still need an offline comparison.
xiaotu030202 commented 2026-11-25 15:08:45 +00:00 (Migrated from github.com)
Author
First-time contributor

Imported from Zettrox/ztrx. Originally posted by xiaotu030202 on 2026-11-25T14:35:27Z.


Thanks — I took both, and I reproduced your result before doing it.

What I checked, on this branch (ab387f1 + your ecfda9ec applied):

your two tests                     ->  2 passed
reinstating `count <= 4`           ->  2 FAILED
  "a descriptor read only as data" at offset: 36 (0x24)

That matches what you reported for main, which is the part that matters: it says the guard is what those two tests depend on, and not something incidental to how I wrote the branch.

Your second test is the one I was missing. Mine only asserts that a s_load_dwordx8 of an unused entry asks for the two address dwords — it never reaches a consumer, so it cannot tell "the address is right" from "the missing dwords behave". Using dword 15 in a stored value and pinning the refusal at 0x24 is exactly the case that distinguishes them, and it also settles a thing I had only asserted in prose:

ceb5eb68cd99cb07 (the fifth shader I originally counted in #38) reads a descriptor's format as data rather than only its address, so it stops one step later and this PR does not move it.

Your …refuses_storing_a_missing_word is now the executable statement of that sentence, so I corrected the comment in lower.rs — it said "five shaders", which I had already amended in the description but not in the code. It says four now, and points at your test for where the fifth stops.

What is now on the branch:

my a_descriptor_load_of_eight_dwords_answers_with_the_address the 8-dword address path
your a_sixteen_dword_descriptor_load_supplies_both_address_words 16 dwords, 4- and 8-dword entries, DXIL validated
your a_sixteen_dword_descriptor_load_refuses_storing_a_missing_word the consumer refusing a dword with no host value

cargo test -p victory-shader --lib is 218 passed, 0 failed, 2 ignored; clippy clean; cargo xtask policy 172 files ok, on Windows 11 / RTX 5070 Ti / Rust 1.98.1 / MSVC 14.44.35207 with VICTORY_DXIL set.

One thing I cannot do that you can: you ran this on macOS and on Windows 10 with an RTX 2060; I have only Windows 11 and one card, so your run is the wider evidence for the container and validator behaviour, not mine.

You are right that this is synthetic. The five containers from #38 still want the offline comparison — I have no game files, so victory translate --list over shaders.rpf is not something I can run. If you have them, the interesting question is whether the four name a different reason now or disappear; either answer is worth having, and the fifth should stay on a descriptor's address or format read as data if I have read it correctly.

<!-- greyfinch-sync:Zettrox/ztrx:comment:7165511505 --> Imported from [Zettrox/ztrx](https://github.com/Zettrox/ztrx/pull/118#issuecomment-7165511505). Originally posted by [xiaotu030202](https://github.com/xiaotu030202) on 2026-11-25T14:35:27Z. --- Thanks — I took both, and I reproduced your result before doing it. **What I checked, on this branch (`ab387f1` + your `ecfda9ec` applied):** ``` your two tests -> 2 passed reinstating `count <= 4` -> 2 FAILED "a descriptor read only as data" at offset: 36 (0x24) ``` That matches what you reported for `main`, which is the part that matters: it says the guard is what those two tests depend on, and not something incidental to how I wrote the branch. **Your second test is the one I was missing.** Mine only asserts that a `s_load_dwordx8` of an unused entry asks for the two address dwords — it never reaches a consumer, so it cannot tell "the address is right" from "the missing dwords behave". Using dword 15 in a stored value and pinning the refusal at `0x24` is exactly the case that distinguishes them, and it also settles a thing I had only asserted in prose: > `ceb5eb68cd99cb07` (the fifth shader I originally counted in #38) reads a descriptor's *format* as data rather than only its address, so it stops one step later and this PR does not move it. Your `…refuses_storing_a_missing_word` is now the executable statement of that sentence, so I corrected the comment in `lower.rs` — it said "five shaders", which I had already amended in the description but not in the code. It says four now, and points at your test for where the fifth stops. **What is now on the branch:** | | | |---|---| | my `a_descriptor_load_of_eight_dwords_answers_with_the_address` | the 8-dword address path | | your `a_sixteen_dword_descriptor_load_supplies_both_address_words` | 16 dwords, 4- and 8-dword entries, DXIL validated | | your `a_sixteen_dword_descriptor_load_refuses_storing_a_missing_word` | the consumer refusing a dword with no host value | `cargo test -p victory-shader --lib` is 218 passed, 0 failed, 2 ignored; clippy clean; `cargo xtask policy` 172 files ok, on Windows 11 / RTX 5070 Ti / Rust 1.98.1 / MSVC 14.44.35207 with `VICTORY_DXIL` set. One thing I cannot do that you can: you ran this on macOS and on Windows 10 with an RTX 2060; I have only Windows 11 and one card, so your run is the wider evidence for the container and validator behaviour, not mine. You are right that this is synthetic. The five containers from #38 still want the offline comparison — I have no game files, so `victory translate --list` over `shaders.rpf` is not something I can run. If you have them, the interesting question is whether the four name a different reason now or disappear; either answer is worth having, and the fifth should stay on `a descriptor's address or format read as data` if I have read it correctly.
Artking175 commented 2026-11-25 16:13:09 +00:00 (Migrated from github.com)
Author
First-time contributor

Imported from Zettrox/ztrx. Originally posted by Artking175 on 2026-11-25T16:11:03Z.


Offline retest on RTX 2060 (driver 531.41), with app-local Agility SDK 1.608.2 and DXIL validator from DXC 1.8.2505.32. I ran translate --jobs 1 --validate --pipelines --list on the same local 1.0.2.1 shader archive.

All five #38 containers were present. The exact head 2dd6396 failed to compile in victory-shader. Three unrelated lowering hunks in lower.rs reference missing flags::DOUBLES, Types::f64, Cast::FPTrunc and Cast::FPExt. I removed those three hunks in a local test build, retaining both descriptor hunks and the full emit/mod.rs from this head.

Hash Refusal on main and the descriptor-only build Offset
2fd01fca16993001 a descriptor read only as data 0x51c4
6b6db9f1a526daeb same 0x49dc
abc6a80d46edc294 same 0x4808
7d0f14ce44746d7e same 0x5204
ceb5eb68cd99cb07 a descriptor's address or format read as data 0x38

The first four did emit, validate and create PSOs on #69 (811d2ca) in the same run matrix. The fifth still refuses there.

<!-- greyfinch-sync:Zettrox/ztrx:comment:7167666755 --> Imported from [Zettrox/ztrx](https://github.com/Zettrox/ztrx/pull/118#issuecomment-7167666755). Originally posted by [Artking175](https://github.com/Artking175) on 2026-11-25T16:11:03Z. --- Offline retest on RTX 2060 (driver 531.41), with app-local Agility SDK 1.608.2 and DXIL validator from DXC 1.8.2505.32. I ran `translate --jobs 1 --validate --pipelines --list` on the same local 1.0.2.1 shader archive. All five #38 containers were present. The exact head `2dd6396` failed to compile in `victory-shader`. Three unrelated lowering hunks in `lower.rs` reference missing `flags::DOUBLES`, `Types::f64`, `Cast::FPTrunc` and `Cast::FPExt`. I removed those three hunks in a local test build, retaining both descriptor hunks and the full `emit/mod.rs` from this head. | Hash | Refusal on main and the descriptor-only build | Offset | | --- | --- | --- | | `2fd01fca16993001` | `a descriptor read only as data` | `0x51c4` | | `6b6db9f1a526daeb` | same | `0x49dc` | | `abc6a80d46edc294` | same | `0x4808` | | `7d0f14ce44746d7e` | same | `0x5204` | | `ceb5eb68cd99cb07` | `a descriptor's address or format read as data` | `0x38` | The first four did emit, validate and create PSOs on #69 (`811d2ca`) in the same run matrix. The fifth still refuses there.
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/118:upstream-pr/118'
git switch 'upstream-pr/118'

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