xshader: read a raw buffer only in lanes inside EXEC #386

Merged
MathiewMay merged 1 commit from upstream-pr/386 into main 2026-11-28 11:19:37 +00:00
MathiewMay commented 2026-11-28 09:20:04 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by MathiewMay on 2026-11-28T09:20:04Z.


Summary

A raw buffer load that has no index register (OFFEN, or a constant offset) was emitted for every lane. On the console a lane outside EXEC performs no memory access, and its address register can hold any value. Through a root SRV, which has no bounds, the host read wherever that value pointed. Indexed raw loads already tested the lane's EXEC bit; this makes every raw load do so (tools/shader-compiler/src/hlsl/emitter/buffer.rs). Stores already did.

ProjectScarlett's skinned mesh programs hit this at the first cinematic. They divide by a meshlet count, which leaves the reciprocal 0xFFFFFF00 / n in a VGPR, then narrow EXEC to the meshlet's vertices and load at a byte offset that only those lanes compute. The other lanes read the root SRV at +0x7ffff000 (n = 2), +0x2aaaa000 (n = 6) or +0x11111000 (n = 15) and faulted the GPU. The fault address in each run was the first unfinished dispatch_mesh's root descriptor plus one of those values.

In game I tested this on c05ce00 together with other fixes of mine, not on this branch alone. Before it, all 7 crash logs with a fault address showed this pattern; in the 14 runs since, no fault had it.

#320's "Known issue" describes TCP read faults at title addresses at world entry. It may be this fault; it could be worth trying #320 with this change.

Tested

  • The checks relevant to this change passed
  • Changed or new behaviour is covered by a Lanes scenario, or the reason it cannot be is stated below
  • Where the table calls for AMD and NVIDIA, they passed on both. Otherwise, say which vendor still needs to run them: NVIDIA still needs to run them.

Not a Lanes scenario: without the change, the failure is a GPU page fault in another lane's read, which would reset the GPU running the check. Two unit tests in tools/shader-compiler/src/tests/hlsl/raw_width.rs cover the emitted code, and both fail on main:

  • raw_loads_read_only_for_lanes_in_exec: a buffer_load_dwordx4 without an address register, with OFFEN, with IDXEN, and with both. Every load sits behind an EXEC test.
  • a_stale_address_outside_exec_is_never_read: the ProjectScarlett pattern above, encoded with llvm-mc -mcpu=gfx1030: an address only lanes in EXEC compute, and a root SRV.

The translator's GPU checks (59, including buffer-loads) and the Lanes suites run the changed loads on the GPU.

GPU, driver and backend: AMD Radeon RX 9070 (1002:7550, RADV GFX1201), Mesa 26.2.7, Linux 7.3, GE-Proton11-14 (--backend proton).

Commands run and their results:

cargo test --locked --target x86_64-unknown-linux-gnu --manifest-path tools/shader-compiler/Cargo.toml
  510 passed (plus 3 in the other test targets); the two new tests fail on main

python tools/check_translator_gpu.py --provider build/d3d12-smoke/d3d12_xs.dll ... --adapter 1002:7550
  59 PASS, 0 FAIL

python tuxbox.py verify --only lanes-shader-cache --only lanes-raster-tables --only lanes-compute-root
    --only lanes-compute-root-recovery --only lanes-bindless-compute --backend proton --adapter 1002:7550
  28 PASS, 0 FAIL

python tuxbox.py check --no-gpu
  passed   Build the shader compiler, Python tests, Shader compiler tests, DXBC tests,
           XG layout tests, Storage codec tests, D3D12 Windows typecheck

The translator checks ran outside their Bubblewrap/xvfb-run sandbox, which stalls on this machine (it has no Xvfb).

Checks

No evidence JSON changes. The recorded host-profile outputs (host_profiles.txt) do not change.

<!-- greyfinch-sync:brcly/TuxBox:issue:5538673824 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/386). Originally posted by [MathiewMay](https://github.com/MathiewMay) on 2026-11-28T09:20:04Z. --- ## Summary A raw buffer load that has no index register (`OFFEN`, or a constant offset) was emitted for every lane. On the console a lane outside EXEC performs no memory access, and its address register can hold any value. Through a root SRV, which has no bounds, the host read wherever that value pointed. Indexed raw loads already tested the lane's EXEC bit; this makes every raw load do so (`tools/shader-compiler/src/hlsl/emitter/buffer.rs`). Stores already did. ProjectScarlett's skinned mesh programs hit this at the first cinematic. They divide by a meshlet count, which leaves the reciprocal `0xFFFFFF00 / n` in a VGPR, then narrow EXEC to the meshlet's vertices and load at a byte offset that only those lanes compute. The other lanes read the root SRV at `+0x7ffff000` (n = 2), `+0x2aaaa000` (n = 6) or `+0x11111000` (n = 15) and faulted the GPU. The fault address in each run was the first unfinished `dispatch_mesh`'s root descriptor plus one of those values. In game I tested this on `c05ce00` together with other fixes of mine, not on this branch alone. Before it, all 7 crash logs with a fault address showed this pattern; in the 14 runs since, no fault had it. #320's "Known issue" describes TCP read faults at title addresses at world entry. It may be this fault; it could be worth trying #320 with this change. ## Tested - [x] The checks relevant to this change passed - [x] Changed or new behaviour is covered by a Lanes scenario, or the reason it cannot be is stated below - [ ] Where the table calls for AMD and NVIDIA, they passed on both. Otherwise, say which vendor still needs to run them: **NVIDIA still needs to run them.** Not a Lanes scenario: without the change, the failure is a GPU page fault in another lane's read, which would reset the GPU running the check. Two unit tests in `tools/shader-compiler/src/tests/hlsl/raw_width.rs` cover the emitted code, and both fail on `main`: - `raw_loads_read_only_for_lanes_in_exec`: a `buffer_load_dwordx4` without an address register, with `OFFEN`, with `IDXEN`, and with both. Every load sits behind an EXEC test. - `a_stale_address_outside_exec_is_never_read`: the ProjectScarlett pattern above, encoded with `llvm-mc -mcpu=gfx1030`: an address only lanes in EXEC compute, and a root SRV. The translator's GPU checks (59, including `buffer-loads`) and the Lanes suites run the changed loads on the GPU. GPU, driver and backend: AMD Radeon RX 9070 (1002:7550, RADV GFX1201), Mesa 26.2.7, Linux 7.3, GE-Proton11-14 (`--backend proton`). Commands run and their results: ```text cargo test --locked --target x86_64-unknown-linux-gnu --manifest-path tools/shader-compiler/Cargo.toml 510 passed (plus 3 in the other test targets); the two new tests fail on main python tools/check_translator_gpu.py --provider build/d3d12-smoke/d3d12_xs.dll ... --adapter 1002:7550 59 PASS, 0 FAIL python tuxbox.py verify --only lanes-shader-cache --only lanes-raster-tables --only lanes-compute-root --only lanes-compute-root-recovery --only lanes-bindless-compute --backend proton --adapter 1002:7550 28 PASS, 0 FAIL python tuxbox.py check --no-gpu passed Build the shader compiler, Python tests, Shader compiler tests, DXBC tests, XG layout tests, Storage codec tests, D3D12 Windows typecheck ``` The translator checks ran outside their Bubblewrap/`xvfb-run` sandbox, which stalls on this machine (it has no Xvfb). ## Checks No evidence JSON changes. The recorded host-profile outputs (`host_profiles.txt`) do not change.
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
brcly/TuxBox!386
No description provided.