Scalar loads: views through NonUniformResourceIndex again, each dword through the map #58

Manually merged
github merged 1 commit from gh-pr/58/head into gh-pr/58/base 2026-11-27 03:16:10 +00:00
Owner

@⁠Sr-0w on GitHub · 2026-11-26 11:38 UTC · original
Sr-0w:shaders/scalar-views-nonuniform → main · +99 −13 · 3 files · 1 commits · merged 2026-11-26 12:20 UTC

What

SBufLoad and SPtrLoad index their views through NonUniformResourceIndex again, and SPtrLoadAt reads as SPtrLoad, one map walk per dword. sptr_views is still emitted and left to dead-code elimination. The change is in the prelude only.

Why

On an RX 7800 XT, since the uniform scalar-load views (53862e66), every boot of a retail game ended in a device hang (0x887a0006). The DRED page fault was at an address no allocation held, existing or recently freed (0x7206000 to 0x73bc000), 1,200 to 2,000 presents in. That happened on eleven boots across main.

How the cause was narrowed down (each a full boot with --d3d12-dred):

build result
main 06:41 + #56/#57 device hang, about 1,200 presents (5 boots)
same, minus 53862e66, 11bc783a, be40d978 6,933 presents, no fault
same, minus 53862e66 only 12,017 presents, no fault
main b5d8d02a, uniform views device hang (2 boots)
main, non-uniform only for emulated program waves narrower than 64 device hang
main, uniform only for emulated wave64 programs, non-uniform otherwise device hang
main, all views non-uniform, SPtrLoadAt's select kept no fault, but the AMD compiler crashes in CreatePipelineState 8 presents in (PS_DeferredTextured_*, found by journaling each pipeline compile)
main, non-uniform, SPtrLoadAt as SPtrLoad (this PR) 9,024 and 13,796 presents, no fault, no compiler crash (warm cache, 40 minutes each)

One mechanism is explained. With wave emulation, a hardware wave wider than the program wave holds several program waves. Their SGPRs differ, because readfirstlane reads each program wave's own first lane. The AMD driver then reads every lane's view at the first lane's index. ScalarViewWaveTests reproduces this.

Another is not. Wave64 programs needed the non-uniform form too: with it applied to everything except them, the hang came back. I could not explain that from their translation; their SGPRs come from user data, scalar loads and uniform arithmetic. So this PR restores the earlier form rather than claiming a narrower fix.

Cost: this gives back the scalar-load part of 53862e66's gain for the G-buffer pixel programs. In return, a boot runs through.

In game (retail game, RX 7800 XT)

  • Before: the boot ends in a device hang 1,200 to 2,000 presents in, during the intro or the loading screen.
  • After: the boot reaches the first controllable scene ("Move around / Move the camera") at about 4 fps, as the game's counter shows, and runs until the run's time limit.
  • Still open: the scene was black on b5d8d02a, before the exposure fixes. A boot on 905deb80 with this change hung with a different fault, with recently freed allocations and over the GPU memory budget. I am looking into it separately.

Tests

  • New ScalarViewWaveTests: program waves pick their view from readfirstlane of the thread index, 1 to 4 program waves per hardware wave.
    • With FIVESTAR_TEST_ADAPTER=hardware on the RX 7800 XT, it fails with the uniform form (two 16-lane program waves on a 32-lane wave read the first one's view) and passes with this change.
    • WARP passes either way.
  • Shader tests: 524 passed, 14 skipped.
  • docs/shader-translation.md is updated.

🤖 Generated with Claude Code

**@⁠Sr-0w** on GitHub · 2026-11-26 11:38 UTC · [original](https://github.com/ThatRecompDev/five-star-recomp/pull/58) `Sr-0w:shaders/scalar-views-nonuniform` → `main` · +99 −13 · 3 files · 1 commits · merged 2026-11-26 12:20 UTC ## What `SBufLoad` and `SPtrLoad` index their views through `NonUniformResourceIndex` again, and `SPtrLoadAt` reads as `SPtrLoad`, one map walk per dword. `sptr_views` is still emitted and left to dead-code elimination. The change is in the prelude only. ## Why On an RX 7800 XT, since the uniform scalar-load views (53862e66), every boot of a retail game ended in a device hang (`0x887a0006`). The DRED page fault was at an address no allocation held, existing or recently freed (0x7206000 to 0x73bc000), 1,200 to 2,000 presents in. That happened on eleven boots across main. How the cause was narrowed down (each a full boot with `--d3d12-dred`): | build | result | |---|---| | main 06:41 + #56/#57 | device hang, about 1,200 presents (5 boots) | | same, minus 53862e66, 11bc783a, be40d978 | 6,933 presents, no fault | | same, minus 53862e66 only | **12,017 presents, no fault** | | main b5d8d02a, uniform views | device hang (2 boots) | | main, non-uniform only for emulated program waves narrower than 64 | device hang | | main, uniform only for emulated wave64 programs, non-uniform otherwise | device hang | | main, all views non-uniform, `SPtrLoadAt`'s select kept | no fault, but the AMD compiler crashes in `CreatePipelineState` 8 presents in (`PS_DeferredTextured_*`, found by journaling each pipeline compile) | | main, non-uniform, `SPtrLoadAt` as `SPtrLoad` (this PR) | **9,024 and 13,796 presents, no fault, no compiler crash** (warm cache, 40 minutes each) | **One mechanism is explained.** With wave emulation, a hardware wave wider than the program wave holds several program waves. Their SGPRs differ, because `readfirstlane` reads each program wave's own first lane. The AMD driver then reads every lane's view at the first lane's index. `ScalarViewWaveTests` reproduces this. **Another is not.** Wave64 programs needed the non-uniform form too: with it applied to everything except them, the hang came back. I could not explain that from their translation; their SGPRs come from user data, scalar loads and uniform arithmetic. So this PR restores the earlier form rather than claiming a narrower fix. **Cost:** this gives back the scalar-load part of 53862e66's gain for the G-buffer pixel programs. In return, a boot runs through. ## In game (retail game, RX 7800 XT) - **Before:** the boot ends in a device hang 1,200 to 2,000 presents in, during the intro or the loading screen. - **After:** the boot reaches the first controllable scene ("Move around / Move the camera") at about 4 fps, as the game's counter shows, and runs until the run's time limit. - **Still open:** the scene was black on b5d8d02a, before the exposure fixes. A boot on 905deb80 with this change hung with a different fault, with recently freed allocations and over the GPU memory budget. I am looking into it separately. ## Tests - New `ScalarViewWaveTests`: program waves pick their view from `readfirstlane` of the thread index, 1 to 4 program waves per hardware wave. - With `FIVESTAR_TEST_ADAPTER=hardware` on the RX 7800 XT, it fails with the uniform form (two 16-lane program waves on a 32-lane wave read the first one's view) and passes with this change. - WARP passes either way. - Shader tests: 524 passed, 14 skipped. - `docs/shader-translation.md` is updated. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
On an RX 7800 XT the uniform scalar-load views (53862e66) ended every boot of a retail game in a device hang with a
page fault at an address no allocation held, 1,200 to 2,000 presents in: eleven boots across main since then. With
only that commit reverted on its own base, the boot ran 12,017 presents without a fault; on main with the views
non-uniform and each dword read through the map, 9,024 and 13,796 presents (warm cache, 40 minutes each), into the
game's first controllable scene.

SBufLoad and SPtrLoad index their views through NonUniformResourceIndex again, and SPtrLoadAt reads as SPtrLoad: a
non-uniform index through its select of two views crashed the AMD compiler in CreatePipelineState on the
PS_DeferredTextured programs, 8 presents into the boot. sptr_views is left to dead-code elimination.

One way the index differs across a hardware wave: with wave emulation a wider hardware wave holds several program
waves, whose SGPRs differ (readfirstlane per program wave). ScalarViewWaveTests reads a view chosen that way; with
FIVESTAR_TEST_ADAPTER=hardware it fails on the RX 7800 XT with the uniform form and passes now. Wave64 programs
needed the non-uniform form too (uniform only for them still faulted), which that does not explain.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 03:16:10 +00:00
github manually merged commit 3aabee9e18 into gh-pr/58/base 2026-11-27 03:16:10 +00:00
Author
Owner

@⁠ThatRecompDev on GitHub · 2026-11-26 12:20 UTC · original

great bisect, thanks. the program-wave-inside-a-hardware-wave case makes total sense once you see it, and the hardware test pins it down

merged it with translator batch 4 so testers only rebuild once. giving back part of 53862e66's gain is fine, a hang on AMD is worse than a few ms

the wave64 case you couldn't explain is interesting, if you find it later a narrower fix is welcome

**@⁠ThatRecompDev** on GitHub · 2026-11-26 12:20 UTC · [original](https://github.com/ThatRecompDev/five-star-recomp/pull/58#issuecomment-7191880388) great bisect, thanks. the program-wave-inside-a-hardware-wave case makes total sense once you see it, and the hardware test pins it down merged it with translator batch 4 so testers only rebuild once. giving back part of 53862e66's gain is fine, a hang on AMD is worse than a few ms the wave64 case you couldn't explain is interesting, if you find it later a narrower fix is welcome
This discussion has been locked. Commenting is limited to contributors.
No description provided.