Grouped s_buffer_load with bounded records: one dword past the view zeroes the whole group #59

Closed
opened 2026-12-01 07:42:23 +00:00 by github-bot · 1 comment
Owner

@⁠Anzymanz on GitHub · 2026-12-01 07:24 UTC · original

Lower::raw_dwords (crates/victory-shader/src/emit/lower.rs, about line 9782 on main) bounds each group of up to four dwords by the group's last byte: self.at(h, a, 4 * n). When a records view has a length and only the tail of the group lies past it, the whole group reads 0. The console bounds each dword on its own: the dwords inside the view keep their values and only the ones past the end read 0.

Where we hit it: shader 6b176df5514d9a3f does an s_buffer_load_dwordx4 at byte 0x14 of a 32-byte view (dwords 5-8). Only dword 8 is past the end, but dwords 5-7 also come back as 0. In that program the lost dwords select a copy source, and the result is that the main characters' faces are over-driven in close-ups (lips and creases pushed too far). With the change, those close-ups look natural and keep their expression, and other characters' faces are unchanged.

The change we run (behind a switch on our side; we'd suggest it unconditionally):

// in raw_dwords, for each group:
let per_dword = self.based.get(&h).is_some_and(|&(_, len)| len.is_some());
let rel = self.s.m.bin(c, Bin::Add, addr, off);
let a = self.at(h, rel, if per_dword { 4 } else { 4 * n });
// ... after the load, for each k in 0..n:
let mut x = self.as_int(x);
if per_dword && k > 0 && let Some(&(_, Some(len))) = self.based.get(&h) {
    let last = self.s.m.i32(4 * k + 3);
    let end = self.s.m.bin(c, Bin::Add, rel, last);
    let inside = self.s.m.cmp(c, pred::IULT, end, len);
    let zero = self.s.m.i32(0);
    x = self.s.m.select(c, inside, x, zero);
}
out.push(x);

The first dword's bound decides whether the group is read at all; each later dword past the view is replaced by 0. Upstream VIctory main doesn't group these loads (it reads one dword per load), so this only affects trees with the grouped raw_dwords.

Checked on: RX 9070 XT, Ryzen 9 5950X, CachyOS, Mesa 26.3.1 RADV with this repository's RADV patches, GE-Proton. One run, judged by looking at the same close-ups with the change on and off (it acts when shaders are translated, so there is no timing to report). No captures attached: hashes and offsets only.

Written with Claude Code.

**@⁠Anzymanz** on GitHub · 2026-12-01 07:24 UTC · [original](https://github.com/lobomfz/VIctory-xmem/issues/59) `Lower::raw_dwords` (crates/victory-shader/src/emit/lower.rs, about line 9782 on main) bounds each group of up to four dwords by the group's last byte: `self.at(h, a, 4 * n)`. When a records view has a length and only the tail of the group lies past it, the whole group reads 0. The console bounds each dword on its own: the dwords inside the view keep their values and only the ones past the end read 0. Where we hit it: shader `6b176df5514d9a3f` does an `s_buffer_load_dwordx4` at byte 0x14 of a 32-byte view (dwords 5-8). Only dword 8 is past the end, but dwords 5-7 also come back as 0. In that program the lost dwords select a copy source, and the result is that the main characters' faces are over-driven in close-ups (lips and creases pushed too far). With the change, those close-ups look natural and keep their expression, and other characters' faces are unchanged. The change we run (behind a switch on our side; we'd suggest it unconditionally): ```rust // in raw_dwords, for each group: let per_dword = self.based.get(&h).is_some_and(|&(_, len)| len.is_some()); let rel = self.s.m.bin(c, Bin::Add, addr, off); let a = self.at(h, rel, if per_dword { 4 } else { 4 * n }); // ... after the load, for each k in 0..n: let mut x = self.as_int(x); if per_dword && k > 0 && let Some(&(_, Some(len))) = self.based.get(&h) { let last = self.s.m.i32(4 * k + 3); let end = self.s.m.bin(c, Bin::Add, rel, last); let inside = self.s.m.cmp(c, pred::IULT, end, len); let zero = self.s.m.i32(0); x = self.s.m.select(c, inside, x, zero); } out.push(x); ``` The first dword's bound decides whether the group is read at all; each later dword past the view is replaced by 0. Upstream VIctory `main` doesn't group these loads (it reads one dword per load), so this only affects trees with the grouped `raw_dwords`. Checked on: RX 9070 XT, Ryzen 9 5950X, CachyOS, Mesa 26.3.1 RADV with this repository's RADV patches, GE-Proton. One run, judged by looking at the same close-ups with the change on and off (it acts when shaders are translated, so there is no timing to report). No captures attached: hashes and offsets only. Written with Claude Code.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 07:42:23 +00:00
Author
Owner

@⁠Anzymanz on GitHub · 2026-12-01 07:25 UTC · original

Closing as a duplicate: this is already fixed on main by #29 (b0bc827b7, per-dword bounds, for #18). I checked an older copy of main before filing; sorry for the noise. The fix matches what we see: with per-dword bounds the faces render correctly here.

Written with Claude Code.

**@⁠Anzymanz** on GitHub · 2026-12-01 07:25 UTC · [original](https://github.com/lobomfz/VIctory-xmem/issues/59#issuecomment-7304030104) Closing as a duplicate: this is already fixed on `main` by #29 (`b0bc827b7`, per-dword bounds, for #18). I checked an older copy of `main` before filing; sorry for the noise. The fix matches what we see: with per-dword bounds the faces render correctly here. Written with Claude Code.
This discussion has been locked. Commenting is limited to contributors.
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.

Dependencies

No dependencies set

Reference
github/lobomfz--VIctory-xmem#59
No description provided.