Repository navigation
Conversation
A compute program whose root signature does not fit the 16 user SGPRs finds its arguments through a spill table: s[0:1] holds a pointer (high dword masked to 40 bits, usually copied to s2/s3 first) to a table of the user data, and the program s_loads descriptors and constants from it. Table dword k is user SGPR 16 + k. The translator only knew addresses that come from the declared root layout, so every such program failed with "an address in an SGPR that is no root parameter". For compute programs whose root layout lies entirely at user SGPR 16 and above, loads from that pointer with a constant offset become s_mov_b32 copies of the user SGPRs the dwords stand for, before the SSA is built, so resource tracking and lowering see what they see for ordinary root arguments. Only straight-line code from the pointer's set-up is rewritten (tags are dropped at branch targets and on any overwrite of the pointer registers); other loads stay loads. On the title's world shaders this took the "SGPR that is no root parameter" failures from 34 programs to 4 in one run. Other failures that were hidden behind it now show (address not from a root parameter, root UAV or typed root view, an address from a phi...). Whether the translated programs render correctly has not been checked beyond that. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
In-game test on an RX 7800 XT (Windows 11 26200), The targeted reason drops a lot:
The two growing rows look like shaders that now get past the spill table and stop at the next unsupported construct. Draws and dispatches lost per frame went from about 1,770 to about 1,340 in total (rates averaged over the run, menus included). The rates are not strictly comparable: this run was shorter, so the menus weigh less. It ended at 67 s on the known page fault inside freed textures (#135's remaining case); comparable builds reached 113–177 s. That is one run, and it may just be that more draws now reach those textures sooner. No world frame was captured, so I can't say whether the picture changed. |
|
Tested on top of
let spilled = p.stage == victory_shader::HwStage::Cs
&& !p.layout.is_empty()
&& p.layout.iter().all(|r| p.stage.user_sgpr(r.user_data) >= 16);
match ir::build_with(&p.patched_code(), p.wave64, p.vgprs, spilled) {Maybe worth exposing one helper for that rule so the two call sites cannot drift.
What blocks them now:
The second row comes from the For context on why this matters: on Linux (RTX 5060 Ti, vkd3d-proton 3.2.0) the world's No game data attached. |
|
Review note, with a small repro. The rewrite turns a spill-table load into With this PR on gives The second load's moves read the values the first load just wrote ( The example in the description loads into s8..s15, so it does not hit this, and the 34 to 4 count may well be unaffected. But nothing stops a program from loading into s16+. Could the rewrite read the entry values directly (the program's inputs for user SGPR 16+k) rather than the live registers, or be skipped once any of those registers has been written earlier in the scan? This is the PR for the top row of #293, so it matters that it cannot bind the wrong argument silently. From a synthetic test only; I have no copy of the title. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Measured this PR against the title's own world shaders (v1.0.2.1). Summary: it clears the first failure of every program it targets, but none of them translate fully yet. The next stop for most is an address that comes out of the spill table. How
Merge noteThis PR conflicts with #309 in Result: 34 programs that fail with
|
| Next failure with this PR | Programs |
|---|---|
an address not from a root parameter |
12 |
a root UAV or typed root view (emit) |
8 |
an address from a root parameter that is no address |
6 |
an address in an SGPR that is no root parameter (at a later instruction) |
4 |
an address from a phi |
2 |
a select on an untracked mask (emit) |
2 |
| fully translated | 0 |
The smallest case
3b90165a77d95cdf is a 22-instruction compute program. Its layout is two root descriptors and one root-constant block, all at user data 16 or above, so spilled is true. It reads the constants from the spill table, which this PR now resolves. It also loads the address of its root UAV from the table (the 64-bit value at that parameter's offset) and builds a buffer descriptor around it for a buffer_store. That address is still reported as an address in an SGPR that is no root parameter at the store. Treating a 64-bit spill-table load at a root-descriptor parameter's offset as that parameter's address looks like the natural next step. Most of the rows above look like the same case.
Side note
victory translate (apps/victory/src/translate.rs) still calls ir::build, so static scans do not apply the spill rule and show none of these programs failing the way they do at run time. With the same spilled condition there, the CLI matches the runtime.
No game data attached.
|
@dadou000 @r4tedx I opened #489 on top of this PR. It fixes the entry-value issue r4tedx reported: the user SGPRs the table loads stand for are copied into an unused SGPR block on entry, and the loads read that block. It does show up in the title's shaders. |
|
Example: the ray-tracing builder's DLL ( Building the CLI's programs the way AI use: Claude Code, Claude Opus 5.5. |
|
Independent check of head Read against the RDNA2 ISA (30-November-2020)
Run on hardware. NVIDIA RTX 3070, driver 616.56, Windows 11, Rust 1.98.1,
Not raised above, small
Verdict from here: correct only together with #489's commit; I would merge them as one. Not checked: the title (no game files here), AMD hardware, the 16-or-more user SGPR case discussed on #489. AI-assisted (Claude Code). |
The ray-tracing builder passes buffer addresses as a pair of root constants rather than as root views, so its programs failed with "an address from a root parameter that is no address". The tracker now takes a root constant as an address's low half when the next dword of the same parameter is its high half, and records which dword (`Address::dword`). The emitter binds such an address as a root CBV or raw SRV, as it does for root descriptors, at a register that names the parameter and the dword (`RootView`, `(dword + 1) << 8 | slot`); root view registers are 16 bits now. The GPU side reads the address from the two constants the title set and binds it as it does a root view. The shader cache format is VSH2 (16-bit registers). Root UAVs (Marvisak#294) and the spill table (Marvisak#302) are still needed for the builder's programs to translate in the title; tested with synthetic programs only (tracking, lowering, dxil.dll validation, pipeline creation on an RTX 5080), no game data. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…pill only with s16 free Port of the rest of upstream Marvisak#489 (Brazlucas: 915d13d, 608f150, fe7210e; JMAN730#302 was already in). Spill-table loads read the root arguments as they were at entry even after the program overwrote the SGPR; the spill rule applies only when the hardware puts nothing in s16 (with 16 user SGPRs the group id sits there), and victory translate uses the same rule; a spill-table pointer mask must keep every address bit. Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
|
Retail-run confirmation on Linux/RADV: this is the change that turned a black screen into a visible, coloured 3D scene here.
Before, the run logged 27 After this PR: 4 such lines left, the scene reaches 3,770-3,881 draws/frame and, with Merge note, in case someone stacks it the same way: on top of #1402 this PR conflicts in Remaining in the log: 4 x |
The ray-tracing builder passes buffer addresses as a pair of root constants rather than as root views, so its programs failed with "an address from a root parameter that is no address". The tracker now takes a root constant as an address's low half when the next dword of the same parameter is its high half, and records which dword (`Address::dword`). The emitter binds such an address as a root CBV or raw SRV, as it does for root descriptors, at a register that names the parameter and the dword (`RootView`, `(dword + 1) << 8 | slot`); root view registers are 16 bits now. The GPU side reads the address from the two constants the title set and binds it as it does a root view. The shader cache format is VSH2 (16-bit registers). Root UAVs (#294) and the spill table (#302) are still needed for the builder's programs to translate in the title; tested with synthetic programs only (tracking, lowering, dxil.dll validation, pipeline creation on an RTX 5080), no game data. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 995f7f3ee720270108dfe93decb0f8c3c53f613b)
|
A note for when this lands: Measured on a full shader pack, |
What
Compute programs whose root signature does not fit the 16 user SGPRs read their arguments through a spill table:
s[0:1]holds a pointer (high dword masked to 40 bits, usually copied tos2/s3first) to a table of user data, and the programs_loads descriptors and constants from it. Table dword k is user SGPR16 + k. The translator only knew addresses that come from the declared root layout, so all of these failed withan address in an SGPR that is no root parameter.For a compute program whose root layout lies entirely at user SGPR 16 and above, loads from that pointer with a constant offset become
s_mov_b32copies of the user SGPRs the dwords stand for. This happens before the SSA is built, so resource tracking and lowering see ordinary root arguments.Only straight-line code from the pointer's set-up is rewritten. Tags are dropped at branch targets and whenever a pointer register is overwritten. Any other load stays a load.
Evidence
Example from the world shaders (a 64-thread group; layout is two constants then two descriptors, user data 16 to 23):
One 64-thread-group dispatch in the title sets nine root parameters (about 35 dwords), and its shader loads at offsets 0x0, 0x20 and 0x4c, which is what a spill table of those arguments would look like.
On the world's compute shaders,
an address in an SGPR that is no root parameterwent from 34 programs to 4 in one run (RTX 4090, Windows 11). Failures that were hidden behind it now show:an address not from a root parameter,a root UAV or typed root view,an address from a phi,a descriptor read only as data.Not verified
cargo test -p victory-shader --libpasses (71 tests).🤖 Generated with Claude Code