Repository navigation
shader: take a descriptor's address however many dwords the load reads - #118
Open
xiaotu030202 wants to merge 1 commit into
Open
xiaotu030202 wants to merge 1 commit into
xiaotu030202 wants to merge 1 commit into
Conversation
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
That is what five shaders in Zettrox#38 hit (`2fd01fca16993001`, `6b6db9f1a526daeb`,
`abc6a80d46edc294`, `7d0f14ce44746d7e`, and `ceb5eb68cd99cb07` with the
"address or format" wording). 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. The address is in the same two dwords either
way, and the host does not read the entry's length.
## The test, and how it was checked
`a_descriptor_load_of_eight_dwords_answers_with_the_address` is a
`s_load_dwordx8 s[8:15], s[4:5], 0x0` of a table entry that nothing uses,
lowered and asserted to ask the host for exactly the two address dwords.
It **fails on the code before this change** and passes after — I reverted the
`count <= 4` line and re-ran to confirm that, because a test that passes both
ways is worth nothing:
```
before: thread panicked ... test result: FAILED. 0 passed; 1 failed
after: test result: ok. 212 passed; 0 failed; 2 ignored
```
Getting there needed the SMEM encoding right on the first try, which I did not
manage: my first attempt was decoded as `s_load_dwordx4` and the test passed
on both trees for the wrong reason. The opcode sits in the low dword
(`0xF40C_0202` for `x8` s[8:15] from s[4:5]; the `0xFA00_0000` word is the
offset). An `eprintln` on the branch confirmed `count=8` reaches it before I
trusted the test.
## 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. 212 passed; 0 failed; 2 ignored
$ cargo clippy -p victory-shader --all-targets
clean
$ cargo xtask policy
asset policy: 172 files ok
```
`native` and `build` in `intersect_tests` gained `dwords` variants
(`native_with`, `build_with`) so a test can state the entry's length; the
existing helpers call them with 4 and are unchanged in behaviour.
## Not claimed
I have not seen those five shaders translate. What is established is that the
length is no longer a reason to refuse, the address path is exercised at 8 by
a test that fails without the change, and 212 tests still pass. Whether each
of the five now lowers or stops at a later, real limit is something the corpus
would say — `victory translate --list` over `shaders.rpf`, which needs game
files.
Same for the `dwords == 8` half: `intersect_tests` passes with `dwords: 8`
where it used to say 4, so the address path works there too, but nothing in
the corpus has been run.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this fixes
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_ADDRESSdwords. That path requiredcount <= 4, sos_load_dwordx8(8) ands_load_dwordx16(16) were refused outright:That is what five shaders in #38 hit:
2fd01fca169930016b6db9f1a526daebabc6a80d46edc2947d0f14ce44746d7eceb5eb68cd99cb07Nothing 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.What changed
lower.rs—count <= 4is gone from that branch. The rest of the load's dwords areMissing, exactly as dwords 2 and 3 already were for as_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. Same contract at 1, 2, 4, 8 and 16.view_addressalso accepted only a 4-dword table entry; it now takes the console's other buffer size, 8. The address is in the same two dwords either way.intersect_tests.rs—native/buildgaineddwordsvariants (native_with,build_with); the existing helpers call them with 4 and behave as before.The test is checked in both directions
a_descriptor_load_of_eight_dwords_answers_with_the_address— as_load_dwordx8 s[8:15], s[4:5], 0x0of a table entry nothing uses, lowered, asserted to ask the host for exactly the two address dwords.I reverted the
count <= 4line and re-ran, because a test that passes both ways is worth nothing:Getting there took three attempts, which is worth recording because it is the kind of mistake that produces a green test that tests nothing:
dwords: 8on the existing ray-tracing test. It passed on both trees — that program's descriptor is used, so it never reaches the branch.s_load_dwordx8as0xF408_03C2. The decoder read it ass_load_dwordx4; the test passed on both trees again, for a different wrong reason.0xF40C_0202forx8s[8:15] from s[4:5], with0xFA00_0000as the offset word. Aneprintlnon the branch confirmedcount=8reached it before I trusted the result.Verification
Windows 11, RTX 5070 Ti, Rust 1.98.1 (pinned), MSVC 14.44.35207, Windows SDK 10.0.26100.0,
VICTORY_DXILset. No game files.What is not claimed
I have not seen those five shaders translate. What is established: the length is no longer a reason to refuse, the address path is exercised at 8 by a test that fails without the change, and 212 tests pass. Whether each of the five now lowers, or stops at a later and real limit, is something
victory translate --listovershaders.rpfwould say — and that needs game files.Same for the
dwords == 8half: the address path works with it, nothing in the corpus has been run.If someone can run the census on this branch and paste the refusal list, that turns "no longer refused for this reason" into a number — and if those five move to a different reason, that reason is the next thing worth looking at.