Shaders: "an address with two computed terms" drops ~900 vertex/pixel programs (200–270 draws a frame); a small fix #773

Closed
opened 2026-11-28 05:34:07 +00:00 by traeb0n · 1 comment
traeb0n commented 2026-11-28 05:34:07 +00:00 (Migrated from github.com)
Contributor

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by traeb0n on 2026-11-28T05:34:07Z.


What happens

resource.rs address() refuses an access when the base register pair holds a table plus a computed index and the instruction's offset operand is computed too. That covers soffset on scalar loads (s_load_dwordx4 s[..], s[t:t+1], s9) and the VGPR offset on global loads. The pipeline is refused, and its draws are dropped.

One run of the opening: release build, Series X, 2560x1440, DLSS Quality, -Fast with VICTORY_SEND_THREAD=0, RTX 5070, about 3.5 minutes:

  • 994 shaders did not translate. 913 different hashes had an address with two computed terms is not supported: 481 vertex, 512 pixel, at code offsets 0x68–0xcc.
  • The frame line showed 200–270 draws a frame dropped without a host pipeline, with none being made.

Why it can be allowed

Address keeps only one computed term (dynamic), but the computed term is only used for arithmetic in three places in lowering. Descriptor loads from tables and heaps (heap_index) already compute their index from the registers (base + offset + soffset), not from Address::dynamic. So the refusal is about bookkeeping, not something lowering can't do.

The change (based on main 63b902f)

crates/victory-shader/src/resource.rs:

pub struct Address {
    pub param: usize,
    pub offset: u32,
    pub dynamic: Option<Value>,
    /// A second computed term, added to `dynamic`: only where `dynamic` is one too
    /// (the base's and the offset operand's when both are computed).
    pub dynamic2: Option<Value>,
}

In address(), in place of the early Err("an address with two computed terms"):

let (dynamic, dynamic2) = match (s.dynamic, extra.dynamic) {
    (Some(a), Some(b)) => (Some(a), Some(b)),
    (a, b) => (a.or(b), None),
};
  • The s_getpc_b64 (table in the code) branch still returns that error when dynamic2.is_some().
  • The final Ok(Address { .. }) uses dynamic and dynamic2.
  • Every other Address literal gets dynamic2: None.

Readers that look at the shape of dynamic won't take a two-term address:

  • root_indexed_view: if address.dynamic2.is_some() { return None; }
  • first_lane_offset: address.ok().filter(|a| a.dynamic2.is_none())?
  • The line-up check for fetched descriptors compares (param, dynamic, dynamic2).

Every other reader only checks dynamic.is_none() / is_some(). Those stay correct because dynamic2 is only ever set when dynamic is set too.

crates/victory-shader/src/emit/lower.rs:

  • Global loads: add both terms, with for d in [a.dynamic, a.dynamic2].into_iter().flatten() { off = off + i32_of(d) }.
  • Scalar loads from the code: Err if a.dynamic2.is_some().
  • built_offset: add dynamic2 to dynamic when present.

Results

  • cargo test --release -p victory-shader --lib: 350 passed, 0 failed.
  • The preload's precompile tally over 25,760 containers lists no two computed terms failures. 225 shaders fail for other reasons: 198 containers with no vertex, pixel, compute or mesh program, 22 with no wave32 lowering for a wave64 program, and 5 with a descriptor read only as data.
  • Not yet checked in the game after the fix. Pipelines from pieces aren't in that tally, so a run should confirm that the dropped-draw count goes down.

Also, for anyone merging PR #18 together with Kemerd#7 onto current main:

  • count_refusal gets defined twice in host/card_steps.rs. Keeping main's fixed-table version works.
  • The old s_pack_ll_b32_b16 arm in lower.rs becomes unreachable behind the new ll/lh/hh arm.
  • vcc_read_on_entry_past_an_empty_exec_reads_as_zero_in_a_program_made_from_pieces still expects a title's program to be refused, but after commit 1150908 that program translates.

Written with an AI assistant (Claude Code); the run was on my machine. No game files attached.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:6659816523 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/773). Originally posted by [traeb0n](https://github.com/traeb0n) on 2026-11-28T05:34:07Z. --- **What happens** `resource.rs` `address()` refuses an access when the base register pair holds a table plus a computed index *and* the instruction's offset operand is computed too. That covers `soffset` on scalar loads (`s_load_dwordx4 s[..], s[t:t+1], s9`) and the VGPR offset on global loads. The pipeline is refused, and its draws are dropped. One run of the opening: release build, Series X, 2560x1440, DLSS Quality, `-Fast` with `VICTORY_SEND_THREAD=0`, RTX 5070, about 3.5 minutes: - 994 shaders did not translate. 913 different hashes had `an address with two computed terms is not supported`: 481 vertex, 512 pixel, at code offsets 0x68–0xcc. - The frame line showed **200–270 draws a frame dropped without a host pipeline**, with none being made. **Why it can be allowed** `Address` keeps only one computed term (`dynamic`), but the computed term is only used for arithmetic in three places in lowering. Descriptor loads from tables and heaps (`heap_index`) already compute their index from the registers (base + offset + soffset), not from `Address::dynamic`. So the refusal is about bookkeeping, not something lowering can't do. **The change** (based on main `63b902f`) `crates/victory-shader/src/resource.rs`: ```rust pub struct Address { pub param: usize, pub offset: u32, pub dynamic: Option<Value>, /// A second computed term, added to `dynamic`: only where `dynamic` is one too /// (the base's and the offset operand's when both are computed). pub dynamic2: Option<Value>, } ``` In `address()`, in place of the early `Err("an address with two computed terms")`: ```rust let (dynamic, dynamic2) = match (s.dynamic, extra.dynamic) { (Some(a), Some(b)) => (Some(a), Some(b)), (a, b) => (a.or(b), None), }; ``` - The `s_getpc_b64` (table in the code) branch still returns that error when `dynamic2.is_some()`. - The final `Ok(Address { .. })` uses `dynamic` and `dynamic2`. - Every other `Address` literal gets `dynamic2: None`. Readers that look at the *shape* of `dynamic` won't take a two-term address: - `root_indexed_view`: `if address.dynamic2.is_some() { return None; }` - `first_lane_offset`: `address.ok().filter(|a| a.dynamic2.is_none())?` - The line-up check for fetched descriptors compares `(param, dynamic, dynamic2)`. Every other reader only checks `dynamic.is_none()` / `is_some()`. Those stay correct because `dynamic2` is only ever set when `dynamic` is set too. `crates/victory-shader/src/emit/lower.rs`: - **Global loads:** add both terms, with `for d in [a.dynamic, a.dynamic2].into_iter().flatten() { off = off + i32_of(d) }`. - **Scalar loads from the code:** `Err` if `a.dynamic2.is_some()`. - **`built_offset`:** add `dynamic2` to `dynamic` when present. **Results** - `cargo test --release -p victory-shader --lib`: 350 passed, 0 failed. - The preload's precompile tally over 25,760 containers lists **no** `two computed terms` failures. 225 shaders fail for other reasons: 198 containers with no vertex, pixel, compute or mesh program, 22 with no wave32 lowering for a wave64 program, and 5 with a descriptor read only as data. - Not yet checked in the game after the fix. Pipelines from pieces aren't in that tally, so a run should confirm that the dropped-draw count goes down. **Also, for anyone merging PR #18 together with Kemerd#7 onto current main:** - `count_refusal` gets defined twice in `host/card_steps.rs`. Keeping main's fixed-table version works. - The old `s_pack_ll_b32_b16` arm in `lower.rs` becomes unreachable behind the new ll/lh/hh arm. - `vcc_read_on_entry_past_an_empty_exec_reads_as_zero_in_a_program_made_from_pieces` still expects a title's program to be refused, but after commit `1150908` that program translates. Written with an AI assistant (Claude Code); the run was on my machine. No game files attached.
github-actions[bot] commented 2026-11-28 05:34:15 +00:00 (Migrated from github.com)
Author
Contributor

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by github-actions[bot] on 2026-11-28T05:34:15Z.


Please attach both logs from the run that went wrong. Without them we can only guess. Paste %LOCALAPPDATA% into the address bar of File Explorer to get there.

  1. The play log, in %LOCALAPPDATA%\victory\logs\: the newest victory-nvidia-play-<date>-<time>-<number>.log (from victory.exe) or victory-nvidia-<date>-<time>.log (from the script launcher). The window shows its path at the start, on the line Log: ....
  2. The crash log: %LOCALAPPDATA%\VIctory\data\7952987A\crashes.log, and, if there is one from that run, the newest victory-<date>-<time>-<number>.crash.log in %LOCALAPPDATA%\VIctory\data\7952987A\temp\.

Also say which GPU, Windows version (10 or 11)

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7234750554 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/773#issuecomment-7234750554). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-28T05:34:15Z. --- Please attach both logs from the run that went wrong. Without them we can only guess. Paste `%LOCALAPPDATA%` into the address bar of File Explorer to get there. 1. The play log, in `%LOCALAPPDATA%\victory\logs\`: the newest `victory-nvidia-play-<date>-<time>-<number>.log` (from `victory.exe`) or `victory-nvidia-<date>-<time>.log` (from the script launcher). The window shows its path at the start, on the line `Log: ...`. 2. The crash log: `%LOCALAPPDATA%\VIctory\data\7952987A\crashes.log`, and, if there is one from that run, the newest `victory-<date>-<time>-<number>.crash.log` in `%LOCALAPPDATA%\VIctory\data\7952987A\temp\`. Also say which GPU, Windows version (10 or 11)
Sign in to join this conversation.
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
trustno1-coder/VIctory-NVIDIA#773
No description provided.